You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by gd...@apache.org on 2007/03/07 15:59:13 UTC
svn commit: r515594 [15/19] - in
/webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/attachments/
axiom-api/src/main/java/org/apache/axiom/attachments/utils/
axiom-api/src/main/java/org/apache/axiom/om/ axiom-api/...
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/AbstractTestCase.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/AbstractTestCase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/AbstractTestCase.java Wed Mar 7 06:59:00 2007
@@ -20,9 +20,7 @@
import java.io.File;
-/**
- * Abstract base class for test cases.
- */
+/** Abstract base class for test cases. */
public abstract class AbstractTestCase
extends TestCase {
protected String testDir = "test" + File.separator;
@@ -36,15 +34,10 @@
"temp";
protected String testResourceDir = "test-resources";
- /**
- * Basedir for all file I/O. Important when running tests from
- * the reactor.
- */
+ /** Basedir for all file I/O. Important when running tests from the reactor. */
public String basedir = System.getProperty("basedir");
- /**
- * @param testName
- */
+ /** @param testName */
public AbstractTestCase(String testName) {
super(testName);
if (basedir == null) {
@@ -62,7 +55,7 @@
public File getTempOutputFile(String filename) {
File f = new File(tempDir);
- if(!f.exists()) {
+ if (!f.exists()) {
f.mkdirs();
}
return new File(f, filename);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java Wed Mar 7 06:59:00 2007
@@ -16,6 +16,7 @@
package org.apache.axiom.om.impl.dom;
+import junit.framework.TestCase;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
@@ -27,15 +28,9 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
-
import java.io.ByteArrayInputStream;
-import junit.framework.TestCase;
-
-/**
- * This test will test the conversion of a LLOM soap envelope to
- * DOOM
- */
+/** This test will test the conversion of a LLOM soap envelope to DOOM */
public class ConvertLLOMToDOOMTest extends TestCase {
public ConvertLLOMToDOOMTest(String arg0) {
@@ -45,123 +40,129 @@
public void testConvert() {
try {
String origXML = "<?xml version='1.0' encoding='UTF-8'?>\n" +
- " <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">\n" +
- " <soapenv:Header>\n" +
- " <wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" soapenv:mustUnderstand=\"1\">\n" +
- " <ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" Id=\"Signature-6426875\">\n" +
- " <ds:SignedInfo>\n" +
- " <ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" />\n" +
- " <ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" />\n" +
- " <ds:Reference URI=\"#id-3083604\">\n" +
- " <ds:Transforms>\n" +
- " <ds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" />\n" +
- " </ds:Transforms>\n" +
- " <ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" />\n" +
- " <ds:DigestValue>lDeZJk0/r6u4tOOhOKbN0IEvwi0=</ds:DigestValue>\n" +
- " </ds:Reference>\n" +
- " </ds:SignedInfo>\n" +
- " <ds:SignatureValue>KhUeWMoUxUFe5jeTlqLdIEIG2Z7Q2q2mh9HT3IAYwbCev+FzXcuLSiPSsb7/+PSDM2SD0gl9tMp+dHjfPxmq7WiduH9mbnP6gkrxxu0T5rR916WsboshJGJKiPlj71bwpMsrrZohx4evHPdQ2SZHthlNb6jZyjq+LS7qFydppHk=</ds:SignatureValue>\n" +
- " <ds:KeyInfo Id=\"KeyId-2529687\">\n" +
- " <wsse:SecurityTokenReference xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"STRId-31966667\">\n" +
- " <ds:X509Data>\n" +
- " <ds:X509IssuerSerial>\n" +
- " <ds:X509IssuerName>CN=OASIS Interop Test CA,O=OASIS</ds:X509IssuerName>\n" +
- " <ds:X509SerialNumber>68652640310044618358965661752471103641</ds:X509SerialNumber>\n" +
- " </ds:X509IssuerSerial>\n" +
- " </ds:X509Data>\n" +
- " </wsse:SecurityTokenReference>\n" +
- " </ds:KeyInfo>\n" +
- " </ds:Signature>\n" +
- " <wsu:Timestamp xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"Timestamp-13986615\">\n" +
- " <wsu:Created>2006-03-31T15:34:38.699Z</wsu:Created>\n" +
- " <wsu:Expires>2006-03-31T15:39:38.699Z</wsu:Expires>\n" +
- " </wsu:Timestamp>\n" +
- " </wsse:Security>\n" +
- " <wsa:To xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">http://localhost:9080/axis2/services/Service</wsa:To>\n" +
- " <wsa:ReplyTo xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">\n" +
- " <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>\n" +
- " </wsa:ReplyTo>\n" +
- " <wsa:MessageID xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">urn:uuid:049875A6E153FCAAF011438192785862</wsa:MessageID>\n" +
- " <wsa:Action xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</wsa:Action>\n" +
- " </soapenv:Header>\n" +
- " <soapenv:Body xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"id-3083604\">\n" +
- " <RequestSecurityToken xmlns=\"http://schemas.xmlsoap.org/ws/2005/02/trust\" Context=\"http://get.optional.attrs.working\">\n" +
- " <TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</TokenType>\n" +
- " <RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</RequestType>\n" +
- " </RequestSecurityToken>\n" +
- " </soapenv:Body>\n" +
- " </soapenv:Envelope>";
+ " <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">\n" +
+ " <soapenv:Header>\n" +
+ " <wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" soapenv:mustUnderstand=\"1\">\n" +
+ " <ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" Id=\"Signature-6426875\">\n" +
+ " <ds:SignedInfo>\n" +
+ " <ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" />\n" +
+ " <ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" />\n" +
+ " <ds:Reference URI=\"#id-3083604\">\n" +
+ " <ds:Transforms>\n" +
+ " <ds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" />\n" +
+ " </ds:Transforms>\n" +
+ " <ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" />\n" +
+ " <ds:DigestValue>lDeZJk0/r6u4tOOhOKbN0IEvwi0=</ds:DigestValue>\n" +
+ " </ds:Reference>\n" +
+ " </ds:SignedInfo>\n" +
+ " <ds:SignatureValue>KhUeWMoUxUFe5jeTlqLdIEIG2Z7Q2q2mh9HT3IAYwbCev+FzXcuLSiPSsb7/+PSDM2SD0gl9tMp+dHjfPxmq7WiduH9mbnP6gkrxxu0T5rR916WsboshJGJKiPlj71bwpMsrrZohx4evHPdQ2SZHthlNb6jZyjq+LS7qFydppHk=</ds:SignatureValue>\n" +
+ " <ds:KeyInfo Id=\"KeyId-2529687\">\n" +
+ " <wsse:SecurityTokenReference xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"STRId-31966667\">\n" +
+ " <ds:X509Data>\n" +
+ " <ds:X509IssuerSerial>\n" +
+ " <ds:X509IssuerName>CN=OASIS Interop Test CA,O=OASIS</ds:X509IssuerName>\n" +
+ " <ds:X509SerialNumber>68652640310044618358965661752471103641</ds:X509SerialNumber>\n" +
+ " </ds:X509IssuerSerial>\n" +
+ " </ds:X509Data>\n" +
+ " </wsse:SecurityTokenReference>\n" +
+ " </ds:KeyInfo>\n" +
+ " </ds:Signature>\n" +
+ " <wsu:Timestamp xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"Timestamp-13986615\">\n" +
+ " <wsu:Created>2006-03-31T15:34:38.699Z</wsu:Created>\n" +
+ " <wsu:Expires>2006-03-31T15:39:38.699Z</wsu:Expires>\n" +
+ " </wsu:Timestamp>\n" +
+ " </wsse:Security>\n" +
+ " <wsa:To xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">http://localhost:9080/axis2/services/Service</wsa:To>\n" +
+ " <wsa:ReplyTo xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">\n" +
+ " <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>\n" +
+ " </wsa:ReplyTo>\n" +
+ " <wsa:MessageID xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">urn:uuid:049875A6E153FCAAF011438192785862</wsa:MessageID>\n" +
+ " <wsa:Action xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</wsa:Action>\n" +
+ " </soapenv:Header>\n" +
+ " <soapenv:Body xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"id-3083604\">\n" +
+ " <RequestSecurityToken xmlns=\"http://schemas.xmlsoap.org/ws/2005/02/trust\" Context=\"http://get.optional.attrs.working\">\n" +
+ " <TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</TokenType>\n" +
+ " <RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</RequestType>\n" +
+ " </RequestSecurityToken>\n" +
+ " </soapenv:Body>\n" +
+ " </soapenv:Envelope>";
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(origXML.getBytes()));
+ XMLStreamReader reader = XMLInputFactory.newInstance()
+ .createXMLStreamReader(new ByteArrayInputStream(origXML.getBytes()));
StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, null);
-
+
SOAPEnvelope env = builder.getSOAPEnvelope();
-
+
env.build();
-
- StAXSOAPModelBuilder doomBuilder = new StAXSOAPModelBuilder(env.getXMLStreamReader(), DOOMAbstractFactory.getSOAP11Factory(), SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-
+
+ StAXSOAPModelBuilder doomBuilder = new StAXSOAPModelBuilder(env.getXMLStreamReader(),
+ DOOMAbstractFactory.getSOAP11Factory(),
+ SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
SOAPEnvelope doomEnv = doomBuilder.getSOAPEnvelope();
-
+
doomEnv.build();
-
+
OMElement payload = doomEnv.getBody().getFirstElement();
-
- StAXOMBuilder llomBuilder = new StAXOMBuilder(payload.getXMLStreamReaderWithoutCaching());
-
- OMElement llomPayload = llomBuilder.getDocumentElement();
-
+
+ StAXOMBuilder llomBuilder =
+ new StAXOMBuilder(payload.getXMLStreamReaderWithoutCaching());
+
+ OMElement llomPayload = llomBuilder.getDocumentElement();
+
llomPayload.build();
-
+
String xml = llomPayload.toString();
-
+
assertTrue("Conversion failed", xml.indexOf("</RequestSecurityToken>") != -1);
-
+
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
-
+
public void testConvert1() {
try {
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope env = fac.getDefaultEnvelope();
fac.createOMElement(new QName("http://test.org", "Test"), env.getBody());
env.build();
-
- StAXSOAPModelBuilder doomBuilder = new StAXSOAPModelBuilder(env.getXMLStreamReader(), DOOMAbstractFactory.getSOAP11Factory(), SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-
+
+ StAXSOAPModelBuilder doomBuilder = new StAXSOAPModelBuilder(env.getXMLStreamReader(),
+ DOOMAbstractFactory.getSOAP11Factory(),
+ SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
SOAPEnvelope doomEnv = doomBuilder.getSOAPEnvelope();
-
+
doomEnv.build();
-
+
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
-
+
public void testAddChild() {
try {
SOAPFactory fac = DOOMAbstractFactory.getSOAP11Factory();
SOAPEnvelope env = fac.getDefaultEnvelope();
fac.createOMElement(new QName("http://test.org", "Test"), env.getBody());
env.build();
-
+
SOAPFactory llomFac = DOOMAbstractFactory.getSOAP11Factory();
OMElement elem = llomFac.createOMElement("newDomElement", null);
-
+
OMElement firstElement = env.getBody().getFirstElement();
firstElement.addChild(elem);
-
- assertTrue("New DOM child missing",
- env.toString().indexOf("newDomElement") > 0);
-
+
+ assertTrue("New DOM child missing",
+ env.toString().indexOf("newDomElement") > 0);
+
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
-
+
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java Wed Mar 7 06:59:00 2007
@@ -26,29 +26,32 @@
public class DOMImplementationTest extends TestCase {
- public DOMImplementationTest(String name) {
- super(name);
- }
-
- public void testDOMImpl() {
- try {
+ public DOMImplementationTest(String name) {
+ super(name);
+ }
+
+ public void testDOMImpl() {
+ try {
// System.setProperty("javax.xml.parsers.DocumentBuilderFactory",DocumentBuilderFactoryImpl.class.getName());
-
+
DocumentBuilderFactoryImpl.setDOOMRequired(true);
-
- DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = fac.newDocumentBuilder();
- Document doc = builder.newDocument();
-
- assertEquals("Incorrect DocumentBuilderFactory instance", DocumentBuilderFactoryImpl.class.getName(),fac.getClass().getName());
- assertEquals("Incorrect DocumentBuilder instance", DocumentBuilderImpl.class.getName(),builder.getClass().getName());
- assertEquals("Incorrect Document instance", DocumentImpl.class.getName(),doc.getClass().getName());
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
+
+ DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = fac.newDocumentBuilder();
+ Document doc = builder.newDocument();
+
+ assertEquals("Incorrect DocumentBuilderFactory instance",
+ DocumentBuilderFactoryImpl.class.getName(), fac.getClass().getName());
+ assertEquals("Incorrect DocumentBuilder instance", DocumentBuilderImpl.class.getName(),
+ builder.getClass().getName());
+ assertEquals("Incorrect Document instance", DocumentImpl.class.getName(),
+ doc.getClass().getName());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
DocumentBuilderFactoryImpl.setDOOMRequired(false);
}
- }
+ }
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java Wed Mar 7 06:59:00 2007
@@ -15,6 +15,7 @@
*/
package org.apache.axiom.om.impl.dom;
+import junit.framework.TestCase;
import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
import org.apache.axiom.om.impl.dom.jaxp.DocumentBuilderFactoryImpl;
import org.w3c.dom.Attr;
@@ -25,74 +26,72 @@
import javax.xml.parsers.DocumentBuilderFactory;
-import junit.framework.TestCase;
-
public class DocumentImplTest extends TestCase {
- public DocumentImplTest() {
- super();
- }
-
- public DocumentImplTest(String name) {
- super(name);
- }
-
- public void testCreateElement() {
- String tagName = "LocalName";
- String namespace = "http://ws.apache.org/axis2/ns";
+ public DocumentImplTest() {
+ super();
+ }
+
+ public DocumentImplTest(String name) {
+ super(name);
+ }
+
+ public void testCreateElement() {
+ String tagName = "LocalName";
+ String namespace = "http://ws.apache.org/axis2/ns";
OMDOMFactory fac = new OMDOMFactory();
- DocumentImpl doc = new DocumentImpl(fac);
- Element elem = doc.createElement(tagName);
-
- assertEquals("Local name misnatch",tagName, elem.getNodeName());
-
- elem = doc.createElementNS(namespace, "axis2:" + tagName);
- assertEquals("Local name misnatch",tagName,elem.getLocalName());
- assertEquals("Namespace misnatch",namespace,elem.getNamespaceURI());
-
- }
-
- public void testCreateAttribute() {
- String attrName = "attrIdentifier";
- String attrValue = "attrValue";
- String attrNs = "http://ws.apache.org/axis2/ns";
- String attrNsPrefix = "axis2";
-
+ DocumentImpl doc = new DocumentImpl(fac);
+ Element elem = doc.createElement(tagName);
+
+ assertEquals("Local name misnatch", tagName, elem.getNodeName());
+
+ elem = doc.createElementNS(namespace, "axis2:" + tagName);
+ assertEquals("Local name misnatch", tagName, elem.getLocalName());
+ assertEquals("Namespace misnatch", namespace, elem.getNamespaceURI());
+
+ }
+
+ public void testCreateAttribute() {
+ String attrName = "attrIdentifier";
+ String attrValue = "attrValue";
+ String attrNs = "http://ws.apache.org/axis2/ns";
+ String attrNsPrefix = "axis2";
+
OMDOMFactory fac = new OMDOMFactory();
DocumentImpl doc = new DocumentImpl(fac);
- Attr attr = doc.createAttribute(attrName);
+ Attr attr = doc.createAttribute(attrName);
+
+ assertEquals("Attr name mismatch", attrName, attr.getName());
+ assertNull("Namespace value should be null", attr.getNamespaceURI());
+
+
+ attr = doc.createAttributeNS(attrNs, attrNsPrefix + ":" + attrName);
+ assertEquals("Attr name mismatch", attrName, attr.getLocalName());
+ assertNotNull("Namespace value should not be null", attr.getNamespaceURI());
+ assertEquals("NamsspaceURI mismatch", attrNs, attr.getNamespaceURI());
+ assertEquals("namespace prefix mismatch", attrNsPrefix, attr.getPrefix());
+
+ attr.setValue(attrValue);
+
+ }
+
+ public void testCreateText() {
+ String textValue = "temp text value";
- assertEquals("Attr name mismatch",attrName,attr.getName());
- assertNull("Namespace value should be null", attr.getNamespaceURI());
-
-
- attr = doc.createAttributeNS(attrNs,attrNsPrefix + ":" + attrName);
- assertEquals("Attr name mismatch",attrName,attr.getLocalName());
- assertNotNull("Namespace value should not be null", attr.getNamespaceURI());
- assertEquals("NamsspaceURI mismatch", attrNs, attr.getNamespaceURI());
- assertEquals("namespace prefix mismatch", attrNsPrefix, attr.getPrefix());
-
- attr.setValue(attrValue);
-
- }
-
- public void testCreateText() {
- String textValue = "temp text value";
-
OMDOMFactory fac = new OMDOMFactory();
DocumentImpl doc = new DocumentImpl(fac);
- Text txt = doc.createTextNode(textValue);
-
- assertEquals("Text value mismatch", textValue, txt.getData());
- }
-
+ Text txt = doc.createTextNode(textValue);
+
+ assertEquals("Text value mismatch", textValue, txt.getData());
+ }
+
public void testDocumentSiblings() {
try {
DocumentBuilderFactoryImpl.setDOOMRequired(true);
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element elem = doc.createElement("test");
doc.appendChild(elem);
-
+
Node node = doc.getNextSibling();
assertNull("Document's next sibling has to be null", node);
Node node2 = doc.getPreviousSibling();
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImplTest.java Wed Mar 7 06:59:00 2007
@@ -31,173 +31,175 @@
public class ElementImplTest extends TestCase {
- public ElementImplTest() {
- super();
- }
-
- public ElementImplTest(String name) {
- super(name);
- }
-
- public void testSetText() {
- OMDOMFactory factory = new OMDOMFactory();
- String localName = "TestLocalName";
- String namespace = "http://ws.apache.org/axis2/ns";
- String prefix = "axis2";
- OMElement elem = factory.createOMElement(localName,namespace,prefix);
-
- String text = "The quick brown fox jumps over the lazy dog";
-
- elem.setText(text);
-
- assertEquals("Text value mismatch", text, elem.getText());
-
- }
-
- public void testSerialize() {
- OMDOMFactory factory = new OMDOMFactory();
- String localName = "TestLocalName";
- String namespace = "http://ws.apache.org/axis2/ns";
- String prefix = "axis2";
- String tempText = "The quick brown fox jumps over the lazy dog";
- String textToAppend = " followed by another";
-
- OMElement elem = factory.createOMElement(localName,namespace,prefix);
- OMText textNode = factory.createOMText(elem,tempText);
-
- ((Text)textNode).appendData(textToAppend);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- elem.serialize(baos);
- String xml = new String(baos.toByteArray());
+ public ElementImplTest() {
+ super();
+ }
+
+ public ElementImplTest(String name) {
+ super(name);
+ }
+
+ public void testSetText() {
+ OMDOMFactory factory = new OMDOMFactory();
+ String localName = "TestLocalName";
+ String namespace = "http://ws.apache.org/axis2/ns";
+ String prefix = "axis2";
+ OMElement elem = factory.createOMElement(localName, namespace, prefix);
+
+ String text = "The quick brown fox jumps over the lazy dog";
+
+ elem.setText(text);
+
+ assertEquals("Text value mismatch", text, elem.getText());
+
+ }
+
+ public void testSerialize() {
+ OMDOMFactory factory = new OMDOMFactory();
+ String localName = "TestLocalName";
+ String namespace = "http://ws.apache.org/axis2/ns";
+ String prefix = "axis2";
+ String tempText = "The quick brown fox jumps over the lazy dog";
+ String textToAppend = " followed by another";
+
+ OMElement elem = factory.createOMElement(localName, namespace, prefix);
+ OMText textNode = factory.createOMText(elem, tempText);
+
+ ((Text) textNode).appendData(textToAppend);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ elem.serialize(baos);
+ String xml = new String(baos.toByteArray());
assertEquals("Incorrect serialized xml", 0, xml.indexOf("<axis2:TestLocalName"));
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- public void testAddChild() {
- OMDOMFactory factory = new OMDOMFactory();
- String localName = "TestLocalName";
- String childLocalName = "TestChildLocalName";
- String namespace = "http://ws.apache.org/axis2/ns";
- String prefix = "axis2";
-
- OMElement elem = factory.createOMElement(localName,namespace,prefix);
- OMElement childElem = factory.createOMElement(childLocalName,namespace, prefix);
-
- elem.addChild(childElem);
-
- Iterator it = elem.getChildrenWithName(new QName(namespace, childLocalName));
-
- int count = 0;
- while (it.hasNext()) {
- OMElement child = (OMElement) it.next();
- assertEquals("Child local name mismatch", childLocalName, child.getLocalName());
- assertEquals("Child namespace mismatch", namespace, child.getNamespace().getNamespaceURI());
- count ++;
- }
- assertEquals("In correct number of children", 1, count );
- }
-
- public void testAppendChild() {
- try {
- String elementName = "TestElem";
- String childElemName = "TestChildElem";
- String childTextValue = "text value of the child text node";
-
- //Apending am Element node
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ public void testAddChild() {
+ OMDOMFactory factory = new OMDOMFactory();
+ String localName = "TestLocalName";
+ String childLocalName = "TestChildLocalName";
+ String namespace = "http://ws.apache.org/axis2/ns";
+ String prefix = "axis2";
+
+ OMElement elem = factory.createOMElement(localName, namespace, prefix);
+ OMElement childElem = factory.createOMElement(childLocalName, namespace, prefix);
+
+ elem.addChild(childElem);
+
+ Iterator it = elem.getChildrenWithName(new QName(namespace, childLocalName));
+
+ int count = 0;
+ while (it.hasNext()) {
+ OMElement child = (OMElement) it.next();
+ assertEquals("Child local name mismatch", childLocalName, child.getLocalName());
+ assertEquals("Child namespace mismatch", namespace,
+ child.getNamespace().getNamespaceURI());
+ count ++;
+ }
+ assertEquals("In correct number of children", 1, count);
+ }
+
+ public void testAppendChild() {
+ try {
+ String elementName = "TestElem";
+ String childElemName = "TestChildElem";
+ String childTextValue = "text value of the child text node";
+
+ //Apending am Element node
DocumentBuilderFactoryImpl.setDOOMRequired(true);
- Document doc = DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder().newDocument();
- Element elem = doc.createElement(elementName);
- Element childElem = doc.createElement(childElemName);
-
- elem.appendChild(childElem);
-
- Element addedChild = (Element)elem.getFirstChild();
- assertNotNull("Child Element node missing",addedChild);
- assertEquals("Incorre node object", childElem, addedChild);
-
- elem = doc.createElement(elementName);
- Text text = doc.createTextNode(childTextValue);
- elem.appendChild(text);
-
- Text addedTextnode = (Text)elem.getFirstChild();
- assertNotNull("Child Text node missing", addedTextnode);
- assertEquals("Incorrect node object", text, addedTextnode);
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- DocumentBuilderFactoryImpl.setDOOMRequired(false);
+ Document doc =
+ DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder().newDocument();
+ Element elem = doc.createElement(elementName);
+ Element childElem = doc.createElement(childElemName);
+
+ elem.appendChild(childElem);
+
+ Element addedChild = (Element) elem.getFirstChild();
+ assertNotNull("Child Element node missing", addedChild);
+ assertEquals("Incorre node object", childElem, addedChild);
+
+ elem = doc.createElement(elementName);
+ Text text = doc.createTextNode(childTextValue);
+ elem.appendChild(text);
+
+ Text addedTextnode = (Text) elem.getFirstChild();
+ assertNotNull("Child Text node missing", addedTextnode);
+ assertEquals("Incorrect node object", text, addedTextnode);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
+ DocumentBuilderFactoryImpl.setDOOMRequired(false);
}
- }
-
- /**
- * Testing the NodeList returned with the elements's children
- */
- public void testGetElementsbyTagName() {
- try {
- String childElementLN = "Child";
-
+ }
+
+ /** Testing the NodeList returned with the elements's children */
+ public void testGetElementsbyTagName() {
+ try {
+ String childElementLN = "Child";
+
DocumentBuilderFactoryImpl.setDOOMRequired(true);
-
- Document doc = DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder().newDocument();
- Element docElem = doc.getDocumentElement();
- assertNull("The document element shoudl be null", docElem);
-
- docElem = doc.createElement("Test");
- docElem.appendChild(doc.createElement(childElementLN));
- docElem.appendChild(doc.createElement(childElementLN));
- docElem.appendChild(doc.createElement(childElementLN));
- docElem.appendChild(doc.createElement(childElementLN));
- docElem.appendChild(doc.createElement(childElementLN));
- docElem.appendChild(doc.createElement(childElementLN));
- docElem.appendChild(doc.createElement(childElementLN));
-
- NodeList list = docElem.getElementsByTagName(childElementLN);
-
- assertEquals("Incorrect number of child elements", 7 ,list.getLength());
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- DocumentBuilderFactoryImpl.setDOOMRequired(false);
+
+ Document doc =
+ DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder().newDocument();
+ Element docElem = doc.getDocumentElement();
+ assertNull("The document element shoudl be null", docElem);
+
+ docElem = doc.createElement("Test");
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+ docElem.appendChild(doc.createElement(childElementLN));
+
+ NodeList list = docElem.getElementsByTagName(childElementLN);
+
+ assertEquals("Incorrect number of child elements", 7, list.getLength());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
+ DocumentBuilderFactoryImpl.setDOOMRequired(false);
}
- }
-
- public void testGetElementsbyTagNameNS() {
- try {
- String childElementLN = "test:Child";
- String childElementNS = "http://ws.apache.org/ns/axis2/dom";
-
+ }
+
+ public void testGetElementsbyTagNameNS() {
+ try {
+ String childElementLN = "test:Child";
+ String childElementNS = "http://ws.apache.org/ns/axis2/dom";
+
DocumentBuilderFactoryImpl.setDOOMRequired(true);
- Document doc = DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder().newDocument();
- Element docElem = doc.getDocumentElement();
- assertNull("The document element shoudl be null", docElem);
-
- docElem = doc.createElementNS("http://test.org", "test:Test");
-
- docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
- docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
- docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
- docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
- docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
- docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
- docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
-
- NodeList list = docElem.getElementsByTagNameNS(childElementNS, childElementLN);
-
- assertEquals("Incorrect number of child elements", 7 ,list.getLength());
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- DocumentBuilderFactoryImpl.setDOOMRequired(false);
+ Document doc =
+ DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder().newDocument();
+ Element docElem = doc.getDocumentElement();
+ assertNull("The document element shoudl be null", docElem);
+
+ docElem = doc.createElementNS("http://test.org", "test:Test");
+
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
+ docElem.appendChild(doc.createElementNS(childElementNS, childElementLN));
+
+ NodeList list = docElem.getElementsByTagNameNS(childElementNS, childElementLN);
+
+ assertEquals("Incorrect number of child elements", 7, list.getLength());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
+ DocumentBuilderFactoryImpl.setDOOMRequired(false);
}
- }
+ }
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java Wed Mar 7 06:59:00 2007
@@ -16,6 +16,7 @@
package org.apache.axiom.om.impl.dom;
+import junit.framework.TestCase;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMTestUtils;
import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
@@ -23,16 +24,10 @@
import org.w3c.dom.Node;
import javax.xml.parsers.DocumentBuilderFactory;
-
import java.io.FileInputStream;
-import junit.framework.TestCase;
-
-/**
- *
- * @author Ruchith Fernando (ruchith.fernando@gmail.com)
- */
-public class ElementImportTest extends TestCase {
+/** @author Ruchith Fernando (ruchith.fernando@gmail.com) */
+public class ElementImportTest extends TestCase {
public void testImport() {
try {
@@ -41,7 +36,7 @@
Document doc = dbf.newDocumentBuilder().parse(
new FileInputStream("test-resources/xml/sigEncr.xml"));
Node n = new OMDOMFactory().getDocument().importNode(doc.getDocumentElement(), true);
- OMTestUtils.compare(doc.getDocumentElement(), (OMElement)n);
+ OMTestUtils.compare(doc.getDocumentElement(), (OMElement) n);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/MessagesTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/MessagesTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/MessagesTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/MessagesTest.java Wed Mar 7 06:59:00 2007
@@ -31,7 +31,7 @@
soapEnvelope =
(SOAPEnvelope) OMTestUtils.getOMBuilder(
getTestResourceFile("soap/whitespacedMessage.xml"))
- .getDocumentElement();
+ .getDocumentElement();
OMTestUtils.walkThrough(soapEnvelope);
}
@@ -39,7 +39,7 @@
soapEnvelope =
(SOAPEnvelope) OMTestUtils.getOMBuilder(
getTestResourceFile("soap/minimalMessage.xml"))
- .getDocumentElement();
+ .getDocumentElement();
OMTestUtils.walkThrough(soapEnvelope);
}
@@ -47,7 +47,7 @@
soapEnvelope =
(SOAPEnvelope) OMTestUtils.getOMBuilder(
getTestResourceFile("soap/reallyReallyBigMessage.xml"))
- .getDocumentElement();
+ .getDocumentElement();
OMTestUtils.walkThrough(soapEnvelope);
}
@@ -55,7 +55,7 @@
soapEnvelope =
(SOAPEnvelope) OMTestUtils.getOMBuilder(
getTestResourceFile("soap/emtyBodymessage.xml"))
- .getDocumentElement();
+ .getDocumentElement();
OMTestUtils.walkThrough(soapEnvelope);
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMDOMFactoryTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMDOMFactoryTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMDOMFactoryTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMDOMFactoryTest.java Wed Mar 7 06:59:00 2007
@@ -21,27 +21,27 @@
import javax.xml.namespace.QName;
-public class OMDOMFactoryTest extends TestCase{
+public class OMDOMFactoryTest extends TestCase {
- public OMDOMFactoryTest() {
- super();
- }
-
- public OMDOMFactoryTest(String name) {
- super(name);
- }
-
- public void testCreateElement() {
- OMDOMFactory factory = new OMDOMFactory();
- String localName = "TestLocalName";
- String namespace = "http://ws.apache.org/axis2/ns";
- String prefix = "axis2";
- OMElement elem = factory.createOMElement(localName,namespace,prefix);
- QName qname = elem.getQName();
-
- assertEquals("Localname mismatch",localName,qname.getLocalPart());
- assertEquals("Namespace mismatch",namespace,qname.getNamespaceURI());
- assertEquals("namespace prefix mismatch", prefix, qname.getPrefix());
- }
+ public OMDOMFactoryTest() {
+ super();
+ }
+
+ public OMDOMFactoryTest(String name) {
+ super(name);
+ }
+
+ public void testCreateElement() {
+ OMDOMFactory factory = new OMDOMFactory();
+ String localName = "TestLocalName";
+ String namespace = "http://ws.apache.org/axis2/ns";
+ String prefix = "axis2";
+ OMElement elem = factory.createOMElement(localName, namespace, prefix);
+ QName qname = elem.getQName();
+
+ assertEquals("Localname mismatch", localName, qname.getLocalPart());
+ assertEquals("Namespace mismatch", namespace, qname.getNamespaceURI());
+ assertEquals("namespace prefix mismatch", prefix, qname.getPrefix());
+ }
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMDOMTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMDOMTestCase.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMDOMTestCase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMDOMTestCase.java Wed Mar 7 06:59:00 2007
@@ -32,24 +32,24 @@
import java.io.InputStream;
import java.io.OutputStream;
-public abstract class OMDOMTestCase extends AbstractTestCase{
+public abstract class OMDOMTestCase extends AbstractTestCase {
- protected static final String IN_FILE_NAME = "soap/soapmessage.xml";
+ protected static final String IN_FILE_NAME = "soap/soapmessage.xml";
protected StAXSOAPModelBuilder builder;
protected OMFactory ombuilderFactory;
protected SOAPFactory soapFactory;
-
+
protected SOAPEnvelope soapEnvelope;
-
+
public OMDOMTestCase(String testName) {
- super(testName);
- }
-
+ super(testName);
+ }
+
protected void setUp() throws Exception {
super.setUp();
soapEnvelope = (SOAPEnvelope) getOMBuilder("").getDocumentElement();
}
-
+
protected StAXSOAPModelBuilder getOMBuilder(String fileName) throws Exception {
if ("".equals(fileName) || fileName == null) {
fileName = IN_FILE_NAME;
@@ -60,8 +60,7 @@
builder = new StAXSOAPModelBuilder(parser, new SOAP11Factory(), null);
return builder;
}
-
-
+
protected StAXSOAPModelBuilder getOMBuilder(InputStream in) throws Exception {
XMLStreamReader parser = XMLInputFactory.newInstance()
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java Wed Mar 7 06:59:00 2007
@@ -51,7 +51,7 @@
while (attibIt.hasNext()) {
TestCase.assertNotNull("once the has next is not null, the " +
"element should not be null",
- attibIt.next());
+ attibIt.next());
}
}
Iterator it = omEle.getChildren();
@@ -72,12 +72,12 @@
return;
} else if (ele != null && omele != null) {
TestCase.assertEquals("Element name not correct",
- ele.getLocalName(),
- omele.getLocalName());
+ ele.getLocalName(),
+ omele.getLocalName());
if (omele.getNamespace() != null) {
TestCase.assertEquals("Namespace URI not correct",
- ele.getNamespaceURI(),
- omele.getNamespace().getNamespaceURI());
+ ele.getNamespaceURI(),
+ omele.getNamespace().getNamespaceURI());
}
@@ -93,7 +93,7 @@
if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
Attr attr = (Attr) node;
TestCase.assertEquals(attr.getValue(),
- omattribute.getAttributeValue());
+ omattribute.getAttributeValue());
} else {
throw new OMException("return type is not a Attribute");
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/TextImplTest.java Wed Mar 7 06:59:00 2007
@@ -23,65 +23,65 @@
public class TextImplTest extends TestCase {
- public TextImplTest() {
- super();
- }
-
- public TextImplTest(String name) {
- super(name);
- }
-
- public void testSetText() {
- OMDOMFactory factory = new OMDOMFactory();
- String localName = "TestLocalName";
- String namespace = "http://ws.apache.org/axis2/ns";
- String prefix = "axis2";
- String tempText = "The quick brown fox jumps over the lazy dog";
-
- OMElement elem = factory.createOMElement(localName, namespace, prefix);
- OMText textNode = factory.createOMText(elem, tempText);
-
- assertEquals("Text value mismatch", tempText, textNode.getText());
- }
-
- public void testAppendText() {
- OMDOMFactory factory = new OMDOMFactory();
- String localName = "TestLocalName";
- String namespace = "http://ws.apache.org/axis2/ns";
- String prefix = "axis2";
- String tempText = "The quick brown fox jumps over the lazy dog";
- String textToAppend = " followed by another fox";
-
- OMElement elem = factory.createOMElement(localName, namespace, prefix);
- OMText textNode = factory.createOMText(elem, tempText);
-
- ((Text) textNode).appendData(textToAppend);
-
- assertEquals("Text value mismatch", tempText + textToAppend, textNode
- .getText());
- }
+ public TextImplTest() {
+ super();
+ }
+
+ public TextImplTest(String name) {
+ super(name);
+ }
+
+ public void testSetText() {
+ OMDOMFactory factory = new OMDOMFactory();
+ String localName = "TestLocalName";
+ String namespace = "http://ws.apache.org/axis2/ns";
+ String prefix = "axis2";
+ String tempText = "The quick brown fox jumps over the lazy dog";
+
+ OMElement elem = factory.createOMElement(localName, namespace, prefix);
+ OMText textNode = factory.createOMText(elem, tempText);
+
+ assertEquals("Text value mismatch", tempText, textNode.getText());
+ }
+
+ public void testAppendText() {
+ OMDOMFactory factory = new OMDOMFactory();
+ String localName = "TestLocalName";
+ String namespace = "http://ws.apache.org/axis2/ns";
+ String prefix = "axis2";
+ String tempText = "The quick brown fox jumps over the lazy dog";
+ String textToAppend = " followed by another fox";
+
+ OMElement elem = factory.createOMElement(localName, namespace, prefix);
+ OMText textNode = factory.createOMText(elem, tempText);
+
+ ((Text) textNode).appendData(textToAppend);
+
+ assertEquals("Text value mismatch", tempText + textToAppend, textNode
+ .getText());
+ }
- public void testSplitText() {
- String textValue = "temp text value";
+ public void testSplitText() {
+ String textValue = "temp text value";
OMDOMFactory fac = new OMDOMFactory();
DocumentImpl doc = new DocumentImpl(fac);
- Text txt = doc.createTextNode(textValue);
- txt.splitText(3);
+ Text txt = doc.createTextNode(textValue);
+ txt.splitText(3);
- assertNotNull("Text value missing in the original Text node", txt
- .getNodeValue());
+ assertNotNull("Text value missing in the original Text node", txt
+ .getNodeValue());
- assertNotNull("Sibling missing after split", txt.getNextSibling());
- assertNotNull("Text value missing in the new split Text node", txt
- .getNextSibling().getNodeValue());
-
- assertEquals("Incorrect split point", textValue.substring(0, 3), txt
- .getNodeValue());
- assertEquals("Incorrect split point", textValue.substring(3, textValue
- .length()), txt.getNextSibling().getNodeValue());
+ assertNotNull("Sibling missing after split", txt.getNextSibling());
+ assertNotNull("Text value missing in the new split Text node", txt
+ .getNextSibling().getNodeValue());
+
+ assertEquals("Incorrect split point", textValue.substring(0, 3), txt
+ .getNodeValue());
+ assertEquals("Incorrect split point", textValue.substring(3, textValue
+ .length()), txt.getNextSibling().getNodeValue());
- }
+ }
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java Wed Mar 7 06:59:00 2007
@@ -16,17 +16,22 @@
*/
import junit.framework.TestCase;
-import org.apache.axiom.om.*;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayInputStream;
public class OMAttributeTest extends TestCase {
public void testAddAttribute() {
- String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header name = \"jhon\"/><soapenv:Body><my:uploadFileUsingMTOM xmlns:my=\"http://localhost/my\"><my:folderName>/home/saliya/Desktop</my:folderName></my:uploadFileUsingMTOM></soapenv:Body><Body>TTTT</Body> </soapenv:Envelope>";
+ String xmlString =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header name = \"jhon\"/><soapenv:Body><my:uploadFileUsingMTOM xmlns:my=\"http://localhost/my\"><my:folderName>/home/saliya/Desktop</my:folderName></my:uploadFileUsingMTOM></soapenv:Body><Body>TTTT</Body> </soapenv:Envelope>";
String test1 = "";
@@ -42,14 +47,14 @@
XMLStreamReader parser2;
try {
- parser2 = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
+ parser2 = XMLInputFactory.newInstance()
+ .createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
StAXOMBuilder builder2 = new StAXOMBuilder(parser2);
OMElement doc = builder2.getDocumentElement();
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://www.me.com", "axiom");
-
//code line to be tested
OMAttribute at = factory.createOMAttribute("id", ns, "value");
doc.addAttribute(at);
@@ -67,7 +72,8 @@
XMLStreamReader parser2;
try {
- parser2 = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
+ parser2 = XMLInputFactory.newInstance()
+ .createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
StAXOMBuilder builder2 = new StAXOMBuilder(parser2);
OMElement doc = builder2.getDocumentElement();
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMDocumentSerilizationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMDocumentSerilizationTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMDocumentSerilizationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMDocumentSerilizationTest.java Wed Mar 7 06:59:00 2007
@@ -28,9 +28,7 @@
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
-/**
- * This tests the serializeAndConsume method
- */
+/** This tests the serializeAndConsume method */
public class OMDocumentSerilizationTest extends TestCase {
private OMDocument document;
@@ -47,10 +45,10 @@
public void setUp() {
OMFactory factory = OMAbstractFactory.getOMFactory();
- OMNamespace namespace = factory.createOMNamespace("http://testuri.org","test");
- OMElement documentElement = factory.createOMElement("DocumentElement",namespace);
+ OMNamespace namespace = factory.createOMNamespace("http://testuri.org", "test");
+ OMElement documentElement = factory.createOMElement("DocumentElement", namespace);
- OMElement child1 = factory.createOMElement("Child1",namespace);
+ OMElement child1 = factory.createOMElement("Child1", namespace);
child1.setText("TestText");
documentElement.addChild(child1);
@@ -70,7 +68,7 @@
String xmlDocument = new String(baos.toByteArray());
- assertTrue("XML Declaration missing",-1<xmlDocument.indexOf(xmlDeclStart));
+ assertTrue("XML Declaration missing", -1 < xmlDocument.indexOf(xmlDeclStart));
}
public void testExcludeXMLDeclaration() throws XMLStreamException {
@@ -92,21 +90,22 @@
String xmlDocument = new String(baos.toByteArray());
- assertTrue("Charset declaration missing",-1 < xmlDocument.indexOf(encoding) ||
- -1 < xmlDocument.indexOf(encoding.toLowerCase()) ||
- -1 < xmlDocument.indexOf(encoding2.toLowerCase()) ||
- -1 < xmlDocument.indexOf(encoding2));
+ assertTrue("Charset declaration missing", -1 < xmlDocument.indexOf(encoding) ||
+ -1 < xmlDocument.indexOf(encoding.toLowerCase()) ||
+ -1 < xmlDocument.indexOf(encoding2.toLowerCase()) ||
+ -1 < xmlDocument.indexOf(encoding2));
}
- public void testCharsetEncodingUTF_16() throws XMLStreamException, UnsupportedEncodingException {
+ public void testCharsetEncodingUTF_16()
+ throws XMLStreamException, UnsupportedEncodingException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding("UTF-16");
document.serializeAndConsume(baos, format);
- String xmlDocument = new String(baos.toByteArray(),"UTF-16");
- assertTrue("Charset declaration missing",-1<xmlDocument.indexOf(encoding_UTF16) ||
- -1<xmlDocument.indexOf(encoding2_UTF16));
+ String xmlDocument = new String(baos.toByteArray(), "UTF-16");
+ assertTrue("Charset declaration missing", -1 < xmlDocument.indexOf(encoding_UTF16) ||
+ -1 < xmlDocument.indexOf(encoding2_UTF16));
}
@@ -115,8 +114,8 @@
document.serializeAndConsume(baos);
String xmlDocument = new String(baos.toByteArray());
- assertTrue("Charset declaration missing",-1<xmlDocument.indexOf(version) ||
- -1<xmlDocument.indexOf(version2));
+ assertTrue("Charset declaration missing", -1 < xmlDocument.indexOf(version) ||
+ -1 < xmlDocument.indexOf(version2));
}
public void testXMLVersion_11() throws XMLStreamException {
@@ -125,7 +124,7 @@
document.serializeAndConsume(baos);
String xmlDocument = new String(baos.toByteArray());
- assertTrue("Charset declaration missing",-1<xmlDocument.indexOf(version_11) ||
- -1<xmlDocument.indexOf(version2_11));
+ assertTrue("Charset declaration missing", -1 < xmlDocument.indexOf(version_11) ||
+ -1 < xmlDocument.indexOf(version2_11));
}
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMElementGetElementTextTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMElementGetElementTextTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMElementGetElementTextTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMElementGetElementTextTest.java Wed Mar 7 06:59:00 2007
@@ -1,11 +1,10 @@
package org.apache.axiom.om.impl.llom;
import junit.framework.TestCase;
-import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMComment;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -28,30 +27,31 @@
public class OMElementGetElementTextTest extends TestCase {
protected OMElement documentElement;
+
public void setUp() {
OMFactory factory = OMAbstractFactory.getOMFactory();
- OMNamespace namespace = factory.createOMNamespace("http://testuri.org","test");
- documentElement = factory.createOMElement("DocumentElement",namespace);
- factory.createOMText(documentElement,"this is a TEXT");
- factory.createOMComment(documentElement,"this is a comment");
- factory.createOMText(documentElement,"this is a TEXT block 2");
+ OMNamespace namespace = factory.createOMNamespace("http://testuri.org", "test");
+ documentElement = factory.createOMElement("DocumentElement", namespace);
+ factory.createOMText(documentElement, "this is a TEXT");
+ factory.createOMComment(documentElement, "this is a comment");
+ factory.createOMText(documentElement, "this is a TEXT block 2");
}
/**
*
*/
- public void testGetElementTextProperly(){
+ public void testGetElementTextProperly() {
try {
XMLStreamReader xmlStreamReader = documentElement.getXMLStreamReader();
//move to the Start_Element
- while(xmlStreamReader.getEventType()!=XMLStreamReader.START_ELEMENT){
+ while (xmlStreamReader.getEventType() != XMLStreamReader.START_ELEMENT) {
xmlStreamReader.next();
}
String elementText = xmlStreamReader.getElementText();
- assertEquals("this is a TEXTthis is a TEXT block 2",elementText);
+ assertEquals("this is a TEXTthis is a TEXT block 2", elementText);
} catch (XMLStreamException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMNamespaceImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMNamespaceImplTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMNamespaceImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMNamespaceImplTest.java Wed Mar 7 06:59:00 2007
@@ -21,16 +21,12 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.apache.axiom.om.impl.OMNamespaceImpl;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import org.apache.axiom.om.impl.OMNamespaceImpl;
-
-/**
- * This class will test the methods and fields of
- * the OMNamespaceImpl class.
- */
+/** This class will test the methods and fields of the OMNamespaceImpl class. */
public class OMNamespaceImplTest extends TestCase {
/**
@@ -43,8 +39,7 @@
}
/**
- * A one arg constructor to allow specifying
- * a single test method to run.
+ * A one arg constructor to allow specifying a single test method to run.
*
* @param name The name of the test to run
*/
@@ -53,8 +48,7 @@
}
/**
- * This method returns a test suite of tests to
- * run.
+ * This method returns a test suite of tests to run.
*
* @return A test suite to be run
*/
@@ -62,44 +56,38 @@
return new TestSuite(OMNamespaceImplTest.class);
}
- /**
- * This method will test the getPrefix method.
- */
+ /** This method will test the getPrefix method. */
public void testGetPrefix() {
OMNamespaceImpl omNsImpl =
- new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace",
- "xml");
+ new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace",
+ "xml");
assertEquals("http://www.w3.org/XML/1998/namespace",
omNsImpl.getNamespaceURI());
omNsImpl = new OMNamespaceImpl(null, null);
assertNull(omNsImpl.getNamespaceURI());
}
- /**
- * This method will test the getName method.
- */
+ /** This method will test the getName method. */
public void testGetName() {
OMNamespaceImpl omNsImpl =
- new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace",
- "xml");
+ new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace",
+ "xml");
assertEquals("xml", omNsImpl.getPrefix());
omNsImpl = new OMNamespaceImpl(null, null);
assertNull(omNsImpl.getPrefix());
}
- /**
- * This method wil test the equals method.
- */
+ /** This method wil test the equals method. */
public void testEquals() {
OMNamespaceImpl omNsImpl =
- new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace",
- null);
+ new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace",
+ null);
assertTrue(omNsImpl.equals("http://www.w3.org/XML/1998/namespace",
null));
omNsImpl =
- new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace",
- "xml");
+ new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace",
+ "xml");
assertTrue(omNsImpl.equals("http://www.w3.org/XML/1998/namespace",
"xml"));
assertTrue(!omNsImpl.equals("http://www.w3.org/XML/1998/namespace",
@@ -113,18 +101,17 @@
omNsImpl = new OMNamespaceImpl(null, null);
assertTrue(!omNsImpl.equals("http://www.w3.org/XML/1998/namespace",
- "xml"));
+ "xml"));
assertTrue(!omNsImpl.equals("http://www.w3.org/XML/1998/namespace",
null));
assertTrue(!omNsImpl.equals(null,
"xml"));
assertTrue(omNsImpl.equals(null, null));
-
+
}
/**
- * This method will insure that the OMNamespaceImpl
- * class remains immutable.
+ * This method will insure that the OMNamespaceImpl class remains immutable.
*
* @throws Exception Any kind of exception
*/
@@ -133,23 +120,23 @@
Field[] clsField = OMNamespaceImpl.class.getDeclaredFields();
for (int i = 0; i < clsField.length; i++) {
String fieldData = clsField[i].toString();
- if ((fieldData.indexOf("prefix") != -1)
- || (fieldData.indexOf("uri") != -1)) {
+ if ((fieldData.indexOf("prefix") != -1)
+ || (fieldData.indexOf("uri") != -1)) {
assertTrue("The field should have been private, "
- + " but instead contained: " + fieldData + ".",
+ + " but instead contained: " + fieldData + ".",
fieldData.indexOf("private") != -1);
}
}
- String[] method = new String[] {"setPrefix", "setUri", "setName"};
+ String[] method = new String[] { "setPrefix", "setUri", "setName" };
for (int i = 0; i < method.length; i++) {
try {
Method m =
- OMNamespaceImpl.class.getMethod(method[i],
- new Class[] {String.class});
+ OMNamespaceImpl.class.getMethod(method[i],
+ new Class[] { String.class });
fail("A NoSuchMethodException should have been thrown"
- + " when trying to get method \"" + method[i]
- + "\".");
+ + " when trying to get method \"" + method[i]
+ + "\".");
} catch (NoSuchMethodException e) {
// These methods should not exist, so this is
// expected.
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java?view=diff&rev=515594&r1=515593&r2=515594
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java Wed Mar 7 06:59:00 2007
@@ -31,9 +31,7 @@
public class OMOutputTest extends AbstractTestCase {
- /**
- * @param testName
- */
+ /** @param testName */
public OMOutputTest(String testName) {
super(testName);
}
@@ -61,7 +59,7 @@
outBase64File = getTempOutputFile(outBase64FileName);
OMFactory fac = OMAbstractFactory.getOMFactory();
-
+
OMNamespaceImpl soap = new OMNamespaceImpl(
"http://schemas.xmlsoap.org/soap/envelope/", "soap");
envelope = new OMElementImpl("Envelope", soap, fac);
@@ -76,10 +74,10 @@
OMElement text = new OMElementImpl("name", dataName, fac);
OMAttribute cType1 = new OMAttributeImpl("contentType", mime,
- "text/plain", fac);
+ "text/plain", fac);
text.addAttribute(cType1);
- byte[] byteArray = new byte[]{13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
- 98};
+ byte[] byteArray = new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
+ 98 };
dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
OMTextImpl textData = new OMTextImpl(dataHandler, false, fac);
@@ -107,7 +105,7 @@
mtomOutputFormat.setDoOptimize(true);
OMOutputFormat baseOutputFormat = new OMOutputFormat();
baseOutputFormat.setDoOptimize(false);
-
+
envelope.serializeAndConsume(new FileOutputStream(outBase64File), baseOutputFormat);
envelope.serializeAndConsume(new FileOutputStream(outMTOMFile), mtomOutputFormat);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org