You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2013/07/31 10:12:57 UTC
[12/22] eliminate checkstyle warnings
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/parser/EdmParserTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/parser/EdmParserTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/parser/EdmParserTest.java
index 4ef463d..9860fef 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/parser/EdmParserTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/parser/EdmParserTest.java
@@ -77,160 +77,17 @@ public class EdmParserTest {
private static final String ASSOCIATION = "ManagerEmployees";
private static final int MAX_LENGTH = 4;
- private final String[] propertyNames = { "EmployeeId", "EmployeeName",
- "Location" };
+ private final String[] propertyNames = { "EmployeeId", "EmployeeName", "Location" };
- private final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\""
- + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\"" + propertyNames[1]
- + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>"
- + "<Property Name=\"" + propertyNames[2]
- + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>"
- + "</EntityType>" + "<ComplexType Name=\"c_Location\">"
- + "<Property Name=\"Country\" Type=\"Edm.String\"/>"
- + "</ComplexType>" + "</Schema>" + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ private final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "<Property Name=\"" + propertyNames[2] + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>" + "</EntityType>" + "<ComplexType Name=\"c_Location\">" + "<Property Name=\"Country\" Type=\"Edm.String\"/>" + "</ComplexType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
- private final String xmlWithBaseType = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\""
- + propertyNames[1]
- + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>"
- + "<Property Name=\""
- + propertyNames[2]
- + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "</EntityType>"
- + "<ComplexType Name=\"c_Location\">"
- + "<Property Name=\"Country\" Type=\"Edm.String\"/>"
- + "</ComplexType>"
- + "</Schema>"
- + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ private final String xmlWithBaseType = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "<Property Name=\"" + propertyNames[2] + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "</EntityType>" + "<ComplexType Name=\"c_Location\">" + "<Property Name=\"Country\" Type=\"Edm.String\"/>" + "</ComplexType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
- private final String xmlWithAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Manager\" ToRole=\"r_Employees\" />"
- + "</EntityType>"
- + "<Association Name=\""
- + ASSOCIATION
- + "\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\">"
- + "<OnDelete Action=\"Cascade\"/>"
- + "</End>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association>"
- + "</Schema>"
- + "<Schema Namespace=\""
- + NAMESPACE2
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>"
- + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>"
- + "<AssociationSet Name=\""
- + ASSOCIATION
- + "\" Association=\"RefScenario."
- + ASSOCIATION
- + "\">"
- + "<End EntitySet=\"Managers\" Role=\"r_Manager\"/>"
- + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>"
- + "</AssociationSet>"
- + "</EntityContainer>"
- + "</Schema>"
- + "</edmx:DataServices>" + "</edmx:Edmx>";
+ private final String xmlWithAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Manager\" ToRole=\"r_Employees\" />" + "</EntityType>" + "<Association Name=\"" + ASSOCIATION + "\">"
+ + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\">" + "<OnDelete Action=\"Cascade\"/>" + "</End>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association>" + "</Schema>" + "<Schema Namespace=\"" + NAMESPACE2 + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>" + "<AssociationSet Name=\"" + ASSOCIATION + "\" Association=\"RefScenario." + ASSOCIATION + "\">" + "<End EntitySet=\"Managers\" Role=\"r_Manager\"/>" + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>" + "</AssociationSet>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
- private final String xmlWithTwoSchemas = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\""
- + propertyNames[1]
- + "\" Type=\"Edm.String\"/>"
- + "</EntityType>"
- + "</Schema>"
- + "<Schema Namespace=\""
- + NAMESPACE2
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Photo\">"
- + "<Key><PropertyRef Name=\"Id\"/></Key>"
- + "<Property Name=\"Id\" Type=\"Edm.Int32\" Nullable=\"false\" ConcurrencyMode=\"Fixed\" MaxLength=\""
- + MAX_LENGTH
- + "\"/>"
- + "<Property Name=\"Name\" Type=\"Edm.String\" Unicode=\"true\" DefaultValue=\""
- + DEFAULT_VALUE
- + "\" FixedLength=\"false\"/>"
- + "<Property Name=\"BinaryData\" Type=\"Edm.Binary\" m:MimeType=\""
- + MIME_TYPE
- + "\"/>"
- + "<Property Name=\"Содержание\" Type=\"Edm.String\" m:FC_TargetPath=\""
- + FC_TARGET_PATH
- + "\" m:FC_NsUri=\""
- + FC_NS_URI
- + "\""
- + " m:FC_NsPrefix=\""
- + FC_NS_PREFIX
- + "\" m:FC_KeepInContent=\""
- + FC_KEEP_IN_CONTENT
- + "\" m:FC_ContentKind=\"text\" >"
- + "</Property>"
- + "</EntityType>"
- + "</Schema>"
- + "</edmx:DataServices>" + "</edmx:Edmx>";
+ private final String xmlWithTwoSchemas = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\"/>" + "</EntityType>" + "</Schema>" + "<Schema Namespace=\"" + NAMESPACE2 + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Photo\">" + "<Key><PropertyRef Name=\"Id\"/></Key>" + "<Property Name=\"Id\" Type=\"Edm.Int32\" Nullable=\"false\" ConcurrencyMode=\"Fixed\" MaxLength=\"" + MAX_LENGTH + "\"/>" + "<Property Name=\"Name\" Type=\"Edm.String\" Unicode=\"true\" DefaultValue=\"" + DEFAULT_VALUE
+ + "\" FixedLength=\"false\"/>" + "<Property Name=\"BinaryData\" Type=\"Edm.Binary\" m:MimeType=\"" + MIME_TYPE + "\"/>" + "<Property Name=\"Содержание\" Type=\"Edm.String\" m:FC_TargetPath=\"" + FC_TARGET_PATH + "\" m:FC_NsUri=\"" + FC_NS_URI + "\"" + " m:FC_NsPrefix=\"" + FC_NS_PREFIX + "\" m:FC_KeepInContent=\"" + FC_KEEP_IN_CONTENT + "\" m:FC_ContentKind=\"text\" >" + "</Property>" + "</EntityType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
@Test
public void test() throws XMLStreamException, EntityProviderException {
@@ -244,12 +101,10 @@ public class EdmParserTest {
assertEquals(1, schema.getEntityTypes().size());
assertEquals("Employee", schema.getEntityTypes().get(0).getName());
assertEquals(Boolean.TRUE, schema.getEntityTypes().get(0).isHasStream());
- for (PropertyRef propertyRef : schema.getEntityTypes().get(0)
- .getKey().getKeys()) {
+ for (PropertyRef propertyRef : schema.getEntityTypes().get(0).getKey().getKeys()) {
assertEquals("EmployeeId", propertyRef.getName());
}
- for (Property property : schema.getEntityTypes().get(0)
- .getProperties()) {
+ for (Property property : schema.getEntityTypes().get(0).getProperties()) {
assertEquals(propertyNames[i], property.getName());
if ("Location".equals(property.getName())) {
ComplexProperty cProperty = (ComplexProperty) property;
@@ -263,14 +118,12 @@ public class EdmParserTest {
i++;
}
assertEquals(1, schema.getComplexTypes().size());
- assertEquals("c_Location", schema.getComplexTypes().get(0)
- .getName());
+ assertEquals("c_Location", schema.getComplexTypes().get(0).getName());
}
}
@Test
- public void testBaseType() throws XMLStreamException,
- EntityProviderException {
+ public void testBaseType() throws XMLStreamException, EntityProviderException {
int i = 0;
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithBaseType);
@@ -280,12 +133,10 @@ public class EdmParserTest {
assertEquals(NAMESPACE, schema.getNamespace());
assertEquals(2, schema.getEntityTypes().size());
assertEquals("Employee", schema.getEntityTypes().get(0).getName());
- for (PropertyRef propertyRef : schema.getEntityTypes().get(0)
- .getKey().getKeys()) {
+ for (PropertyRef propertyRef : schema.getEntityTypes().get(0).getKey().getKeys()) {
assertEquals("EmployeeId", propertyRef.getName());
}
- for (Property property : schema.getEntityTypes().get(0)
- .getProperties()) {
+ for (Property property : schema.getEntityTypes().get(0).getProperties()) {
assertEquals(propertyNames[i], property.getName());
i++;
}
@@ -294,29 +145,9 @@ public class EdmParserTest {
}
@Test
- public void testComplexTypeWithBaseType() throws XMLStreamException,
- EntityProviderException {
- final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08 + "\">"
- + "<Schema Namespace=\"" + NAMESPACE + "\" Alias=\"RS\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\"" + propertyNames[2]
- + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>"
- + "</EntityType>"
- + "<ComplexType Name=\"c_BaseType_for_Location\" Abstract=\"true\">"
- + "<Property Name=\"Country\" Type=\"Edm.String\"/>"
- + "</ComplexType>"
- + "<ComplexType Name=\"c_Location\" BaseType=\"RefScenario.c_BaseType_for_Location\">"
- + "</ComplexType>"
- + "<ComplexType Name=\"c_Other_Location\" BaseType=\"RS.c_BaseType_for_Location\">"
- + "</ComplexType>"
- + "</Schema>" + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ public void testComplexTypeWithBaseType() throws XMLStreamException, EntityProviderException {
+ final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" Alias=\"RS\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[2] + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>" + "</EntityType>" + "<ComplexType Name=\"c_BaseType_for_Location\" Abstract=\"true\">" + "<Property Name=\"Country\" Type=\"Edm.String\"/>" + "</ComplexType>" + "<ComplexType Name=\"c_Location\" BaseType=\"RefScenario.c_BaseType_for_Location\">" + "</ComplexType>" + "<ComplexType Name=\"c_Other_Location\" BaseType=\"RS.c_BaseType_for_Location\">" + "</ComplexType>" + "</Schema>"
+ + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xml);
DataServices result = parser.readMetadata(reader, true);
@@ -328,14 +159,12 @@ public class EdmParserTest {
assertTrue(!complexType.isAbstract());
assertEquals("c_BaseType_for_Location", complexType.getBaseType().getName());
assertEquals("RefScenario", complexType.getBaseType().getNamespace());
- }
- else if ("c_Other_Location".equals(complexType.getName())) {
+ } else if ("c_Other_Location".equals(complexType.getName())) {
assertNotNull(complexType.getBaseType());
assertTrue(!complexType.isAbstract());
assertEquals("c_BaseType_for_Location", complexType.getBaseType().getName());
assertEquals("RS", complexType.getBaseType().getNamespace());
- }
- else if ("c_BaseType_for_Location".equals(complexType.getName())) {
+ } else if ("c_BaseType_for_Location".equals(complexType.getName())) {
assertNotNull(complexType.isAbstract());
assertTrue(complexType.isAbstract());
} else {
@@ -347,62 +176,23 @@ public class EdmParserTest {
}
@Test(expected = EntityProviderException.class)
- public void testComplexTypeWithInvalidBaseType() throws XMLStreamException,
- EntityProviderException {
- final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\""
- + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\"" + propertyNames[2]
- + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>"
- + "</EntityType>"
- + "<ComplexType Name=\"c_BaseType_for_Location\" Abstract=\"true\">"
- + "<Property Name=\"Country\" Type=\"Edm.String\"/>"
- + "</ComplexType>"
- + "<ComplexType Name=\"c_Location\" BaseType=\"RefScenario.Employee\">"
- + "</ComplexType>"
- + "</Schema>" + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ public void testComplexTypeWithInvalidBaseType() throws XMLStreamException, EntityProviderException {
+ final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[2] + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>" + "</EntityType>" + "<ComplexType Name=\"c_BaseType_for_Location\" Abstract=\"true\">" + "<Property Name=\"Country\" Type=\"Edm.String\"/>" + "</ComplexType>" + "<ComplexType Name=\"c_Location\" BaseType=\"RefScenario.Employee\">" + "</ComplexType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xml);
parser.readMetadata(reader, true);
}
@Test(expected = EntityProviderException.class)
- public void testComplexTypeWithInvalidBaseType2() throws XMLStreamException,
- EntityProviderException {
- final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\""
- + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\"" + propertyNames[2]
- + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>"
- + "</EntityType>"
- + "<ComplexType Name=\"c_BaseType_for_Location\" Abstract=\"true\">"
- + "<Property Name=\"Country\" Type=\"Edm.String\"/>"
- + "</ComplexType>"
- + "<ComplexType Name=\"c_Location\" BaseType=\"c_BaseType_for_Location\">"
- + "</ComplexType>"
- + "</Schema>" + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ public void testComplexTypeWithInvalidBaseType2() throws XMLStreamException, EntityProviderException {
+ final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[2] + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>" + "</EntityType>" + "<ComplexType Name=\"c_BaseType_for_Location\" Abstract=\"true\">" + "<Property Name=\"Country\" Type=\"Edm.String\"/>" + "</ComplexType>" + "<ComplexType Name=\"c_Location\" BaseType=\"c_BaseType_for_Location\">" + "</ComplexType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xml);
parser.readMetadata(reader, true);
}
@Test
- public void testAssociation() throws XMLStreamException,
- EntityProviderException {
+ public void testAssociation() throws XMLStreamException, EntityProviderException {
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithAssociation);
DataServices result = parser.readMetadata(reader, true);
@@ -410,35 +200,27 @@ public class EdmParserTest {
for (Schema schema : result.getSchemas()) {
for (EntityType entityType : schema.getEntityTypes()) {
if ("Manager".equals(entityType.getName())) {
- assertEquals("RefScenario", entityType.getBaseType()
- .getNamespace());
+ assertEquals("RefScenario", entityType.getBaseType().getNamespace());
assertEquals("Employee", entityType.getBaseType().getName());
- for (NavigationProperty navProperty : entityType
- .getNavigationProperties()) {
+ for (NavigationProperty navProperty : entityType.getNavigationProperties()) {
assertEquals("r_Manager", navProperty.getFromRole());
assertEquals("r_Employees", navProperty.getToRole());
- assertEquals("RefScenario", navProperty
- .getRelationship().getNamespace());
- assertEquals(ASSOCIATION, navProperty.getRelationship()
- .getName());
+ assertEquals("RefScenario", navProperty.getRelationship().getNamespace());
+ assertEquals(ASSOCIATION, navProperty.getRelationship().getName());
}
}
if ("Employee".equals(entityType.getName())) {
- for (NavigationProperty navProperty : entityType
- .getNavigationProperties()) {
+ for (NavigationProperty navProperty : entityType.getNavigationProperties()) {
assertEquals("r_Employees", navProperty.getFromRole());
- assertEquals("RefScenario", navProperty
- .getRelationship().getNamespace());
- assertEquals(ASSOCIATION, navProperty.getRelationship()
- .getName());
+ assertEquals("RefScenario", navProperty.getRelationship().getNamespace());
+ assertEquals(ASSOCIATION, navProperty.getRelationship().getName());
}
}
}
for (Association association : schema.getAssociations()) {
AssociationEnd end;
assertEquals(ASSOCIATION, association.getName());
- if ("Employee"
- .equals(association.getEnd1().getType().getName())) {
+ if ("Employee".equals(association.getEnd1().getType().getName())) {
end = association.getEnd1();
} else {
end = association.getEnd2();
@@ -451,8 +233,7 @@ public class EdmParserTest {
}
@Test
- public void testTwoSchemas() throws XMLStreamException,
- EntityProviderException {
+ public void testTwoSchemas() throws XMLStreamException, EntityProviderException {
int i = 0;
String schemasNs[] = { NAMESPACE, NAMESPACE2 };
EdmParser parser = new EdmParser();
@@ -469,8 +250,7 @@ public class EdmParserTest {
}
@Test
- public void testProperties() throws EntityProviderException,
- XMLStreamException {
+ public void testProperties() throws EntityProviderException, XMLStreamException {
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithTwoSchemas);
DataServices result = parser.readMetadata(reader, true);
@@ -489,43 +269,26 @@ public class EdmParserTest {
for (Property property : entityType.getProperties()) {
SimpleProperty sProperty = (SimpleProperty) property;
if ("Id".equals(property.getName())) {
- assertEquals(Boolean.FALSE, property.getFacets()
- .isNullable());
- assertEquals(EdmConcurrencyMode.Fixed, property
- .getFacets().getConcurrencyMode());
- assertEquals(new Integer(MAX_LENGTH), property
- .getFacets().getMaxLength());
+ assertEquals(Boolean.FALSE, property.getFacets().isNullable());
+ assertEquals(EdmConcurrencyMode.Fixed, property.getFacets().getConcurrencyMode());
+ assertEquals(new Integer(MAX_LENGTH), property.getFacets().getMaxLength());
- assertEquals(EdmSimpleTypeKind.Int32,
- sProperty.getType());
+ assertEquals(EdmSimpleTypeKind.Int32, sProperty.getType());
assertNull(property.getCustomizableFeedMappings());
}
if ("Name".equals(property.getName())) {
- assertEquals(Boolean.TRUE, property.getFacets()
- .isUnicode());
- assertEquals(DEFAULT_VALUE, property.getFacets()
- .getDefaultValue());
- assertEquals(Boolean.FALSE, property.getFacets()
- .isFixedLength());
- assertEquals(EdmSimpleTypeKind.String,
- sProperty.getType());
+ assertEquals(Boolean.TRUE, property.getFacets().isUnicode());
+ assertEquals(DEFAULT_VALUE, property.getFacets().getDefaultValue());
+ assertEquals(Boolean.FALSE, property.getFacets().isFixedLength());
+ assertEquals(EdmSimpleTypeKind.String, sProperty.getType());
assertNull(property.getCustomizableFeedMappings());
}
if ("Содержание".equals(property.getName())) {
- assertEquals(FC_TARGET_PATH, property
- .getCustomizableFeedMappings()
- .getFcTargetPath());
- assertEquals(FC_NS_URI, property
- .getCustomizableFeedMappings().getFcNsUri());
- assertEquals(FC_NS_PREFIX, property
- .getCustomizableFeedMappings()
- .getFcNsPrefix());
- assertEquals(FC_KEEP_IN_CONTENT, property
- .getCustomizableFeedMappings()
- .isFcKeepInContent());
- assertEquals(EdmContentKind.text, property
- .getCustomizableFeedMappings()
- .getFcContentKind());
+ assertEquals(FC_TARGET_PATH, property.getCustomizableFeedMappings().getFcTargetPath());
+ assertEquals(FC_NS_URI, property.getCustomizableFeedMappings().getFcNsUri());
+ assertEquals(FC_NS_PREFIX, property.getCustomizableFeedMappings().getFcNsPrefix());
+ assertEquals(FC_KEEP_IN_CONTENT, property.getCustomizableFeedMappings().isFcKeepInContent());
+ assertEquals(EdmContentKind.text, property.getCustomizableFeedMappings().getFcContentKind());
}
if ("BinaryData".equals(property.getName())) {
assertEquals(MIME_TYPE, property.getMimeType());
@@ -537,34 +300,8 @@ public class EdmParserTest {
}
@Test
- public void testEntitySet() throws XMLStreamException,
- EntityProviderException {
- final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\""
- + propertyNames[1]
- + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>"
- + "</EntityType>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>"
- + "</EntityContainer>"
- + "</Schema>"
- + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ public void testEntitySet() throws XMLStreamException, EntityProviderException {
+ final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmWithEntityContainer);
DataServices result = parser.readMetadata(reader, true);
@@ -574,18 +311,15 @@ public class EdmParserTest {
assertEquals(Boolean.TRUE, container.isDefaultEntityContainer());
for (EntitySet entitySet : container.getEntitySets()) {
assertEquals("Employees", entitySet.getName());
- assertEquals("Employee", entitySet.getEntityType()
- .getName());
- assertEquals(NAMESPACE, entitySet.getEntityType()
- .getNamespace());
+ assertEquals("Employee", entitySet.getEntityType().getName());
+ assertEquals(NAMESPACE, entitySet.getEntityType().getNamespace());
}
}
}
}
@Test
- public void testAssociationSet() throws XMLStreamException,
- EntityProviderException {
+ public void testAssociationSet() throws XMLStreamException, EntityProviderException {
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithAssociation);
DataServices result = parser.readMetadata(reader, true);
@@ -611,36 +345,9 @@ public class EdmParserTest {
}
@Test
- public void testFunctionImport() throws XMLStreamException,
- EntityProviderException {
- final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\""
- + propertyNames[1]
- + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>"
- + "</EntityType>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>"
- + "<FunctionImport Name=\"EmployeeSearch\" ReturnType=\"Collection(RefScenario.Employee)\" EntitySet=\"Employees\" m:HttpMethod=\"GET\">"
- + "<Parameter Name=\"q\" Type=\"Edm.String\" Nullable=\"true\" />"
- + "</FunctionImport>"
- + "</EntityContainer>"
- + "</Schema>"
- + "</edmx:DataServices>" + "</edmx:Edmx>";
+ public void testFunctionImport() throws XMLStreamException, EntityProviderException {
+ final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<FunctionImport Name=\"EmployeeSearch\" ReturnType=\"Collection(RefScenario.Employee)\" EntitySet=\"Employees\" m:HttpMethod=\"GET\">" + "<Parameter Name=\"q\" Type=\"Edm.String\" Nullable=\"true\" />"
+ + "</FunctionImport>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmWithEntityContainer);
DataServices result = parser.readMetadata(reader, true);
@@ -668,26 +375,7 @@ public class EdmParserTest {
@Test()
public void testAlias() throws XMLStreamException, EntityProviderException {
- final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" Alias=\"RS\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RS.Employee\" m:HasStream=\"true\">"
- + "</EntityType>" + "</Schema>" + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" Alias=\"RS\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RS.Employee\" m:HasStream=\"true\">" + "</EntityType>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xml);
DataServices result = parser.readMetadata(reader, true);
@@ -705,97 +393,33 @@ public class EdmParserTest {
@Test(expected = EntityProviderException.class)
public void testEntityTypeWithoutKeys() throws XMLStreamException, EntityProviderException {
- final String xmlWithoutKeys = "<Schema Namespace=\"" + NAMESPACE
- + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\">" + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "</EntityType>" + "</Schema>";
+ final String xmlWithoutKeys = "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "</EntityType>" + "</Schema>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithoutKeys);
parser.readMetadata(reader, true);
}
@Test(expected = EntityProviderException.class)
- public void testInvalidBaseType() throws XMLStreamException,
- EntityProviderException {
- final String xmlWithInvalidBaseType = "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Manager\" BaseType=\"Employee\" m:HasStream=\"true\">"
- + "</EntityType>" + "</Schema>";
+ public void testInvalidBaseType() throws XMLStreamException, EntityProviderException {
+ final String xmlWithInvalidBaseType = "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Manager\" BaseType=\"Employee\" m:HasStream=\"true\">" + "</EntityType>" + "</Schema>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidBaseType);
parser.readMetadata(reader, true);
}
@Test(expected = EntityProviderException.class)
- public void testInvalidRole() throws XMLStreamException,
- EntityProviderException {
- final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"Manager\" ToRole=\"Employees\" />"
- + "</EntityType>"
- + "<Association Name=\"ManagerEmployees\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association>"
- + "</Schema>"
- + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ public void testInvalidRole() throws XMLStreamException, EntityProviderException {
+ final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"Manager\" ToRole=\"Employees\" />" + "</EntityType>" + "<Association Name=\"ManagerEmployees\">" + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association>" + "</Schema>"
+ + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociation);
parser.readMetadata(reader, true);
}
@Test(expected = EntityProviderException.class)
- public void testInvalidRelationship() throws XMLStreamException,
- EntityProviderException {
- final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployee\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "</EntityType>"
- + "<Association Name=\"ManagerEmployees\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association>"
- + "</Schema>"
- + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ public void testInvalidRelationship() throws XMLStreamException, EntityProviderException {
+ final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployee\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "</EntityType>" + "<Association Name=\"ManagerEmployees\">" + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association>" + "</Schema>"
+ + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociation);
parser.readMetadata(reader, true);
@@ -803,21 +427,7 @@ public class EdmParserTest {
@Test(expected = EntityProviderException.class)
public void testMissingRelationship() throws Exception {
- final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">"
- + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "</EntityType>"
- + "<Association Name=\"ManagerEmployees\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association></Schema></edmx:DataServices></edmx:Edmx>";
+ final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "</EntityType>" + "<Association Name=\"ManagerEmployees\">" + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association></Schema></edmx:DataServices></edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociation);
try {
@@ -833,24 +443,8 @@ public class EdmParserTest {
@Test(expected = EntityProviderException.class)
public void testMissingEntityType() throws Exception {
- final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">"
- + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "</EntityType>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" />"
- + "</EntityContainer>"
- + "<Association Name=\"ManagerEmployees\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association></Schema></edmx:DataServices></edmx:Edmx>";
+ final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" />" + "</EntityContainer>" + "<Association Name=\"ManagerEmployees\">"
+ + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association></Schema></edmx:DataServices></edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociation);
try {
@@ -866,21 +460,7 @@ public class EdmParserTest {
@Test(expected = EntityProviderException.class)
public void testMissingType() throws Exception {
- final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">"
- + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0] + "\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "</EntityType>"
- + "<Association Name=\"ManagerEmployees\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association></Schema></edmx:DataServices></edmx:Edmx>";
+ final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "</EntityType>" + "<Association Name=\"ManagerEmployees\">" + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association></Schema></edmx:DataServices></edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociation);
try {
@@ -896,21 +476,7 @@ public class EdmParserTest {
@Test(expected = EntityProviderException.class)
public void testMissingTypeAtAssociation() throws Exception {
- final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">"
- + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "</EntityType>"
- + "<Association Name=\"ManagerEmployees\">"
- + "<End Multiplicity=\"*\" Role=\"r_Employees\"/>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association></Schema></edmx:DataServices></edmx:Edmx>";
+ final String xmlWithInvalidAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "</EntityType>" + "<Association Name=\"ManagerEmployees\">" + "<End Multiplicity=\"*\" Role=\"r_Employees\"/>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association></Schema></edmx:DataServices></edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociation);
try {
@@ -926,21 +492,7 @@ public class EdmParserTest {
@Test(expected = EntityProviderException.class)
public void testMissingTypeAtFunctionImport() throws Exception {
- final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>"
- + "</EntityType>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>"
- + "<FunctionImport Name=\"EmployeeSearch\" ReturnType=\"Collection(RefScenario.Employee)\" EntitySet=\"Employees\" m:HttpMethod=\"GET\">"
- + "<Parameter Name=\"q\" Nullable=\"true\" />"
- + "</FunctionImport>"
+ final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<FunctionImport Name=\"EmployeeSearch\" ReturnType=\"Collection(RefScenario.Employee)\" EntitySet=\"Employees\" m:HttpMethod=\"GET\">" + "<Parameter Name=\"q\" Nullable=\"true\" />" + "</FunctionImport>"
+ "</EntityContainer></Schema></edmx:DataServices></edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xml);
@@ -957,25 +509,9 @@ public class EdmParserTest {
@Test(expected = EntityProviderException.class)
public void testMissingAssociation() throws Exception {
- final String xmlWithAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">"
- + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />"
- + "</EntityType>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>"
- + "<AssociationSet Name=\"" + ASSOCIATION
- // + "\" Association=\"RefScenario." + ASSOCIATION
- + "\">"
- + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>"
- + "</AssociationSet>"
- + "</EntityContainer>"
- + "</Schema>"
- + "</edmx:DataServices></edmx:Edmx>";
+ final String xmlWithAssociation = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<AssociationSet Name=\"" + ASSOCIATION
+ // + "\" Association=\"RefScenario." + ASSOCIATION
+ + "\">" + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>" + "</AssociationSet>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices></edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithAssociation);
try {
@@ -990,51 +526,9 @@ public class EdmParserTest {
}
@Test(expected = EntityProviderException.class)
- public void testInvalidAssociation() throws XMLStreamException,
- EntityProviderException {
- final String xmlWithInvalidAssociationSet = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Manager\" ToRole=\"r_Employees\" />"
- + "</EntityType>"
- + "<Association Name=\""
- + ASSOCIATION
- + "\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\">"
- + "<OnDelete Action=\"Cascade\"/>"
- + "</End>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>"
- + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>"
- + "<AssociationSet Name=\""
- + ASSOCIATION
- + "\" Association=\"RefScenario2."
- + ASSOCIATION
- + "\">"
- + "<End EntitySet=\"Managers\" Role=\"r_Manager\"/>"
- + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>"
- + "</AssociationSet>"
- + "</EntityContainer>"
- + "</Schema>"
- + "</edmx:DataServices>" + "</edmx:Edmx>";
+ public void testInvalidAssociation() throws XMLStreamException, EntityProviderException {
+ final String xmlWithInvalidAssociationSet = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Manager\" ToRole=\"r_Employees\" />" + "</EntityType>" + "<Association Name=\"" + ASSOCIATION + "\">"
+ + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\">" + "<OnDelete Action=\"Cascade\"/>" + "</End>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>" + "<AssociationSet Name=\"" + ASSOCIATION + "\" Association=\"RefScenario2." + ASSOCIATION + "\">" + "<End EntitySet=\"Managers\" Role=\"r_Manager\"/>" + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>" + "</AssociationSet>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociationSet);
parser.readMetadata(reader, true);
@@ -1042,68 +536,11 @@ public class EdmParserTest {
}
@Test(expected = EntityProviderException.class)
- public void testInvalidAssociationEnd() throws XMLStreamException,
- EntityProviderException {
+ public void testInvalidAssociationEnd() throws XMLStreamException, EntityProviderException {
final String employees = "r_Employees";
final String manager = "r_Manager";
- final String xmlWithInvalidAssociationSetEnd = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\""
- + employees
- + "\" ToRole=\""
- + manager
- + "\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\""
- + manager
- + "\" ToRole=\""
- + employees
- + "\" />"
- + "</EntityType>"
- + "<Association Name=\""
- + ASSOCIATION
- + "\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\""
- + employees
- + "1"
- + "\"/>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\""
- + manager
- + "\"/>"
- + "</Association>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>"
- + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>"
- + "<AssociationSet Name=\""
- + ASSOCIATION
- + "\" Association=\"RefScenario2."
- + ASSOCIATION
- + "\">"
- + "<End EntitySet=\"Managers\" Role=\""
- + manager
- + "\"/>"
- + "<End EntitySet=\"Employees\" Role=\""
- + employees
- + "\"/>"
- + "</AssociationSet>"
- + "</EntityContainer>"
- + "</Schema>"
- + "</edmx:DataServices>" + "</edmx:Edmx>";
+ final String xmlWithInvalidAssociationSetEnd = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"" + employees + "\" ToRole=\"" + manager + "\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"" + manager + "\" ToRole=\"" + employees + "\" />" + "</EntityType>" + "<Association Name=\"" + ASSOCIATION + "\">"
+ + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"" + employees + "1" + "\"/>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"" + manager + "\"/>" + "</Association>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>" + "<AssociationSet Name=\"" + ASSOCIATION + "\" Association=\"RefScenario2." + ASSOCIATION + "\">" + "<End EntitySet=\"Managers\" Role=\"" + manager + "\"/>" + "<End EntitySet=\"Employees\" Role=\"" + employees + "\"/>" + "</AssociationSet>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociationSetEnd);
parser.readMetadata(reader, true);
@@ -1111,67 +548,11 @@ public class EdmParserTest {
}
@Test(expected = EntityProviderException.class)
- public void testInvalidAssociationEnd2() throws XMLStreamException,
- EntityProviderException {
+ public void testInvalidAssociationEnd2() throws XMLStreamException, EntityProviderException {
final String employees = "r_Employees";
final String manager = "r_Manager";
- final String xmlWithInvalidAssociationSetEnd = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\""
- + employees
- + "\" ToRole=\""
- + manager
- + "\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\""
- + manager
- + "\" ToRole=\""
- + employees
- + "\" />"
- + "</EntityType>"
- + "<Association Name=\""
- + ASSOCIATION
- + "\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\""
- + employees
- + "\"/>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\""
- + manager
- + "\"/>"
- + "</Association>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>"
- + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>"
- + "<AssociationSet Name=\""
- + ASSOCIATION
- + "\" Association=\"RefScenario2."
- + ASSOCIATION
- + "\">"
- + "<End EntitySet=\"Managers\" Role=\""
- + manager
- + "\"/>"
- + "<End EntitySet=\"Managers\" Role=\""
- + manager
- + "\"/>"
- + "</AssociationSet>"
- + "</EntityContainer>"
- + "</Schema>"
- + "</edmx:DataServices>" + "</edmx:Edmx>";
+ final String xmlWithInvalidAssociationSetEnd = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"" + employees + "\" ToRole=\"" + manager + "\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">" + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"" + manager + "\" ToRole=\"" + employees + "\" />" + "</EntityType>" + "<Association Name=\"" + ASSOCIATION + "\">"
+ + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"" + employees + "\"/>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"" + manager + "\"/>" + "</Association>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Employee\"/>" + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>" + "<AssociationSet Name=\"" + ASSOCIATION + "\" Association=\"RefScenario2." + ASSOCIATION + "\">" + "<End EntitySet=\"Managers\" Role=\"" + manager + "\"/>" + "<End EntitySet=\"Managers\" Role=\"" + manager + "\"/>" + "</AssociationSet>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmlWithInvalidAssociationSetEnd);
parser.readMetadata(reader, true);
@@ -1179,34 +560,8 @@ public class EdmParserTest {
}
@Test(expected = EntityProviderException.class)
- public void testInvalidEntitySet() throws XMLStreamException,
- EntityProviderException {
- final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\""
- + propertyNames[1]
- + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>"
- + "</EntityType>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Mitarbeiter\"/>"
- + "</EntityContainer>"
- + "</Schema>"
- + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ public void testInvalidEntitySet() throws XMLStreamException, EntityProviderException {
+ final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[1] + "\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RefScenario.Mitarbeiter\"/>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmWithEntityContainer);
parser.readMetadata(reader, true);
@@ -1215,34 +570,7 @@ public class EdmParserTest {
@Test
public void testEntityTypeInOtherSchema() throws XMLStreamException, EntityProviderException {
- final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\" m:HasStream=\"true\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "</EntityType>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Photos\" EntityType=\"" + NAMESPACE2 + ".Photo\"/>"
- + "</EntityContainer>"
- + "</Schema>"
- + "<Schema Namespace=\"" + NAMESPACE2 + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Photo\">"
- + "<Key><PropertyRef Name=\"Id\"/></Key>"
- + "<Property Name=\"Id\" Type=\"Edm.Int32\" Nullable=\"false\"/>"
- + "</EntityType>"
- + "</Schema>"
- + "</edmx:DataServices>"
+ final String xmWithEntityContainer = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" m:HasStream=\"true\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Photos\" EntityType=\"" + NAMESPACE2 + ".Photo\"/>" + "</EntityContainer>" + "</Schema>" + "<Schema Namespace=\"" + NAMESPACE2 + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Photo\">" + "<Key><PropertyRef Name=\"Id\"/></Key>" + "<Property Name=\"Id\" Type=\"Edm.Int32\" Nullable=\"false\"/>" + "</EntityType>" + "</Schema>" + "</edmx:DataServices>"
+ "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xmWithEntityContainer);
@@ -1260,114 +588,12 @@ public class EdmParserTest {
}
@Test
- public void scenarioTest() throws XMLStreamException,
- EntityProviderException {
+ public void scenarioTest() throws XMLStreamException, EntityProviderException {
final String ASSOCIATION2 = "TeamEmployees";
- final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\""
- + Edm.NAMESPACE_EDMX_2007_06
- + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\""
- + Edm.NAMESPACE_M_2007_08
- + "\">"
- + "<Schema Namespace=\""
- + NAMESPACE
- + "\" Alias=\"RS\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Employee\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\""
- + propertyNames[0]
- + "\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\""
- + propertyNames[2]
- + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>"
- + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />"
- + "<NavigationProperty Name=\"ne_Team\" Relationship=\"RefScenario.TeamEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Team\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
- + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Manager\" ToRole=\"r_Employees\" />"
- + "</EntityType>"
- + "<EntityType Name=\"Team\">"
- + "<Key>"
- + "<PropertyRef Name=\"Id\"/>"
- + "</Key>"
- + "<NavigationProperty Name=\"nt_Employees\" Relationship=\"RefScenario.TeamEmployees\" FromRole=\"r_Team\" ToRole=\"r_Employees\" />"
- + "</EntityType>"
- + "<ComplexType Name=\"c_Location\">"
- + "<Property Name=\"Country\" Type=\"Edm.String\"/>"
- + "</ComplexType>"
- + "<Association Name=\""
- + ASSOCIATION
- + "\">"
- + "<End Type=\"RS.Employee\" Multiplicity=\"*\" Role=\"r_Employees\">"
- + "<OnDelete Action=\"Cascade\"/>"
- + "</End>"
- + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>"
- + "</Association>"
- + "<Association Name=\""
- + ASSOCIATION2
- + "\">"
- + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>"
- + "<End Type=\"RefScenario.Team\" Multiplicity=\"1\" Role=\"r_Team\"/>"
- + "</Association>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Employees\" EntityType=\"RS.Employee\"/>"
- + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>"
- + "<EntitySet Name=\"Teams\" EntityType=\"RefScenario.Team\"/>"
- + "<AssociationSet Name=\""
- + ASSOCIATION
- + "\" Association=\"RefScenario."
- + ASSOCIATION
- + "\">"
- + "<End EntitySet=\"Managers\" Role=\"r_Manager\"/>"
- + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>"
- + "</AssociationSet>"
- + "<AssociationSet Name=\""
- + ASSOCIATION2
- + "\" Association=\"RefScenario."
- + ASSOCIATION2
- + "\">"
- + "<End EntitySet=\"Teams\" Role=\"r_Team\"/>"
- + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>"
- + "</AssociationSet>"
- + "</EntityContainer>"
- + "</Schema>"
- + "<Schema Namespace=\""
- + NAMESPACE2
- + "\" xmlns=\""
- + Edm.NAMESPACE_EDM_2008_09
- + "\">"
- + "<EntityType Name= \"Photo\">"
- + "<Key>"
- + "<PropertyRef Name=\"Id\"/>"
- + "<PropertyRef Name=\"Name\"/>"
- + "</Key>"
- + "<Property Name=\"Id\" Type=\"Edm.Int32\" Nullable=\"false\" ConcurrencyMode=\"Fixed\" MaxLength=\""
- + MAX_LENGTH
- + "\"/>"
- + "<Property Name=\"Name\" Type=\"Edm.String\" Unicode=\"true\" DefaultValue=\""
- + DEFAULT_VALUE
- + "\" FixedLength=\"false\"/>"
- + "<Property Name=\"BinaryData\" Type=\"Edm.Binary\" m:MimeType=\""
- + MIME_TYPE
- + "\"/>"
- + "<Property Name=\"Содержание\" Type=\"Edm.String\" m:FC_TargetPath=\""
- + FC_TARGET_PATH
- + "\" m:FC_NsUri=\""
- + FC_NS_URI
- + "\""
- + " m:FC_NsPrefix=\""
- + FC_NS_PREFIX
- + "\" m:FC_KeepInContent=\""
- + FC_KEEP_IN_CONTENT
- + "\" m:FC_ContentKind=\"text\" >"
- + "</Property>"
- + "</EntityType>"
- + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">"
- + "<EntitySet Name=\"Photos\" EntityType=\"RefScenario2.Photo\"/>"
- + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>"
- + "</edmx:Edmx>";
+ final String xml = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" Alias=\"RS\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"" + propertyNames[0] + "\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"" + propertyNames[2] + "\" Type=\"RefScenario.c_Location\" Nullable=\"false\"/>" + "<NavigationProperty Name=\"ne_Manager\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Manager\" />" + "<NavigationProperty Name=\"ne_Team\" Relationship=\"RefScenario.TeamEmployees\" FromRole=\"r_Employees\" ToRole=\"r_Team\" />" + "</EntityType>" + "<EntityType Name=\"Manager\" BaseType=\"RefScenario.Employee\" m:HasStream=\"true\">"
+ + "<NavigationProperty Name=\"nm_Employees\" Relationship=\"RefScenario.ManagerEmployees\" FromRole=\"r_Manager\" ToRole=\"r_Employees\" />" + "</EntityType>" + "<EntityType Name=\"Team\">" + "<Key>" + "<PropertyRef Name=\"Id\"/>" + "</Key>" + "<NavigationProperty Name=\"nt_Employees\" Relationship=\"RefScenario.TeamEmployees\" FromRole=\"r_Team\" ToRole=\"r_Employees\" />" + "</EntityType>" + "<ComplexType Name=\"c_Location\">" + "<Property Name=\"Country\" Type=\"Edm.String\"/>" + "</ComplexType>" + "<Association Name=\"" + ASSOCIATION + "\">" + "<End Type=\"RS.Employee\" Multiplicity=\"*\" Role=\"r_Employees\">" + "<OnDelete Action=\"Cascade\"/>" + "</End>" + "<End Type=\"RefScenario.Manager\" Multiplicity=\"1\" Role=\"r_Manager\"/>" + "</Association>" + "<Association Name=\"" + ASSOCIATION2 + "\">" + "<End Type=\"RefScenario.Employee\" Multiplicity=\"*\" Role=\"r_Employees\"/>" + "<End Type=\"RefScenario.Team\" Multiplicity=\"1\" Role=\"r_Team\"/>" + "</Association>"
+ + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Employees\" EntityType=\"RS.Employee\"/>" + "<EntitySet Name=\"Managers\" EntityType=\"RefScenario.Manager\"/>" + "<EntitySet Name=\"Teams\" EntityType=\"RefScenario.Team\"/>" + "<AssociationSet Name=\"" + ASSOCIATION + "\" Association=\"RefScenario." + ASSOCIATION + "\">" + "<End EntitySet=\"Managers\" Role=\"r_Manager\"/>" + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>" + "</AssociationSet>" + "<AssociationSet Name=\"" + ASSOCIATION2 + "\" Association=\"RefScenario." + ASSOCIATION2 + "\">" + "<End EntitySet=\"Teams\" Role=\"r_Team\"/>" + "<End EntitySet=\"Employees\" Role=\"r_Employees\"/>" + "</AssociationSet>" + "</EntityContainer>" + "</Schema>" + "<Schema Namespace=\"" + NAMESPACE2 + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Photo\">" + "<Key>" + "<PropertyRef Name=\"Id\"/>" + "<PropertyRef Name=\"Name\"/>" + "</Key>"
+ + "<Property Name=\"Id\" Type=\"Edm.Int32\" Nullable=\"false\" ConcurrencyMode=\"Fixed\" MaxLength=\"" + MAX_LENGTH + "\"/>" + "<Property Name=\"Name\" Type=\"Edm.String\" Unicode=\"true\" DefaultValue=\"" + DEFAULT_VALUE + "\" FixedLength=\"false\"/>" + "<Property Name=\"BinaryData\" Type=\"Edm.Binary\" m:MimeType=\"" + MIME_TYPE + "\"/>" + "<Property Name=\"Содержание\" Type=\"Edm.String\" m:FC_TargetPath=\"" + FC_TARGET_PATH + "\" m:FC_NsUri=\"" + FC_NS_URI + "\"" + " m:FC_NsPrefix=\"" + FC_NS_PREFIX + "\" m:FC_KeepInContent=\"" + FC_KEEP_IN_CONTENT + "\" m:FC_ContentKind=\"text\" >" + "</Property>" + "</EntityType>" + "<EntityContainer Name=\"Container1\" m:IsDefaultEntityContainer=\"true\">" + "<EntitySet Name=\"Photos\" EntityType=\"RefScenario2.Photo\"/>" + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>" + "</edmx:Edmx>";
EdmParser parser = new EdmParser();
XMLStreamReader reader = createStreamReader(xml);
DataServices result = parser.readMetadata(reader, true);
@@ -1406,23 +632,8 @@ public class EdmParserTest {
@Test
public void testAnnotations() throws XMLStreamException, EntityProviderException {
- final String xmlWithAnnotations = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">"
- + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">"
- + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">"
- + "<EntityType Name= \"Employee\" prefix1:href=\"http://google.de\" xmlns:prefix1=\"namespaceForAnno\">"
- + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>"
- + "<Property Name=\"EmployeeId\" Type=\"Edm.String\" Nullable=\"false\"/>"
- + "<Property Name=\"EmployeeName\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\" annoPrefix:annoName=\"annoText\" xmlns:annoPrefix=\"http://annoNamespace\">"
- + "<propertyAnnoElement>text</propertyAnnoElement>"
- + "<propertyAnnoElement2 />"
- + "</Property>"
- + "</EntityType>"
- + "<schemaElementTest1>"
- + "<prefix:schemaElementTest2 xmlns:prefix=\"namespace\">text3"
- + "</prefix:schemaElementTest2>"
- + "<schemaElementTest3 rel=\"self\" pre:href=\"http://google.com\" xmlns:pre=\"namespaceForAnno\">text4</schemaElementTest3>"
- + " </schemaElementTest1>"
- + "</Schema>"
+ final String xmlWithAnnotations = "<edmx:Edmx Version=\"1.0\" xmlns:edmx=\"" + Edm.NAMESPACE_EDMX_2007_06 + "\">" + "<edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"" + Edm.NAMESPACE_M_2007_08 + "\">" + "<Schema Namespace=\"" + NAMESPACE + "\" xmlns=\"" + Edm.NAMESPACE_EDM_2008_09 + "\">" + "<EntityType Name= \"Employee\" prefix1:href=\"http://google.de\" xmlns:prefix1=\"namespaceForAnno\">" + "<Key><PropertyRef Name=\"EmployeeId\"/></Key>" + "<Property Name=\"EmployeeId\" Type=\"Edm.String\" Nullable=\"false\"/>" + "<Property Name=\"EmployeeName\" Type=\"Edm.String\" m:FC_TargetPath=\"SyndicationTitle\" annoPrefix:annoName=\"annoText\" xmlns:annoPrefix=\"http://annoNamespace\">" + "<propertyAnnoElement>text</propertyAnnoElement>" + "<propertyAnnoElement2 />" + "</Property>" + "</EntityType>" + "<schemaElementTest1>" + "<prefix:schemaElementTest2 xmlns:prefix=\"namespace\">text3" + "</prefix:schemaElementTest2>"
+ + "<schemaElementTest3 rel=\"self\" pre:href=\"http://google.com\" xmlns:pre=\"namespaceForAnno\">text4</schemaElementTest3>" + " </schemaElementTest1>" + "</Schema>"
+ "</edmx:DataServices>" + "
<TRUNCATED>