Author: veithen
Date: Mon Apr 16 21:24:07 2012
New Revision: 1326803

URL: http://svn.apache.org/viewvc?rev=1326803&view=rev
Log:
Refactored some test cases.

Added:
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithInputStream.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithReader.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithXMLStreamReader.java
   (with props)
Removed:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMXMLParserWrapperTestBase.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMXMLParserWrapperTest.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMXMLParserWrapperTest.java
Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1326803&r1=1326802&r2=1326803&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
 Mon Apr 16 21:24:07 2012
@@ -63,6 +63,9 @@ public class OMTestSuiteBuilder extends 
         addTest(new 
org.apache.axiom.ts.om.attribute.TestGetQNameWithNamespace(metaFactory));
         addTest(new 
org.apache.axiom.ts.om.attribute.TestGetQNameWithoutNamespace(metaFactory));
         addTest(new 
org.apache.axiom.ts.om.attribute.TestSetLocalName(metaFactory));
+        addTest(new 
org.apache.axiom.ts.om.builder.TestCloseWithInputStream(metaFactory));
+        addTest(new 
org.apache.axiom.ts.om.builder.TestCloseWithReader(metaFactory));
+        addTest(new 
org.apache.axiom.ts.om.builder.TestCloseWithXMLStreamReader(metaFactory));
         for (int i=0; i<conformanceFiles.length; i++) {
             addTest(new 
org.apache.axiom.ts.om.builder.TestCreateOMBuilderFromDOMSource(metaFactory, 
conformanceFiles[i]));
             addTest(new 
org.apache.axiom.ts.om.builder.TestCreateOMBuilderFromSAXSource(metaFactory, 
conformanceFiles[i]));

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithInputStream.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithInputStream.java?rev=1326803&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithInputStream.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithInputStream.java
 Mon Apr 16 21:24:07 2012
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.builder;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.testutils.io.CloseSensorInputStream;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestCloseWithInputStream extends AxiomTestCase {
+       public TestCloseWithInputStream(OMMetaFactory metaFactory) {
+               super(metaFactory);
+       }
+
+       protected void runTest() throws Throwable {
+        CloseSensorInputStream in = new 
CloseSensorInputStream(AbstractTestCase.getTestResource(TestConstants.TEST));
+        try {
+            OMXMLParserWrapper builder = 
OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in);
+            builder.getDocument().build();
+            builder.close();
+            // OMXMLParserWrapper#close() does _not_ close the underlying 
input stream
+            assertFalse(in.isClosed());
+        } finally {
+            in.close();
+        }
+       }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithReader.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithReader.java?rev=1326803&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithReader.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithReader.java
 Mon Apr 16 21:24:07 2012
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.builder;
+
+import java.io.StringReader;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.testutils.io.CloseSensorReader;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestCloseWithReader extends AxiomTestCase {
+       public TestCloseWithReader(OMMetaFactory metaFactory) {
+               super(metaFactory);
+       }
+
+       protected void runTest() throws Throwable {
+        CloseSensorReader in = new CloseSensorReader(new 
StringReader("<root><child/></root>"));
+        try {
+            OMXMLParserWrapper builder = 
OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in);
+            builder.getDocument().build();
+            builder.close();
+            // OMXMLParserWrapper#close() does _not_ close the underlying 
input stream
+            assertFalse(in.isClosed());
+        } finally {
+            in.close();
+        }
+       }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithXMLStreamReader.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithXMLStreamReader.java?rev=1326803&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithXMLStreamReader.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithXMLStreamReader.java
 Mon Apr 16 21:24:07 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.builder;
+
+import java.io.InputStream;
+import java.lang.ref.WeakReference;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestCloseWithXMLStreamReader extends AxiomTestCase {
+       public TestCloseWithXMLStreamReader(OMMetaFactory metaFactory) {
+               super(metaFactory);
+       }
+
+       protected void runTest() throws Throwable {
+        InputStream in = AbstractTestCase.getTestResource(TestConstants.TEST);
+        try {
+            XMLStreamReader reader = StAXUtils.createXMLStreamReader(in);
+            OMXMLParserWrapper builder = 
metaFactory.createStAXOMBuilder(metaFactory.getOMFactory(), reader);
+            WeakReference readerWeakRef = new WeakReference(reader);
+            reader = null;
+            builder.getDocument().build();
+            builder.close();
+            for (int i=0; i<10; i++) {
+                Thread.sleep(500);
+                if (readerWeakRef.get() == null) {
+                    return;
+                }
+                System.gc();
+            }
+            fail("Builder didn't release reference to the underlying parser");
+        } finally {
+            in.close();
+        }
+       }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCloseWithXMLStreamReader.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to