use of org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource in project webservices-axiom by apache.
the class TestName3DefaultPrefix method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory f = metaFactory.getOMFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
OMElement element = f.createOMElement(new PullOMDataSource(TestDocument.DOCUMENT1.getContent()), "DUMMYNAME", ns);
OMElement root = f.createOMElement("root", rootNS);
root.addChild(element);
// Test getting the namespace, localpart and prefix. This should used not result in expansion
assertTrue(element.getLocalName().equals("DUMMYNAME"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://DUMMYNS"));
assertTrue(element.getNamespace().getPrefix().equals("DUMMYPREFIX"));
// Serialize and cache. This should cause expansion and update the name to match the testDocument string
StringWriter writer = new StringWriter();
try {
root.serialize(writer);
} catch (Exception e) {
// are consistent with the original setting.
return;
}
String result = writer.toString();
assertTrue(element.getLocalName().equals("library"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://www.sosnoski.com/uwjws/library"));
assertTrue(element.getNamespace().getPrefix().equals(""));
assertTrue(result.indexOf("DUMMY") < // Make sure that the serialized string does not contain the DUMMY values
0);
assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
// Serialize again
writer = new StringWriter();
root.serialize(writer);
result = writer.toString();
assertTrue(element.getLocalName().equals("library"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://www.sosnoski.com/uwjws/library"));
assertTrue(element.getNamespace().getPrefix().equals(""));
assertTrue(result.indexOf("DUMMY") < // Make sure that the serialized string does not contain the DUMMY values
0);
assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
}
use of org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource in project webservices-axiom by apache.
the class TestName3QualifiedPrefix method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory f = metaFactory.getOMFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
OMElement element = f.createOMElement(new PullOMDataSource(TestDocument.DOCUMENT2.getContent()), "DUMMYNAME", ns);
OMElement root = f.createOMElement("root", rootNS);
root.addChild(element);
// Test getting the namespace, localpart and prefix. This should used not result in expansion
assertTrue(element.getLocalName().equals("DUMMYNAME"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://DUMMYNS"));
assertTrue(element.getNamespace().getPrefix().equals("DUMMYPREFIX"));
// Serialize and cache. This should cause expansion and update the name to match the testDocument string
StringWriter writer = new StringWriter();
try {
root.serialize(writer);
} catch (Exception e) {
// are consistent with the original setting.
return;
}
String result = writer.toString();
assertTrue(element.getLocalName().equals("library"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://www.sosnoski.com/uwjws/library"));
assertTrue(element.getNamespace().getPrefix().equals(""));
assertTrue(result.indexOf("DUMMY") < // Make sure that the serialized string does not contain the DUMMY values
0);
assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
// Serialize again
writer = new StringWriter();
root.serialize(writer);
result = writer.toString();
assertTrue(element.getLocalName().equals("library"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://www.sosnoski.com/uwjws/library"));
assertTrue(element.getNamespace().getPrefix().equals(""));
assertTrue(result.indexOf("DUMMY") < // Make sure that the serialized string does not contain the DUMMY values
0);
assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
}
use of org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource in project webservices-axiom by apache.
the class TestName4DefaultPrefix method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory f = metaFactory.getOMFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
OMElement element = f.createOMElement(new PullOMDataSource(TestDocument.DOCUMENT1.getContent()), "DUMMYNAME", ns);
OMElement root = f.createOMElement("root", rootNS);
root.addChild(element);
// Test getting the namespace, localpart and prefix. This should used not result in expansion
assertTrue(element.getLocalName().equals("DUMMYNAME"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://DUMMYNS"));
assertTrue(element.getNamespace().getPrefix().equals("DUMMYPREFIX"));
// Serialize and consume. This should not cause expansion and currently won't update
// the name of the element.
StringWriter writer = new StringWriter();
root.serializeAndConsume(writer);
String result = writer.toString();
assertTrue(element.getLocalName().equals("DUMMYNAME"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://DUMMYNS"));
assertTrue(element.getNamespace().getPrefix().equals("DUMMYPREFIX"));
assertTrue(result.indexOf("DUMMY") < // Make sure that the serialized string does not contain the DUMMY values
0);
assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
}
use of org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource in project webservices-axiom by apache.
the class TestName3Unqualified method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory f = metaFactory.getOMFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
OMElement element = f.createOMElement(new PullOMDataSource(TestDocument.DOCUMENT3.getContent()), "DUMMYNAME", ns);
OMElement root = f.createOMElement("root", rootNS);
root.addChild(element);
// Test getting the namespace, localpart and prefix. This should used not result in expansion
assertTrue(element.getLocalName().equals("DUMMYNAME"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://DUMMYNS"));
assertTrue(element.getNamespace().getPrefix().equals("DUMMYPREFIX"));
// Serialize and cache. This should cause expansion and update the name to match the testDocument string
StringWriter writer = new StringWriter();
try {
root.serialize(writer);
} catch (Exception e) {
// are consistent with the original setting.
return;
}
String result = writer.toString();
assertTrue(element.getLocalName().equals("library"));
assertTrue(element.getNamespace().getNamespaceURI().equals(""));
assertTrue(element.getNamespace().getPrefix().equals(""));
assertTrue(result.indexOf("DUMMY") < // Make sure that the serialized string does not contain the DUMMY values
0);
assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
// Serialize again
writer = new StringWriter();
root.serialize(writer);
result = writer.toString();
assertTrue(element.getLocalName().equals("library"));
assertTrue(element.getNamespace().getNamespaceURI().equals("http://www.sosnoski.com/uwjws/library"));
assertTrue(element.getNamespace().getPrefix().equals(""));
assertTrue(result.indexOf("DUMMY") < // Make sure that the serialized string does not contain the DUMMY values
0);
assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
}
use of org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource in project webservices-axiom by apache.
the class TestGetAttributeValue method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMSourcedElement element = factory.createOMElement(new PullOMDataSource("<root attr='value'/>"), "root", null);
assertThat(element.getAttributeValue(new QName("attr"))).isEqualTo("value");
}
Aggregations