You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/10/05 08:02:01 UTC
[04/11] olingo-odata4 git commit: [OLINGO-789] server support for
action parameters of all types
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
index a533820..f50cbc9 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXMLDeserializerActionParametersTest.java
@@ -19,58 +19,56 @@
package org.apache.olingo.server.core.deserializer.xml;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.Parameter;
-import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.EdmParameter;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.CsdlAction;
-import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
-import org.apache.olingo.commons.api.edm.provider.CsdlParameter;
-import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.core.edm.EdmActionImpl;
-import org.apache.olingo.commons.core.edm.EdmComplexTypeImpl;
-import org.apache.olingo.commons.core.edm.EdmProviderImpl;
import org.apache.olingo.server.api.OData;
import org.apache.olingo.server.api.deserializer.DeserializerException;
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
+import org.apache.olingo.server.api.deserializer.DeserializerException.MessageKeys;
+import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest;
import org.junit.Test;
-import org.mockito.Mockito;
-public class ODataXMLDeserializerActionParametersTest {
+public class ODataXMLDeserializerActionParametersTest extends AbstractODataDeserializerTest {
+
+ private static final String PREAMBLE = "<?xml version='1.0' encoding='UTF-8'?>"
+ + "<metadata:parameters xmlns:data=\"" + Constants.NS_DATASERVICES + "\""
+ + " xmlns:metadata=\"" + Constants.NS_METADATA + "\">";
+ private static final String POSTAMBLE = "</metadata:parameters>";
@Test
public void empty() throws Exception {
- final String input = "";
- final Map<String, Parameter> parameters = deserialize(input, "UART");
+ final Map<String, Parameter> parameters = deserialize(PREAMBLE + POSTAMBLE, "UART", null);
assertNotNull(parameters);
assertTrue(parameters.isEmpty());
}
@Test
public void primitive() throws Exception {
- final String input = "<?xml version='1.0' encoding='UTF-8'?>"
- +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
- +"<ParameterInt16>42</ParameterInt16>"
- +"<ParameterDuration>P42DT11H22M33S</ParameterDuration>"
- +"</metadata:parameters>";
-
- final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam");
+ final String input = PREAMBLE
+ + "<ParameterDuration>P42DT11H22M33S</ParameterDuration>"
+ + "<ParameterInt16>42</ParameterInt16>"
+ + POSTAMBLE;
+
+ final Map<String, Parameter> parameters = deserialize(input, "UARTTwoParam", null);
assertNotNull(parameters);
assertEquals(2, parameters.size());
Parameter parameter = parameters.get("ParameterInt16");
@@ -80,158 +78,115 @@ public class ODataXMLDeserializerActionParametersTest {
assertNotNull(parameter);
assertEquals(BigDecimal.valueOf(3669753), parameter.getValue());
}
-
+
+ @Test
+ public void primitiveCollection() throws Exception {
+ EdmParameter parameter = mock(EdmParameter.class);
+ when(parameter.getType()).thenReturn(
+ OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration));
+ when(parameter.isCollection()).thenReturn(true);
+ EdmAction action = mock(EdmAction.class);
+ when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+ when(action.getParameter("Parameter")).thenReturn(parameter);
+
+ final String input = PREAMBLE
+ + "<Parameter>"
+ + "<metadata:element>PT0S</metadata:element>"
+ + "<metadata:element>PT42S</metadata:element>"
+ + "<metadata:element>PT1H2M3S</metadata:element>"
+ + "</Parameter>"
+ + POSTAMBLE;
+ final Map<String, Parameter> parameters = deserialize(input, action);
+
+ assertNotNull(parameters);
+ assertEquals(1, parameters.size());
+ Parameter parameterData = parameters.get("Parameter");
+ assertNotNull(parameterData);
+ assertTrue(parameterData.isPrimitive());
+ assertTrue(parameterData.isCollection());
+ assertEquals(BigDecimal.ZERO, parameterData.asCollection().get(0));
+ assertEquals(BigDecimal.valueOf(42), parameterData.asCollection().get(1));
+ assertEquals(BigDecimal.valueOf(3723), parameterData.asCollection().get(2));
+ }
+
@Test
public void complex() throws Exception {
- EdmProviderImpl provider = mock(EdmProviderImpl.class);
- CsdlComplexType address = new CsdlComplexType();
- address.setProperties(Arrays.asList(createProperty("Street", "Edm.String"),
- createProperty("Zip", "Edm.Int32")));
- address.setName("Address");
- EdmComplexTypeImpl edmAddress = new EdmComplexTypeImpl(provider,
- new FullQualifiedName("namespace.Address"), address);
- Mockito.stub(provider.getComplexType(Mockito.any(FullQualifiedName.class))).toReturn(edmAddress);
-
- List<CsdlParameter> parameters = new ArrayList<CsdlParameter>();
- parameters.add(createParam("param1", "Edm.Int16"));
- parameters.add(createParam("param2", "namespace.Address"));
- parameters.add(createParam("param3", "Edm.Int32").setCollection(true));
- parameters.add(createParam("param4", "Edm.String").setNullable(true));
-
- FullQualifiedName actionName = new FullQualifiedName("namespace", "action");
- CsdlAction csdlAction = new CsdlAction().setName("action1").setParameters(parameters);
- EdmAction action = new EdmActionImpl(provider, actionName, csdlAction);
-
- final String input = "<?xml version='1.0' encoding='UTF-8'?>" +
- "<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">\n" +
- " <param1>42</param1>\n" +
- " <param2 metadata:type=\"#namespace.Address\">\n" +
- " <Street>One Microsoft Way</Street>\n" +
- " <Zip>98052</Zip>\n" +
- " </param2>\n" +
- " <param3>\n" +
- " <element>1</element>\n" +
- " <element>42</element>\n" +
- " <element>99</element>\n" +
- " </param3>\n" +
- " <param4 metadata:null=\"true\"/>\n" +
- "</metadata:parameters>";
- final Map<String, Parameter> response = OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
- .actionParameters(new ByteArrayInputStream(input.getBytes()), action).getActionParameters();
-
- assertNotNull(response);
- assertEquals(4, response.size());
- Parameter parameter = response.get("param1");
- assertNotNull(response);
- assertEquals((short) 42, parameter.getValue());
- parameter = response.get("param2");
- assertNotNull(parameter);
- ComplexValue addressValue = (ComplexValue)parameter.getValue();
- assertEquals("Street", addressValue.getValue().get(0).getName());
- assertEquals("One Microsoft Way", addressValue.getValue().get(0).getValue());
- assertEquals("Zip", addressValue.getValue().get(1).getName());
- assertEquals(98052, addressValue.getValue().get(1).getValue());
-
- parameter = response.get("param3");
- assertNotNull(parameter);
- assertEquals(Arrays.asList(1, 42, 99), parameter.getValue());
-
- parameter = response.get("param4");
- assertNull(parameter.getValue());
+ EdmParameter parameter = mock(EdmParameter.class);
+ when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
+ EdmAction action = mock(EdmAction.class);
+ when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+ when(action.getParameter("Parameter")).thenReturn(parameter);
+
+ final String input = PREAMBLE
+ + "<Parameter>"
+ + "<PropertyInt16>42</PropertyInt16>"
+ + "<PropertyString>Yes</PropertyString>"
+ + "</Parameter>"
+ + POSTAMBLE;
+ final Map<String, Parameter> parameters = deserialize(input, action);
+
+ assertNotNull(parameters);
+ assertEquals(1, parameters.size());
+ final Parameter parameterData = parameters.get("Parameter");
+ assertNotNull(parameterData);
+ assertTrue(parameterData.isComplex());
+ assertFalse(parameterData.isCollection());
+ final List<Property> complexValues = parameterData.asComplex().getValue();
+ assertEquals((short) 42, complexValues.get(0).getValue());
+ assertEquals("Yes", complexValues.get(1).getValue());
}
-
+
@Test
public void complexCollection() throws Exception {
- EdmProviderImpl provider = mock(EdmProviderImpl.class);
- CsdlComplexType address = new CsdlComplexType();
- address.setProperties(Arrays.asList(createProperty("Street", "Edm.String"),
- createProperty("Zip", "Edm.Int32")));
- address.setName("Address");
- EdmComplexTypeImpl edmAddress = new EdmComplexTypeImpl(provider,
- new FullQualifiedName("namespace.Address"), address);
- Mockito.stub(provider.getComplexType(Mockito.any(FullQualifiedName.class))).toReturn(edmAddress);
-
- List<CsdlParameter> parameters = new ArrayList<CsdlParameter>();
- parameters.add(createParam("param1", "Edm.Int16"));
- parameters.add(createParam("param2", "namespace.Address").setCollection(true));
- parameters.add(createParam("param3", "Edm.Int32").setCollection(true));
- parameters.add(createParam("param4", "Edm.String").setNullable(true));
-
- FullQualifiedName actionName = new FullQualifiedName("namespace", "action");
- CsdlAction csdlAction = new CsdlAction().setName("action1").setParameters(parameters);
- EdmAction action = new EdmActionImpl(provider, actionName, csdlAction);
-
- final String input = "<?xml version='1.0' encoding='UTF-8'?>" +
- "<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">\n" +
- " <param1>42</param1>\n" +
- " <param2 metadata:type=\"#namespace.Address\">\n" +
- " <element>" +
- " <Street>One Microsoft Way</Street>\n" +
- " <Zip>98052</Zip>\n" +
- " </element>" +
- " <element>" +
- " <Street>Two Microsoft Way</Street>\n" +
- " <Zip>98052</Zip>\n" +
- " </element>" +
- " </param2>\n" +
- " <param3>\n" +
- " <element>1</element>\n" +
- " <element>42</element>\n" +
- " <element>99</element>\n" +
- " </param3>\n" +
- " <param4 metadata:null=\"true\"/>\n" +
- "</metadata:parameters>";
- final Map<String, Parameter> response = OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
- .actionParameters(new ByteArrayInputStream(input.getBytes()), action).getActionParameters();
-
- assertNotNull(response);
- assertEquals(4, response.size());
- Parameter parameter = response.get("param1");
- assertNotNull(response);
- assertEquals((short) 42, parameter.getValue());
- parameter = response.get("param2");
- assertNotNull(parameter);
- ComplexValue addressValue = (ComplexValue)((List<?>)parameter.getValue()).get(0);
- assertEquals("One Microsoft Way", addressValue.getValue().get(0).getValue());
- assertEquals(98052, addressValue.getValue().get(1).getValue());
+ EdmParameter parameter = mock(EdmParameter.class);
+ when(parameter.getType()).thenReturn(edm.getComplexType(new FullQualifiedName(NAMESPACE, "CTTwoPrim")));
+ when(parameter.isCollection()).thenReturn(true);
+ EdmAction action = mock(EdmAction.class);
+ when(action.getParameterNames()).thenReturn(Collections.singletonList("Parameter"));
+ when(action.getParameter("Parameter")).thenReturn(parameter);
- addressValue = (ComplexValue)((List<?>)parameter.getValue()).get(1);
- assertEquals("Two Microsoft Way", addressValue.getValue().get(0).getValue());
- assertEquals(98052, addressValue.getValue().get(1).getValue());
-
- parameter = response.get("param3");
- assertNotNull(parameter);
- assertEquals(Arrays.asList(1, 42, 99), parameter.getValue());
-
- parameter = response.get("param4");
- assertNull(parameter.getValue());
- }
+ final String input = PREAMBLE
+ + "<Parameter>"
+ + "<metadata:element>"
+ + "<PropertyInt16>9999</PropertyInt16><PropertyString>One</PropertyString>"
+ + "</metadata:element>"
+ + "<metadata:element>"
+ + "<PropertyInt16>-123</PropertyInt16><PropertyString>Two</PropertyString>"
+ + "</metadata:element>"
+ + "</Parameter>"
+ + POSTAMBLE;
+ final Map<String, Parameter> parameters = deserialize(input, action);
- private CsdlParameter createParam(String name, String type) {
- return new CsdlParameter().setName(name).setType(new FullQualifiedName(type));
- }
+ assertNotNull(parameters);
+ assertEquals(1, parameters.size());
+ Parameter parameterData = parameters.get("Parameter");
+ assertNotNull(parameterData);
+ assertTrue(parameterData.isComplex());
+ assertTrue(parameterData.isCollection());
+ ComplexValue complexValue = (ComplexValue) parameterData.asCollection().get(0);
+ assertEquals((short) 9999, complexValue.getValue().get(0).getValue());
+ assertEquals("One", complexValue.getValue().get(1).getValue());
- private CsdlProperty createProperty(String name, String type) {
- return new CsdlProperty().setName(name).setType(type);
+ complexValue = (ComplexValue) parameterData.asCollection().get(1);
+ assertEquals((short) -123, complexValue.getValue().get(0).getValue());
+ assertEquals("Two", complexValue.getValue().get(1).getValue());
}
-
+
@Test
public void boundEmpty() throws Exception {
- final String input = "";
- final Map<String, Parameter> parameters = deserialize(input, "BAETAllPrimRT", "ETAllPrim");
+ final Map<String, Parameter> parameters = deserialize(PREAMBLE + POSTAMBLE,
+ "BAETAllPrimRT", "ETAllPrim");
assertNotNull(parameters);
assertTrue(parameters.isEmpty());
}
@Test
- public void testParameterWithNullLiteral() throws Exception {
- final String input = "<?xml version='1.0' encoding='UTF-8'?>"
- +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
- +"<ParameterInt16>1</ParameterInt16>"
- +"</metadata:parameters>";
-
- final Map<String, Parameter> parameters = deserialize(input,
- "UARTCollStringTwoParam");
+ public void parameterWithNullLiteral() throws Exception {
+ final String input = PREAMBLE
+ + "<ParameterInt16>1</ParameterInt16>"
+ + "<ParameterDuration metadata:null=\"true\" />"
+ + POSTAMBLE;
+ final Map<String, Parameter> parameters = deserialize(input, "UARTCollStringTwoParam", null);
assertNotNull(parameters);
assertEquals(2, parameters.size());
Parameter parameter = parameters.get("ParameterInt16");
@@ -241,63 +196,62 @@ public class ODataXMLDeserializerActionParametersTest {
assertNotNull(parameter);
assertEquals(null, parameter.getValue());
}
-
+
@Test
public void bindingParameter() throws Exception {
- final String input = "<?xml version='1.0' encoding='UTF-8'?>"
- +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
- +"<ParameterETAllPrim>1</ParameterETAllPrim>"
- +"</metadata:parameters>";
+ final String input = PREAMBLE + "<ParameterETAllPrim>1</ParameterETAllPrim>" + POSTAMBLE;
deserialize(input, "BAETAllPrimRT", "ETAllPrim");
}
- @Test(expected = DeserializerException.class)
+ @Test
public void wrongName() throws Exception {
- final String input = "<?xml version='1.0' encoding='UTF-8'?>"
- +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
- +"<ParameterWrong>1</ParameterWrong>"
- +"</metadata:parameters>";
- deserialize(input, "UARTParam");
+ expectException(PREAMBLE + "<ParameterWrong>1</ParameterWrong>" + POSTAMBLE,
+ "UARTParam", null, MessageKeys.UNKNOWN_CONTENT);
}
- @Test(expected = DeserializerException.class)
+ @Test
public void nullNotNullable() throws Exception {
- final String input = "<?xml version='1.0' encoding='UTF-8'?>"
- +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
- +"<ParameterInt16>null</ParameterInt16>"
- +"</metadata:parameters>";
- deserialize(input, "UARTCTTwoPrimParam");
+ expectException(PREAMBLE + "<ParameterInt16>null</ParameterInt16>" + POSTAMBLE,
+ "UARTCTTwoPrimParam", null, MessageKeys.INVALID_VALUE_FOR_PROPERTY);
}
- @Test(expected = DeserializerException.class)
+ @Test
public void missingParameter() throws Exception {
- deserialize("", "UARTCTTwoPrimParam");
+ expectException(PREAMBLE + POSTAMBLE, "UARTCTTwoPrimParam", null, MessageKeys.INVALID_NULL_PARAMETER);
}
- @Test(expected = DeserializerException.class)
+ @Test
public void parameterTwice() throws Exception {
- final String input = "<?xml version='1.0' encoding='UTF-8'?>"
- +"<metadata:parameters xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
- +"<ParameterInt16>1</ParameterInt16>"
- +"<ParameterInt16>2</ParameterInt16>"
- +"</metadata:parameters>";
- deserialize(input, "UARTParam");
+ expectException(PREAMBLE
+ + "<ParameterInt16>1</ParameterInt16>"
+ + "<ParameterInt16>2</ParameterInt16>"
+ + POSTAMBLE,
+ "UARTParam", null, MessageKeys.DUPLICATE_PROPERTY);
}
-
- protected static final Edm edm = OData.newInstance().createServiceMetadata(
- new EdmTechProvider(), Collections.<EdmxReference> emptyList()).getEdm();
-
- private Map<String, Parameter> deserialize(final String input, final String actionName) throws DeserializerException {
+
+ private Map<String, Parameter> deserialize(final String input, final EdmAction action) throws DeserializerException {
return OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
- .actionParameters(new ByteArrayInputStream(input.getBytes()),
- edm.getUnboundAction(new FullQualifiedName("Namespace1_Alias", actionName))).getActionParameters();
+ .actionParameters(new ByteArrayInputStream(input.getBytes()), action)
+ .getActionParameters();
}
- private Map<String, Parameter> deserialize(final String input, final String actionName, final String typeName)
+ private Map<String, Parameter> deserialize(final String input, final String actionName, final String bindingTypeName)
throws DeserializerException {
- return OData.newInstance().createDeserializer(ContentType.APPLICATION_XML)
- .actionParameters(new ByteArrayInputStream(input.getBytes()),
- edm.getBoundAction(new FullQualifiedName("Namespace1_Alias", actionName),
- new FullQualifiedName("Namespace1_Alias", typeName), false)).getActionParameters();
+ return deserialize(input,
+ bindingTypeName == null ?
+ edm.getUnboundAction(new FullQualifiedName(NAMESPACE, actionName)) :
+ edm.getBoundAction(new FullQualifiedName(NAMESPACE, actionName),
+ new FullQualifiedName(NAMESPACE, bindingTypeName),
+ false));
+ }
+
+ private void expectException(final String input, final String actionName, final String bindingTypeName,
+ final DeserializerException.MessageKeys messageKey) {
+ try {
+ deserialize(input, actionName, bindingTypeName);
+ fail("Expected exception not thrown.");
+ } catch (final DeserializerException e) {
+ assertEquals(messageKey, e.getMessageKey());
+ }
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
index 497e8f5..71f4d35 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/xml/ODataXmlDeserializerTest.java
@@ -19,10 +19,11 @@
package org.apache.olingo.server.core.deserializer.xml;
import java.io.ByteArrayInputStream;
+import java.math.BigDecimal;
import java.net.URI;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
+import java.util.UUID;
import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.Entity;
@@ -40,39 +41,22 @@ import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
import org.apache.olingo.commons.core.edm.EdmComplexTypeImpl;
import org.apache.olingo.commons.core.edm.EdmPropertyImpl;
import org.apache.olingo.commons.core.edm.primitivetype.EdmBinary;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmByte;
import org.apache.olingo.commons.core.edm.primitivetype.EdmDate;
import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmGuid;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
import org.apache.olingo.commons.core.edm.primitivetype.EdmTimeOfDay;
-import org.apache.olingo.server.api.ServiceMetadata;
import org.apache.olingo.server.api.deserializer.ODataDeserializer;
-import org.apache.olingo.server.api.edmx.EdmxReference;
-import org.apache.olingo.server.core.ServiceMetadataImpl;
-import org.apache.olingo.server.core.deserializer.xml.ODataXmlDeserializer;
-import org.apache.olingo.server.tecsvc.MetadataETagSupport;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
+import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
-public class ODataXmlDeserializerTest {
-
- private static final ServiceMetadata metadata = new ServiceMetadataImpl(
- new EdmTechProvider(), Collections.<EdmxReference> emptyList(), new MetadataETagSupport("WmetadataETag"));
- private static final EdmEntityContainer entityContainer = metadata.getEdm().getEntityContainer();
- private final ODataDeserializer serializer = new ODataXmlDeserializer();
-
+public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
+
+ private static final EdmEntityContainer entityContainer = edm.getEntityContainer();
+ private final ODataDeserializer deserializer = new ODataXmlDeserializer();
+
@BeforeClass
public static void setup() {
XMLUnit.setIgnoreComments(true);
@@ -81,64 +65,24 @@ public class ODataXmlDeserializerTest {
XMLUnit.setNormalizeWhitespace(true);
XMLUnit.setCompareUnmatched(false);
}
-
- protected Object edmInt16(String value) throws EdmPrimitiveTypeException {
- return EdmInt16.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmInt16.getInstance().getDefaultType());
- }
- protected Object edmInt32(String value) throws EdmPrimitiveTypeException {
- return EdmInt32.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmInt32.getInstance().getDefaultType());
- }
- protected Object edmInt64(String value) throws EdmPrimitiveTypeException {
- return EdmInt64.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmInt64.getInstance().getDefaultType());
- }
- protected Object edmSingle(String value) throws EdmPrimitiveTypeException {
- return EdmSingle.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmSingle.getInstance().getDefaultType());
- }
- protected Object edmDouble(String value) throws EdmPrimitiveTypeException {
- return EdmDouble.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmDouble.getInstance().getDefaultType());
- }
- protected Object edmSByte(String value) throws EdmPrimitiveTypeException {
- return EdmSByte.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmSByte.getInstance().getDefaultType());
- }
- protected Object edmByte(String value) throws EdmPrimitiveTypeException {
- return EdmByte.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmByte.getInstance().getDefaultType());
- }
- protected Object edmDecimal(String value) throws EdmPrimitiveTypeException {
- return EdmDecimal.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmDecimal.getInstance().getDefaultType());
- }
- protected Object edmBinary(String value) throws EdmPrimitiveTypeException {
- return EdmBinary.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmBinary.getInstance().getDefaultType());
+
+ protected byte[] edmBinary(String value) throws EdmPrimitiveTypeException {
+ return EdmBinary.getInstance().valueOfString(value, true, null, null, null, true,
+ byte[].class);
}
protected Object edmDate(String value) throws EdmPrimitiveTypeException {
- return EdmDate.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmDate.getInstance().getDefaultType());
+ return EdmDate.getInstance().valueOfString(value, true, null, null, null, true,
+ EdmDate.getInstance().getDefaultType());
}
protected Object edmDateTimeOffset(String value) throws EdmPrimitiveTypeException {
- return EdmDateTimeOffset.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmDateTimeOffset.getInstance().getDefaultType());
- }
- protected Object edmDuration(String value) throws EdmPrimitiveTypeException {
- return EdmDuration.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmDuration.getInstance().getDefaultType());
- }
- protected Object edmGUID(String value) throws EdmPrimitiveTypeException {
- return EdmGuid.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmGuid.getInstance().getDefaultType());
+ return EdmDateTimeOffset.getInstance().valueOfString(value, true, null, null, null, true,
+ EdmDateTimeOffset.getInstance().getDefaultType());
}
protected Object edmTimeOfDay(String value) throws EdmPrimitiveTypeException {
- return EdmTimeOfDay.getInstance().valueOfString(value, true, 10, 10, 10, true,
- EdmTimeOfDay.getInstance().getDefaultType());
+ return EdmTimeOfDay.getInstance().valueOfString(value, true, null, null, null, true,
+ EdmTimeOfDay.getInstance().getDefaultType());
}
-
+
@Test
public void entitySimple() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
@@ -179,32 +123,31 @@ public class ODataXmlDeserializerTest {
" </atom:content>\n" +
"</atom:entry>\n";
- Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
+ Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()),
edmEntitySet.getEntityType()).getEntity();
Assert.assertEquals(16, result.getProperties().size());
Assert.assertEquals(2, result.getNavigationBindings().size());
- Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
+ Assert.assertEquals((short) 32767, result.getProperty("PropertyInt16").asPrimitive());
Assert.assertEquals("First Resource - positive values", result.getProperty("PropertyString").asPrimitive());
- Assert.assertEquals(edmByte("255"), result.getProperty("PropertyByte").asPrimitive());
- Assert.assertEquals(edmSByte("127"), result.getProperty("PropertySByte").asPrimitive());
- Assert.assertEquals(edmInt32("2147483647"), result.getProperty("PropertyInt32").asPrimitive());
- Assert.assertEquals(edmInt64("9223372036854775807"), result.getProperty("PropertyInt64").asPrimitive());
- Assert.assertEquals(edmSingle("1.79E20"), result.getProperty("PropertySingle").asPrimitive());
- Assert.assertEquals(edmDouble("-1.79E19"), result.getProperty("PropertyDouble").asPrimitive());
- Assert.assertEquals(edmDecimal("34"), result.getProperty("PropertyDecimal").asPrimitive());
-// Assert.assertEquals(edmBinary("ASNFZ4mrze8="), result.getProperty("PropertyBinary").asPrimitive());
+ Assert.assertEquals((short) 255, result.getProperty("PropertyByte").asPrimitive());
+ Assert.assertEquals((byte) 127, result.getProperty("PropertySByte").asPrimitive());
+ Assert.assertEquals(2147483647, result.getProperty("PropertyInt32").asPrimitive());
+ Assert.assertEquals(9223372036854775807L, result.getProperty("PropertyInt64").asPrimitive());
+ Assert.assertEquals(1.79E20F, result.getProperty("PropertySingle").asPrimitive());
+ Assert.assertEquals(-1.79E19, result.getProperty("PropertyDouble").asPrimitive());
+ Assert.assertEquals(BigDecimal.valueOf(34), result.getProperty("PropertyDecimal").asPrimitive());
+ Assert.assertArrayEquals(edmBinary("ASNFZ4mrze8="), (byte[]) result.getProperty("PropertyBinary").asPrimitive());
Assert.assertEquals(edmDate("2012-12-03"), result.getProperty("PropertyDate").asPrimitive());
Assert.assertEquals(edmDateTimeOffset("2012-12-03T07:16:23Z"), result.getProperty("PropertyDateTimeOffset")
.asPrimitive());
- Assert.assertEquals(edmDuration("PT6S"), result.getProperty("PropertyDuration")
- .asPrimitive());
- Assert.assertEquals(edmGUID("01234567-89ab-cdef-0123-456789abcdef"), result.getProperty("PropertyGuid")
- .asPrimitive());
+ Assert.assertEquals(BigDecimal.valueOf(6), result.getProperty("PropertyDuration").asPrimitive());
+ Assert.assertEquals(UUID.fromString("01234567-89ab-cdef-0123-456789abcdef"),
+ result.getProperty("PropertyGuid").asPrimitive());
Assert.assertEquals(edmTimeOfDay("03:26:05"), result.getProperty("PropertyTimeOfDay").asPrimitive());
}
-
+
@Test
public void entitySimpleWithTypes() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
@@ -247,32 +190,31 @@ public class ODataXmlDeserializerTest {
" </atom:content>\n" +
"</atom:entry>\n";
- Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
+ Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()),
edmEntitySet.getEntityType()).getEntity();
Assert.assertEquals(16, result.getProperties().size());
Assert.assertEquals(2, result.getNavigationBindings().size());
- Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
+ Assert.assertEquals((short) 32767, result.getProperty("PropertyInt16").asPrimitive());
Assert.assertEquals("First Resource - positive values", result.getProperty("PropertyString").asPrimitive());
- Assert.assertEquals(edmByte("255"), result.getProperty("PropertyByte").asPrimitive());
- Assert.assertEquals(edmSByte("127"), result.getProperty("PropertySByte").asPrimitive());
- Assert.assertEquals(edmInt32("2147483647"), result.getProperty("PropertyInt32").asPrimitive());
- Assert.assertEquals(edmInt64("9223372036854775807"), result.getProperty("PropertyInt64").asPrimitive());
- Assert.assertEquals(edmSingle("1.79E20"), result.getProperty("PropertySingle").asPrimitive());
- Assert.assertEquals(edmDouble("-1.79E19"), result.getProperty("PropertyDouble").asPrimitive());
- Assert.assertEquals(edmDecimal("34"), result.getProperty("PropertyDecimal").asPrimitive());
-// Assert.assertEquals(edmBinary("ASNFZ4mrze8="), result.getProperty("PropertyBinary").asPrimitive());
+ Assert.assertEquals((short) 255, result.getProperty("PropertyByte").asPrimitive());
+ Assert.assertEquals((byte) 127, result.getProperty("PropertySByte").asPrimitive());
+ Assert.assertEquals(2147483647, result.getProperty("PropertyInt32").asPrimitive());
+ Assert.assertEquals(9223372036854775807L, result.getProperty("PropertyInt64").asPrimitive());
+ Assert.assertEquals(1.79E20F, result.getProperty("PropertySingle").asPrimitive());
+ Assert.assertEquals(-1.79E19, result.getProperty("PropertyDouble").asPrimitive());
+ Assert.assertEquals(BigDecimal.valueOf(34), result.getProperty("PropertyDecimal").asPrimitive());
+ Assert.assertArrayEquals(edmBinary("ASNFZ4mrze8="), (byte[]) result.getProperty("PropertyBinary").asPrimitive());
Assert.assertEquals(edmDate("2012-12-03"), result.getProperty("PropertyDate").asPrimitive());
Assert.assertEquals(edmDateTimeOffset("2012-12-03T07:16:23Z"), result.getProperty("PropertyDateTimeOffset")
.asPrimitive());
- Assert.assertEquals(edmDuration("PT6S"), result.getProperty("PropertyDuration")
- .asPrimitive());
- Assert.assertEquals(edmGUID("01234567-89ab-cdef-0123-456789abcdef"), result.getProperty("PropertyGuid")
- .asPrimitive());
+ Assert.assertEquals(BigDecimal.valueOf(6), result.getProperty("PropertyDuration").asPrimitive());
+ Assert.assertEquals(UUID.fromString("01234567-89ab-cdef-0123-456789abcdef"),
+ result.getProperty("PropertyGuid").asPrimitive());
Assert.assertEquals(edmTimeOfDay("03:26:05"), result.getProperty("PropertyTimeOfDay").asPrimitive());
}
-
+
@Test
public void entityCompAllPrim() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompAllPrim");
@@ -309,7 +251,7 @@ public class ODataXmlDeserializerTest {
+ "</atom:content>"
+ "</atom:entry>";
- Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
+ Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()),
edmEntitySet.getEntityType()).getEntity();
Assert.assertEquals("olingo.odata.test1.ETCompAllPrim",result.getType());
@@ -317,8 +259,8 @@ public class ODataXmlDeserializerTest {
Assert.assertEquals(2, result.getProperties().size());
Assert.assertEquals(0, result.getNavigationLinks().size());
- Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
-
+ Assert.assertEquals((short) 32767, result.getProperty("PropertyInt16").asPrimitive());
+
Assert.assertNotNull(result.getProperty("PropertyComp"));
Property comp = result.getProperty("PropertyComp");
Assert.assertEquals("olingo.odata.test1.CTAllPrim", comp.getType());
@@ -326,14 +268,14 @@ public class ODataXmlDeserializerTest {
Assert.assertEquals(16, cv.getValue().size());
- Assert.assertEquals(edmInt16("32767"), getCVProperty(cv, "PropertyInt16").asPrimitive());
+ Assert.assertEquals((short) 32767, getCVProperty(cv, "PropertyInt16").asPrimitive());
Assert.assertEquals("First Resource - first", getCVProperty(cv, "PropertyString").asPrimitive());
- Assert.assertEquals(edmByte("255"), getCVProperty(cv, "PropertyByte").asPrimitive());
- Assert.assertEquals(edmSByte("127"), getCVProperty(cv, "PropertySByte").asPrimitive());
- Assert.assertEquals(edmInt32("2147483647"), getCVProperty(cv, "PropertyInt32").asPrimitive());
- Assert.assertEquals(edmInt64("9223372036854775807"), getCVProperty(cv, "PropertyInt64").asPrimitive());
+ Assert.assertEquals((short) 255, getCVProperty(cv, "PropertyByte").asPrimitive());
+ Assert.assertEquals((byte) 127, getCVProperty(cv, "PropertySByte").asPrimitive());
+ Assert.assertEquals(2147483647, getCVProperty(cv, "PropertyInt32").asPrimitive());
+ Assert.assertEquals(9223372036854775807L, getCVProperty(cv, "PropertyInt64").asPrimitive());
}
-
+
private Property getCVProperty(ComplexValue cv, String name) {
for (Property p:cv.getValue()) {
if (p.getName().equals(name)) {
@@ -343,7 +285,6 @@ public class ODataXmlDeserializerTest {
return null;
}
- @SuppressWarnings("unchecked")
@Test
public void entityMixPrimCollComp() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
@@ -384,7 +325,7 @@ public class ODataXmlDeserializerTest {
" </atom:content>\n" +
"</atom:entry>\n";
- Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
+ Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()),
edmEntitySet.getEntityType()).getEntity();
Assert.assertEquals(4, result.getProperties().size());
@@ -398,22 +339,22 @@ public class ODataXmlDeserializerTest {
ComplexValue cv = (ComplexValue)comp.getValue();
Assert.assertEquals(2, cv.getValue().size());
- Assert.assertEquals(edmInt16("111"), getCVProperty(cv, "PropertyInt16").asPrimitive());
+ Assert.assertEquals((short) 111, getCVProperty(cv, "PropertyInt16").asPrimitive());
Assert.assertEquals("TEST A", getCVProperty(cv, "PropertyString").asPrimitive());
comp = result.getProperty("CollPropertyComp");
Assert.assertEquals("Collection(olingo.odata.test1.CTTwoPrim)", comp.getType());
+ @SuppressWarnings("unchecked")
List<ComplexValue> properties = (List<ComplexValue>)comp.getValue();
Assert.assertEquals(3, properties.size());
- Assert.assertEquals(edmInt16("123"), getCVProperty(properties.get(0), "PropertyInt16")
- .asPrimitive());
- Assert.assertEquals("TEST 1", getCVProperty(properties.get(0), "PropertyString")
- .asPrimitive());
+ Assert.assertEquals((short) 123,
+ getCVProperty(properties.get(0), "PropertyInt16").asPrimitive());
+ Assert.assertEquals("TEST 1",
+ getCVProperty(properties.get(0), "PropertyString").asPrimitive());
- Assert.assertEquals(edmInt16("789"), getCVProperty(properties.get(2), "PropertyInt16")
- .asPrimitive());
+ Assert.assertEquals((short) 789, getCVProperty(properties.get(2), "PropertyInt16").asPrimitive());
Assert.assertEquals("TEST 3", getCVProperty(properties.get(2), "PropertyString")
.asPrimitive());
}
@@ -461,13 +402,13 @@ public class ODataXmlDeserializerTest {
"</atom:entry>\n" +
"";
- Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
+ Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()),
edmEntitySet.getEntityType()).getEntity();
Assert.assertEquals(2, result.getProperties().size());
Assert.assertEquals(1, result.getNavigationLinks().size());
- Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
+ Assert.assertEquals((short) 32767, result.getProperty("PropertyInt16").asPrimitive());
Assert.assertEquals("Test String4", result.getProperty("PropertyString").asPrimitive());
Assert.assertEquals(1, result.getNavigationLinks().size());
@@ -491,8 +432,8 @@ public class ODataXmlDeserializerTest {
+ "<metadata:value xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
+ "234</metadata:value>";
- Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
- Assert.assertEquals(edmInt16("234"), result.getValue());
+ Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
+ Assert.assertEquals((short) 234, result.getValue());
}
@Test
@@ -503,7 +444,7 @@ public class ODataXmlDeserializerTest {
+ "<metadata:value xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
+ "metadata:null=\"true\"/>";
- Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
+ Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
Assert.assertNull(result.getValue());
}
@@ -517,7 +458,7 @@ public class ODataXmlDeserializerTest {
+ "<metadata:element>Employee2@company.example</metadata:element>"
+ "<metadata:element>Employee3@company.example</metadata:element>"
+ "</metadata:value>";
- Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
+ Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
Assert.assertEquals(Arrays.asList("Employee1@company.example", "Employee2@company.example",
"Employee3@company.example"), result.getValue());
@@ -557,7 +498,7 @@ public class ODataXmlDeserializerTest {
" <data:PostalCode>12209</data:PostalCode>\n" +
"</data:ShipTo>";
- Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
+ Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
Assert.assertEquals("ShipTo", result.getName());
Assert.assertTrue(result.getValue() instanceof ComplexValue);
@@ -588,15 +529,15 @@ public class ODataXmlDeserializerTest {
" <data:PropertyString>TEST 3</data:PropertyString>\n" +
" </metadata:element>\n" +
"</metadata:value>";
- Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
+ Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
List<ComplexValue> complex = (List<ComplexValue>)result.getValue();
Assert.assertEquals(3, complex.size());
Assert.assertEquals("Collection(olingo.odata.test1.CTTwoPrim)", result.getType());
- Assert.assertEquals(edmInt16("123"), getCVProperty(complex.get(0), "PropertyInt16").asPrimitive());
+ Assert.assertEquals((short) 123, getCVProperty(complex.get(0), "PropertyInt16").asPrimitive());
Assert.assertEquals("TEST 1", getCVProperty(complex.get(0), "PropertyString").asPrimitive());
- Assert.assertEquals(edmInt16("789"), getCVProperty(complex.get(2), "PropertyInt16").asPrimitive());
+ Assert.assertEquals((short) 789, getCVProperty(complex.get(2), "PropertyInt16").asPrimitive());
Assert.assertEquals("TEST 3", getCVProperty(complex.get(2), "PropertyString").asPrimitive());
}
@@ -607,7 +548,7 @@ public class ODataXmlDeserializerTest {
" xmlns=\"http://www.w3.org/2005/Atom\" "+
" id=\"http://host/service/Orders(10643)\" />";
- List<URI> result = serializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
+ List<URI> result = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
.getEntityReferences();
Assert.assertEquals(1, result.size());
Assert.assertEquals("http://host/service/Orders(10643)", result.get(0).toASCIIString());
@@ -622,7 +563,7 @@ public class ODataXmlDeserializerTest {
" <metadata:ref id=\"http://host/service/Orders(10759)\" />\n" +
"</feed>";
- List<URI> result = serializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
+ List<URI> result = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
.getEntityReferences();
Assert.assertEquals(2, result.size());
Assert.assertEquals("http://host/service/Orders(10643)", result.get(0).toASCIIString());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d6db341d/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index 9f79a84..b115fb8 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -18,12 +18,11 @@
*/
package org.apache.olingo.server.core.uri.antlr;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import java.util.Arrays;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.core.Encoder;
import org.apache.olingo.commons.core.edm.EdmProviderImpl;
import org.apache.olingo.server.api.uri.UriInfoKind;
import org.apache.olingo.server.api.uri.UriResourceKind;
@@ -326,7 +325,7 @@ public class TestUriParserImpl {
}
@Test
- public void testEntitySet() throws UnsupportedEncodingException {
+ public void entitySet() throws Exception {
// plain entity set
testRes.run("ESAllPrim")
@@ -351,7 +350,7 @@ public class TestUriParserImpl {
.isKeyPredicate(1, "PropertyString", "'ABC'");
// with all keys
- testRes.run("ESAllKey(" + encode(allKeys) + ")")
+ testRes.run("ESAllKey(" + Encoder.encode(allKeys) + ")")
.isEntitySet("ESAllKey")
.isKeyPredicate(0, "PropertyString", "'ABC'")
.isKeyPredicate(1, "PropertyInt16", "1")
@@ -1165,8 +1164,4 @@ public class TestUriParserImpl {
testUri.runEx("ESMixPrimCollComp", "$select=/PropertyInt16")
.isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
}
-
- public static String encode(final String decoded) throws UnsupportedEncodingException {
- return URLEncoder.encode(decoded, "UTF-8");
- }
}