use of org.eclipse.persistence.internal.oxm.mappings.Descriptor in project eclipselink by eclipse-ee4j.
the class XMLDescriptor method setDeclaredTypeOnXMLRoot.
private void setDeclaredTypeOnXMLRoot(Root xmlRoot, String elementNamespaceUri, String elementLocalName, boolean isNamespaceAware, Unmarshaller unmarshaller) {
XPathQName xpathQName = new XPathQName(elementNamespaceUri, elementLocalName, isNamespaceAware);
Descriptor desc = unmarshaller.getContext().getDescriptor(xpathQName);
if (desc != null) {
xmlRoot.setDeclaredType(desc.getJavaClass());
}
}
use of org.eclipse.persistence.internal.oxm.mappings.Descriptor in project eclipselink by eclipse-ee4j.
the class GenerateSingleSchemaTestCases method testElementFormQualifiedNoDefaultRootElement.
/**
* Test global complex type generation. Element form default is qualified.
*/
public void testElementFormQualifiedNoDefaultRootElement() throws Exception {
Schema generatedSchema = null;
Document tDoc = null;
Document cDoc = null;
try {
boolean setSchemaContext = true;
boolean setDefaultRootElement = false;
SchemaModelGeneratorProperties props = new SchemaModelGeneratorProperties();
props.addProperty(MYNS, SchemaModelGeneratorProperties.ELEMENT_FORM_QUALIFIED_KEY, true);
Project prj = new TestProject(setSchemaContext, setDefaultRootElement, MYNS);
loginProject(prj);
List<Descriptor> descriptorsToProcess = setupDescriptorList(prj);
Map<String, Schema> generatedSchemas = sg.generateSchemas(descriptorsToProcess, props);
generatedSchema = generatedSchemas.get(MYNS);
assertNotNull("No schema was generated for namespace [" + MYNS + "]", generatedSchema);
// debugging
// writeSchema(generatedSchema);
tDoc = getDocument(generatedSchema);
cDoc = getDocument(ELEMENT_FORM_QUALIFIED_NO_DRE_RESOURCE);
} catch (Exception ex) {
ex.printStackTrace();
fail();
}
assertNotNull("Schema to Document conversion failed", tDoc);
assertNotNull("A problem occurred loading the control schema", cDoc);
assertTrue("Schema comparsion failed", comparer.isSchemaEqual(cDoc, tDoc));
}
use of org.eclipse.persistence.internal.oxm.mappings.Descriptor in project eclipselink by eclipse-ee4j.
the class GenerateSingleSchemaTestCases method testElementFormQualifiedNoSchemaContext.
/**
* Test global element and anonymous complex type generation. Element form
* default is qualified.
*/
public void testElementFormQualifiedNoSchemaContext() throws Exception {
Schema generatedSchema = null;
Document tDoc = null;
Document cDoc = null;
try {
boolean setSchemaContext = false;
boolean setDefaultRootElement = true;
SchemaModelGeneratorProperties props = new SchemaModelGeneratorProperties();
props.addProperty(MYNS, SchemaModelGeneratorProperties.ELEMENT_FORM_QUALIFIED_KEY, true);
Project prj = new TestProject(setSchemaContext, setDefaultRootElement, MYNS);
loginProject(prj);
List<Descriptor> descriptorsToProcess = setupDescriptorList(prj);
Map<String, Schema> generatedSchemas = sg.generateSchemas(descriptorsToProcess, props);
generatedSchema = generatedSchemas.get(MYNS);
assertNotNull("No schema was generated for namespace [" + MYNS + "]", generatedSchema);
// debugging
// writeSchema(generatedSchema);
tDoc = getDocument(generatedSchema);
cDoc = getDocument(ELEMENT_FORM_QUALIFIED_NO_CTX_RESOURCE);
} catch (Exception ex) {
ex.printStackTrace();
fail();
}
assertNotNull("Schema to Document conversion failed", tDoc);
assertNotNull("A problem occurred loading the control schema", cDoc);
assertTrue("Schema comparsion failed", comparer.isSchemaEqual(cDoc, tDoc));
}
use of org.eclipse.persistence.internal.oxm.mappings.Descriptor in project eclipselink by eclipse-ee4j.
the class GenerateSingleSchemaTestCases method testElementFormUnqualifiedNoCtxNoDRE.
/**
* No schema should be generated since there is no default root element
* or schema context set on any descriptors
*/
public void testElementFormUnqualifiedNoCtxNoDRE() throws Exception {
Schema generatedSchema = null;
try {
boolean setSchemaContext = false;
boolean setDefaultRootElement = false;
Project prj = new TestProject(setSchemaContext, setDefaultRootElement);
loginProject(prj);
List<Descriptor> descriptorsToProcess = setupDescriptorList(prj);
SchemaModelGeneratorProperties props = new SchemaModelGeneratorProperties();
props.addProperty(MYEMPTYNS, SchemaModelGeneratorProperties.ELEMENT_FORM_QUALIFIED_KEY, false);
Map<String, Schema> generatedSchemas = sg.generateSchemas(descriptorsToProcess, props);
generatedSchema = generatedSchemas.get(MYEMPTYNS);
} catch (Exception ex) {
ex.printStackTrace();
fail();
}
assertNull("A schema should not have been generated", generatedSchema);
}
use of org.eclipse.persistence.internal.oxm.mappings.Descriptor in project eclipselink by eclipse-ee4j.
the class GenerateSingleSchemaTestCases method testElementFormUnqualifiedNoDefaultRootElement.
/**
* Test global complex type generation. Element form default is unqualified.
* Element refs will be generated for local elements whose type is that of
* a global complex type. In these cases, global elements will be
* generated for the refs.
*/
public void testElementFormUnqualifiedNoDefaultRootElement() throws Exception {
Schema generatedSchema = null;
Document tDoc = null;
Document cDoc = null;
try {
boolean setSchemaContext = true;
boolean setDefaultRootElement = false;
SchemaModelGeneratorProperties props = new SchemaModelGeneratorProperties();
props.addProperty(MYEMPTYNS, SchemaModelGeneratorProperties.ELEMENT_FORM_QUALIFIED_KEY, false);
Project prj = new TestProject(setSchemaContext, setDefaultRootElement);
loginProject(prj);
List<Descriptor> descriptorsToProcess = setupDescriptorList(prj);
Map<String, Schema> generatedSchemas = sg.generateSchemas(descriptorsToProcess, props);
generatedSchema = generatedSchemas.get(MYEMPTYNS);
assertNotNull("No schema was generated for namespace [" + MYEMPTYNS + "]", generatedSchema);
// debugging
// writeSchema(generatedSchema);
tDoc = getDocument(generatedSchema);
cDoc = getDocument(ELEMENT_FORM_UNQUALIFIED_NO_DRE_RESOURCE);
} catch (Exception ex) {
ex.printStackTrace();
fail();
}
assertNotNull("Schema to Document conversion failed", tDoc);
assertNotNull("A problem occurred loading the control schema", cDoc);
assertTrue("Schema comparsion failed", comparer.isSchemaEqual(cDoc, tDoc));
}
Aggregations