You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2022/02/06 01:52:00 UTC
svn commit: r1897795 [9/39] - in /xmlbeans: site/src/documentation/content/xdocs/ trunk/ trunk/src/main/java/org/apache/xmlbeans/impl/store/ trunk/src/test/java/ValidatingXSRTests/checkin/ trunk/src/test/java/ValidatingXSRTests/detailed/ trunk/src/test...
Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression1_50Test.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression1_50Test.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression1_50Test.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression1_50Test.java Sun Feb 6 01:51:55 2022
@@ -19,32 +19,36 @@ import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.tool.Parameters;
import org.apache.xmlbeans.impl.tool.SchemaCompiler;
import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import xmlbeans48.FeedInfoType;
import javax.xml.namespace.QName;
import java.io.*;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class JiraRegression1_50Test extends JiraTestBase {
/*
- * [XMLBEANS-2] Problem with XmlError.forObject(String,int,XmlObject)
- */
+ * [XMLBEANS-2] Problem with XmlError.forObject(String,int,XmlObject)
+ */
@Test
- public void test_jira_xmlbeans02() throws Exception {
+ void test_jira_xmlbeans02() throws Exception {
StringBuilder xmlstringbuf = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
xmlstringbuf.append("<test>");
xmlstringbuf.append("<testchild attr=\"abcd\"> Jira02 </testchild>");
xmlstringbuf.append("</test>");
XmlObject myxmlobj = null;
- List errors = new ArrayList();
+ List<XmlError> errors = new ArrayList<>();
XmlOptions options = new XmlOptions().setErrorListener(errors);
try {
myxmlobj = XmlObject.Factory.parse(xmlstringbuf.toString(), options);
@@ -54,46 +58,39 @@ public class JiraRegression1_50Test exte
// call an API on the cursor : verification of cursor not being disposed
System.out.println("Cursor Text Value: " + cur.getTextValue());
}
- } catch (XmlException xme) {
- if (!xme.getErrors().isEmpty()) {
- for (Iterator itr = xme.getErrors().iterator(); itr.hasNext();) {
- System.out.println("Parse Errors :" + itr.next());
- }
- }
-
+ } catch (XmlException ignored) {
} catch (NullPointerException npe) {
- fail("test_jira_xmlbeans02() : Null Pointer Exception thrown !");
+ Assertions.fail("test_jira_xmlbeans02() : Null Pointer Exception thrown !");
}
- printOptionErrMsgs(errors);
+ hasSevereError(errors);
}
/*
- * [XMLBEANS-4] xs:decimal size greater than 18 results in uncompilable java code
- */
+ * [XMLBEANS-4] xs:decimal size greater than 18 results in uncompilable java code
+ */
@Test
- public void test_jira_xmlbeans04() {
- List errors = new ArrayList();
+ void test_jira_xmlbeans04() {
+ List<XmlError> errors = new ArrayList<>();
Parameters params = new Parameters();
- params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_04.xsd_")});
+ params.setXsdFiles(new File(scompTestFilesRoot + "xmlbeans_04.xsd_"));
params.setErrorListener(errors);
params.setSrcDir(schemaCompSrcDir);
params.setClassesDir(schemaCompClassesDir);
SchemaCompiler.compile(params);
- if (printOptionErrMsgs(errors)) {
- fail("test_jira_xmlbeans04() : Errors found when executing scomp");
+ if (hasSevereError(errors)) {
+ Assertions.fail("test_jira_xmlbeans04() : Errors found when executing scomp");
}
}
-
/*
- * [XMLBEANS-9] Null Pointer Exception when running validate from cmd line
- */
+ * [XMLBEANS-9] Null Pointer Exception when running validate from cmd line
+ */
@Test
- @Ignore("no shell tests on junit")
+ @Disabled("no shell tests on junit")
public void test_jira_xmlbeans09() throws Exception {
// Exec validate script from cmd line - Refer xmlbeans_09.xsd, xmlbeans_09.xml
@@ -104,7 +101,7 @@ public class JiraRegression1_50Test exte
try {
validator_proc = Runtime.getRuntime().exec(sb.toString());
} catch (NullPointerException npe) {
- fail("test_jira_xmlbeans09() : Null Pointer Exception when running validate for schema");
+ Assertions.fail("test_jira_xmlbeans09() : Null Pointer Exception when running validate for schema");
}
System.out.println("cmd:" + sb);
@@ -124,30 +121,30 @@ public class JiraRegression1_50Test exte
}
/*
- * [XMLBEANS-11]: Calling getUnionMemberTypes() on SchemaType for non-union types results in NullPointerException
- * status : fixed
- */
- @Test
- public void test_jira_xmlbeans11() throws Exception {
-
- StringBuilder xsdAsString = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
- xsdAsString.append(" <!-- W3C Schema generated by XML Spy v4.3 U (http://www.xmlspy.com)\n");
- xsdAsString.append(" --> \n");
- xsdAsString.append(" <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">\n");
- xsdAsString.append(" <xs:simpleType name=\"restrictsString\">\n");
- xsdAsString.append(" <xs:restriction base=\"xs:string\">\n");
- xsdAsString.append(" <xs:length value=\"10\" /> \n");
- xsdAsString.append(" </xs:restriction>\n");
- xsdAsString.append(" </xs:simpleType>\n");
- xsdAsString.append(" </xs:schema>");
+ * [XMLBEANS-11]: Calling getUnionMemberTypes() on SchemaType for non-union types results in NullPointerException
+ * status : fixed
+ */
+ @Test
+ void test_jira_xmlbeans11() throws Exception {
+
+ String xsdAsString =
+ "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + " <!-- W3C Schema generated by XML Spy v4.3 U (http://www.xmlspy.com)\n" +
+ " --> \n" +
+ " <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">\n" +
+ " <xs:simpleType name=\"restrictsString\">\n" +
+ " <xs:restriction base=\"xs:string\">\n" +
+ " <xs:length value=\"10\" /> \n" +
+ " </xs:restriction>\n" +
+ " </xs:simpleType>\n" +
+ " </xs:schema>";
// load schema file as SchemaDocument XmlObject
- SchemaDocument sd = SchemaDocument.Factory.parse(xsdAsString.toString());
+ SchemaDocument sd = SchemaDocument.Factory.parse(xsdAsString);
// compile loaded XmlObject
SchemaTypeSystem sts = XmlBeans.compileXsd((XmlObject[]) Collections.singletonList(sd).toArray(new XmlObject[]{}),
- XmlBeans.getContextTypeLoader(),
- new XmlOptions());
+ XmlBeans.getContextTypeLoader(),
+ new XmlOptions());
sts.resolve();
SchemaType[] st = sts.globalTypes();
@@ -155,22 +152,21 @@ public class JiraRegression1_50Test exte
System.out.println("NUMBER OF GLOBAL TYPES: " + st.length);
try {
- for (int i = 0; i < st.length; i++)
- // check if it is union type
- {
- System.out.println("IS UNION TYPE: " + (st[i].getUnionMemberTypes() != null));
+ // check if it is union type
+ for (SchemaType schemaType : st) {
+ System.out.println("IS UNION TYPE: " + (schemaType.getUnionMemberTypes() != null));
}
} catch (NullPointerException npe) {
- fail("test_jira_xmlbeans11(): Null Pointer Exception thrown !");
+ Assertions.fail("test_jira_xmlbeans11(): Null Pointer Exception thrown !");
}
}
/*
- * [XMLBEANS-14]: newDomNode() throws NullPointerException
- */
+ * [XMLBEANS-14]: newDomNode() throws NullPointerException
+ */
@Test
- public void test_jira_xmlbeans14() throws Exception {
+ void test_jira_xmlbeans14() throws Exception {
XmlObject xObj = XmlObject.Factory.parse("<Baz/>");
// add element
try (XmlCursor xCursor = xObj.newCursor()) {
@@ -183,31 +179,27 @@ public class JiraRegression1_50Test exte
xObj.save(System.out);
// throws npe in v1
- try {
- xObj.newDomNode();
- } catch (NullPointerException npe) {
- fail("test_jira_xmlbeans14() : Null Pointer Exception when create Dom Node");
- }
+ xObj.newDomNode();
}
/*
- * [XMLBEANS-16]: newDomNode creates a DOM with empty strings for namespace URIs for unprefixed
- * attributes (rather than null)
- * status : fails with crimson and not with Xerces
- */
+ * [XMLBEANS-16]: newDomNode creates a DOM with empty strings for namespace URIs for unprefixed
+ * attributes (rather than null)
+ * status : fails with crimson and not with Xerces
+ */
@Test
- @Ignore("still happens with current xerces 2.11")
+ @Disabled("still happens with current xerces 2.11")
public void test_jira_xmlbeans16() throws Exception {
- StringBuilder sb = new StringBuilder(100);
- sb.append("<?xml version='1.0'?>\n");
- sb.append("<test noprefix='nonamespace' \n");
- sb.append(" ns:prefix='namespace' \n");
- sb.append(" xmlns:ns='http://xml.apache.org/xmlbeans'>value</test>");
+ String sb =
+ "<?xml version='1.0'?>\n" +
+ "<test noprefix='nonamespace' \n" +
+ " ns:prefix='namespace' \n" +
+ " xmlns:ns='http://xml.apache.org/xmlbeans'>value</test>";
// Parse it using XMLBeans
- XmlObject xdoc = XmlObject.Factory.parse(sb.toString());
+ XmlObject xdoc = XmlObject.Factory.parse(sb);
// Convert to a DOM Element
Element firstChild = (Element) xdoc.newDomNode().getFirstChild();
@@ -215,54 +207,54 @@ public class JiraRegression1_50Test exte
// We expect to find a null namespace for the first attribute and 'ns' for the second
NamedNodeMap attributes = firstChild.getAttributes();
System.out.println("Prefix for attr noprefix is:" + attributes.getNamedItem("noprefix").getPrefix() + ":");
- assertNull("Expected null namespace for attribute noprefix", attributes.getNamedItem("noprefix").getPrefix());
- assertEquals("Wrong namespace for attribute prefix", "ns", attributes.getNamedItem("ns:prefix").getPrefix());
+ assertNull(attributes.getNamedItem("noprefix").getPrefix(), "Expected null namespace for attribute noprefix");
+ assertEquals("ns", attributes.getNamedItem("ns:prefix").getPrefix(), "Wrong namespace for attribute prefix");
// We should be able to lookup 'prefix' by specifying the appropriate URI
String prefix = firstChild.getAttributeNS("http://xml.apache.org/xmlbeans", "prefix");
- assertEquals("Wrong value for prefixed attribute", "namespace", prefix);
+ assertEquals("namespace", prefix, "Wrong value for prefixed attribute");
// And 'noprefix' by specifying a null namespace URI
String noprefix = firstChild.getAttributeNS(null, "noprefix");
- assertEquals("Wrong value for unprefixed attribute", "nonamespace", noprefix); // This assertion fails under Crimson
+ assertEquals("nonamespace", noprefix, "Wrong value for unprefixed attribute"); // This assertion fails under Crimson
}
/*
- * [XMLBEANS-33]: insertions occur in improper order when subclassing schema types
- */
+ * [XMLBEANS-33]: insertions occur in improper order when subclassing schema types
+ */
@Test
- public void test_jira_xmlbeans33() throws Exception {
+ void test_jira_xmlbeans33() throws Exception {
xbeansJira33B.SubjectType subject =
- xbeansJira33B.SubjectType.Factory.newInstance();
+ xbeansJira33B.SubjectType.Factory.newInstance();
subject.addNewIDPProvidedNameIdentifier();
subject.addNewSubjectConfirmation().addConfirmationMethod("foo");
subject.addNewNameIdentifier();
XmlOptions options = new XmlOptions();
- ArrayList list = new ArrayList();
+ List<XmlError> list = new ArrayList<>();
options.setErrorListener(list);
boolean bResult = subject.validate(options);
System.out.println(bResult ? "valid" : "invalid");
// print out errors
- for (int i = 0; i < list.size(); i++) {
- System.out.println("Validation Error : " + list.get(i));
+ for (XmlError xmlError : list) {
+ System.out.println("Validation Error : " + xmlError);
}
- assertTrue("Validation Failed, should pass", bResult);
+ assertTrue(bResult, "Validation Failed, should pass");
}
/*
- * [XMLBEANS-34]: error compiling classes when using a schema with a redefined subelement
- */
+ * [XMLBEANS-34]: error compiling classes when using a schema with a redefined subelement
+ */
@Test
- public void test_jira_xmlbeans34() throws Exception {
- List errors = new ArrayList();
+ void test_jira_xmlbeans34() throws Exception {
+ List<XmlError> errors = new ArrayList<>();
Parameters params = new Parameters();
- params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_34b.xsd_")});
+ params.setXsdFiles(new File(scompTestFilesRoot + "xmlbeans_34b.xsd_"));
params.setErrorListener(errors);
params.setSrcDir(schemaCompSrcDir);
params.setClassesDir(schemaCompClassesDir);
@@ -270,8 +262,8 @@ public class JiraRegression1_50Test exte
params.setNoPvr(true);
SchemaCompiler.compile(params);
- if (printOptionErrMsgs(errors)) {
- fail("test_jira_xmlbeans34() : Errors found when executing scomp");
+ if (hasSevereError(errors)) {
+ Assertions.fail("test_jira_xmlbeans34() : Errors found when executing scomp");
}
}
@@ -281,70 +273,73 @@ public class JiraRegression1_50Test exte
* BUGBUG: [XMLBEANS-38]
* [XMLBEANS-38] Does not support xs:key (keyRef NoIllegalEntries)
*/
+ @Disabled
public void test_jira_xmlbeans38() throws Exception {
- String keyrefXSD = "<?xml version=\"1.0\"?>" +
- "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
- "<xsd:element name=\"supermarket\">" +
- "<xsd:complexType>" +
- "<xsd:sequence> " +
- "<xsd:element name=\"aisle\" maxOccurs=\"unbounded\"> \n" +
- "<xsd:complexType> " +
- "<xsd:sequence>" +
- "<xsd:element name=\"item\" maxOccurs=\"unbounded\"> \n" +
- "<xsd:complexType> " +
- "<xsd:simpleContent>" +
- "<xsd:extension base=\"xsd:string\"> \n" +
- "<xsd:attribute name=\"code\" type=\"xsd:positiveInteger\"/> \n" +
- "<xsd:attribute name=\"quantity\" type=\"xsd:positiveInteger\"/> \n" +
- "<xsd:attribute name=\"price\" type=\"xsd:decimal\"/> \n" +
- "</xsd:extension> \n" +
- "</xsd:simpleContent> \n" +
- "</xsd:complexType> \n" +
- "</xsd:element> \n" +
- "</xsd:sequence> \n" + //"<!-- Attribute Of Aisle --> \n" +
- "<xsd:attribute name=\"name\" type=\"xsd:string\"/> \n" +
- "<xsd:attribute name=\"number\" type=\"xsd:positiveInteger\"/> \n" + //"<!-- Of Aisle --> \n" +
- "</xsd:complexType> \n" +
- "<xsd:keyref name=\"NoIllegalEntries\" refer=\"itemKey\"> \n" +
- "<xsd:selector xpath=\"item\"/> \n" +
- "<xsd:field xpath=\"@code\"/> \n" +
- "</xsd:keyref> \n" +
- "</xsd:element> \n" +
- "<xsd:element name=\"items\"> \n" +
- "<xsd:complexType> \n" +
- "<xsd:sequence> \n" +
- "<xsd:element name=\"item\" maxOccurs=\"unbounded\"> \n" +
- "<xsd:complexType> \n" +
- "<xsd:simpleContent> \n" +
- "<xsd:extension base=\"xsd:string\"> \n" +
- "<xsd:attribute name=\"code\" type=\"xsd:positiveInteger\"/> \n" +
- "</xsd:extension> \n" +
- "</xsd:simpleContent> \n" +
- "</xsd:complexType> \n" +
- "</xsd:element> \n" +
- "</xsd:sequence> \n" +
- "</xsd:complexType> \n" +
- "</xsd:element> \n" +
- "</xsd:sequence> \n" +
- "<xsd:attribute name=\"name\" type=\"xsd:string\"/> \n" +
- "</xsd:complexType> \n" +
- "<xsd:key name=\"itemKey\"> \n" +
- "<xsd:selector xpath=\"items/item\"/> \n" +
- "<xsd:field xpath=\"@code\"/> \n" +
- "</xsd:key> \n" +
- "</xsd:element> \n" +
- "</xsd:schema>";
-
-
- String keyRefInstance = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" +
- "<supermarket xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"C:\\tmp\\Supermarket.xsd\" name=\"String\"> \n" +
- "<aisle name=\"String\" number=\"2\"> \n" +
- "<item code=\"1234\" quantity=\"2\" price=\"3.1415926535897932384626433832795\">String</item> \n" +
- "</aisle> \n" +
- "<items> \n" +
- "<item code=\"1234\">Java</item> \n" +
- "</items> \n" +
- "</supermarket>";
+ String keyrefXSD =
+ "<?xml version=\"1.0\"?>" +
+ "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
+ "<xsd:element name=\"supermarket\">" +
+ "<xsd:complexType>" +
+ "<xsd:sequence> " +
+ "<xsd:element name=\"aisle\" maxOccurs=\"unbounded\"> \n" +
+ "<xsd:complexType> " +
+ "<xsd:sequence>" +
+ "<xsd:element name=\"item\" maxOccurs=\"unbounded\"> \n" +
+ "<xsd:complexType> " +
+ "<xsd:simpleContent>" +
+ "<xsd:extension base=\"xsd:string\"> \n" +
+ "<xsd:attribute name=\"code\" type=\"xsd:positiveInteger\"/> \n" +
+ "<xsd:attribute name=\"quantity\" type=\"xsd:positiveInteger\"/> \n" +
+ "<xsd:attribute name=\"price\" type=\"xsd:decimal\"/> \n" +
+ "</xsd:extension> \n" +
+ "</xsd:simpleContent> \n" +
+ "</xsd:complexType> \n" +
+ "</xsd:element> \n" +
+ "</xsd:sequence> \n" + //"<!-- Attribute Of Aisle --> \n" +
+ "<xsd:attribute name=\"name\" type=\"xsd:string\"/> \n" +
+ "<xsd:attribute name=\"number\" type=\"xsd:positiveInteger\"/> \n" + //"<!-- Of Aisle --> \n" +
+ "</xsd:complexType> \n" +
+ "<xsd:keyref name=\"NoIllegalEntries\" refer=\"itemKey\"> \n" +
+ "<xsd:selector xpath=\"item\"/> \n" +
+ "<xsd:field xpath=\"@code\"/> \n" +
+ "</xsd:keyref> \n" +
+ "</xsd:element> \n" +
+ "<xsd:element name=\"items\"> \n" +
+ "<xsd:complexType> \n" +
+ "<xsd:sequence> \n" +
+ "<xsd:element name=\"item\" maxOccurs=\"unbounded\"> \n" +
+ "<xsd:complexType> \n" +
+ "<xsd:simpleContent> \n" +
+ "<xsd:extension base=\"xsd:string\"> \n" +
+ "<xsd:attribute name=\"code\" type=\"xsd:positiveInteger\"/> \n" +
+ "</xsd:extension> \n" +
+ "</xsd:simpleContent> \n" +
+ "</xsd:complexType> \n" +
+ "</xsd:element> \n" +
+ "</xsd:sequence> \n" +
+ "</xsd:complexType> \n" +
+ "</xsd:element> \n" +
+ "</xsd:sequence> \n" +
+ "<xsd:attribute name=\"name\" type=\"xsd:string\"/> \n" +
+ "</xsd:complexType> \n" +
+ "<xsd:key name=\"itemKey\"> \n" +
+ "<xsd:selector xpath=\"items/item\"/> \n" +
+ "<xsd:field xpath=\"@code\"/> \n" +
+ "</xsd:key> \n" +
+ "</xsd:element> \n" +
+ "</xsd:schema>";
+
+
+ String keyRefInstance =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" +
+ "<supermarket xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"C:\\tmp\\Supermarket.xsd\" name=\"String\"> \n" +
+ "<aisle name=\"String\" number=\"2\"> \n" +
+ "<item code=\"1234\" quantity=\"2\" price=\"3.1415926535897932384626433832795\">String</item> \n" +
+ "</aisle> \n" +
+ "<items> \n" +
+ "<item code=\"1234\">Java</item> \n" +
+ "</items> \n" +
+ "</supermarket>";
validateInstance(new String[]{keyrefXSD}, new String[]{keyRefInstance}, null);
}
@@ -357,19 +352,23 @@ public class JiraRegression1_50Test exte
* <p/>
* [XMLBEANS-45] <xsd:redefine> tag is not supported
*/
+ @Disabled
public void test_jira_XmlBeans45() throws Exception {
//this class is built during the build.schemas target
- Class cls = Class.forName("xmlbeans45.PersonName");
+ Class<?> cls = Class.forName("xmlbeans45.PersonName");
//check for methods in class
//getGeneration()
- if (cls.getMethod("getGeneration") == null)
+ if (cls.getMethod("getGeneration") == null) {
throw new Exception("getGeneration() was not found in class");
+ }
//getTitle()
- if (cls.getMethod("getTitle") == null)
+ if (cls.getMethod("getTitle") == null) {
throw new Exception("getTitle() was not found in class");
+ }
//getForenameArray()
- if (cls.getMethod("getForenameArray") == null)
+ if (cls.getMethod("getForenameArray") == null) {
throw new Exception("getForenameArray() was not found in class");
+ }
}
@@ -377,7 +376,8 @@ public class JiraRegression1_50Test exte
* Could not Repro this
* [XMLBEANS-46] Regex validation fails in multi-threaded, multi-processor environment
*/
- public void test_jira_XmlBeans46() throws Exception {
+ @Test
+ void test_jira_XmlBeans46() throws Exception {
RegexThread[] threads = new RegexThread[45];
for (int i = 0; i < threads.length; i++) {
@@ -390,13 +390,15 @@ public class JiraRegression1_50Test exte
System.out.println("Done with RegEx Threading Test...");
StringBuilder sb = new StringBuilder();
- for (int i = 0; i < threads.length; i++) {
- if (threads[i].getException() != null)
- sb.append(threads[i].getException().getMessage() + "\n");
+ for (RegexThread thread : threads) {
+ if (thread.getException() != null) {
+ sb.append(thread.getException().getMessage() + "\n");
+ }
}
- if (sb.length() > 0)
+ if (sb.length() > 0) {
throw new Exception("Threaded Regex Validation Failed\n" + sb.toString());
+ }
}
@@ -404,42 +406,45 @@ public class JiraRegression1_50Test exte
* Incorrect XML
* [XMLBEANS-48] Bug with Root.fetch ( Splay parent, QName name, QNameSet set, int n )
*/
- public void test_jira_XmlBeans48() throws Exception {
+ @Test
+ void test_jira_XmlBeans48() throws Exception {
String incorrectXml = "<sch:Feed xmlns:sch=\"http://xmlbeans_48\">" +
- "<sch:Feed>" +
- "<sch:Location>http://xmlbeans.apache.org</sch:Location>" +
- "<sch:TimeEntered>2004-08-11T15:50:23.064-04:00</sch:TimeEntered>" +
- "</sch:Feed>" +
- "</sch:Feed>";
+ "<sch:Feed>" +
+ "<sch:Location>http://xmlbeans.apache.org</sch:Location>" +
+ "<sch:TimeEntered>2004-08-11T15:50:23.064-04:00</sch:TimeEntered>" +
+ "</sch:Feed>" +
+ "</sch:Feed>";
xmlbeans48.FeedDocument feedDoc = (xmlbeans48.FeedDocument) XmlObject.Factory.parse(incorrectXml);
FeedInfoType feedInfoType = feedDoc.getFeed();
String location = feedInfoType.getLocation();
System.out.println("Location: " + location);
- if (location != null)
+ if (location != null) {
throw new Exception("Location value should not have been populated");
+ }
String correctXml = "<sch:Feed xmlns:sch=\"http://xmlbeans_48\">" +
- "<sch:Location>http://xmlbeans.apache.org</sch:Location>" +
- "<sch:TimeEntered>2004-08-11T15:50:23.064-04:00</sch:TimeEntered>" +
- "</sch:Feed>";
+ "<sch:Location>http://xmlbeans.apache.org</sch:Location>" +
+ "<sch:TimeEntered>2004-08-11T15:50:23.064-04:00</sch:TimeEntered>" +
+ "</sch:Feed>";
feedDoc = (xmlbeans48.FeedDocument) XmlObject.Factory.parse(correctXml);
feedInfoType = feedDoc.getFeed();
location = feedInfoType.getLocation();
System.out.println("Location: " + location);
- if (location == null)
+ if (location == null) {
throw new Exception("Location value should have been populated");
+ }
}
/*
- * [XMLBEANS-49]: Schema compiler won't compile portlet.xsd from jsr168/pluto
- *
- */
- public void test_jira_xmlbeans49() {
- List errors = new ArrayList();
+ * [XMLBEANS-49]: Schema compiler won't compile portlet.xsd from jsr168/pluto
+ */
+ @Test
+ void test_jira_xmlbeans49() {
+ List<XmlError> errors = new ArrayList<>();
Parameters params = new Parameters();
- params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_49.xsd_")});
+ params.setXsdFiles(new File(scompTestFilesRoot + "xmlbeans_49.xsd_"));
params.setErrorListener(errors);
params.setSrcDir(schemaCompSrcDir);
params.setClassesDir(schemaCompClassesDir);
@@ -450,33 +455,24 @@ public class JiraRegression1_50Test exte
try {
SchemaCompiler.compile(params);
} catch (Exception ex) {
- if (!errors.isEmpty()) {
- for (Iterator itr = errors.iterator(); itr.hasNext();) {
- System.out.println("scomp errors: ");
- }
- }
-
- fail("test_jira_xmlbeans49() :Exception thrown with above errors!");
+ Assertions.fail("test_jira_xmlbeans49() :Exception thrown with above errors!");
}
// view errors
- if (printOptionErrMsgs(errors)) {
- fail("test_jira_xmlbeans49() : Errors found when executing scomp");
+ if (hasSevereError(errors)) {
+ Assertions.fail("test_jira_xmlbeans49() : Errors found when executing scomp");
}
}
/**
* For Testing jira issue 46
*/
- public static class RegexThread extends TestThread
- {
- private xmlbeans46.UsPhoneNumberDocument phone;
+ public static class RegexThread extends TestThread {
Random rand;
- public RegexThread()
- {
+ public RegexThread() {
super();
- phone = xmlbeans46.UsPhoneNumberDocument.Factory.newInstance();
+ xmlbeans46.UsPhoneNumberDocument phone = xmlbeans46.UsPhoneNumberDocument.Factory.newInstance();
rand = new Random();
}
@@ -486,8 +482,7 @@ public class JiraRegression1_50Test exte
* <xs:pattern value="\d{3}\-\d{3}\-\d{4}"/>
* </xs:restriction>
*/
- public void run()
- {
+ public void run() {
try {
for (int i = 0; i < 9; i++) {
@@ -495,12 +490,12 @@ public class JiraRegression1_50Test exte
int mid = rand.nextInt(999);
int post = rand.nextInt(9999);
String testVal = ((pre > 100) ? String.valueOf(pre) : "128") + "-" +
- ((mid > 100) ? String.valueOf(mid) : "256") + "-" +
- ((post > 1000) ? String.valueOf(post) : "1024");
+ ((mid > 100) ? String.valueOf(mid) : "256") + "-" +
+ ((post > 1000) ? String.valueOf(post) : "1024");
String xmlData = "<xb:usPhoneNumber xmlns:xb=\"http://xmlbeans_46\">" +
- testVal +
- "</xb:usPhoneNumber>";
+ testVal +
+ "</xb:usPhoneNumber>";
//cannot repro using this method
//phone.setUsPhoneNumber(testVal);
//if (!phone.validate(xm)) {
@@ -524,21 +519,18 @@ public class JiraRegression1_50Test exte
}
}
- private boolean parseAndValidate(String val) throws XmlException
- {
+ private boolean parseAndValidate(String val) throws XmlException {
xmlbeans46.UsPhoneNumberDocument xml = xmlbeans46.UsPhoneNumberDocument.Factory.parse(val);
return validate(xml);
}
- private boolean validate(xmlbeans46.UsPhoneNumberDocument rdd)
- {
- Collection errors = new ArrayList();
+ private boolean validate(xmlbeans46.UsPhoneNumberDocument rdd) {
+ List<XmlError> errors = new ArrayList<>();
XmlOptions validateOptions = new XmlOptions();
validateOptions.setErrorListener(errors);
boolean valid = rdd.validate(validateOptions);
if (!valid) {
- for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
- XmlError xmlError = (XmlError) iterator.next();
+ for (XmlError xmlError : errors) {
System.out.println("XML Error - " + xmlError.getMessage() + " at\n" + xmlError.getCursorLocation().xmlText());
}
Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression201_250Test.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression201_250Test.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression201_250Test.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression201_250Test.java Sun Feb 6 01:51:55 2022
@@ -20,43 +20,42 @@ import jira.xmlbeans228.substitution.Fir
import jira.xmlbeans228.substitution.PersonDocument;
import misc.common.JiraTestBase;
import misc.detailed.jira208.FrogBreathDocument;
+import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlOptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.xml.namespace.QName;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class JiraRegression201_250Test extends JiraTestBase {
/*
- * [XMLBEANS-206]: Wrong method finding in getMethod() of InterfaceExtensionImpl
- *
- */
+ * [XMLBEANS-206]: Wrong method finding in getMethod() of InterfaceExtensionImpl
+ *
+ */
// Refer test case xmlobject.extensions.interfaceFeature.averageCase.checkin.testJiraXMLBEANS_206
/*
- * [XMLBEANS-208]: validation of decimal with fractionDigits -- special case, additional zero digits
- *
- */
+ * [XMLBEANS-208]: validation of decimal with fractionDigits -- special case, additional zero digits
+ *
+ */
@Test
- public void test_jira_xmlbeans208() throws Exception {
+ void test_jira_xmlbeans208() throws Exception {
XmlOptions options = new XmlOptions();
- List err = new ArrayList();
+ List<XmlError> err = new ArrayList<>();
options.setErrorListener(err);
// decimal value invalid
FrogBreathDocument invalidDoc = FrogBreathDocument.Factory.parse("<dec:frog_breath xmlns:dec=\"http://misc/detailed/jira208\">1000.000001</dec:frog_breath>");
boolean valid = invalidDoc.validate(options);
- if(!valid)
- {
- for (Iterator iterator = err.iterator(); iterator.hasNext();) {
- System.out.println("Validation Error (invalid doc):" + iterator.next());
+ if (!valid) {
+ for (XmlError xmlError : err) {
+ System.out.println("Validation Error (invalid doc):" + xmlError);
}
}
// expected to fail
@@ -67,10 +66,9 @@ public class JiraRegression201_250Test e
err.clear();
boolean valid2 = validDoc.validate(options);
- if(!valid2)
- {
- for (Iterator iterator = err.iterator(); iterator.hasNext();) {
- System.out.println("Validation Error (valid doc):" + iterator.next());
+ if (!valid2) {
+ for (XmlError xmlError : err) {
+ System.out.println("Validation Error (valid doc):" + xmlError);
}
}
@@ -78,30 +76,29 @@ public class JiraRegression201_250Test e
}
/*
- * [XMLBEANS-228]:
- * element order in sequence incorrect after calling substitute()
- */
+ * [XMLBEANS-228]:
+ * element order in sequence incorrect after calling substitute()
+ */
@Test
- public void test_jira_xmlbeans228() throws Exception
- {
+ void test_jira_xmlbeans228() throws Exception {
PersonDocument personDocument = PersonDocument.Factory.newInstance();
PersonDocument.Person person = personDocument.addNewPerson();
CommentType commentType = person.addNewComment();
String ns = "http://jira/xmlbeans_228/substitution";
QName qName = new QName(ns, "FirstCommentElement");
Object resultObject = commentType.substitute(qName, FirstCommentType.type);
- FirstCommentType firstCommentType = (FirstCommentType)resultObject;
+ FirstCommentType firstCommentType = (FirstCommentType) resultObject;
firstCommentType.setStringValue("ThirdElement");
person.setComment(firstCommentType);
-
+
person.setFirstName("FirstElement");
person.setLastName("SecondElement");
-
+
XmlOptions opts = new XmlOptions().setSavePrettyPrint().setUseDefaultNamespace();
StringWriter out = new StringWriter();
personDocument.save(out, opts);
- String exp =
+ String exp =
"<Person xmlns=\"http://jira/xmlbeans_228/substitution\">" + NEWLINE +
" <FirstName>FirstElement</FirstName>" + NEWLINE +
" <LastName>SecondElement</LastName>" + NEWLINE +
@@ -109,9 +106,6 @@ public class JiraRegression201_250Test e
"</Person>";
assertEquals(exp, out.toString());
- if (!personDocument.validate())
- {
- fail("Wrong element order!");
- }
+ assertTrue(personDocument.validate(), "Wrong element order!");
}
}
Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression251_300Test.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression251_300Test.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression251_300Test.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression251_300Test.java Sun Feb 6 01:51:55 2022
@@ -17,19 +17,17 @@ package misc.detailed;
import com.easypo.XmlShipperBean;
import misc.common.JiraTestBase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
-public class JiraRegression251_300Test extends JiraTestBase
-{
+public class JiraRegression251_300Test extends JiraTestBase {
/*
- * [XMLBEANS-260]: SchemaType#isSkippedAnonymousType() throws an NPE
- * if _outerSchemaTypeRef is not set
- */
+ * [XMLBEANS-260]: SchemaType#isSkippedAnonymousType() throws an NPE
+ * if _outerSchemaTypeRef is not set
+ */
@Test
- public void test_jira_xmlbeans260()
- {
+ void test_jira_xmlbeans260() {
// construct an instance of a non-anonymous type
XmlShipperBean xbean = XmlShipperBean.Factory.newInstance();
// the following call should not throw an NPE;
Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression451_500Test.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression451_500Test.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression451_500Test.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression451_500Test.java Sun Feb 6 01:51:55 2022
@@ -19,23 +19,22 @@ import misc.common.JiraTestBase;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class JiraRegression451_500Test extends JiraTestBase {
/*
- * [XMLBEANS-487]: Entity replacement in wrong place when expansion
- * coincides with buffer growth
- */
+ * [XMLBEANS-487]: Entity replacement in wrong place when expansion
+ * coincides with buffer growth
+ */
@Test
- public void test_jira_xmlbeans487() throws IOException, XmlException
- {
- XmlObject dok = XmlObject.Factory.parse(new File(JIRA_CASES + "xmlbeans_487.xml"));
+ void test_jira_xmlbeans487() throws IOException, XmlException {
+ XmlObject dok = XmlObject.Factory.parse(new File(JIRA_CASES + "xmlbeans_487.xml"));
XmlOptions XML_OPTIONS = new XmlOptions().setSaveOuter().setSaveNamespacesFirst().setSaveAggressiveNamespaces();
int INITIAL_READ = 28;
@@ -48,6 +47,6 @@ public class JiraRegression451_500Test e
String totalResult = part1 + part2;
- assertEquals("Should be identical", dok.xmlText(XML_OPTIONS), totalResult);
+ assertEquals(dok.xmlText(XML_OPTIONS), totalResult, "Should be identical");
}
}
Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegression50_100Test.java Sun Feb 6 01:51:55 2022
@@ -25,8 +25,9 @@ import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.tool.Parameters;
import org.apache.xmlbeans.impl.tool.SchemaCompiler;
import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Node;
@@ -45,7 +46,7 @@ import java.io.FileInputStream;
import java.net.URL;
import java.util.*;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
public class JiraRegression50_100Test extends JiraTestBase
@@ -67,7 +68,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-52] Validator loops when schema has certain conditions
*/
@Test
- public void test_jira_XmlBeans52() {
+ void test_jira_XmlBeans52() {
//reusing code from method test_jira_XmlBeans48()
String correctXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" +
"<!--Sample XML file generated by XMLSPY v5 rel. 4 U (http://www.xmlspy.com)--/> \n" +
@@ -87,7 +88,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-54]: problem with default value
*/
@Test
- public void test_jira_xmlbeans54() {
+ void test_jira_xmlbeans54() {
List<XmlError> errors = new ArrayList<>();
Parameters params = new Parameters();
@@ -105,7 +106,7 @@ public class JiraRegression50_100Test ex
try {
SchemaCompiler.compile(params);
} catch (OutOfMemoryError ome) {
- fail("test_jira_xmlbeans54() - out of Heap Memory");
+ Assertions.fail("test_jira_xmlbeans54() - out of Heap Memory");
}
}
@@ -113,7 +114,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-56] samples issue with easypo schema and config file
*/
@Test
- public void test_jira_XmlBeans56() throws Exception {
+ void test_jira_XmlBeans56() throws Exception {
String xsdConfig = "<xb:config " +
" xmlns:xb=\"http://xml.apache.org/xmlbeans/2004/02/xbean/config\"\n" +
" xmlns:ep=\"http://openuri.org/easypo\">\n" +
@@ -134,7 +135,7 @@ public class JiraRegression50_100Test ex
ConfigDocument config = ConfigDocument.Factory.parse(xsdConfig);
xmOpts.setErrorListener(errorList);
if (!config.validate(xmOpts)) {
- fail("Config File did not validate - Error: " + errorList);
+ Assertions.fail("Config File did not validate - Error: " + errorList);
}
}
@@ -142,7 +143,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-57] scomp failure for XSD namespace "DAV:"
*/
@Test
- public void test_jira_XmlBeans57() throws Exception {
+ void test_jira_XmlBeans57() throws Exception {
String P = File.separator;
String outputDir = OUTPUTROOT + P + "dav";
@@ -184,7 +185,7 @@ public class JiraRegression50_100Test ex
* Hence adding a new testcase with the new schemas
*/
@Test
- @Ignore("the url doesn't exist anymore ...")
+ @Disabled("the url doesn't exist anymore ...")
public void test_jira_xmlbeans58() throws Exception {
List<XmlError> errors = new ArrayList<>();
Parameters params = new Parameters();
@@ -199,8 +200,8 @@ public class JiraRegression50_100Test ex
params.setDownload(true);
SchemaCompiler.compile(params);
- if (printOptionErrMsgs(errors)) {
- fail("test_jira_xmlbeans55() : Errors found when executing scomp");
+ if (hasSevereError(errors)) {
+ Assertions.fail("test_jira_xmlbeans55() : Errors found when executing scomp");
}
}
@@ -210,7 +211,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-62] Avoid class cast exception when compiling older schema namespace
*/
@Test
- public void test_jira_XmlBeans62() throws Exception {
+ void test_jira_XmlBeans62() throws Exception {
String P = File.separator;
String outputDir = "build" + P + "jiratest62";
@@ -237,14 +238,14 @@ public class JiraRegression50_100Test ex
classDir.deleteOnExit();
//validate error present
- assertTrue("Warning for 1999 schema was not found when compiling srcs", warningPresent);
+ assertTrue(warningPresent, "Warning for 1999 schema was not found when compiling srcs");
}
/**
* [XMLBEANS-64] ArrayIndexOutOfBoundsException during validation
*/
@Test
- public void test_jira_XmlBeans64() throws Exception {
+ void test_jira_XmlBeans64() throws Exception {
// load the document
File inst = new File(JIRA_CASES + "xmlbeans_64.xml");
XmlObject doc = RecorderSessionDocument.Factory.parse(inst);
@@ -263,7 +264,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-66] NullPointerException when restricting a union with one of the union members
*/
@Test
- public void test_jira_XmlBeans66() throws Exception {
+ void test_jira_XmlBeans66() throws Exception {
String reproXsd = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" +
"<xsd:schema targetNamespace=\"http://www.w3.org/2003/12/XQueryX\" \n" +
" xmlns=\"http://www.w3.org/2003/12/XQueryX\" \n" +
@@ -296,7 +297,7 @@ public class JiraRegression50_100Test ex
SchemaTypeLoader stl = makeSchemaTypeLoader(new String[]{reproXsd});
QName reproQName = new QName("http://www.w3.org/2003/12/XQueryX", "Kludge");
SchemaGlobalElement elVal = stl.findElement(reproQName);
- assertTrue("Element is null or not found", (elVal != null));
+ assertTrue((elVal != null), "Element is null or not found");
String reproInst = "<Kludge xmlns=\"http://www.w3.org/2003/12/XQueryX\"><value>12</value></Kludge>";
validateInstance(new String[]{reproXsd}, new String[]{reproInst}, null);
@@ -306,7 +307,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-68] GDateBuilder outputs empty string when used without time or timezone
*/
@Test
- public void test_jira_XmlBeans68() throws Exception {
+ void test_jira_XmlBeans68() throws Exception {
Calendar cal = Calendar.getInstance();
GDateBuilder gdateBuilder = new GDateBuilder(cal);
gdateBuilder.clearTime();
@@ -335,7 +336,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-71] when trying to retrieve data from a XMLBean with Input from a XML Document, we cannot get any data from the Bean.
*/
@Test
- public void test_jira_XmlBeans71() throws Exception {
+ void test_jira_XmlBeans71() throws Exception {
//schema src lives in cases/xbean/xmlobject/xmlbeans_71.xsd
abc.BazResponseDocument doc = abc.BazResponseDocument.Factory.parse(JarUtil.getResourceFromJarasFile("xbean/misc/jira/xmlbeans_71.xml"), xmOpts);
xmOpts.setErrorListener(errorList);
@@ -366,7 +367,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-72] Document properties are lost
*/
@Test
- @Ignore
+ @Disabled
public void test_jira_XmlBeans72() throws Exception {
String docTypeName = "struts-config";
String docTypePublicID = "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN";
@@ -434,7 +435,7 @@ public class JiraRegression50_100Test ex
* XMLBEANS-78 - NPE when processing XMLStreamReader Midstream
*/
@Test
- public void test_jira_xmlbeans78() throws Exception {
+ void test_jira_xmlbeans78() throws Exception {
XMLInputFactory factory = XMLInputFactory.newInstance();
FileInputStream fis = new FileInputStream(JIRA_CASES + "xmlbeans_78.xml");
XMLStreamReader reader = factory.createXMLStreamReader(fis);
@@ -467,7 +468,7 @@ public class JiraRegression50_100Test ex
* XMLBEANS-80 problems in XPath selecting with namespaces and Predicates.
*/
@Test
- public void test_jira_xmlbeans80() throws Exception {
+ void test_jira_xmlbeans80() throws Exception {
String xpathDoc = "<?xml version=\"1.0\"?> \n" +
"<doc xmlns:ext=\"http://somebody.elses.extension\"> \n" +
" <ext:a test=\"test\" /> \n" +
@@ -495,7 +496,7 @@ public class JiraRegression50_100Test ex
* XMLBEANS-81 Cursor selectPath() method not working with predicates
*/
@Test
- public void test_jira_xmlbeans81() throws Exception {
+ void test_jira_xmlbeans81() throws Exception {
String xpathDoc = "<MatchedRecords>" +
" <MatchedRecord>" +
" <TableName>" +
@@ -512,7 +513,7 @@ public class JiraRegression50_100Test ex
// change $this to '.' to avoid XQuery syntax error for $this not being declared
//XmlObject[] resSet = xb81.selectPath("$this//MatchedRecord[TableName=\"ABC\"]/TableName");
XmlObject[] resSet = xb81.selectPath(".//MatchedRecord[TableName=\"ABC\"]/TableName");
- assertEquals(resSet.length , 1);
+ assertEquals(resSet.length, 1);
try (XmlCursor cursor = xb81.newCursor()) {
//cursor.selectPath("$this//MatchedRecord[TableName=\"ABC\"]/TableName");
cursor.selectPath(".//MatchedRecord[TableName=\"ABC\"]/TableName");
@@ -523,7 +524,7 @@ public class JiraRegression50_100Test ex
* XMLBeans-84 Cannot run XmlObject.selectPath using Jaxen in multi threaded environment
*/
@Test
- public void test_jira_XmlBeans84() throws Exception {
+ void test_jira_XmlBeans84() throws Exception {
XPathThread[] threads = new XPathThread[15];
for (int i = 0; i < threads.length; i++) {
@@ -544,9 +545,9 @@ public class JiraRegression50_100Test ex
/*
* [XMLBEANS-88]:Cannot compile eBay schema
*/
- @Ignore
+ @Disabled
@Test
- public void test_jira_xmlbeans88() throws Exception {
+ void test_jira_xmlbeans88() throws Exception {
List<XmlError> errors = new ArrayList<>();
Parameters params = new Parameters();
@@ -568,14 +569,14 @@ public class JiraRegression50_100Test ex
System.out.println(ome.getCause());
System.out.println(ome.getMessage());
System.out.println(ome.getStackTrace());
- fail("test_jira_xmlbeans88(): Out Of Memory Error");
+ Assertions.fail("test_jira_xmlbeans88(): Out Of Memory Error");
} catch (Throwable t) {
t.getMessage();
System.out.println("Ok Some Exception is caught here");
}
- if (printOptionErrMsgs(errors)) {
- fail("test_jira_xmlbeans88() : Errors found when executing scomp");
+ if (hasSevereError(errors)) {
+ Assertions.fail("test_jira_xmlbeans88() : Errors found when executing scomp");
}
}
@@ -583,7 +584,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-96]:XmlDocumentProperties missing version and encoding
*/
@Test
- @Ignore
+ @Disabled
public void test_jira_xmlbeans96() throws Exception {
String xmlstringbuf =
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
@@ -593,8 +594,8 @@ public class JiraRegression50_100Test ex
XmlObject doc = XmlObject.Factory.parse(xmlstringbuf);
XmlDocumentProperties props = doc.documentProperties();
- assertEquals("test_jira_xmlbeans96() : Xml Version is not picked up", "1.0", props.getVersion());
- assertEquals("test_jira_xmlbeans96() : Xml Encoding is not picked up", "UTF-8", props.getEncoding());
+ assertEquals("1.0", props.getVersion(), "test_jira_xmlbeans96() : Xml Version is not picked up");
+ assertEquals("UTF-8", props.getEncoding(), "test_jira_xmlbeans96() : Xml Encoding is not picked up");
}
@@ -603,7 +604,7 @@ public class JiraRegression50_100Test ex
* work for QName attribute values
*/
@Test
- @Ignore
+ @Disabled
public void test_jira_xmlbeans98() throws Exception {
String outfn = outputroot + "xmlbeans_98.xml";
String structnamespace = "http://www.orthogony.net/xml/sample/structure";
@@ -652,7 +653,7 @@ public class JiraRegression50_100Test ex
//NamedNodeMap n = xObj.getDomNode().getAttributes();
//Assert.assertTrue("Length was not as expected", n.getLength() == 3);
Node no = xObj.getDomNode();//n.getNamedItem("a-root");
- assertEquals("Expected Prefix was not present: " + no.getPrefix(), 0, no.getPrefix().compareTo("s"));
+ assertEquals(0, no.getPrefix().compareTo("s"), "Expected Prefix was not present: " + no.getPrefix());
//Assert.assertTrue("s prefix was not found " + no.lookupPrefix(structnamespace), no.lookupPrefix(structnamespace).compareTo("s") == 0);
//Assert.assertTrue("d prefix was not found " + no.lookupPrefix(datanamespace), no.lookupPrefix(datanamespace).compareTo("s") == 0);
//Assert.assertTrue("v prefix was not found " + no.lookupPrefix(xsinamespace), no.lookupPrefix(xsinamespace).compareTo("s") == 0);
@@ -666,7 +667,7 @@ public class JiraRegression50_100Test ex
* [XMLBEANS-99] NPE/AssertionFailure in newDomNode()
*/
@Test
- public void test_jira_xmlbeans99_a() throws Exception {
+ void test_jira_xmlbeans99_a() throws Exception {
//typed verification
DummyDocument doc = DummyDocument.Factory.parse(new File(JIRA_CASES + "xmlbeans_99.xml"));
org.w3c.dom.Node node = doc.newDomNode();
@@ -683,7 +684,7 @@ public class JiraRegression50_100Test ex
* refer to [XMLBEANS-14]
*/
@Test
- public void test_jira_xmlbeans99_b() {
+ void test_jira_xmlbeans99_b() {
StringBuilder xmlstringbuf = new StringBuilder("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?> \n");
xmlstringbuf.append(" <x:dummy xmlns:x=\"http://dufourrault\" xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\" xsi:SchemaLocation=\"dummy.xsd\">\n");
xmlstringbuf.append(" <x:father>\n");
@@ -722,9 +723,9 @@ public class JiraRegression50_100Test ex
System.out.println("New Father Type Node: "+ fatherTypeNode);
} catch (NullPointerException npe) {
- fail("test_jira_xmlbeans99() : Null Pointer Exception when create Dom Node");
+ Assertions.fail("test_jira_xmlbeans99() : Null Pointer Exception when create Dom Node");
} catch (Exception e) {
- fail("test_jira_xmlbeans99() : Exception when create Dom Node");
+ Assertions.fail("test_jira_xmlbeans99() : Exception when create Dom Node");
}
}
@@ -778,7 +779,7 @@ public class JiraRegression50_100Test ex
"</statusreport>";
XmlObject path = XmlObject.Factory.parse(statusDoc, xm);
XmlObject[] resSet = path.selectPath("//*:status");
- assertEquals(resSet.length + "", 4, resSet.length);
+ assertEquals(4, resSet.length, resSet.length + "");
resSet = path.selectPath("//*:status[@name='first']");
assertEquals(2, resSet.length);
Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionSchemaCompilerTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionSchemaCompilerTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionSchemaCompilerTest.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionSchemaCompilerTest.java Sun Feb 6 01:51:55 2022
@@ -18,23 +18,18 @@ import misc.common.JiraTestBase;
import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.impl.tool.Parameters;
import org.apache.xmlbeans.impl.tool.SchemaCompiler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class JiraRegressionSchemaCompilerTest extends JiraTestBase {
- private List _testCompile(File[] xsdFiles,
- String outputDirName)
- {
- System.out.println(xsdFiles[0].getAbsolutePath());
- List errors = new ArrayList();
+ private List<XmlError> _testCompile(File[] xsdFiles, String outputDirName) {
+ List<XmlError> errors = new ArrayList<>();
Parameters params = new Parameters();
params.setXsdFiles(xsdFiles);
params.setErrorListener(errors);
@@ -45,79 +40,48 @@ public class JiraRegressionSchemaCompile
return errors;
}
- private boolean findErrMsg(Collection errors, String msg)
- {
- boolean errFound = false;
- if (!errors.isEmpty())
- {
- for (Iterator i = errors.iterator(); i.hasNext();)
- {
- XmlError err = (XmlError) i.next();
- int errSeverity = err.getSeverity();
- if (errSeverity == XmlError.SEVERITY_ERROR)
- {
- if (msg.equals(err.getMessage()))
- errFound = true;
- }
- }
- }
+ private boolean findErrMsg(List<XmlError> errors, String msg) {
+ boolean errFound = errors.stream().anyMatch(e -> e.getSeverity() == XmlError.SEVERITY_ERROR && msg.equals(e.getMessage()));
errors.clear();
return errFound;
}
@Test
- public void test_jira_xmlbeans236()
- {
- File[] xsdFiles =
- new File[] { new File(scompTestFilesRoot + "xmlbeans_236.xsd_") };
+ void test_jira_xmlbeans236() {
+ File[] xsdFiles = {new File(scompTestFilesRoot + "xmlbeans_236.xsd_")};
String outputDirName = "xmlbeans_236";
- List errors = _testCompile(xsdFiles, outputDirName);
- if (printOptionErrMsgs(errors))
- {
- fail("test_jira_xmlbeans236(): failure when executing scomp");
- }
+ List<XmlError> errors = _testCompile(xsdFiles, outputDirName);
+ assertFalse(hasSevereError(errors),"test_jira_xmlbeans236(): failure when executing scomp");
}
@Test
- public void test_jira_xmlbeans239()
- {
+ void test_jira_xmlbeans239() {
/* complexType with complexContent extending base type with
simpleContent is valid */
- File[] xsdFiles =
- new File[] { new File(scompTestFilesRoot + "xmlbeans_239a.xsd_") };
+ File[] xsdFiles = {new File(scompTestFilesRoot + "xmlbeans_239a.xsd_")};
String outputDirName = "xmlbeans_239";
- List errors = _testCompile(xsdFiles, outputDirName);
- if (printOptionErrMsgs(errors))
- {
- fail("test_jira_xmlbeans239(): failure when executing scomp");
- }
+ List<XmlError> errors = _testCompile(xsdFiles, outputDirName);
+ assertFalse(hasSevereError(errors),"test_jira_xmlbeans239(): failure when executing scomp");
/* complexType with complexContent extending simpleType is not valid */
- xsdFiles =
- new File[] { new File(scompTestFilesRoot + "xmlbeans_239b.xsd_") };
+ xsdFiles = new File[]{new File(scompTestFilesRoot + "xmlbeans_239b.xsd_")};
errors = _testCompile(xsdFiles, outputDirName);
String msg = "Type 'dtSTRING@http://www.test.bmecat.org' is being used as the base type for a complexContent definition. To do this the base type must be a complex type.";
assertTrue(findErrMsg(errors, msg));
/* complexType with complexContent extending base type with
simpleContent cannot add particles */
- xsdFiles =
- new File[] { new File(scompTestFilesRoot + "xmlbeans_239c.xsd_") };
+ xsdFiles = new File[]{new File(scompTestFilesRoot + "xmlbeans_239c.xsd_")};
errors = _testCompile(xsdFiles, outputDirName);
msg = "This type extends a base type 'dtMLSTRING@http://www.test.bmecat.org' which has simpleContent. In that case this type cannot add particles.";
assertTrue(findErrMsg(errors, msg));
}
@Test
- public void test_jira_xmlbeans251()
- {
- File[] xsdFiles =
- new File[] { new File(scompTestFilesRoot + "xmlbeans_251.xsd_") };
+ void test_jira_xmlbeans251() {
+ File[] xsdFiles = {new File(scompTestFilesRoot + "xmlbeans_251.xsd_")};
String outputDirName = "xmlbeans_251";
- List errors = _testCompile(xsdFiles, outputDirName);
- if (printOptionErrMsgs(errors))
- {
- fail("test_jira_xmlbeans251(): failure when executing scomp");
- }
+ List<XmlError> errors = _testCompile(xsdFiles, outputDirName);
+ assertFalse(hasSevereError(errors), "test_jira_xmlbeans251(): failure when executing scomp");
}
}
Modified: xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionTest101_150.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionTest101_150.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionTest101_150.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/JiraRegressionTest101_150.java Sun Feb 6 01:51:55 2022
@@ -20,14 +20,14 @@ import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.impl.tool.Parameters;
import org.apache.xmlbeans.impl.tool.SchemaCompiler;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
*
@@ -38,10 +38,10 @@ public class JiraRegressionTest101_150 e
* [XMLBEANS-103] XMLBeans - QName thread cache, cause memory leaks
*/
@Test
- public void test_jira_xmlbeans102a() throws Exception{
+ void test_jira_xmlbeans102a() throws Exception{
// set the parameters similar to those in the bug
Parameters params = new Parameters();
- params.setXsdFiles(new File[]{new File(JIRA_CASES + "xmlbeans_102.xsd")});
+ params.setXsdFiles(new File(JIRA_CASES + "xmlbeans_102.xsd"));
params.setOutputJar(new File(outputroot+P+"xmlbeans_102.jar"));
File outputDir = new File(outputroot + P + "xmlbeans_102");
outputDir.mkdirs();
@@ -60,22 +60,22 @@ public class JiraRegressionTest101_150 e
* [XMLBEANS-102]: scomp - infinite loop during jar for specific xsd and params for netui_config.xsd
*/
@Test
- public void test_jira_xmlbeans102b() {
+ void test_jira_xmlbeans102b() {
//Assert.fail("test_jira_xmlbeans102: Infinite loop after completion of parsing" );
Parameters params = new Parameters();
params.setOutputJar(new File(schemaCompOutputDirPath + "jira102.jar"));
params.setClassesDir(schemaCompClassesDir);
- params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_102_netui-config.xsd_")});
- List errors = new ArrayList();
+ params.setXsdFiles(new File(scompTestFilesRoot + "xmlbeans_102_netui-config.xsd_"));
+ List<XmlError> errors = new ArrayList<>();
params.setErrorListener(errors);
params.setSrcDir(schemaCompSrcDir);
params.setClassesDir(schemaCompClassesDir);
SchemaCompiler.compile(params);
- if (printOptionErrMsgs(errors)) {
- fail("test_jira_xmlbeans102() : Errors found when executing scomp");
+ if (hasSevereError(errors)) {
+ Assertions.fail("test_jira_xmlbeans102() : Errors found when executing scomp");
}
}
@@ -85,7 +85,7 @@ public class JiraRegressionTest101_150 e
* an a complex type from a different type system
*/
@Test
- public void test_jira_xmlbeans105() throws Exception {
+ void test_jira_xmlbeans105() throws Exception {
//run untyped parse
XmlObject obj = XmlObject.Factory.parse(new File(JIRA_CASES + "xmlbeans_105.xml"));
@@ -96,8 +96,8 @@ public class JiraRegressionTest101_150 e
// / we know the instance is invalid
// make sure the error message is what is expected
rud.validate(xmOpts);
- assertEquals("More Errors than expected", 1, errorList.size());
- assertEquals("Did not receive the expected error code: " + ((XmlError) errorList.get(0)).getErrorCode(), 0, ((XmlError) errorList.get(0)).getErrorCode().compareToIgnoreCase("cvc-complex-type.2.4a"));
+ assertEquals(1, errorList.size(), "More Errors than expected");
+ assertEquals(0, ((XmlError) errorList.get(0)).getErrorCode().compareToIgnoreCase("cvc-complex-type.2.4a"), "Did not receive the expected error code: " + ((XmlError) errorList.get(0)).getErrorCode());
}
}
Modified: xmlbeans/trunk/src/test/java/misc/detailed/LargeEnumTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/LargeEnumTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/LargeEnumTest.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/LargeEnumTest.java Sun Feb 6 01:51:55 2022
@@ -19,12 +19,13 @@ import org.apache.xmlbeans.SchemaType;
import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.XmlToken;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import xmlbeans307.*;
import java.util.ArrayList;
+import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* This test was put together for:
@@ -36,96 +37,75 @@ public class LargeEnumTest {
* These are tests for a enumeration type
*/
@Test
- public void testEnumCount_closeToMax() throws Exception {
+ void testEnumCount_closeToMax() throws Exception {
SchemaType mType = MaxAllowedEnumType.type;
- assertNotNull("Enumeration SchemaType was null", mType.getEnumerationValues());
- assertEquals("EnumerationValue was not 3660 as expected was" + mType.getEnumerationValues().length, 3660, mType.getEnumerationValues().length);
+ assertNotNull(mType.getEnumerationValues(), "Enumeration SchemaType was null");
+ assertEquals(3660, mType.getEnumerationValues().length, "EnumerationValue was not 3660 as expected was" + mType.getEnumerationValues().length);
SchemaType mElem = MaxAllowedElementDocument.type;
- assertNull("Enumeration SchemaType was null", mElem.getEnumerationValues());
+ assertNull(mElem.getEnumerationValues(), "Enumeration SchemaType was null");
// Test that the Java type associated to this is an enum type
- assertNotNull("This type does not correspond to a Java enumeration", mType.getStringEnumEntries());
+ assertNotNull(mType.getStringEnumEntries(), "This type does not correspond to a Java enumeration");
}
@Test
- public void testEnumCount_greaterThanMax() throws Exception {
+ void testEnumCount_greaterThanMax() throws Exception {
// TODO: verify if any xpath/xquery issues
SchemaType mType = MoreThanAllowedEnumType.type;
- assertNotNull("Enumeration should be null as type should be base type " + mType.getEnumerationValues(),
- mType.getEnumerationValues());
- assertEquals("EnumerationValue was not 3678 as expected was " + mType.getEnumerationValues().length, 3678, mType.getEnumerationValues().length);
- System.out.println("GET BASE TYPE: " + mType.getBaseType());
- System.out.println("GET BASE TYPE: " + mType.getPrimitiveType());
- assertEquals("type should have been base type, was " + mType.getBaseType(), mType.getBaseType().getBuiltinTypeCode(), XmlToken.type.getBuiltinTypeCode());
+ assertNotNull(mType.getEnumerationValues(), "Enumeration should be null as type should be base type " + mType.getEnumerationValues());
+ assertEquals(3678, mType.getEnumerationValues().length, "EnumerationValue was not 3678 as expected was " + mType.getEnumerationValues().length);
+ assertEquals(mType.getBaseType().getBuiltinTypeCode(), XmlToken.type.getBuiltinTypeCode(), "type should have been base type, was " + mType.getBaseType());
SchemaType mElem = GlobalMoreThanElementDocument.type;
- assertNull("Enumeration SchemaType was null", mElem.getBaseEnumType());
+ assertNull(mElem.getBaseEnumType(), "Enumeration SchemaType was null");
// Test that the Java type associated to this is not an enum type
- assertNull("This type corresponds to a Java enumeration, even though it has too many enumeration values",
- mType.getStringEnumEntries());
+ assertNull(mType.getStringEnumEntries(), "This type corresponds to a Java enumeration, even though it has too many enumeration values");
}
@Test
- public void testEnumCount_validate_invalid_enum() throws Exception {
+ void testEnumCount_validate_invalid_enum() throws Exception {
MoreThanAllowedEnumType mType = MoreThanAllowedEnumType.Factory.newInstance();
//This value dos not exist in the enumeration set
mType.setStringValue("12345AAA");
- ArrayList errors = new ArrayList();
+ List<XmlError> errors = new ArrayList<>();
XmlOptions options = (new XmlOptions()).setErrorListener(errors);
mType.validate(options);
- XmlError[] xErr = new XmlError[errors.size()];
- for (int i = 0; i < errors.size(); i++) {
- System.out.println("ERROR: " + errors.get(i));
- xErr[i] = (XmlError)errors.get(i);
- }
- assertEquals("NO Expected Errors after validating enumType after set", 1, errors.size());
- assertEquals("Expected ERROR CODE was not as expected", 0, xErr[0].getErrorCode().compareTo("cvc-enumeration-valid"));
+ assertEquals(1, errors.size(), "NO Expected Errors after validating enumType after set");
+ assertEquals(0, errors.get(0).getErrorCode().compareTo("cvc-enumeration-valid"), "Expected ERROR CODE was not as expected");
// string value '12345AAA' is not a valid enumeration value for MoreThanAllowedEnumType in
}
@Test
- public void test_MoreEnum_Operations() throws Exception {
+ void test_MoreEnum_Operations() throws Exception {
MoreThanAllowedEnumType mType = MoreThanAllowedEnumType.Factory.newInstance();
mType.setStringValue("AAA");
- ArrayList errors = new ArrayList();
+ List<XmlError> errors = new ArrayList<>();
XmlOptions options = (new XmlOptions()).setErrorListener(errors);
mType.validate(options);
- for (int i = 0; i < errors.size(); i++) {
- System.out.println("ERROR: " + errors.get(i));
- }
- assertEquals("There were errors validating enumType after set", 0, errors.size());
+ assertEquals(0, errors.size(), "There were errors validating enumType after set");
GlobalMoreThanElementDocument mDoc = GlobalMoreThanElementDocument.Factory.newInstance();
mDoc.setGlobalMoreThanElement("AAA");
- errors = null;
- errors = new ArrayList();
+ errors.clear();
options = (new XmlOptions()).setErrorListener(errors);
mDoc.validate(options);
- for (int i = 0; i < errors.size(); i++) {
- System.out.println("ERROR: " + errors.get(i));
- }
-
- assertEquals("There were errors validating enumDoc after set", 0, errors.size());
+ assertEquals(0, errors.size(), "There were errors validating enumDoc after set");
MoreThanAllowedComplexType mcType = MoreThanAllowedComplexType.Factory.newInstance();
mcType.setComplexTypeMoreThanEnum("AAA");
mcType.setSimpleString("This should work");
- errors = null;
- errors = new ArrayList();
+ errors.clear();
mcType.validate(options);
- for (int i = 0; i < errors.size(); i++) {
- System.out.println("ERROR: " + errors.get(i));
- }
- assertEquals("There were errors validating complxType after set", 0, errors.size());
+ assertEquals(0, errors.size(), "There were errors validating complxType after set");
}
Modified: xmlbeans/trunk/src/test/java/misc/detailed/SampleRunner.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/misc/detailed/SampleRunner.java?rev=1897795&r1=1897794&r2=1897795&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/detailed/SampleRunner.java (original)
+++ xmlbeans/trunk/src/test/java/misc/detailed/SampleRunner.java Sun Feb 6 01:51:55 2022
@@ -15,9 +15,9 @@
package misc.detailed;
import org.apache.tools.ant.*;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FilenameFilter;
@@ -33,26 +33,25 @@ public class SampleRunner {
private List<File> samples;
private String XMLBEANS_HOME;
- private SamplesBuildFileTest runSampleTest;
+ private BuildFileTest runSampleTest;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Project proj = new Project();
proj.setName("Samples Task Tests");
XMLBEANS_HOME = new File(proj.getBaseDir(), "build").getAbsolutePath();
samples = new ArrayList<>();
- runSampleTest = new SamplesBuildFileTest();
+ runSampleTest = new BuildFileTest();
}
@Test
- @Ignore
+ @Disabled
public void testSamples() throws Exception {
loadSampleDirs(new File("./samples"));
List<Object> exceptions = new ArrayList<>();
for (File sample : samples) {
-
- runSampleTest.call_samples_task(sample.getAbsolutePath(), "test");
+ runSampleTest.call_samples_task(sample.getAbsolutePath(), "test", XMLBEANS_HOME);
BuildException e;
if ((e = runSampleTest.getAnyExceptions()) != null) {
exceptions.add(sample.getAbsolutePath());
@@ -89,204 +88,202 @@ public class SampleRunner {
}
}
- private class SamplesBuildFileTest extends BuildFileTest {
- public void call_samples_task(String projectPath, String taskName) {
+ private static class BuildFileTest {
+
+ protected Project project;
+
+ private StringBuilder logBuffer;
+ private StringBuilder fullLogBuffer;
+ private StringBuilder outBuffer;
+ private StringBuilder errBuffer;
+ private BuildException buildException;
+
+ protected String getOutput() {
+ return cleanBuffer(outBuffer);
+ }
+
+ protected String getError() {
+ return cleanBuffer(errBuffer);
+ }
+
+ protected BuildException getBuildException() {
+ return buildException;
+ }
+
+ public void call_samples_task(String projectPath, String taskName, String xmlbeansHome) {
configureProject(projectPath);
Project proj = getProject();
- proj.setProperty("xmlbeans.home", XMLBEANS_HOME);
+ proj.setProperty("xmlbeans.home", xmlbeansHome);
executeTarget(proj.getDefaultTarget());
}
public BuildException getAnyExceptions() {
return this.getBuildException();
}
- }
-}
-
-abstract class BuildFileTest {
-
- protected Project project;
-
- private StringBuilder logBuffer;
- private StringBuilder fullLogBuffer;
- private StringBuilder outBuffer;
- private StringBuilder errBuffer;
- private BuildException buildException;
-
- protected String getOutput() {
- return cleanBuffer(outBuffer);
- }
- protected String getError() {
- return cleanBuffer(errBuffer);
- }
-
- protected BuildException getBuildException() {
- return buildException;
- }
-
- private String cleanBuffer(StringBuilder buffer) {
- StringBuilder cleanedBuffer = new StringBuilder();
- boolean cr = false;
- for (int i = 0; i < buffer.length(); i++) {
- char ch = buffer.charAt(i);
- if (ch == '\r') {
- cr = true;
- continue;
- }
+ private String cleanBuffer(StringBuilder buffer) {
+ StringBuilder cleanedBuffer = new StringBuilder();
+ boolean cr = false;
+ for (int i = 0; i < buffer.length(); i++) {
+ char ch = buffer.charAt(i);
+ if (ch == '\r') {
+ cr = true;
+ continue;
+ }
- if (!cr) {
- cleanedBuffer.append(ch);
- } else {
- if (ch == '\n') {
+ if (!cr) {
cleanedBuffer.append(ch);
} else {
- cleanedBuffer.append('\r').append(ch);
+ if (ch == '\n') {
+ cleanedBuffer.append(ch);
+ } else {
+ cleanedBuffer.append('\r').append(ch);
+ }
}
}
+ return cleanedBuffer.toString();
}
- return cleanedBuffer.toString();
- }
-
- /**
- * set up to run the named project
- *
- * @param filename name of project file to run
- */
- protected void configureProject(String filename) throws BuildException {
- logBuffer = new StringBuilder();
- fullLogBuffer = new StringBuilder();
- project = new Project();
- project.init();
- project.setUserProperty("ant.file", new File(filename).getAbsolutePath());
- project.addBuildListener(new BuildFileTest.AntTestListener());
- //ProjectHelper.configureProject(project, new File(filename));
- ProjectHelper.getProjectHelper().parse(project, new File(filename));
- }
-
- /**
- * execute a target we have set up.
- * configureProject needs to be called before
- *
- * @param targetName target to run
- */
- protected void executeTarget(String targetName) {
- PrintStream sysOut = System.out;
- PrintStream sysErr = System.err;
- try {
- sysOut.flush();
- sysErr.flush();
- outBuffer = new StringBuilder();
- PrintStream out = new PrintStream(new BuildFileTest.AntOutputStream());
- System.setOut(out);
- errBuffer = new StringBuilder();
- PrintStream err = new PrintStream(new BuildFileTest.AntOutputStream());
- System.setErr(err);
- logBuffer = new StringBuilder();
- fullLogBuffer = new StringBuilder();
- buildException = null;
- project.executeTarget(targetName);
- } finally {
- System.setOut(sysOut);
- System.setErr(sysErr);
- // rajus: 2004/04/07
- System.out.println("STDOUT+STDERR:\n" + getOutput() + getError());
- System.out.println("END STDOUT+STDERR:");
- }
-
- }
-
- /**
- * Get the project which has been configured for a test.
- *
- * @return the Project instance for this test.
- */
- protected Project getProject() {
- return project;
- }
-
- /**
- * an output stream which saves stuff to our buffer.
- */
- private class AntOutputStream extends java.io.OutputStream {
- public void write(int b) {
- outBuffer.append((char) b);
- }
- }
- /**
- * our own personal build listener
- */
- private class AntTestListener implements BuildListener {
/**
- * Fired before any targets are started.
- */
- public void buildStarted(BuildEvent event) {
- }
-
- /**
- * Fired after the last target has finished. This event
- * will still be thrown if an error occured during the build.
+ * set up to run the named project
*
- * @see BuildEvent#getException()
+ * @param filename name of project file to run
*/
- public void buildFinished(BuildEvent event) {
+ protected void configureProject(String filename) throws BuildException {
+ logBuffer = new StringBuilder();
+ fullLogBuffer = new StringBuilder();
+ project = new Project();
+ project.init();
+ project.setUserProperty("ant.file", new File(filename).getAbsolutePath());
+ project.addBuildListener(new BuildFileTest.AntTestListener());
+ //ProjectHelper.configureProject(project, new File(filename));
+ ProjectHelper.getProjectHelper().parse(project, new File(filename));
}
/**
- * Fired when a target is started.
+ * execute a target we have set up.
+ * configureProject needs to be called before
*
- * @see BuildEvent#getTarget()
+ * @param targetName target to run
*/
- public void targetStarted(BuildEvent event) {
- //System.out.println("targetStarted " + event.getTarget().getName());
- }
+ protected void executeTarget(String targetName) {
+ PrintStream sysOut = System.out;
+ PrintStream sysErr = System.err;
+ try {
+ sysOut.flush();
+ sysErr.flush();
+ outBuffer = new StringBuilder();
+ PrintStream out = new PrintStream(new BuildFileTest.AntOutputStream());
+ System.setOut(out);
+ errBuffer = new StringBuilder();
+ PrintStream err = new PrintStream(new BuildFileTest.AntOutputStream());
+ System.setErr(err);
+ logBuffer = new StringBuilder();
+ fullLogBuffer = new StringBuilder();
+ buildException = null;
+ project.executeTarget(targetName);
+ } finally {
+ System.setOut(sysOut);
+ System.setErr(sysErr);
+ // rajus: 2004/04/07
+ System.out.println("STDOUT+STDERR:\n" + getOutput() + getError());
+ System.out.println("END STDOUT+STDERR:");
+ }
- /**
- * Fired when a target has finished. This event will
- * still be thrown if an error occured during the build.
- *
- * @see BuildEvent#getException()
- */
- public void targetFinished(BuildEvent event) {
- //System.out.println("targetFinished " + event.getTarget().getName());
}
/**
- * Fired when a task is started.
+ * Get the project which has been configured for a test.
*
- * @see BuildEvent#getTask()
+ * @return the Project instance for this test.
*/
- public void taskStarted(BuildEvent event) {
- //System.out.println("taskStarted " + event.getTask().getTaskName());
+ protected Project getProject() {
+ return project;
}
/**
- * Fired when a task has finished. This event will still
- * be throw if an error occured during the build.
- *
- * @see BuildEvent#getException()
+ * an output stream which saves stuff to our buffer.
*/
- public void taskFinished(BuildEvent event) {
- //System.out.println("taskFinished " + event.getTask().getTaskName());
+ private class AntOutputStream extends java.io.OutputStream {
+ public void write(int b) {
+ outBuffer.append((char) b);
+ }
}
/**
- * Fired whenever a message is logged.
- *
- * @see BuildEvent#getMessage()
- * @see BuildEvent#getPriority()
+ * our own personal build listener
*/
- public void messageLogged(BuildEvent event) {
- if (event.getPriority() == Project.MSG_INFO ||
- event.getPriority() == Project.MSG_WARN ||
- event.getPriority() == Project.MSG_ERR) {
- logBuffer.append(event.getMessage());
+ private class AntTestListener implements BuildListener {
+ /**
+ * Fired before any targets are started.
+ */
+ public void buildStarted(BuildEvent event) {
+ }
+
+ /**
+ * Fired after the last target has finished. This event
+ * will still be thrown if an error occured during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void buildFinished(BuildEvent event) {
+ }
+
+ /**
+ * Fired when a target is started.
+ *
+ * @see BuildEvent#getTarget()
+ */
+ public void targetStarted(BuildEvent event) {
+ //System.out.println("targetStarted " + event.getTarget().getName());
+ }
+
+ /**
+ * Fired when a target has finished. This event will
+ * still be thrown if an error occured during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void targetFinished(BuildEvent event) {
+ //System.out.println("targetFinished " + event.getTarget().getName());
+ }
+
+ /**
+ * Fired when a task is started.
+ *
+ * @see BuildEvent#getTask()
+ */
+ public void taskStarted(BuildEvent event) {
+ //System.out.println("taskStarted " + event.getTask().getTaskName());
+ }
+
+ /**
+ * Fired when a task has finished. This event will still
+ * be throw if an error occured during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void taskFinished(BuildEvent event) {
+ //System.out.println("taskFinished " + event.getTask().getTaskName());
}
- fullLogBuffer.append(event.getMessage());
+ /**
+ * Fired whenever a message is logged.
+ *
+ * @see BuildEvent#getMessage()
+ * @see BuildEvent#getPriority()
+ */
+ public void messageLogged(BuildEvent event) {
+ if (event.getPriority() == Project.MSG_INFO ||
+ event.getPriority() == Project.MSG_WARN ||
+ event.getPriority() == Project.MSG_ERR) {
+ logBuffer.append(event.getMessage());
+ }
+ fullLogBuffer.append(event.getMessage());
+
+ }
}
- }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org