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 2012/12/27 12:17:39 UTC
svn commit: r1426164 - in
/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element:
TestGetChildElementsConsumed.java TestGetXMLStreamReaderWithCaching.java
TestSerializeAndConsumeConsumed.java
Author: veithen
Date: Thu Dec 27 11:17:39 2012
New Revision: 1426164
URL: http://svn.apache.org/viewvc?rev=1426164&view=rev
Log:
* Be more precise with respect to the exception that is expected when accessing a part of a document that has already been consumed.
* Avoid the catch-and-fail JUnit anti-pattern.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElementsConsumed.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithCaching.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeAndConsumeConsumed.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElementsConsumed.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElementsConsumed.java?rev=1426164&r1=1426163&r2=1426164&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElementsConsumed.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetChildElementsConsumed.java Thu Dec 27 11:17:39 2012
@@ -22,6 +22,7 @@ import java.util.Iterator;
import javax.xml.stream.XMLStreamReader;
+import org.apache.axiom.om.NodeUnavailableException;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMMetaFactory;
@@ -60,9 +61,9 @@ public class TestGetChildElementsConsume
while (childElements.hasNext()) {
childElements.next();
}
- fail("The stream should've been consumed by now!");
- } catch (Exception e) {
- //if we are here without failing, then we are successful
+ fail("Expected NodeUnavailableException");
+ } catch (NodeUnavailableException ex) {
+ // Expected
}
documentElement.close(false);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithCaching.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithCaching.java?rev=1426164&r1=1426163&r2=1426164&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithCaching.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetXMLStreamReaderWithCaching.java Thu Dec 27 11:17:39 2012
@@ -56,13 +56,9 @@ public class TestGetXMLStreamReaderWithC
//error even when the underlying stream is fully consumed , the object tree is already complete
Iterator childElements = documentElement.getChildElements();
int count = 0;
- try {
- while (childElements.hasNext()) {
- childElements.next();
- count++;
- }
- } catch (Exception e) {
- fail("The object tree needs to be built and traversing the children is to be a success!");
+ while (childElements.hasNext()) {
+ childElements.next();
+ count++;
}
assertEquals("Number of elements need to be 2", count, 2);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeAndConsumeConsumed.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeAndConsumeConsumed.java?rev=1426164&r1=1426163&r2=1426164&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeAndConsumeConsumed.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestSerializeAndConsumeConsumed.java Thu Dec 27 11:17:39 2012
@@ -35,6 +35,7 @@ import org.apache.axiom.ts.AxiomTestCase
* exception if the part of the tree has already been consumed using
* {@link OMContainer#getXMLStreamReaderWithoutCaching()}.
*/
+// TODO: in this scenario we should trigger a NodeUnavailableException as well; fix this with AXIOM-288
public class TestSerializeAndConsumeConsumed extends AxiomTestCase {
public TestSerializeAndConsumeConsumed(OMMetaFactory metaFactory) {
super(metaFactory);