Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/olingo-odata4
This commit is contained in:
commit
ed8e0e3cc1
|
@ -110,13 +110,6 @@
|
|||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>..</directory>
|
||||
<targetPath>META-INF</targetPath>
|
||||
<includes>
|
||||
<include>LICENSE</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<testResources>
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
package org.apache.olingo.fit.proxy.v3;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
|
||||
import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
|
||||
import org.apache.olingo.ext.proxy.EntityContainerFactory;
|
||||
import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.
|
||||
DefaultContainer;
|
||||
|
@ -31,19 +31,17 @@ import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.service
|
|||
public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase {
|
||||
|
||||
@BeforeClass
|
||||
public static void enableBasicAuth() {
|
||||
public static void setupContaner() {
|
||||
containerFactory = EntityContainerFactory.getV3(testAuthServiceRootURL);
|
||||
containerFactory.getConfiguration().
|
||||
setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
|
||||
container = containerFactory.getEntityContainer(DefaultContainer.class);
|
||||
assertNotNull(container);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void disableBasicAuth() {
|
||||
containerFactory.getConfiguration().setHttpClientFactory(new DefaultHttpClientFactory());
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setupContaner() {
|
||||
containerFactory = EntityContainerFactory.getV3(testAuthServiceRootURL);
|
||||
containerFactory = EntityContainerFactory.getV3(testStaticServiceRootURL);
|
||||
container = containerFactory.getEntityContainer(DefaultContainer.class);
|
||||
assertNotNull(container);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.apache.olingo.fit.proxy.v3;
|
||||
|
||||
import static org.apache.olingo.fit.proxy.v3.AbstractTest.container;
|
||||
import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.
|
||||
types.Customer;
|
||||
import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.
|
||||
|
@ -43,168 +44,166 @@ import org.junit.Test;
|
|||
*/
|
||||
public class EntityCreateTestITCase extends AbstractTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void create() {
|
||||
final String sampleName = "sample customer from proxy";
|
||||
final Integer id = 100;
|
||||
@Test
|
||||
public void create() {
|
||||
container.getCustomer().get(-10);
|
||||
final String sampleName = "sample customer from proxy";
|
||||
final Integer id = 100;
|
||||
|
||||
getSampleCustomerProfile(id, sampleName, container);
|
||||
container.flush();
|
||||
getSampleCustomerProfile(id, sampleName, container);
|
||||
container.flush();
|
||||
|
||||
Customer actual = readCustomer(container, id);
|
||||
checkSampleCustomerProfile(actual, id, sampleName);
|
||||
Customer actual = readCustomer(container, id);
|
||||
checkSampleCustomerProfile(actual, id, sampleName);
|
||||
|
||||
container.getCustomer().delete(actual.getCustomerId());
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
container.getCustomer().delete(actual.getCustomerId());
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
|
||||
entityContext.detachAll();
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNotNull(actual);
|
||||
entityContext.detachAll();
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNotNull(actual);
|
||||
|
||||
container.getCustomer().delete(actual.getCustomerId());
|
||||
container.flush();
|
||||
container.getCustomer().delete(actual.getCustomerId());
|
||||
container.flush();
|
||||
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
|
||||
entityContext.detachAll();
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
}
|
||||
entityContext.detachAll();
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void createEmployee() {
|
||||
final Integer id = 101;
|
||||
@Test
|
||||
@Ignore
|
||||
public void createEmployee() {
|
||||
final Integer id = 101;
|
||||
|
||||
final Employee employee = container.getPerson().newEmployee();
|
||||
employee.setPersonId(id);
|
||||
employee.setName("sample employee from proxy");
|
||||
employee.setManagersPersonId(-9918);
|
||||
employee.setSalary(2147483647);
|
||||
employee.setTitle("CEO");
|
||||
final Employee employee = container.getPerson().newEmployee();
|
||||
employee.setPersonId(id);
|
||||
employee.setName("sample employee from proxy");
|
||||
employee.setManagersPersonId(-9918);
|
||||
employee.setSalary(2147483647);
|
||||
employee.setTitle("CEO");
|
||||
|
||||
container.flush();
|
||||
container.flush();
|
||||
|
||||
Employee actual = container.getPerson().get(id, Employee.class);
|
||||
assertNotNull(actual);
|
||||
assertEquals(id, actual.getPersonId());
|
||||
Employee actual = container.getPerson().get(id, Employee.class);
|
||||
assertNotNull(actual);
|
||||
assertEquals(id, actual.getPersonId());
|
||||
|
||||
entityContext.detachAll();
|
||||
actual = container.getPerson().get(id, Employee.class);
|
||||
assertNotNull(actual);
|
||||
entityContext.detachAll();
|
||||
actual = container.getPerson().get(id, Employee.class);
|
||||
assertNotNull(actual);
|
||||
|
||||
container.getPerson().delete(actual.getPersonId());
|
||||
container.flush();
|
||||
container.getPerson().delete(actual.getPersonId());
|
||||
container.flush();
|
||||
|
||||
actual = container.getPerson().get(id, Employee.class);
|
||||
assertNull(actual);
|
||||
actual = container.getPerson().get(id, Employee.class);
|
||||
assertNull(actual);
|
||||
|
||||
entityContext.detachAll();
|
||||
actual = container.getPerson().get(id, Employee.class);
|
||||
assertNull(actual);
|
||||
}
|
||||
entityContext.detachAll();
|
||||
actual = container.getPerson().get(id, Employee.class);
|
||||
assertNull(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void createWithNavigation() {
|
||||
final String sampleName = "sample customer from proxy with navigation";
|
||||
final Integer id = 101;
|
||||
@Test
|
||||
public void createWithNavigation() {
|
||||
final String sampleName = "sample customer from proxy with navigation";
|
||||
final Integer id = 101;
|
||||
|
||||
final Customer original = getSampleCustomerProfile(id, sampleName, container);
|
||||
original.setInfo(container.getCustomerInfo().get(16));
|
||||
container.flush();
|
||||
final Customer original = getSampleCustomerProfile(id, sampleName, container);
|
||||
original.setInfo(container.getCustomerInfo().get(16));
|
||||
container.flush();
|
||||
|
||||
Customer actual = readCustomer(container, id);
|
||||
checkSampleCustomerProfile(actual, id, sampleName);
|
||||
assertEquals(Integer.valueOf(16), actual.getInfo().getCustomerInfoId());
|
||||
Customer actual = readCustomer(container, id);
|
||||
checkSampleCustomerProfile(actual, id, sampleName);
|
||||
assertEquals(Integer.valueOf(16), actual.getInfo().getCustomerInfoId());
|
||||
|
||||
container.getCustomer().delete(actual.getCustomerId());
|
||||
container.flush();
|
||||
container.getCustomer().delete(actual.getCustomerId());
|
||||
container.flush();
|
||||
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
}
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void createWithBackNavigation() {
|
||||
final String sampleName = "sample customer from proxy with back navigation";
|
||||
final Integer id = 102;
|
||||
@Test
|
||||
@Ignore
|
||||
public void createWithBackNavigation() {
|
||||
final String sampleName = "sample customer from proxy with back navigation";
|
||||
final Integer id = 102;
|
||||
|
||||
Order order = container.getOrder().newOrder();
|
||||
order.setCustomerId(id);
|
||||
order.setOrderId(id); // same id ...
|
||||
Order order = container.getOrder().newOrder();
|
||||
order.setCustomerId(id);
|
||||
order.setOrderId(id); // same id ...
|
||||
|
||||
final Customer customer = getSampleCustomerProfile(id, sampleName, container);
|
||||
final Customer customer = getSampleCustomerProfile(id, sampleName, container);
|
||||
|
||||
final OrderCollection orders = container.getOrder().newOrderCollection();
|
||||
orders.add(order);
|
||||
final OrderCollection orders = container.getOrder().newOrderCollection();
|
||||
orders.add(order);
|
||||
|
||||
customer.setOrders(orders);
|
||||
order.setCustomer(customer);
|
||||
container.flush();
|
||||
customer.setOrders(orders);
|
||||
order.setCustomer(customer);
|
||||
container.flush();
|
||||
|
||||
assertEquals(id, order.getOrderId());
|
||||
assertEquals(id, order.getCustomerId());
|
||||
assertEquals(id, order.getOrderId());
|
||||
assertEquals(id, order.getCustomerId());
|
||||
|
||||
Customer actual = readCustomer(container, id);
|
||||
checkSampleCustomerProfile(actual, id, sampleName);
|
||||
Customer actual = readCustomer(container, id);
|
||||
checkSampleCustomerProfile(actual, id, sampleName);
|
||||
|
||||
assertEquals(1, actual.getOrders().size());
|
||||
assertEquals(id, actual.getOrders().iterator().next().getOrderId());
|
||||
assertEquals(id, actual.getOrders().iterator().next().getCustomerId());
|
||||
assertEquals(1, actual.getOrders().size());
|
||||
assertEquals(id, actual.getOrders().iterator().next().getOrderId());
|
||||
assertEquals(id, actual.getOrders().iterator().next().getCustomerId());
|
||||
|
||||
order = container.getOrder().get(id);
|
||||
assertNotNull(order);
|
||||
assertEquals(id, order.getCustomer().getCustomerId());
|
||||
order = container.getOrder().get(id);
|
||||
assertNotNull(order);
|
||||
assertEquals(id, order.getCustomer().getCustomerId());
|
||||
|
||||
container.getOrder().delete(actual.getOrders());
|
||||
container.flush();
|
||||
container.getOrder().delete(actual.getOrders());
|
||||
container.flush();
|
||||
|
||||
order = container.getOrder().get(id);
|
||||
assertNull(order);
|
||||
order = container.getOrder().get(id);
|
||||
assertNull(order);
|
||||
|
||||
actual = readCustomer(container, id);
|
||||
assertTrue(actual.getOrders().isEmpty());
|
||||
actual = readCustomer(container, id);
|
||||
assertTrue(actual.getOrders().isEmpty());
|
||||
|
||||
container.getCustomer().delete(actual.getCustomerId());
|
||||
container.flush();
|
||||
container.getCustomer().delete(actual.getCustomerId());
|
||||
container.flush();
|
||||
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
}
|
||||
actual = container.getCustomer().get(id);
|
||||
assertNull(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void multiKey() {
|
||||
Message message = container.getMessage().newMessage();
|
||||
message.setMessageId(100);
|
||||
message.setFromUsername("fromusername");
|
||||
message.setToUsername("myusername");
|
||||
message.setIsRead(false);
|
||||
message.setSubject("test message");
|
||||
message.setBody("test");
|
||||
@Test
|
||||
public void multiKey() {
|
||||
Message message = container.getMessage().newMessage();
|
||||
message.setMessageId(100);
|
||||
message.setFromUsername("fromusername");
|
||||
message.setToUsername("myusername");
|
||||
message.setIsRead(false);
|
||||
message.setSubject("test message");
|
||||
message.setBody("test");
|
||||
|
||||
container.flush();
|
||||
container.flush();
|
||||
|
||||
MessageKey key = new MessageKey();
|
||||
key.setFromUsername("fromusername");
|
||||
key.setMessageId(100);
|
||||
MessageKey key = new MessageKey();
|
||||
key.setFromUsername("fromusername");
|
||||
key.setMessageId(100);
|
||||
|
||||
message = container.getMessage().get(key);
|
||||
assertNotNull(message);
|
||||
assertEquals(Integer.valueOf(100), message.getMessageId());
|
||||
assertEquals("fromusername", message.getFromUsername());
|
||||
assertEquals("myusername", message.getToUsername());
|
||||
assertEquals("test message", message.getSubject());
|
||||
assertEquals("test", message.getBody());
|
||||
message = container.getMessage().get(key);
|
||||
assertNotNull(message);
|
||||
assertEquals(Integer.valueOf(100), message.getMessageId());
|
||||
assertEquals("fromusername", message.getFromUsername());
|
||||
assertEquals("myusername", message.getToUsername());
|
||||
assertEquals("test message", message.getSubject());
|
||||
assertEquals("test", message.getBody());
|
||||
|
||||
container.getMessage().delete(key);
|
||||
container.flush();
|
||||
container.getMessage().delete(key);
|
||||
container.flush();
|
||||
|
||||
assertNull(container.getMessage().get(key));
|
||||
}
|
||||
assertNull(container.getMessage().get(key));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,31 +18,29 @@
|
|||
*/
|
||||
package org.apache.olingo.fit.proxy.v4;
|
||||
|
||||
import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
|
||||
import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
|
||||
import org.apache.olingo.ext.proxy.EntityContainerFactory;
|
||||
import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
|
||||
import org.apache.olingo.ext.proxy.EntityContainerFactory;
|
||||
import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
|
||||
|
||||
public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase {
|
||||
|
||||
@BeforeClass
|
||||
public static void enableBasicAuth() {
|
||||
containerFactory.getConfiguration().
|
||||
setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void disableBasicAuth() {
|
||||
containerFactory.getConfiguration().setHttpClientFactory(new DefaultHttpClientFactory());
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setupContaner() {
|
||||
containerFactory = EntityContainerFactory.getV3(testAuthServiceRootURL);
|
||||
containerFactory.getConfiguration().
|
||||
setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
|
||||
container = containerFactory.getEntityContainer(InMemoryEntities.class);
|
||||
assertNotNull(container);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void disableBasicAuth() {
|
||||
containerFactory = EntityContainerFactory.getV3(testStaticServiceRootURL);
|
||||
container = containerFactory.getEntityContainer(InMemoryEntities.class);
|
||||
assertNotNull(container);
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
|||
createReq.setPrefer(client.newPreferences().returnContent());
|
||||
|
||||
try {
|
||||
final ODataEntityCreateResponse createRes = createReq.execute();
|
||||
final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
|
||||
assertEquals(201, createRes.getStatusCode());
|
||||
} catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
|
|
|
@ -407,8 +407,20 @@ public final class URIUtils {
|
|||
|
||||
public static HttpEntity buildInputStreamEntity(final CommonODataClient<?> client, final InputStream input) {
|
||||
HttpEntity entity;
|
||||
|
||||
// --------------------------
|
||||
// Check just required by batch requests since their ansynchronous entity specification mechanism
|
||||
// --------------------------
|
||||
boolean contentAvailable;
|
||||
try {
|
||||
contentAvailable = input.available()>0;
|
||||
} catch (IOException ex) {
|
||||
contentAvailable = false;
|
||||
}
|
||||
// --------------------------
|
||||
|
||||
boolean repeatableRequired = shouldUseRepeatableHttpBodyEntry(client);
|
||||
if (!repeatableRequired) {
|
||||
if (!contentAvailable || !repeatableRequired) {
|
||||
entity = new InputStreamEntity(input, -1);
|
||||
} else {
|
||||
byte[] bytes = new byte[0];
|
||||
|
|
Loading…
Reference in New Issue