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