You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by da...@apache.org on 2004/08/23 18:28:17 UTC
cvs commit: xml-xmlbeans/v2/test/src/xmlcursor/xpath/xbean_xpath/detailed AxesTest.java NodeTest.java
daveremy 2004/08/23 09:28:17
Modified: v2/test/src/xmlcursor/detailed
CursorGeneratedTypedObjectTest.java
CursorLocations.java InsertNamespaceTest.java
MoveXmlTest2.java MultipleCopyFromCursorTest.java
PrefixForNamespaceTest.java ToChildTest.java
v2/test/src/xmlcursor/xpath/xbean_xpath/detailed
AxesTest.java NodeTest.java
Log:
Contributed by:Yana Kadiyska. Fixing tests
Revision Changes Path
1.4 +7 -6 xml-xmlbeans/v2/test/src/xmlcursor/detailed/CursorGeneratedTypedObjectTest.java
Index: CursorGeneratedTypedObjectTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/detailed/CursorGeneratedTypedObjectTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CursorGeneratedTypedObjectTest.java 1 Jul 2004 00:01:29 -0000 1.3
+++ CursorGeneratedTypedObjectTest.java 23 Aug 2004 16:28:16 -0000 1.4
@@ -93,8 +93,8 @@
"<loc:SubdivisionCode>xyz</loc:SubdivisionCode>" +
"</xml-fragment>";
XmlOptions map = new XmlOptions();
- map.put(XmlOptions.SAVE_PRETTY_PRINT, "");
- map.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, new Integer(-1));
+ //map.put(XmlOptions.SAVE_PRETTY_PRINT, "");
+ //map.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, new Integer(-1));
try {
assertEquals(sExpectedXML, xc0.xmlText(map));
loc = (LocationDocument.Location) xc0.getObject();
@@ -133,9 +133,10 @@
xc0.toNextToken();
assertEquals(TokenType.END, xc0.currentTokenType());
- xc0.insertElement("LocationIdentifier",
+ xc0.beginElement("LocationIdentifier",
"http://www.tranxml.org/TranXML/Version4.0");
xc0.insertAttributeWithValue("Qualifier", "FR");
+ xc0.toEndToken();
xc0.insertElementWithText("CountrySubdivisionCode",
"http://www.tranxml.org/TranXML/Version4.0", "xyz");
xc0.toCursor(xc);
@@ -143,9 +144,9 @@
String sExpectedXML = "<GeographicLocation " + sNamespace +
"><CityName>DALLAS</CityName><StateOrProvinceCode>TX</StateOrProvinceCode><LocationIdentifier Qualifier=\"FR\"/><CountrySubdivisionCode>xyz</CountrySubdivisionCode></GeographicLocation>";
XmlOptions map = new XmlOptions();
- map.put(XmlOptions.SAVE_PRETTY_PRINT, "");
- map.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, new Integer(-1));
- assertEquals(sExpectedXML, xc0.xmlText(map));
+ // map.put(XmlOptions.SAVE_PRETTY_PRINT, "");
+ // map.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, new Integer(-1));
+ assertEquals(sExpectedXML, xc0.xmlText());
String sOExpectedXML = "<xml-fragment xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\"><ver:CityName xmlns:ver=\"http://www.tranxml.org/TranXML/Version4.0\">DALLAS</ver:CityName><ver:StateOrProvinceCode xmlns:ver=\"http://www.tranxml.org/TranXML/Version4.0\">TX</ver:StateOrProvinceCode><ver:LocationIdentifier Qualifier=\"FR\" xmlns:ver=\"http://www.tranxml.org/TranXML/Version4.0\"/><ver:CountrySubdivisionCode xmlns:ver=\"http://www.tranxml.org/TranXML/Version4.0\">xyz</ver:CountrySubdivisionCode></xml-fragment>";
1.5 +12 -19 xml-xmlbeans/v2/test/src/xmlcursor/detailed/CursorLocations.java
Index: CursorLocations.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/detailed/CursorLocations.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CursorLocations.java 22 Jul 2004 23:53:59 -0000 1.4
+++ CursorLocations.java 23 Aug 2004 16:28:16 -0000 1.5
@@ -78,7 +78,8 @@
xc2.toPrevToken();
}
- System.out.println("Current Token Type " + xc1.currentTokenType() + " " + xc2.currentTokenType());
+ assertEquals("Current Token Type ",xc1.currentTokenType(), xc2.currentTokenType());
+ assertEquals(xc1.getChars(), xc1.getTextValue());
assertEquals(xc1.getChars(), xc2.getTextValue());
//System.out.println(xc2.getTextValue());
xc2.toNextToken();
@@ -240,22 +241,12 @@
public void testXmlObjectUsingCursor() throws Exception {
XmlCursor xc1, xc2, xc3;
- //PurchaseOrderDocument pod = (PurchaseOrderDocument)XmlObject.Factory.parse(Common.XML_PURCHASEORDER);
- PurchaseOrderDocument pod = PurchaseOrderDocument.Factory.parse(
+ PurchaseOrderDocument pod = PurchaseOrderDocument.Factory.parse(
JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO));
xc1 = pod.newCursor();
xc2 = pod.newCursor();
xc3 = pod.newCursor();
- //while(xc1.currentTokenType() != TokenType.ENDDOC)
- // {
- //System.out.println(xc1.currentTokenType());
-
- //if (xc1.currentTokenType() == TokenType.TEXT)
- //System.out.println( xc1.getChars());
-
- //xc1.toNextToken();
- //}
//moving cursor location so that it comes to zip under shipto
@@ -276,10 +267,11 @@
toPrevTokenOfType(xc2, TokenType.TEXT);
toPrevTokenOfType(xc3, TokenType.TEXT);
toPrevTokenOfType(xc3, TokenType.TEXT);
-
+ //all cursors are now at: 90952
assertEquals(xc1.getChars(), xc2.getChars(), xc3.getChars());
-
+ //at 52
xc2.toNextChar(3);
+ //after 90952
xc3.toNextChar(5);
assertEquals(false, xc2.isAtSamePositionAs(xc3));
assertEquals(false, xc3.isAtSamePositionAs(xc1));
@@ -290,13 +282,14 @@
USAddress usa = pt.getShipTo();
usa.setZip(new BigDecimal(500));
- //System.out.println(usa.getZip());
-
+ assertEquals(500,usa.getZip().intValue());
+ //xc2 and xc3 should now both be past 500
+ //xc1 should be right at 500
assertEquals(true, xc2.isAtSamePositionAs(xc3));
- assertEquals(true, xc3.isAtSamePositionAs(xc1));
+ assertEquals(false, xc3.isAtSamePositionAs(xc1));
- xc1.toPrevChar(3);
- xc2.toPrevChar(3);
+ assertEquals(0,xc1.toPrevChar(3));
+ assertEquals(3,xc2.toPrevChar(3));
//System.out.println(xc1.getChars());
assertEquals(xc1.getChars(), xc2.getChars());
1.3 +2 -2 xml-xmlbeans/v2/test/src/xmlcursor/detailed/InsertNamespaceTest.java
Index: InsertNamespaceTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/detailed/InsertNamespaceTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InsertNamespaceTest.java 17 Jun 2004 16:29:39 -0000 1.2
+++ InsertNamespaceTest.java 23 Aug 2004 16:28:16 -0000 1.3
@@ -161,9 +161,9 @@
try {
m_xc.insertNamespace("prefix", null);
- assertTrue(false); // should NOT get here.
+ fail("Inserting null NS not OK");
} catch (IllegalArgumentException e) {
- assertTrue(true);
+
}
// OLD CODE:
1.3 +11 -2 xml-xmlbeans/v2/test/src/xmlcursor/detailed/MoveXmlTest2.java
Index: MoveXmlTest2.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/detailed/MoveXmlTest2.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MoveXmlTest2.java 17 Jun 2004 16:29:39 -0000 1.2
+++ MoveXmlTest2.java 23 Aug 2004 16:28:16 -0000 1.3
@@ -46,7 +46,9 @@
public void testNormalCase(){
String sExpectedTrg1="<!--BOOK COMMENT--><target/>";
- String sExpectedSrc1="<bk:book at0=\"value0\" xmlns:bk=\"urn:loc.gov:books\">text0<author at0=\"v0\" at1=\"value1\"/></bk:book>";
+ String sExpectedSrc1="<bk:book at0=\"value0\" " +
+ "xmlns:bk=\"urn:loc.gov:books\">" +
+ "text0<author at0=\"v0\" at1=\"value1\"/></bk:book>";
toNextTokenOfType(m_xc1,TokenType.START);
@@ -59,10 +61,17 @@
sExpectedTrg1="<!--BOOK COMMENT--><target xmlns:bk=\"urn:loc.gov:books\"/>";
- sExpectedSrc1="<urn:book at0=\"value0\" xmlns:urn=\"urn:loc.gov:books\">text0<author at0=\"v0\" at1=\"value1\"/></urn:book>";
+ sExpectedSrc1="<bk:book " +
+ "at0=\"value0\" " +
+ "xmlns:bk=\"urn:loc.gov:books\">" +
+ "text0<author at0=\"v0\" at1=\"value1\"/>" +
+ "</bk:book>";
+
+ //copy the namespace declaration exlplicitly
toNextTokenOfType(m_xc1,TokenType.END);
toNextTokenOfType(m_xc, TokenType.NAMESPACE);
m_xc.moveXml(m_xc1);
+
toPrevTokenOfType(m_xc,TokenType.STARTDOC);
toPrevTokenOfType(m_xc1,TokenType.STARTDOC);
1.4 +4 -2 xml-xmlbeans/v2/test/src/xmlcursor/detailed/MultipleCopyFromCursorTest.java
Index: MultipleCopyFromCursorTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/detailed/MultipleCopyFromCursorTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MultipleCopyFromCursorTest.java 1 Jul 2004 00:01:29 -0000 1.3
+++ MultipleCopyFromCursorTest.java 23 Aug 2004 16:28:16 -0000 1.4
@@ -71,7 +71,8 @@
xc.toStartDoc();
xc.selectPath(Common.CLM_NS_XQUERY_DEFAULT +
"$this//GeographicLocation");
- xc.toNextSelection();
+ assertTrue( xc.getSelectionCount() > 0 );
+ assertTrue( xc.toNextSelection());
aCursors[0].toLastChild();
assertEquals("TX", aCursors[0].getTextValue());
@@ -81,9 +82,10 @@
aCursors[0].toNextToken();
assertEquals(TokenType.END, aCursors[0].currentTokenType());
- aCursors[0].insertElement("LocationIdentifier",
+ aCursors[0].beginElement("LocationIdentifier",
"http://www.tranxml.org/TranXML/Version4.0");
aCursors[0].insertAttributeWithValue("Qualifier", "FR");
+ aCursors[0].toEndToken();
aCursors[0].insertElementWithText("CountrySubdivisionCode",
"http://www.tranxml.org/TranXML/Version4.0",
"xyz");
1.4 +2 -7 xml-xmlbeans/v2/test/src/xmlcursor/detailed/PrefixForNamespaceTest.java
Index: PrefixForNamespaceTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/detailed/PrefixForNamespaceTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PrefixForNamespaceTest.java 1 Jul 2004 00:01:29 -0000 1.3
+++ PrefixForNamespaceTest.java 23 Aug 2004 16:28:16 -0000 1.4
@@ -127,13 +127,8 @@
m_xc.insertNamespace("pre3", "uri3");
m_xc.insertNamespace(null, "uridefault");
toNextTokenOfType(m_xc, TokenType.END);
-
- try {
- m_xc.prefixForNamespace("nsa");
- fail("Expected IllegalStateException");
- } catch (IllegalStateException iae) {
- }
- // assertEquals("ns1", m_xc.prefixForNamespace("nsa"));
+ //the default prefix
+ assertEquals("", m_xc.prefixForNamespace("nsa"));
// assertEquals("pre1", m_xc.prefixForNamespace("uri1"));
}
1.3 +2 -0 xml-xmlbeans/v2/test/src/xmlcursor/detailed/ToChildTest.java
Index: ToChildTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/detailed/ToChildTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ToChildTest.java 17 Jun 2004 16:29:39 -0000 1.2
+++ ToChildTest.java 23 Aug 2004 16:28:16 -0000 1.3
@@ -68,7 +68,9 @@
}
public void testToChildInvalidName()throws Exception{
m_xc = XmlObject.Factory.parse(sDoc).newCursor();
+
assertEquals(false,m_xc.toChild(""));
+
}
public void testToChildNull()throws Exception{
1.4 +3 -3 xml-xmlbeans/v2/test/src/xmlcursor/xpath/xbean_xpath/detailed/AxesTest.java
Index: AxesTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/xpath/xbean_xpath/detailed/AxesTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AxesTest.java 26 Jul 2004 18:24:17 -0000 1.3
+++ AxesTest.java 23 Aug 2004 16:28:16 -0000 1.4
@@ -165,7 +165,7 @@
public void testChildAttribute() throws XmlException {
- String sExpected = "<xml-fragment at0=\"val0\"/>";
+ String sExpected = "<xml-fragment at0=\"val0\" xmlns:pre=\"http://uri.com\"/>";
String sQuery1 = "$this/foo/bar/attribute::at0";
XmlCursor c = Public2.getCursor(Public2.parse(sXmlChild));
c.selectPath(sQuery1, options );
@@ -175,7 +175,7 @@
}
public void testChildAttributeAbbrev() throws XmlException {
- String sExpected = "<xml-fragment at0=\"val0\"/>";
+ String sExpected = "<xml-fragment at0=\"val0\" xmlns:pre=\"http://uri.com\"/>";
;
String sQuery1 = "$this/foo/bar/@at0";
XmlCursor c = Public2.getCursor(Public2.parse(sXmlChild));
@@ -186,7 +186,7 @@
}
public void testDescAttribute() throws XmlException {
- String sExpected = "<xml-fragment at0=\"val0\"/>";
+ String sExpected = "<xml-fragment at0=\"val0\" xmlns:pre=\"http://uri.com\"/>";
String sQuery1 = "$this//attribute::at0";
XmlCursor c = Public2.getCursor(Public2.parse(sXmlChild));
assertEquals(XmlCursor.TokenType.START, c.toNextToken());
1.4 +1 -0 xml-xmlbeans/v2/test/src/xmlcursor/xpath/xbean_xpath/detailed/NodeTest.java
Index: NodeTest.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/test/src/xmlcursor/xpath/xbean_xpath/detailed/NodeTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NodeTest.java 26 Jul 2004 18:24:17 -0000 1.3
+++ NodeTest.java 23 Aug 2004 16:28:16 -0000 1.4
@@ -75,6 +75,7 @@
XmlCursor c = Public2.getCursor(Public2.parse(sXmlChild));
String sExpected ="<pre:baz pre:at0=\"val1\" xmlns:pre=\"http://uri\"/>";
assertEquals( XmlCursor.TokenType.START, c.toNextToken() );
+ assertEquals("foo",c.getName().getLocalPart());
c.selectPath(sQuery1);
assertEquals(1, c.getSelectionCount());
c.toNextSelection();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org