You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2015/05/04 11:48:03 UTC
svn commit: r1677571 - in /webservices/axiom/trunk:
implementations/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/
modules/axiom-api/src/test/java/org/apache/axiom/om/impl/
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/ testing/...
Author: veithen
Date: Mon May 4 09:48:03 2015
New Revision: 1677571
URL: http://svn.apache.org/r1677571
Log:
AXIOM-311: Refactor and simplify the test cases for AXIS2-4791. Also remove the System.out.println calls that pollute the build logs.
Added:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeWithXmlStreamWriterFilter.java
- copied, changed from r1677559, webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamWriterFilterTestCase.java
Removed:
webservices/axiom/trunk/implementations/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/XMLStreamWriterFilterTest.java
webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamWriterFilterTestCase.java
Modified:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1677571&r1=1677570&r2=1677571&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Mon May 4 09:48:03 2015
@@ -374,6 +374,8 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.element.TestSerializeAndConsumeConsumed(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestSerializeAndConsumePartiallyBuilt(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestSerializeAndConsumeWithIncompleteDescendant(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestSerializeWithXmlStreamWriterFilter(metaFactory, (char)0));
+ addTest(new org.apache.axiom.ts.om.element.TestSerializeWithXmlStreamWriterFilter(metaFactory, (char)0x15));
for (int i=0; i<3; i++) {
Boolean declare = i == 0 ? null : Boolean.valueOf(i==2);
boolean implicitDeclare = declare == null || declare.booleanValue();
Copied: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeWithXmlStreamWriterFilter.java (from r1677559, webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamWriterFilterTestCase.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeWithXmlStreamWriterFilter.java?p2=webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeWithXmlStreamWriterFilter.java&p1=webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamWriterFilterTestCase.java&r1=1677559&r2=1677571&rev=1677571&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamWriterFilterTestCase.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeWithXmlStreamWriterFilter.java Mon May 4 09:48:03 2015
@@ -16,93 +16,40 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.om.impl;
+package org.apache.axiom.ts.om.element;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.axiom.om.AbstractTestCase;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.util.XMLStreamWriterRemoveIllegalChars;
-import org.apache.axiom.soap.SOAPBody;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.ts.AxiomTestCase;
-public class XMLStreamWriterFilterTestCase extends AbstractTestCase {
-
- private char ILLEGAL_CHAR = 0x15;
-
- private char NULL_CHAR = 0x00;
-
- private final OMMetaFactory omMetaFactory;
-
- protected XMLStreamWriterFilterTestCase(OMMetaFactory omMetaFactory) {
- this.omMetaFactory = omMetaFactory;
- }
-
- public void test01() throws Exception {
- char[] chars = new char[] {ILLEGAL_CHAR};
- String insert = new String(chars);
- testInsert(insert);
- }
+public class TestSerializeWithXmlStreamWriterFilter extends AxiomTestCase {
+ private char c;
- public void test02() throws Exception {
- char[] chars = new char[] {NULL_CHAR};
- String insert = new String(chars);
- testInsert(insert);
+ public TestSerializeWithXmlStreamWriterFilter(OMMetaFactory metaFactory, char c) {
+ super(metaFactory);
+ addTestParameter("char", c);
}
- private void testInsert(String insert) throws Exception {
-
- // Read XML
- InputStream is = getTestResource(TestConstants.TEST);
-
- // Build SOAP OM
- SOAPEnvelope env1 = createEnvelope(is);
-
- // Add illegal character
- SOAPBody body = env1.getBody();
- OMElement omElement = body.getFirstElement();
- String text = omElement.getText();
- text = text + "[" + insert + "]";
- System.out.println("New Text = " + text);
- omElement.setText(text);
+ @Override
+ protected void runTest() throws Throwable {
+ // Create object model containing an invalid character
+ OMElement root = metaFactory.getOMFactory().createOMElement("test", null);
+ root.setText("[" + c + "]");
// Serialize
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OMOutputFormat omFormat = new OMOutputFormat();
omFormat.setXmlStreamWriterFilter(new XMLStreamWriterRemoveIllegalChars());
- env1.serialize(baos, omFormat);
-
- String xmlText = baos.toString();
- System.out.println("Serialized Text = " + xmlText);
+ root.serialize(baos, omFormat);
- ByteArrayInputStream bais = new ByteArrayInputStream(xmlText.getBytes("UTF-8"));
-
- SOAPEnvelope env2 = createEnvelope(bais);
- env2.build();
- }
-
- /**
- * Create SOAPEnvelope from the test in the indicated file
- * @param input stream
- * @return
- * @throws Exception
- */
- protected SOAPEnvelope createEnvelope(InputStream is) throws Exception {
- XMLStreamReader parser =
- XMLInputFactory.newInstance().createXMLStreamReader(is);
- OMXMLParserWrapper builder = new StAXSOAPModelBuilder(omMetaFactory, parser, null);
- SOAPEnvelope sourceEnv = (SOAPEnvelope) builder.getDocumentElement();
- return sourceEnv;
+ // Parse the result; this will fail if the invalid character has not been removed
+ OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
+ new ByteArrayInputStream(baos.toByteArray())).getDocument().build();
}
-
}