olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chri...@apache.org
Subject [2/4] olingo-odata4 git commit: [OLINGO-795] server support for Enums and Type Definitions
Date Fri, 09 Oct 2015 12:50:45 GMT
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
deleted file mode 100644
index 25dcb03..0000000
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertArrayEquals;
-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.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember;
-import org.apache.olingo.commons.api.edm.provider.CsdlEnumType;
-import org.apache.olingo.commons.core.edm.EdmEnumTypeImpl;
-import org.apache.olingo.commons.core.edm.EdmProviderImpl;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-public class EdmEnumTest {
-
-  private final EdmEnumType instance;
-  private final EdmEnumType otherInstance;
-  private final EdmEnumType nonFlagsInstance;
-  private final EdmEnumType int16EnumType;
-  private final EdmEnumType int32EnumType;
-  private final EdmEnumType int32FlagType;
-
-  public EdmEnumTest() {
-    final List<CsdlEnumMember> memberList = Arrays.asList(
-        new CsdlEnumMember().setName("first").setValue("1"),
-        new CsdlEnumMember().setName("second").setValue("64"));
-
-    final FullQualifiedName enumName = new FullQualifiedName("namespace", "name");
-
-    instance = new EdmEnumTypeImpl(mock(EdmProviderImpl.class), enumName,
-        new CsdlEnumType().setName("name").setMembers(memberList).setFlags(true)
-            .setUnderlyingType(EdmPrimitiveTypeKind.SByte.getFullQualifiedName()));
-    
-    otherInstance = new EdmEnumTypeImpl(mock(EdmProviderImpl.class), enumName,
-        new CsdlEnumType().setName("name").setMembers(memberList).setFlags(true)
-            .setUnderlyingType(EdmPrimitiveTypeKind.SByte.getFullQualifiedName()));
-
-    nonFlagsInstance = new EdmEnumTypeImpl(mock(EdmProviderImpl.class), enumName,
-        new CsdlEnumType().setName("name").setMembers(memberList).setFlags(false)
-            .setUnderlyingType(EdmPrimitiveTypeKind.SByte.getFullQualifiedName()));
-
-    int16EnumType = new EdmEnumTypeImpl(Mockito.mock(Edm.class),
-        new FullQualifiedName("testNamespace", "testName"), new CsdlEnumType()
-    .setName("MyEnum")
-    .setFlags(false)
-    .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
-    .setMembers(
-        Arrays.asList(
-            new CsdlEnumMember().setName("A")
-            .setValue("0"),
-            new CsdlEnumMember().setName("B")
-            .setValue("1"),
-            new CsdlEnumMember().setName("C")
-            .setValue("2"))));
-
-    int32EnumType =
-        new EdmEnumTypeImpl(Mockito.mock(Edm.class),
-            new FullQualifiedName("testNamespace", "testName"), new CsdlEnumType()
-        .setName("MyEnum")
-        .setFlags(false)
-        .setUnderlyingType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName())
-        .setMembers(
-            Arrays
-            .asList(new CsdlEnumMember().setName("A").setValue("0"), new CsdlEnumMember().setName("B")
-                .setValue("1"),
-                new CsdlEnumMember().setName("C").setValue("2"))));
-
-    int32FlagType =
-        new EdmEnumTypeImpl(Mockito.mock(Edm.class),
-            new FullQualifiedName("testNamespace", "testName"), new CsdlEnumType()
-        .setName("MyEnum")
-        .setFlags(true)
-        .setUnderlyingType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName())
-        .setMembers(
-            Arrays
-            .asList(new CsdlEnumMember().setName("A").setValue("2"), new CsdlEnumMember().setName("B")
-                .setValue("4"),
-                new CsdlEnumMember().setName("C").setValue("8"))));
-  }
-
-  @Test
-  public void nameSpace() throws Exception {
-    assertEquals("namespace", instance.getNamespace());
-  }
-
-  @Test
-  public void name() throws Exception {
-    assertEquals("name", instance.getName());
-  }
-
-  @Test
-  public void kind() throws Exception {
-    assertEquals(EdmTypeKind.ENUM, instance.getKind());
-  }
-
-  @Test
-  public void compatibility() {
-    assertTrue(instance.isCompatible(instance));
-    assertTrue(instance.isCompatible(otherInstance));
-    assertFalse(instance.isCompatible(instance.getUnderlyingType()));
-  }
-
-  @Test
-  public void defaultType() throws Exception {
-    assertEquals(Byte.class, instance.getDefaultType());
-    EdmEnumType instance = new EdmEnumTypeImpl(Mockito.mock(Edm.class),
-        new FullQualifiedName("testNamespace", "testName"),
-        new CsdlEnumType()
-            .setName("MyEnum"));
-    assertEquals(Integer.class, instance.getUnderlyingType().getDefaultType());
-  }
-
-  @Test
-  public void members() throws Exception {
-    assertArrayEquals(new String[] { "first", "second" }, instance.getMemberNames().toArray());
-    assertEquals("64", instance.getMember("second").getValue());
-    assertNull(instance.getMember("notExisting"));
-  }
-
-  @Test
-  public void underlyingType() throws Exception {
-    assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.SByte), instance.getUnderlyingType());
-  }
-
-  @Test
-  public void validate() throws Exception {
-    assertTrue(instance.validate(null, null, null, null, null, null));
-    assertTrue(instance.validate(null, true, null, null, null, null));
-    assertFalse(instance.validate(null, false, null, null, null, null));
-    assertFalse(instance.validate("", null, null, null, null, null));
-    assertFalse(instance.validate("something", null, null, null, null, null));
-
-    assertTrue(instance.validate("second", null, null, null, null, null));
-    assertTrue(instance.validate("first,second", null, null, null, null, null));
-    assertTrue(instance.validate("64", null, null, null, null, null));
-    assertTrue(instance.validate("1,64", null, null, null, null, null));
-  }
-
-  @Test
-  public void toUriLiteral() throws Exception {
-    assertNull(instance.toUriLiteral(null));
-    assertEquals("namespace.name'first'", instance.toUriLiteral("first"));
-  }
-
-  @Test
-  public void fromUriLiteral() throws Exception {
-    assertNull(instance.fromUriLiteral(null));
-    assertEquals("first", instance.fromUriLiteral("namespace.name'first'"));
-
-    expectErrorInFromUriLiteral(instance, "");
-    expectErrorInFromUriLiteral(instance, "name'first'");
-    expectErrorInFromUriLiteral(instance, "namespace.name'first");
-    expectErrorInFromUriLiteral(instance, "namespace.namespace'first");
-  }
-
-  @Test
-  public void valueToString() throws Exception {
-    assertNull(instance.valueToString(null, null, null, null, null, null));
-    assertNull(instance.valueToString(null, true, null, null, null, null));
-    assertEquals("first", instance.valueToString(1, null, null, null, null, null));
-    assertEquals("first", instance.valueToString((byte) 1, null, null, null, null, null));
-    assertEquals("first", instance.valueToString((short) 1, null, null, null, null, null));
-    assertEquals("second", instance.valueToString(Integer.valueOf(64), null, null, null, null, null));
-    assertEquals("second", instance.valueToString(64L, null, null, null, null, null));
-    assertEquals("first,second", instance.valueToString(65, null, null, null, null, null));
-
-    expectNullErrorInValueToString(instance);
-    expectContentErrorInValueToString(instance, 3);
-    expectTypeErrorInValueToString(instance, 1.0);
-
-    assertEquals("A", int32EnumType.valueToString(0, false, 0, 0, 0, false));
-    assertEquals("B", int32EnumType.valueToString(1, false, 0, 0, 0, false));
-    assertEquals("C", int32EnumType.valueToString(2, false, 0, 0, 0, false));
-
-    assertEquals("A", int16EnumType.valueToString(0, false, 0, 0, 0, false));
-    assertEquals("B", int16EnumType.valueToString(1, false, 0, 0, 0, false));
-    assertEquals("C", int16EnumType.valueToString(2, false, 0, 0, 0, false));
-
-    assertEquals("A", int32FlagType.valueToString(2, false, 0, 0, 0, false));
-    assertEquals("B", int32FlagType.valueToString(4, false, 0, 0, 0, false));
-    assertEquals("C", int32FlagType.valueToString(8, false, 0, 0, 0, false));
-    assertEquals("A,B", int32FlagType.valueToString(0x2 + 0x4, false, 0, 0, 0, false));
-    assertEquals("B,C", int32FlagType.valueToString(0x4 + 0x8, false, 0, 0, 0, false));
-  }
-
-  @Test
-  public void valueOfString() throws Exception {
-    assertNull(instance.valueOfString(null, null, null, null, null, null, Byte.class));
-    assertNull(instance.valueOfString(null, true, null, null, null, null, Byte.class));
-    assertEquals(Short.valueOf((short) 1), instance.valueOfString("1", null, null, null, null, null, Short.class));
-    assertEquals(Integer.valueOf(1), instance.valueOfString("1", null, null, null, null, null, Integer.class));
-    assertEquals(Long.valueOf(64L), instance.valueOfString("64", null, null, null, null, null, Long.class));
-    assertEquals(Long.valueOf(1), instance.valueOfString("first", null, null, null, null, null, Long.class));
-    assertEquals(Byte.valueOf((byte) 65), instance.valueOfString("first,64", null, null, null, null, null, Byte.class));
-    assertEquals(Integer.valueOf(1), instance.valueOfString("1,1,first", null, null, null, null, null, Integer.class));
-
-    assertEquals(Integer.valueOf(1), nonFlagsInstance.valueOfString("1", null, null, null, null, null, Integer.class));
-    expectContentErrorInValueOfString(nonFlagsInstance, "1,64");
-
-    expectNullErrorInValueOfString(instance);
-    expectContentErrorInValueOfString(instance, "2");
-    expectContentErrorInValueOfString(instance, "1,");
-    expectContentErrorInValueOfString(instance, ",1");
-    expectTypeErrorInValueOfString(instance, "1");
-
-    assertEquals(Integer.valueOf(0), int32EnumType.valueOfString("A", null, null, null, null, null, Integer.class));
-    assertEquals(Integer.valueOf(1), int32EnumType.valueOfString("B", null, null, null, null, null, Integer.class));
-    assertEquals(Integer.valueOf(2), int32EnumType.valueOfString("C", null, null, null, null, null, Integer.class));
-
-    assertEquals(Integer.valueOf(0), int16EnumType.valueOfString("A", null, null, null, null, null, Integer.class));
-    assertEquals(Integer.valueOf(1), int16EnumType.valueOfString("B", null, null, null, null, null, Integer.class));
-    assertEquals(Integer.valueOf(2), int16EnumType.valueOfString("C", null, null, null, null, null, Integer.class));
-
-    assertEquals(Integer.valueOf(2), int32FlagType.valueOfString("A", null, null, null, null, null, Integer.class));
-    assertEquals(Integer.valueOf(4), int32FlagType.valueOfString("B", null, null, null, null, null, Integer.class));
-    assertEquals(Integer.valueOf(8), int32FlagType.valueOfString("C", null, null, null, null, null, Integer.class));
-    assertEquals(Integer.valueOf(0x2 + 0x4), int32FlagType.valueOfString("A,B", null, null, null, null, null,
-        Integer.class));
-    assertEquals(Integer.valueOf(0x4 + 0x8), int32FlagType.valueOfString("B,C", null, null, null, null, null,
-        Integer.class));
-    assertEquals(Integer.valueOf(0x2 + 0x4), int32FlagType.valueOfString("B,A", null, null, null, null, null,
-        Integer.class));
-  }
-
-  private void expectErrorInValueToString(final EdmEnumType instance,
-      final Object value, final Boolean isNullable, final Integer maxLength,
-      final Integer precision, final Integer scale, final Boolean isUnicode,
-      final String message) {
-    try {
-      instance.valueToString(value, isNullable, maxLength, precision, scale, isUnicode);
-      fail("Expected exception not thrown");
-    } catch (final EdmPrimitiveTypeException e) {
-      assertNotNull(e.getLocalizedMessage());
-      assertThat(e.getLocalizedMessage(), containsString(message));
-    }
-  }
-
-  private void expectErrorInUnderlyingType(
-      final EdmPrimitiveTypeKind underlyingType,
-      final String message) {
-    try {
-      new EdmEnumTypeImpl(Mockito.mock(Edm.class),
-          new FullQualifiedName("testNamespace", "testName"),
-          new CsdlEnumType()
-              .setName("MyEnum")
-              .setFlags(false)
-              .setUnderlyingType(underlyingType.getFullQualifiedName())
-              .setMembers(
-                  Arrays.asList(
-                      new CsdlEnumMember().setName("A")
-                          .setValue("0"))));
-      fail("Expected exception not thrown");
-    } catch (final EdmException e) {
-      assertNotNull(e.getLocalizedMessage());
-      assertThat(e.getLocalizedMessage(), containsString(message));
-    }
-  }
-
-  @Test
-  public void unsupportedUnderlyingType() throws Exception {
-    // Test some random unsupported types
-    expectErrorInUnderlyingType(EdmPrimitiveTypeKind.Date, "");
-    expectErrorInUnderlyingType(EdmPrimitiveTypeKind.Geography, "");
-    expectErrorInUnderlyingType(EdmPrimitiveTypeKind.Guid, "");
-  }
-
-  @Test
-  public void outOfRangeValueToString() throws Exception {
-    expectErrorInValueToString(int16EnumType, Integer.MAX_VALUE, null, null, null, null, null, "");
-  }
-
-  protected void expectErrorInFromUriLiteral(final EdmPrimitiveType instance, final String value) {
-    try {
-      instance.fromUriLiteral(value);
-      fail("Expected exception not thrown");
-    } catch (final EdmPrimitiveTypeException e) {
-      assertNotNull(e.getLocalizedMessage());
-      assertThat(e.getLocalizedMessage(), containsString("' has illegal content."));
-    }
-  }
-
-  private void expectErrorInValueToString(final EdmPrimitiveType instance,
-      final Object value, final Boolean isNullable, final Integer maxLength,
-      final Integer precision, final Integer scale, final Boolean isUnicode,
-      final String message) {
-    try {
-      instance.valueToString(value, isNullable, maxLength, precision, scale, isUnicode);
-      fail("Expected exception not thrown");
-    } catch (final EdmPrimitiveTypeException e) {
-      assertNotNull(e.getLocalizedMessage());
-      assertThat(e.getLocalizedMessage(), containsString(message));
-    }
-  }
-
-  protected void expectNullErrorInValueToString(final EdmPrimitiveType instance) {
-    expectErrorInValueToString(instance, null, false, null, null, null, null, "The value NULL is not allowed.");
-  }
-
-  protected void expectTypeErrorInValueToString(final EdmPrimitiveType instance, final Object value) {
-    expectErrorInValueToString(instance, value, null, null, null, null, null, "value type");
-  }
-
-  protected void expectContentErrorInValueToString(final EdmPrimitiveType instance, final Object value) {
-    expectErrorInValueToString(instance, value, null, null, null, null, null, "' is not valid.");
-  }
-
-  private void expectErrorInValueOfString(final EdmPrimitiveType instance,
-      final String value, final Boolean isNullable, final Integer maxLength, final Integer precision,
-      final Integer scale, final Boolean isUnicode, final Class<?> returnType,
-      final String message) {
-
-    try {
-      instance.valueOfString(value, isNullable, maxLength, precision, scale, isUnicode, returnType);
-      fail("Expected exception not thrown");
-    } catch (final EdmPrimitiveTypeException e) {
-      assertNotNull(e.getLocalizedMessage());
-      assertThat(e.getLocalizedMessage(), containsString(message));
-    }
-  }
-
-  protected void expectTypeErrorInValueOfString(final EdmPrimitiveType instance, final String value) {
-    expectErrorInValueOfString(instance, value, null, null, null, null, null, Class.class,
-        "The value type class java.lang.Class is not supported.");
-  }
-
-  protected void expectContentErrorInValueOfString(final EdmPrimitiveType instance, final String value) {
-    expectErrorInValueOfString(instance, value, null, null, null, null, null, instance.getDefaultType(),
-        "illegal content");
-  }
-
-  protected void expectNullErrorInValueOfString(final EdmPrimitiveType instance) {
-    expectErrorInValueOfString(instance, null, false, null, null, null, null, instance.getDefaultType(),
-        "The literal 'null' is not allowed.");
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImplTest.java
deleted file mode 100644
index 63d21f5..0000000
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImplTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.api.edm.provider.CsdlTypeDefinition;
-import org.apache.olingo.commons.core.edm.EdmProviderImpl;
-import org.apache.olingo.commons.core.edm.EdmTypeDefinitionImpl;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-import org.junit.Test;
-
-public class EdmTypeDefinitionImplTest {
-
-  @Test
-  public void typeDefOnStringNoFacets() throws Exception {
-    final FullQualifiedName typeDefName = new FullQualifiedName("namespace", "name");
-    final CsdlTypeDefinition providerTypeDef =
-        new CsdlTypeDefinition().setName("typeDef").setUnderlyingType(new FullQualifiedName("Edm", "String"));
-    final EdmTypeDefinition typeDefImpl =
-        new EdmTypeDefinitionImpl(mock(EdmProviderImpl.class), typeDefName, providerTypeDef);
-
-    assertEquals("name", typeDefImpl.getName());
-    assertEquals("namespace", typeDefImpl.getNamespace());
-    assertEquals(String.class, typeDefImpl.getDefaultType());
-    assertEquals(EdmTypeKind.DEFINITION, typeDefImpl.getKind());
-    assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String), typeDefImpl.getUnderlyingType());
-    assertTrue(typeDefImpl.isCompatible(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String)));
-
-    // String validation
-    assertEquals("'StringValue'", typeDefImpl.toUriLiteral("StringValue"));
-    assertEquals("String''Value", typeDefImpl.fromUriLiteral("'String''''Value'"));
-    assertTrue(typeDefImpl.validate("text", null, null, null, null, null));
-    assertEquals("text", typeDefImpl.valueToString("text", null, null, null, null, null));
-    assertEquals("text", typeDefImpl.valueOfString("text", null, null, null, null, null, String.class));
-
-    // Facets must be initial
-    assertNull(typeDefImpl.getMaxLength());
-    assertNull(typeDefImpl.getPrecision());
-    assertNull(typeDefImpl.getScale());
-    assertTrue(typeDefImpl.isUnicode());
-  }
-
-  @Test(expected = EdmException.class)
-  public void invalidTypeResultsInEdmException() throws Exception {
-    FullQualifiedName typeDefName = new FullQualifiedName("namespace", "name");
-    CsdlTypeDefinition providerTypeDef =
-        new CsdlTypeDefinition().setName("typeDef").setUnderlyingType(new FullQualifiedName("wrong", "wrong"));
-    EdmTypeDefinitionImpl def = new EdmTypeDefinitionImpl(mock(EdmProviderImpl.class), typeDefName, providerTypeDef);
-    def.getUnderlyingType();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java
index 04bf11d..1fdb256 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/ServiceDocumentXmlSerializerTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.Collections;
 
 import org.apache.commons.io.IOUtils;
@@ -43,7 +42,6 @@ import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.core.ServiceMetadataImpl;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.mockito.Mockito;
 
 public class ServiceDocumentXmlSerializerTest {
   private static ODataSerializer serializer;
@@ -52,16 +50,16 @@ public class ServiceDocumentXmlSerializerTest {
   public static void init() throws SerializerException {
     serializer = OData.newInstance().createSerializer(ContentType.APPLICATION_ATOM_XML);
   }
-  
+
   @Test
   public void writeServiceWithEmptyMockedEdm() throws Exception {
     final Edm edm = mock(Edm.class);
     EdmEntityContainer container = mock(EdmEntityContainer.class);
-    Mockito.stub(container.getFullQualifiedName()).toReturn(new FullQualifiedName("service.test"));
-    when(container.getEntitySets()).thenReturn(new ArrayList<EdmEntitySet>());
-    when(container.getFunctionImports()).thenReturn(new ArrayList<EdmFunctionImport>());
-    when(container.getSingletons()).thenReturn(new ArrayList<EdmSingleton>());
-    when(edm.getEntityContainer(null)).thenReturn(container);
+    when(container.getFullQualifiedName()).thenReturn(new FullQualifiedName("service", "test"));
+    when(container.getEntitySets()).thenReturn(Collections.<EdmEntitySet> emptyList());
+    when(container.getFunctionImports()).thenReturn(Collections.<EdmFunctionImport> emptyList());
+    when(container.getSingletons()).thenReturn(Collections.<EdmSingleton> emptyList());
+    when(edm.getEntityContainer()).thenReturn(container);
     ServiceMetadata metadata = mock(ServiceMetadata.class);
     when(metadata.getEdm()).thenReturn(edm);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index 01af921..ccc7de5 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -1138,7 +1138,11 @@ public class DataCreator {
   }
 
   protected static Property createPrimitiveCollection(final String name, final Object... values) {
-    return new Property(null, name, ValueType.COLLECTION_PRIMITIVE, Arrays.asList(values));
+    List<Object> propertyValues = new ArrayList<Object>();
+    for (final Object value : values) {
+      propertyValues.add(value);
+    }
+    return new Property(null, name, ValueType.COLLECTION_PRIMITIVE, propertyValues);
   }
 
   protected static Property createComplex(final String name, final Property... properties) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index f9e2ee2..a4f63f1 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -48,6 +48,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmStructuredType;
+import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
@@ -235,9 +236,10 @@ public class DataProvider {
 
   private Property createProperty(final EdmProperty edmProperty, final String propertyName)
       throws DataProviderException {
+    final EdmType type = edmProperty.getType();
     Property newProperty;
-
-    if (edmProperty.isPrimitive()) {
+    if (edmProperty.isPrimitive()
+        || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
       newProperty = edmProperty.isCollection() ?
           DataCreator.createPrimitiveCollection(propertyName) :
           DataCreator.createPrimitive(propertyName, null);
@@ -248,10 +250,9 @@ public class DataProvider {
         newProperty = newProperty2;
       } else {
         newProperty = DataCreator.createComplex(propertyName);
-        createProperties((EdmComplexType) edmProperty.getType(), newProperty.asComplex().getValue());
+        createProperties((EdmComplexType) type, newProperty.asComplex().getValue());
       }
     }
-
     return newProperty;
   }
 
@@ -414,40 +415,36 @@ public class DataProvider {
   @SuppressWarnings("unchecked")
   public void updateProperty(final EdmProperty edmProperty, Property property, final Property newProperty,
       final boolean patch) throws DataProviderException {
-    if (edmProperty.isPrimitive()) {
-      if (newProperty != null || !patch) {
-        final Object value = newProperty == null ? null : newProperty.getValue();
-        updatePropertyValue(property, value);
-      }
-    } else if (edmProperty.isCollection()) {
+    final EdmType type = edmProperty.getType();
+    if (edmProperty.isCollection()) {
       // Updating collection properties means replacing all entries with the given ones.
       property.asCollection().clear();
 
       if (newProperty != null) {
-        if (edmProperty.getType().getKind() == EdmTypeKind.COMPLEX) {
-          // Complex type
-          final List<ComplexValue> complexValues = (List<ComplexValue>) newProperty.asCollection();
-
-          // Create each complex value
-          for (final ComplexValue complexValue : complexValues) {
+        if (type.getKind() == EdmTypeKind.COMPLEX) {
+          // Create each complex value.
+          for (final ComplexValue complexValue : (List<ComplexValue>) newProperty.asCollection()) {
             ((List<ComplexValue>) property.asCollection()).add(createComplexValue(edmProperty, complexValue, patch));
           }
         } else {
           // Primitive type
-          final List<Object> values = (List<Object>) newProperty.asCollection();
-          ((List<Object>) property.asCollection()).addAll(values);
+          ((List<Object>) property.asCollection()).addAll(newProperty.asCollection());
         }
       }
-    } else {
-      final EdmComplexType type = (EdmComplexType) edmProperty.getType();
-      for (final String propertyName : type.getPropertyNames()) {
+    } else if (type.getKind() == EdmTypeKind.COMPLEX) {
+      for (final String propertyName : ((EdmComplexType) type).getPropertyNames()) {
         final List<Property> newProperties = newProperty == null || newProperty.asComplex() == null ? null :
             newProperty.asComplex().getValue();
-        updateProperty(type.getStructuralProperty(propertyName),
+        updateProperty(((EdmComplexType) type).getStructuralProperty(propertyName),
             findProperty(propertyName, property.asComplex().getValue()),
             newProperties == null ? null : findProperty(propertyName, newProperties),
             patch);
       }
+    } else {
+      if (newProperty != null || !patch) {
+        final Object value = newProperty == null ? null : newProperty.getValue();
+        updatePropertyValue(property, value);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java
index 690e1d3..c8c4549 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java
@@ -777,12 +777,10 @@ public class PropertyProvider {
   // TypeDefinition Properties ---------------------------------------------------------------------------------------
   public static final CsdlProperty propertyTypeDefinition_TDString = new CsdlProperty()
       .setName("PropertyDefString")
-      .setType(TypeDefinitionProvider.nameTDString)
-      .setMaxLength(15);
+      .setType(TypeDefinitionProvider.nameTDString);
 
   public static final CsdlProperty collPropertyTypeDefinition_TDString = new CsdlProperty()
       .setName("CollPropertyDefString")
       .setType(TypeDefinitionProvider.nameTDString)
-      .setMaxLength(15)
       .setCollection(true);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/TypeDefinitionProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/TypeDefinitionProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/TypeDefinitionProvider.java
index 3a357a2..1c2be72 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/TypeDefinitionProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/TypeDefinitionProvider.java
@@ -28,10 +28,10 @@ public class TypeDefinitionProvider {
 
   public CsdlTypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) {
     if (nameTDString.equals(typeDefinitionName)) {
-      return new CsdlTypeDefinition().setName(nameTDString.getName()).setUnderlyingType(
-          EdmPrimitiveTypeKind.String.getFullQualifiedName()).setMaxLength(15);
+      return new CsdlTypeDefinition().setName(nameTDString.getName())
+          .setUnderlyingType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
+          .setMaxLength(15);
     }
     return null;
   }
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
index f3899d1..fbaf085 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
@@ -466,6 +466,10 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     Property complexProperty = entity.getProperty("PropertyCompMixedEnumDef");
     List<Property> value = complexProperty.asComplex().getValue();
     assertEquals((short) 2, value.get(0).getValue());
+
+    defProperty = ((ComplexValue) entity.getProperty("CollPropertyCompMixedEnumDef").asCollection().get(1))
+        .getValue().get(2);
+    assertEquals("string", defProperty.getValue());
     stream.close();
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/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 71f4d35..8b9431b 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
@@ -25,21 +25,15 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.UUID;
 
+import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntityContainer;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
-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.EdmDate;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
@@ -50,7 +44,6 @@ import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.mockito.Mockito;
 
 public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
 
@@ -264,7 +257,7 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
     Assert.assertNotNull(result.getProperty("PropertyComp"));
     Property comp = result.getProperty("PropertyComp");
     Assert.assertEquals("olingo.odata.test1.CTAllPrim", comp.getType());
-    ComplexValue cv = (ComplexValue)comp.getValue();
+    ComplexValue cv = comp.asComplex();
     
     Assert.assertEquals(16, cv.getValue().size());
     
@@ -277,14 +270,14 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
   }  
 
   private Property getCVProperty(ComplexValue cv, String name) {
-    for (Property p:cv.getValue()) {
+    for (Property p : cv.getValue()) {
       if (p.getName().equals(name)) {
         return p;
       }
     }
     return null;
   }
-  
+
   @Test
   public void entityMixPrimCollComp() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
@@ -336,7 +329,7 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
 
     Property comp = result.getProperty("PropertyComp");
     Assert.assertEquals("olingo.odata.test1.CTTwoPrim", comp.getType());
-    ComplexValue cv = (ComplexValue)comp.getValue();
+    ComplexValue cv = comp.asComplex();
     
     Assert.assertEquals(2, cv.getValue().size());
     Assert.assertEquals((short) 111, getCVProperty(cv, "PropertyInt16").asPrimitive());
@@ -344,21 +337,85 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
     
     comp = result.getProperty("CollPropertyComp");
     Assert.assertEquals("Collection(olingo.odata.test1.CTTwoPrim)", comp.getType());
-    @SuppressWarnings("unchecked")
-    List<ComplexValue> properties = (List<ComplexValue>)comp.getValue();
-    
+
+    List<?> properties = comp.asCollection();
     Assert.assertEquals(3, properties.size());
     
-    Assert.assertEquals((short) 123,
-        getCVProperty(properties.get(0), "PropertyInt16").asPrimitive());
-    Assert.assertEquals("TEST 1",
-        getCVProperty(properties.get(0), "PropertyString").asPrimitive());
+    Assert.assertEquals((short) 123, getCVProperty((ComplexValue) properties.get(0), "PropertyInt16").asPrimitive());
+    Assert.assertEquals("TEST 1", getCVProperty((ComplexValue) properties.get(0), "PropertyString").asPrimitive());
 
-    Assert.assertEquals((short) 789, getCVProperty(properties.get(2), "PropertyInt16").asPrimitive());
-    Assert.assertEquals("TEST 3", getCVProperty(properties.get(2), "PropertyString")
-        .asPrimitive());    
+    Assert.assertEquals((short) 789, getCVProperty((ComplexValue) properties.get(2), "PropertyInt16").asPrimitive());
+    Assert.assertEquals("TEST 3", getCVProperty((ComplexValue) properties.get(2), "PropertyString").asPrimitive());
   }
-  
+
+  @Test
+  public void entityMixEnumDefCollComp() throws Exception {
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixEnumDefCollComp");
+    final String payload = "<?xml version='1.0' encoding='UTF-8'?>\n"
+        + "<a:entry xmlns:a=\"" + Constants.NS_ATOM + "\""
+        + "  xmlns:m=\"" + Constants.NS_METADATA + "\" xmlns:d=\"" + Constants.NS_DATASERVICES + "\">\n"
+        + "  <a:content type=\"application/xml\">\n"
+        + "    <m:properties>\n"
+        + "      <d:PropertyInt16 m:type=\"Int16\">1</d:PropertyInt16>\n"
+        + "      <d:PropertyEnumString m:type=\"#olingo.odata.test1.ENString\">String2,String3"
+        + "</d:PropertyEnumString>\n"
+        + "      <d:CollPropertyEnumString m:type=\"#Collection(olingo.odata.test1.ENString)\">\n"
+        + "        <m:element>String2</m:element>\n"
+        + "        <m:element>String3</m:element>\n"
+        + "        <m:element>String2,String3</m:element>\n"
+        + "      </d:CollPropertyEnumString>\n"
+        + "      <d:PropertyDefString m:type=\"#olingo.odata.test1.TDString\">Test</d:PropertyDefString>\n"
+        + "      <d:CollPropertyDefString m:type=\"#Collection(olingo.odata.test1.TDString)\">\n"
+        + "        <m:element>Test1</m:element>\n"
+        + "        <m:element>Test2</m:element>\n"
+        + "      </d:CollPropertyDefString>\n"
+        + "      <d:PropertyCompMixedEnumDef m:type=\"#olingo.odata.test1.CTMixEnumDef\">\n"
+        + "        <d:PropertyEnumString m:type=\"#olingo.odata.test1.ENString\">String2,String3"
+        + "</d:PropertyEnumString>\n"
+        + "        <d:CollPropertyEnumString m:type=\"#Collection(olingo.odata.test1.ENString)\">\n"
+        + "          <m:element>String2</m:element>\n"
+        + "          <m:element>String3</m:element>\n"
+        + "          <m:element>String2,String3</m:element>\n"
+        + "        </d:CollPropertyEnumString>\n"
+        + "        <d:PropertyDefString m:type=\"#olingo.odata.test1.TDString\">Test</d:PropertyDefString>\n"
+        + "        <d:CollPropertyDefString m:type=\"#Collection(olingo.odata.test1.TDString)\">\n"
+        + "          <m:element>Test1</m:element>\n"
+        + "          <m:element>Test2</m:element>\n"
+        + "        </d:CollPropertyDefString>\n"
+        + "      </d:PropertyCompMixedEnumDef>\n"
+        + "      <d:CollPropertyCompMixedEnumDef m:type=\"#Collection(olingo.odata.test1.CTMixEnumDef)\">\n"
+        + "        <m:element>\n"
+        + "          <d:PropertyEnumString m:type=\"#olingo.odata.test1.ENString\">String2,String3"
+        + "</d:PropertyEnumString>\n"
+        + "          <d:CollPropertyEnumString m:type=\"#Collection(olingo.odata.test1.ENString)\">\n"
+        + "            <m:element>String2</m:element>\n"
+        + "            <m:element>String3</m:element>\n"
+        + "            <m:element>String2,String3</m:element>\n"
+        + "          </d:CollPropertyEnumString>\n"
+        + "          <d:PropertyDefString m:type=\"#olingo.odata.test1.TDString\">Test</d:PropertyDefString>\n"
+        + "          <d:CollPropertyDefString m:type=\"#Collection(olingo.odata.test1.TDString)\">\n"
+        + "            <m:element>Test1</m:element>\n"
+        + "            <m:element>Test2</m:element>\n"
+        + "          </d:CollPropertyDefString>\n"
+        + "        </m:element>\n"
+        + "      </d:CollPropertyCompMixedEnumDef>\n"
+        + "    </m:properties>\n"
+        + "  </a:content>\n"
+        + "</a:entry>";
+    final Entity result = deserializer.entity(new ByteArrayInputStream(payload.getBytes()), 
+        edmEntitySet.getEntityType()).getEntity();
+
+    Assert.assertEquals(7, result.getProperties().size());
+    
+    Assert.assertEquals((short) 1, result.getProperty("PropertyInt16").asPrimitive());
+    Assert.assertEquals((short) 6, result.getProperty("PropertyEnumString").asEnum());
+    Assert.assertEquals(3, result.getProperty("CollPropertyEnumString").asCollection().size());
+    Assert.assertEquals("Test", result.getProperty("PropertyDefString").asPrimitive());
+    Assert.assertEquals(2, result.getProperty("CollPropertyDefString").asCollection().size());
+    Assert.assertEquals(4, result.getProperty("PropertyCompMixedEnumDef").asComplex().getValue().size());
+    Assert.assertEquals(1, result.getProperty("CollPropertyCompMixedEnumDef").asCollection().size());
+  }
+
   @Test
   public void entityWithNavigation() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
@@ -461,54 +518,30 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
     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());
-    
   }
-  
+
   @Test
   public void complexProperty() throws Exception {
-    Edm edm = Mockito.mock(Edm.class);
-
-    CsdlProperty street = new CsdlProperty().setName("Street")
-        .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
-    CsdlProperty city = new CsdlProperty().setName("City")
-        .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
-    CsdlProperty region = new CsdlProperty().setName("Region")
-        .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
-    CsdlProperty postalcode = new CsdlProperty().setName("PostalCode")
-        .setType(EdmPrimitiveTypeKind.Int64.getFullQualifiedName());
-    
-    CsdlComplexType ct = new CsdlComplexType()
-        .setName("Model.Address")
-        .setProperties(Arrays.asList(street, city, region, postalcode));
-    EdmComplexTypeImpl complexType = new EdmComplexTypeImpl(edm, new FullQualifiedName("Model.Address"), ct);
-    
-    Mockito.stub(edm.getComplexType(new FullQualifiedName("Model.Address"))).toReturn(complexType);
-    
-    CsdlProperty prop = new CsdlProperty();
-    prop.setName("ShipTo");
-    prop.setType(new FullQualifiedName("Model.Address"));
-    EdmPropertyImpl edmProperty = new EdmPropertyImpl(edm, null, prop);
-
-    String payload = "<data:ShipTo xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" " +
-        " xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
-        " metadata:type=\"#Model.Address\">\n" + 
-        "  <data:Street>Obere Str. 57</data:Street>\n" + 
-        "  <data:City>Berlin</data:City>\n" + 
-        "  <data:Region metadata:null=\"true\"/>\n" + 
-        "  <data:PostalCode>12209</data:PostalCode>\n" + 
-        "</data:ShipTo>";
-    
-    Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
+    final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("PropertyComp");
+    final String payload = "<data:PropertyComp xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
+        + " xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n"
+        + " metadata:type=\"#olingo.odata.test1.CTTwoPrim\">\n"
+        + "  <data:PropertyInt16>123</data:PropertyInt16>\n" 
+        + "  <data:PropertyString metadata:null=\"true\"/>\n"
+        + "</data:PropertyComp>";
 
-    Assert.assertEquals("ShipTo", result.getName());
-    Assert.assertTrue(result.getValue() instanceof ComplexValue);
-    ComplexValue cv = (ComplexValue)result.getValue();
-    Assert.assertEquals("Model.Address", result.getType());
-    Assert.assertEquals("Berlin", getCVProperty(cv, "City").asPrimitive());
-    Assert.assertEquals("Obere Str. 57", getCVProperty(cv, "Street").asPrimitive());    
+    final Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty)
+        .getProperty();
+
+    Assert.assertEquals("PropertyComp", result.getName());
+    Assert.assertTrue(result.isComplex());
+    final ComplexValue cv = result.asComplex();
+    Assert.assertEquals("olingo.odata.test1.CTTwoPrim", result.getType());
+    Assert.assertEquals((short) 123, getCVProperty(cv, "PropertyInt16").asPrimitive());
+    Assert.assertTrue(getCVProperty(cv, "PropertyString").isNull());    
   }
-  
-  @SuppressWarnings("unchecked")
+
   @Test
   public void complexCollectionProperty() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
@@ -531,16 +564,20 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
         "</metadata:value>";
     Property result = deserializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
 
-    List<ComplexValue> complex = (List<ComplexValue>)result.getValue();
-    
-    Assert.assertEquals(3, complex.size());
+    List<?> complexCollection = result.asCollection();
+
+    Assert.assertEquals(3, complexCollection.size());
     Assert.assertEquals("Collection(olingo.odata.test1.CTTwoPrim)", result.getType());
-    Assert.assertEquals((short) 123, getCVProperty(complex.get(0), "PropertyInt16").asPrimitive());
-    Assert.assertEquals("TEST 1", getCVProperty(complex.get(0), "PropertyString").asPrimitive());
-    Assert.assertEquals((short) 789, getCVProperty(complex.get(2), "PropertyInt16").asPrimitive());
-    Assert.assertEquals("TEST 3", getCVProperty(complex.get(2), "PropertyString").asPrimitive());
+    Assert.assertEquals((short) 123,
+        getCVProperty((ComplexValue) complexCollection.get(0), "PropertyInt16").asPrimitive());
+    Assert.assertEquals("TEST 1",
+        getCVProperty((ComplexValue) complexCollection.get(0), "PropertyString").asPrimitive());
+    Assert.assertEquals((short) 789,
+        getCVProperty((ComplexValue) complexCollection.get(2), "PropertyInt16").asPrimitive());
+    Assert.assertEquals("TEST 3",
+        getCVProperty((ComplexValue) complexCollection.get(2), "PropertyString").asPrimitive());
   }
-  
+
   @Test
   public void entityReference() throws Exception {
     String payload = "<metadata:ref xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" + 
@@ -553,7 +590,7 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
     Assert.assertEquals(1, result.size());
     Assert.assertEquals("http://host/service/Orders(10643)", result.get(0).toASCIIString());
   }
-  
+
   @Test
   public void entityReferences() throws Exception {
     String payload = "<feed xmlns=\"http://www.w3.org/2005/Atom\"\n" + 
@@ -562,7 +599,7 @@ public class ODataXmlDeserializerTest extends AbstractODataDeserializerTest {
         "  <metadata:ref id=\"http://host/service/Orders(10643)\" />\n" + 
         "  <metadata:ref id=\"http://host/service/Orders(10759)\" />\n" + 
         "</feed>";
-    
+
     List<URI> result = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
         .getEntityReferences();    
     Assert.assertEquals(2, result.size());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index a882fa6..b5da9ae 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
 import java.util.Collections;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.ContextURL.Suffix;
 import org.apache.olingo.commons.api.data.Entity;
@@ -113,7 +114,7 @@ public class ODataJsonSerializerTest {
   public void entityAllPrimAllNull() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
     Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
-    entity.getProperties().retainAll(Arrays.asList(entity.getProperties().get(0)));
+    entity.getProperties().retainAll(Collections.singletonList(entity.getProperties().get(0)));
     final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(),
         entity,
         EntitySerializerOptions.with()
@@ -292,7 +293,7 @@ public class ODataJsonSerializerTest {
   public void entityMixPrimCollCompAllNull() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
     Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
-    entity.getProperties().retainAll(Arrays.asList(entity.getProperties().get(0)));
+    entity.getProperties().retainAll(Collections.singletonList(entity.getProperties().get(0)));
     final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
@@ -305,6 +306,45 @@ public class ODataJsonSerializerTest {
   }
 
   @Test
+  public void enumAndTypeDefinition() throws Exception {
+    final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixEnumDefCollComp");
+    Entity entity = new Entity();
+    entity.addProperty(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, 1));
+    entity.addProperty(new Property(null, "PropertyEnumString", ValueType.ENUM, 6));
+    entity.addProperty(new Property(null, "CollPropertyEnumString", ValueType.COLLECTION_ENUM,
+        Arrays.asList(2, 4, 6)));
+    entity.addProperty(new Property(null, "PropertyDefString", ValueType.PRIMITIVE, "Test"));
+    entity.addProperty(new Property(null, "CollPropertyDefString", ValueType.COLLECTION_PRIMITIVE,
+        Arrays.asList("Test1", "Test2")));
+    ComplexValue complexValue = new ComplexValue();
+    complexValue.getValue().add(entity.getProperty("PropertyEnumString"));
+    complexValue.getValue().add(entity.getProperty("CollPropertyEnumString"));
+    complexValue.getValue().add(entity.getProperty("PropertyDefString"));
+    complexValue.getValue().add(entity.getProperty("CollPropertyDefString"));
+    entity.addProperty(new Property(null, "PropertyCompMixedEnumDef", ValueType.COMPLEX, complexValue));
+    entity.addProperty(new Property(null, "CollPropertyCompMixedEnumDef", ValueType.COLLECTION_COMPLEX,
+        Collections.singletonList(complexValue)));
+    final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
+        EntitySerializerOptions.with()
+            .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
+            .build()).getContent());
+    Assert.assertEquals("{\"@odata.context\":\"$metadata#ESMixEnumDefCollComp/$entity\","
+        + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+        + "\"PropertyInt16\":1,"
+        + "\"PropertyEnumString\":\"String2,String3\","
+        + "\"CollPropertyEnumString\":[\"String2\",\"String3\",\"String2,String3\"],"
+        + "\"PropertyDefString\":\"Test\","
+        + "\"CollPropertyDefString\":[\"Test1\",\"Test2\"],"
+        + "\"PropertyCompMixedEnumDef\":{\"PropertyEnumString\":\"String2,String3\","
+        + "\"CollPropertyEnumString\":[\"String2\",\"String3\",\"String2,String3\"],"
+        + "\"PropertyDefString\":\"Test\",\"CollPropertyDefString\":[\"Test1\",\"Test2\"]},"
+        + "\"CollPropertyCompMixedEnumDef\":[{\"PropertyEnumString\":\"String2,String3\","
+        + "\"CollPropertyEnumString\":[\"String2\",\"String3\",\"String2,String3\"],"
+        + "\"PropertyDefString\":\"Test\",\"CollPropertyDefString\":[\"Test1\",\"Test2\"]}]}",
+        resultString);
+  }
+
+  @Test
   public void entityTwoPrimNoMetadata() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
@@ -452,7 +492,7 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
     final EdmEntityType entityType = edmEntitySet.getEntityType();
     final EntityCollection entitySet = data.readAll(edmEntitySet);
-    final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
+    final SelectOption select = ExpandSelectMock.mockSelectOption(Collections.singletonList(
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString")));
     InputStream result = serializer
         .entityCollection(metadata, entityType, entitySet,
@@ -501,7 +541,7 @@ public class ODataJsonSerializerTest {
   public void expand() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
-    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(
         ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne")));
     InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
@@ -537,11 +577,11 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
     final EdmEntityType entityType = edmEntitySet.getEntityType();
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
-    final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
+    final SelectOption select = ExpandSelectMock.mockSelectOption(Collections.singletonList(
         ExpandSelectMock.mockSelectItem(entityContainer.getEntitySet("ESAllPrim"), "PropertyDate")));
     ExpandItem expandItem = ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne");
     Mockito.when(expandItem.getSelectOption()).thenReturn(select);
-    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItem));
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(expandItem));
     final String resultString = IOUtils.toString(serializer
         .entity(metadata, entityType, entity,
             EntitySerializerOptions.with()
@@ -568,7 +608,7 @@ public class ODataJsonSerializerTest {
     Mockito.when(expandItemAll.isStar()).thenReturn(true);
     final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(
         expandItem, expandItem, expandItemAll));
-    final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
+    final SelectOption select = ExpandSelectMock.mockSelectOption(Collections.singletonList(
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertySByte")));
     final String resultString = IOUtils.toString(serializer
         .entity(metadata, entityType, entity,
@@ -595,8 +635,8 @@ public class ODataJsonSerializerTest {
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
     ExpandItem expandItemAll = Mockito.mock(ExpandItem.class);
     Mockito.when(expandItemAll.isStar()).thenReturn(true);
-    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemAll));
-    final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(expandItemAll));
+    final SelectOption select = ExpandSelectMock.mockSelectOption(Collections.singletonList(
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyTimeOfDay")));
     final String resultString = IOUtils.toString(serializer
         .entity(metadata, entityType, entity,
@@ -623,13 +663,13 @@ public class ODataJsonSerializerTest {
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
     ExpandItem expandItemSecond = Mockito.mock(ExpandItem.class);
     Mockito.when(expandItemSecond.isStar()).thenReturn(true);
-    final ExpandOption expandInner = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemSecond));
+    final ExpandOption expandInner = ExpandSelectMock.mockExpandOption(Collections.singletonList(expandItemSecond));
     ExpandItem expandItemFirst = ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimMany");
     Mockito.when(expandItemFirst.getExpandOption()).thenReturn(expandInner);
-    final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
+    final SelectOption select = ExpandSelectMock.mockSelectOption(Collections.singletonList(
         ExpandSelectMock.mockSelectItem(innerEntitySet, "PropertyInt32")));
     Mockito.when(expandItemFirst.getSelectOption()).thenReturn(select);
-    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemFirst));
+    final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(expandItemFirst));
     final String resultString = IOUtils.toString(serializer
         .entity(metadata, entityType, entity,
             EntitySerializerOptions.with()

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
index 066103c..3b5f58f 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
@@ -30,20 +30,29 @@ import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.etag.ServiceMetadataETagSupport;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.tecsvc.MetadataETagSupport;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Test;
 
 public class ServiceDocumentTest {
 
+  private static final String serviceRoot = "http://localhost:8080/odata.svc";
   private static final ServiceMetadata metadata = OData.newInstance().createServiceMetadata(
-      new EdmTechProvider(), Collections.<EdmxReference> emptyList(), new MetadataETagSupport("W/\"metadataETag\""));
+      new EdmTechProvider(), Collections.<EdmxReference> emptyList(),
+      new ServiceMetadataETagSupport() {
+        @Override
+        public String getServiceDocumentETag() {
+          return "W/\"serviceDocumentETag\"";
+        }
+        @Override
+        public String getMetadataETag() {
+          return "W/\"metadataETag\"";
+        }
+      });
 
   @Test
   public void writeServiceDocumentJson() throws Exception {
-    final String serviceRoot = "http://localhost:8080/odata.svc";
-
     OData server = OData.newInstance();
     assertNotNull(server);
 
@@ -54,7 +63,8 @@ public class ServiceDocumentTest {
     assertNotNull(result);
     final String jsonString = IOUtils.toString(result);
 
-    assertTrue(jsonString.contains(metadata.getServiceMetadataETagSupport().getMetadataETag().replace("\"", "\\\"")));
+    assertTrue(jsonString.contains(
+        metadata.getServiceMetadataETagSupport().getMetadataETag().replace("\"", "\\\"")));
 
     assertTrue(jsonString.contains("ESAllPrim"));
     assertTrue(jsonString.contains("ESCollAllPrim"));
@@ -75,7 +85,6 @@ public class ServiceDocumentTest {
 
   @Test
   public void serviceDocumentNoMetadata() throws Exception {
-    final String serviceRoot = "http://localhost:8080/odata.svc";
     final String result = IOUtils.toString(
         OData.newInstance().createSerializer(ContentType.JSON_NO_METADATA)
             .serviceDocument(metadata, serviceRoot).getContent());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d364dfa/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index 6f59060..a55398f 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -23,8 +23,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 
 import java.net.URI;
-import java.util.Arrays;
-import java.util.List;
+import java.util.Collections;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.format.ContentType;
@@ -44,7 +43,10 @@ public class MetadataDocumentTest {
   public void writeMetadataWithTechnicalScenario() throws Exception {
     final OData odata = OData.newInstance();
     final ServiceMetadata serviceMetadata = odata.createServiceMetadata(
-        new EdmTechProvider(), getEdmxReferences());
+        new EdmTechProvider(),
+        Collections.singletonList(
+            new EdmxReference(URI.create(CORE_VOCABULARY))
+                .addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", "Core"))));
 
     final String metadata = IOUtils.toString(
         odata.createSerializer(ContentType.APPLICATION_XML).metadataDocument(serviceMetadata).getContent());
@@ -138,23 +140,8 @@ public class MetadataDocumentTest {
 
     // TypeDefCheck
     assertThat(metadata,
-        containsString("<Property Name=\"PropertyDefString\" Type=\"Namespace1_Alias.TDString\" MaxLength=\"15\"/>"));
-    assertThat(metadata, containsString("<Property Name=\"CollPropertyDefString\" " +
-        "Type=\"Collection(Namespace1_Alias.TDString)\" MaxLength=\"15\"/>"));
-  }
-
-  /**
-   * <code>
-   * <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml">
-   * <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core"/>
-   * </edmx:Reference>
-   * </code>
-   *
-   * @return default emdx reference
-   */
-  private List<EdmxReference> getEdmxReferences() {
-    EdmxReference reference = new EdmxReference(URI.create(CORE_VOCABULARY));
-    reference.addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", "Core"));
-    return Arrays.asList(reference);
+        containsString("<Property Name=\"PropertyDefString\" Type=\"Namespace1_Alias.TDString\"/>"));
+    assertThat(metadata,
+        containsString("<Property Name=\"CollPropertyDefString\" Type=\"Collection(Namespace1_Alias.TDString)\"/>"));
   }
 }


Mime
View raw message