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 2020/08/28 20:49:50 UTC
svn commit: r1881284 [18/18] - in /xmlbeans/trunk/src:
main/java/org/apache/xmlbeans/ main/java/org/apache/xmlbeans/impl/common/
main/java/org/apache/xmlbeans/impl/schema/
main/java/org/apache/xmlbeans/impl/store/
main/java/org/apache/xmlbeans/impl/too...
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java Fri Aug 28 20:49:50 2020
@@ -63,8 +63,7 @@ public class XBeansXQuery
public XBeansXQuery(final String query, String contextVar, Integer boundary, XmlOptions xmlOptions) {
config = new Configuration();
StaticQueryContext sc = config.newStaticQueryContext();
- @SuppressWarnings("unchecked")
- Map<String,String> nsMap = (Map<String,String>)xmlOptions.get(XmlOptions.LOAD_ADDITIONAL_NAMESPACES);
+ Map<String, String> nsMap = xmlOptions.getLoadAdditionalNamespaces();
if (nsMap != null) {
nsMap.forEach(sc::declareNamespace);
}
@@ -87,14 +86,14 @@ public class XBeansXQuery
? (Document) contextNode : contextNode.getOwnerDocument();
DocumentWrapper docWrapper = new DocumentWrapper(dom, null, config);
- NodeInfo root = docWrapper.wrap(contextNode);
+ NodeInfo root = docWrapper.wrap(contextNode);
DynamicQueryContext dc = new DynamicQueryContext(config);
dc.setContextItem(root);
dc.setParameter(new StructuredQName("", null, contextVar), root);
// Set the other variables
if (variableBindings != null) {
- for (Map.Entry<String, Object> me : ((Map<String,Object>)variableBindings).entrySet()) {
+ for (Map.Entry<String, Object> me : ((Map<String, Object>) variableBindings).entrySet()) {
StructuredQName key = new StructuredQName("", null, me.getKey());
Object value = me.getValue();
if (value instanceof XmlTokenSource) {
@@ -134,7 +133,7 @@ public class XBeansXQuery
if (value instanceof Boolean) {
return BooleanValue.get((Boolean) value);
} else if (value instanceof byte[]) {
- return new HexBinaryValue((byte[])value);
+ return new HexBinaryValue((byte[]) value);
} else if (value instanceof Byte) {
return new Int64Value((Byte) value, BuiltInAtomicType.BYTE, false);
} else if (value instanceof Float) {
@@ -148,13 +147,13 @@ public class XBeansXQuery
} else if (value instanceof Short) {
return new Int64Value((Short) value, BuiltInAtomicType.SHORT, false);
} else if (value instanceof String) {
- return new StringValue((String)value);
+ return new StringValue((String) value);
} else if (value instanceof BigDecimal) {
- return new BigDecimalValue((BigDecimal)value);
+ return new BigDecimalValue((BigDecimal) value);
} else if (value instanceof BigInteger) {
- return new BigIntegerValue((BigInteger)value);
+ return new BigIntegerValue((BigInteger) value);
} else if (value instanceof SaxonDuration) {
- return ((SaxonDuration)value).getDurationValue();
+ return ((SaxonDuration) value).getDurationValue();
} else if (value instanceof Duration) {
// this is simpler and safer (but perhaps slower) than extracting all the components
//return DurationValue.makeDuration(value.toString()).asAtomic();
@@ -162,9 +161,9 @@ public class XBeansXQuery
return new DurationValue(dv.getSign() >= 0, dv.getYears(), dv.getMonths(), dv.getDays(),
dv.getHours(), dv.getMinutes(), dv.getSeconds(), 0); // take correct millis..
} else if (value instanceof SaxonXMLGregorianCalendar) {
- return ((SaxonXMLGregorianCalendar)value).toCalendarValue();
+ return ((SaxonXMLGregorianCalendar) value).toCalendarValue();
} else if (value instanceof XMLGregorianCalendar) {
- XMLGregorianCalendar g = (XMLGregorianCalendar)value;
+ XMLGregorianCalendar g = (XMLGregorianCalendar) value;
QName gtype = g.getXMLSchemaType();
if (gtype.equals(DatatypeConstants.DATETIME)) {
return DateTimeValue.makeDateTimeValue(value.toString(), config.getConversionRules()).asAtomic();
@@ -191,19 +190,20 @@ public class XBeansXQuery
throw new AssertionError("Unknown Gregorian date type");
}
} else if (value instanceof QName) {
- QName q = (QName)value;
+ QName q = (QName) value;
return new QNameValue(q.getPrefix(), q.getNamespaceURI(), q.getLocalPart()); //BuiltInAtomicType.QNAME, null);
} else if (value instanceof URI) {
return new AnyURIValue(value.toString());
} else if (value instanceof Map) {
HashTrieMap htm = new HashTrieMap();
- for (Map.Entry<?,?> me : ((Map<?,?>)value).entrySet()) {
+ for (Map.Entry<?, ?> me : ((Map<?, ?>) value).entrySet()) {
htm.initialPut(
- (AtomicValue)objectToItem(me.getKey(), config),
+ (AtomicValue) objectToItem(me.getKey(), config),
objectToItem(me.getValue(), config));
}
return htm;
} else {
return new ObjectValue(value);
}
- }}
+ }
+}
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java Fri Aug 28 20:49:50 2020
@@ -36,7 +36,7 @@ import java.nio.charset.StandardCharsets
import java.util.*;
public class SampleXmlUtil {
- private boolean _soapEnc;
+ private final boolean _soapEnc;
private static final int MAX_ELEMENTS = 1000;
private int _nElements;
@@ -57,11 +57,10 @@ public class SampleXmlUtil {
// end of the doc so we use the original xml object that the cursor was
// created upon to do the xmlText() against.
XmlOptions options = new XmlOptions();
- options.put(XmlOptions.SAVE_PRETTY_PRINT);
- options.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, 2);
- options.put(XmlOptions.SAVE_AGGRESSIVE_NAMESPACES);
- String result = object.xmlText(options);
- return result;
+ options.setSavePrettyPrint();
+ options.setSavePrettyPrintIndent(2);
+ options.setSaveAggressiveNamespaces();
+ return object.xmlText(options);
}
Random _picker = new Random(1);
@@ -226,21 +225,7 @@ public class SampleXmlUtil {
}
case SchemaType.BTC_STRING: {
- String result;
- switch (closestBuiltin(sType).getBuiltinTypeCode()) {
- case SchemaType.BTC_STRING:
- case SchemaType.BTC_NORMALIZED_STRING:
- result = "string";
- break;
-
- case SchemaType.BTC_TOKEN:
- result = "token";
- break;
-
- default:
- result = "string";
- break;
- }
+ String result = closestBuiltin(sType).getBuiltinTypeCode() == SchemaType.BTC_TOKEN ? "token" : "string";
return formatToLength(result, sType);
}
@@ -299,32 +284,6 @@ public class SampleXmlUtil {
return a[pick(a.length)];
}
- private String pick(String[] a, int count) {
- if (count <= 0) {
- return "";
- }
-
- int i = pick(a.length);
- StringBuilder sb = new StringBuilder(a[i]);
- while (count-- > 0) {
- i += 1;
- if (i >= a.length) {
- i = 0;
- }
- sb.append(' ');
- sb.append(a[i]);
- }
- return sb.toString();
- }
-
- private String pickDigits(int digits) {
- StringBuilder sb = new StringBuilder();
- while (digits-- > 0) {
- sb.append(Integer.toString(pick(10)));
- }
- return sb.toString();
- }
-
private int pickLength(SchemaType sType) {
XmlInteger length = (XmlInteger) sType.getFacet(SchemaType.FACET_LENGTH);
if (length != null) {
@@ -385,8 +344,8 @@ public class SampleXmlUtil {
result = result.substring(0, len);
}
}
- } catch (Exception e) // intValue can be out of range
- {
+ } catch (Exception ignored) {
+ // intValue can be out of range
}
return result;
}
@@ -457,10 +416,11 @@ public class SampleXmlUtil {
sb.append('1');
increment = new BigDecimal(sb.toString());
} else {
- increment = new BigDecimal(1.0);
+ increment = BigDecimal.ONE;
}
}
+ //noinspection StatementWithEmptyBody
if (minOk && maxOk) {
// OK
} else if (minOk && !maxOk) {
@@ -529,7 +489,6 @@ public class SampleXmlUtil {
}
GDurationBuilder gdurb = new GDurationBuilder();
- BigInteger min, max;
gdurb.setSecond(pick(800000));
gdurb.setMonth(pick(20));
@@ -609,7 +568,7 @@ public class SampleXmlUtil {
gdurb.setSecond(minExclusive.getSecond() + 1);
}
if (gdurb.getFraction().compareTo(minExclusive.getFraction()) <= 0) {
- gdurb.setFraction(minExclusive.getFraction().add(new BigDecimal(0.001)));
+ gdurb.setFraction(minExclusive.getFraction().add(new BigDecimal("0.001")));
}
}
@@ -644,7 +603,6 @@ public class SampleXmlUtil {
private String formatDate(SchemaType sType) {
GDateBuilder gdateb = new GDateBuilder(new Date(1000L * pick(365 * 24 * 60 * 60) + (30L + pick(20)) * 365 * 24 * 60 * 60 * 1000));
GDate min = null, max = null;
- GDate temp;
// Find the min and the max according to the type
switch (sType.getPrimitiveType().getBuiltinTypeCode()) {
@@ -853,7 +811,7 @@ public class SampleXmlUtil {
if (max.compareToGDate(gdateb) <= 0) {
// Reset the date to max - (1-8) hours
Calendar c = gdateb.getCalendar();
- c.add(Calendar.HOUR_OF_DAY, 0 - pick(8));
+ c.add(Calendar.HOUR_OF_DAY, -pick(8));
gdateb = new GDateBuilder(c);
}
} else if (min != null && max != null) {
@@ -975,26 +933,13 @@ public class SampleXmlUtil {
xmlc.insertComment(minOccurs + " or more repetitions:");
}
} else if (sp.getIntMaxOccurs() > 1) {
- xmlc.insertComment(minOccurs + " to " + String.valueOf(sp.getMaxOccurs()) + " repetitions:");
+ xmlc.insertComment(minOccurs + " to " + sp.getMaxOccurs() + " repetitions:");
} else {
xmlc.insertComment("Optional:");
}
return result;
}
- /*
- Return a name for the element or the particle type to use in the comment for minoccurs, max occurs
- */
- private String getItemNameOrType(SchemaParticle sp, XmlCursor xmlc) {
- String elementOrTypeName = null;
- if (sp.getParticleType() == SchemaParticle.ELEMENT) {
- elementOrTypeName = "Element (" + sp.getName().getLocalPart() + ")";
- } else {
- elementOrTypeName = printParticleType(sp.getParticleType());
- }
- return elementOrTypeName;
- }
-
private void processElement(SchemaParticle sp, XmlCursor xmlc, boolean mixed) {
// cast as schema local element
SchemaLocalElement element = (SchemaLocalElement) sp;
@@ -1015,17 +960,7 @@ public class SampleXmlUtil {
}
- private void moveToken(int numToMove, XmlCursor xmlc) {
- for (int i = 0; i < Math.abs(numToMove); i++) {
- if (numToMove < 0) {
- xmlc.toPrevToken();
- } else {
- xmlc.toNextToken();
- }
- }
- }
-
- private static final String formatQName(XmlCursor xmlc, QName qName) {
+ private static String formatQName(XmlCursor xmlc, QName qName) {
XmlCursor parent = xmlc.newCursor();
parent.toParent();
String prefix = parent.prefixForNamespace(qName.getNamespaceURI());
@@ -1045,7 +980,7 @@ public class SampleXmlUtil {
private static final QName ENC_ARRAYTYPE = new QName("http://schemas.xmlsoap.org/soap/encoding/", "arrayType");
private static final QName ENC_OFFSET = new QName("http://schemas.xmlsoap.org/soap/encoding/", "offset");
- private static final Set SKIPPED_SOAP_ATTRS = new HashSet(Arrays.asList(new QName[]{HREF, ID, ENC_OFFSET}));
+ private static final Set<QName> SKIPPED_SOAP_ATTRS = new HashSet<>(Arrays.asList(HREF, ID, ENC_OFFSET));
private void processAttributes(SchemaType stype, XmlCursor xmlc) {
if (_soapEnc) {
@@ -1056,8 +991,7 @@ public class SampleXmlUtil {
}
SchemaProperty[] attrProps = stype.getAttributeProperties();
- for (int i = 0; i < attrProps.length; i++) {
- SchemaProperty attr = attrProps[i];
+ for (SchemaProperty attr : attrProps) {
if (_soapEnc) {
if (SKIPPED_SOAP_ATTRS.contains(attr.getName())) {
continue;
@@ -1090,9 +1024,9 @@ public class SampleXmlUtil {
private void processChoice(SchemaParticle sp, XmlCursor xmlc, boolean mixed) {
SchemaParticle[] spc = sp.getParticleChildren();
- xmlc.insertComment("You have a CHOICE of the next " + String.valueOf(spc.length) + " items at this level");
- for (int i = 0; i < spc.length; i++) {
- processParticle(spc[i], xmlc, mixed);
+ xmlc.insertComment("You have a CHOICE of the next " + spc.length + " items at this level");
+ for (SchemaParticle schemaParticle : spc) {
+ processParticle(schemaParticle, xmlc, mixed);
}
}
@@ -1112,45 +1046,5 @@ public class SampleXmlUtil {
xmlc.insertElement("AnyElement");
}
- /**
- * This method will get the base type for the schema type
- */
-
- private static QName getClosestName(SchemaType sType) {
- while (sType.getName() == null) {
- sType = sType.getBaseType();
- }
-
- return sType.getName();
- }
-
- private String printParticleType(int particleType) {
- StringBuilder returnParticleType = new StringBuilder();
- returnParticleType.append("Schema Particle Type: ");
-
- switch (particleType) {
- case SchemaParticle.ALL:
- returnParticleType.append("ALL\n");
- break;
- case SchemaParticle.CHOICE:
- returnParticleType.append("CHOICE\n");
- break;
- case SchemaParticle.ELEMENT:
- returnParticleType.append("ELEMENT\n");
- break;
- case SchemaParticle.SEQUENCE:
- returnParticleType.append("SEQUENCE\n");
- break;
- case SchemaParticle.WILDCARD:
- returnParticleType.append("WILDCARD\n");
- break;
- default:
- returnParticleType.append("Schema Particle Type Unknown");
- break;
- }
-
- return returnParticleType.toString();
- }
-
- private ArrayList _typeStack = new ArrayList();
+ private final ArrayList<SchemaType> _typeStack = new ArrayList<>();
}
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/xml/stream/StartElement.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/xml/stream/StartElement.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/xml/stream/StartElement.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/xml/stream/StartElement.java Fri Aug 28 20:49:50 2020
@@ -16,41 +16,47 @@
package org.apache.xmlbeans.xml.stream;
import java.util.Map;
+
/**
* The StartElement interface provides access to information about
* start elements
*
- * @since Weblogic XML Input Stream 1.0
* @version 1.0
* @see org.apache.xmlbeans.xml.stream.AttributeIterator
+ * @since Weblogic XML Input Stream 1.0
*/
public interface StartElement extends XMLEvent {
- /**
- * Returns an AttributeIterator of non-namespace declared attributes
- */
- public AttributeIterator getAttributes();
- /**
- * Returns an AttributeIterator of namespaces declared in this element
- */
- public AttributeIterator getNamespaces();
- /**
- * Returns the union of declared attributes and namespaces
- */
- public AttributeIterator getAttributesAndNamespaces();
- /**
- * Returns the attribute referred to by this name
- */
- public Attribute getAttributeByName(XMLName name);
- /**
- * Gets the value that the prefix is bound to in the
- * context of this element. Returns null if
- * the prefix is not bound in this context
- */
- public String getNamespaceUri(String prefix);
- /**
- * Gets a java.util.Map from prefixes to URIs in scope for this
- * element.
- */
- public Map getNamespaceMap();
+ /**
+ * Returns an AttributeIterator of non-namespace declared attributes
+ */
+ AttributeIterator getAttributes();
+
+ /**
+ * Returns an AttributeIterator of namespaces declared in this element
+ */
+ AttributeIterator getNamespaces();
+
+ /**
+ * Returns the union of declared attributes and namespaces
+ */
+ AttributeIterator getAttributesAndNamespaces();
+
+ /**
+ * Returns the attribute referred to by this name
+ */
+ Attribute getAttributeByName(XMLName name);
+
+ /**
+ * Gets the value that the prefix is bound to in the
+ * context of this element. Returns null if
+ * the prefix is not bound in this context
+ */
+ String getNamespaceUri(String prefix);
+
+ /**
+ * Gets a java.util.Map from prefixes to URIs in scope for this
+ * element.
+ */
+ Map<String, String> getNamespaceMap();
}
Modified: xmlbeans/trunk/src/test/java/common/Common.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/common/Common.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/common/Common.java (original)
+++ xmlbeans/trunk/src/test/java/common/Common.java Fri Aug 28 20:49:50 2020
@@ -24,8 +24,7 @@ import java.util.*;
import static org.junit.Assert.assertNotNull;
-public class Common
-{
+public class Common {
public static final String NEWLINE = System.getProperty("line.separator");
public static final String P = File.separator;
@@ -34,7 +33,7 @@ public class Common
public static String XBEAN_CASE_ROOT = getCaseLocation() + P + "xbean";
//location of files under "cases folder"
- public static String OUTPUTROOT = FWROOT+P+"build" + P + "test" + P + "output";
+ public static String OUTPUTROOT = FWROOT + P + "build" + P + "test" + P + "output";
public final LinkedList errorList = new LinkedList();
@@ -52,13 +51,13 @@ public class Common
* @return
* @throws IllegalStateException
*/
- public static String getRootFile() throws IllegalStateException
- {
+ public static String getRootFile() throws IllegalStateException {
String baseDir = System.getProperty("xbean.rootdir");
- if (baseDir == null)
+ if (baseDir == null) {
return new File(".").getAbsolutePath();
- else
+ } else {
return new File(baseDir).getAbsolutePath();
+ }
}
/**
@@ -68,8 +67,7 @@ public class Common
*
* @throws IllegalStateException
*/
- public static String getCaseLocation() throws IllegalStateException
- {
+ public static String getCaseLocation() throws IllegalStateException {
String baseDir = System.getProperty("cases.location");
if (baseDir == null) {
return new File("." + P + "src" + P + "test" + P + "resources").getAbsolutePath();
@@ -84,8 +82,7 @@ public class Common
* @param strPath
* @return file Object for references location
*/
- public static File xbeanCase(String strPath)
- {
+ public static File xbeanCase(String strPath) {
return (new File(CASEROOT, strPath));
}
@@ -95,8 +92,7 @@ public class Common
* @param strPath
* @return File Object specified by strPath
*/
- public static File xbeanOutput(String strPath)
- {
+ public static File xbeanOutput(String strPath) {
File result = (new File(OUTPUTROOT, strPath));
File parentdir = result.getParentFile();
parentdir.mkdirs();
@@ -108,16 +104,17 @@ public class Common
*
* @param dir
*/
- public static void deltree(File dir)
- {
+ public static void deltree(File dir) {
if (dir.exists()) {
if (dir.isDirectory()) {
String[] list = dir.list();
- for (int i = 0; i < list.length; i++)
+ for (int i = 0; i < list.length; i++) {
deltree(new File(dir, list[i]));
+ }
}
- if (!dir.delete())
+ if (!dir.delete()) {
System.out.println("Could not delete " + dir);
+ }
//throw new IllegalStateException("Could not delete " + dir);
}
}
@@ -127,25 +124,25 @@ public class Common
*
* @param errors
*/
- public static void listErrors(List errors)
- {
+ public static void listErrors(List errors) {
for (int i = 0; i < errors.size(); i++) {
XmlError error = (XmlError) errors.get(i);
- if (error.getSeverity() == XmlError.SEVERITY_ERROR)
+ if (error.getSeverity() == XmlError.SEVERITY_ERROR) {
System.out.println(error.toString());
+ }
}
}
/**
* check list of errors/warnings/msgs and print them. Return true if errors found
+ *
* @param errors
* @return
*/
- public static boolean printOptionErrMsgs(Collection errors)
- {
+ public static boolean printOptionErrMsgs(Collection errors) {
boolean errFound = false;
if (!errors.isEmpty()) {
- for (Iterator i = errors.iterator(); i.hasNext();) {
+ for (Iterator i = errors.iterator(); i.hasNext(); ) {
XmlError eacherr = (XmlError) i.next();
int errSeverity = eacherr.getSeverity();
if (errSeverity == XmlError.SEVERITY_ERROR) {
@@ -164,25 +161,25 @@ public class Common
/**
* Validate schemas to instance based on the docType
+ *
* @param schemas
* @param instances
* @param docType
* @throws Exception
*/
- public static void validateInstance(String[] schemas, String[] instances, QName docType) throws Exception
- {
+ public static void validateInstance(String[] schemas, String[] instances, QName docType) throws Exception {
SchemaTypeLoader stl = makeSchemaTypeLoader(schemas);
XmlOptions options = new XmlOptions();
if (docType != null) {
SchemaType docSchema = stl.findDocumentType(docType);
Assert.assertTrue(docSchema != null);
- options.put(XmlOptions.DOCUMENT_TYPE, docSchema);
+ options.setDocumentType(docSchema);
}
for (int i = 0; i < instances.length; i++) {
XmlObject x =
- stl.parse((String) instances[i], null, options);
+ stl.parse((String) instances[i], null, options);
//if (!startOnDocument) {
// XmlCursor c = x.newCursor();
@@ -191,9 +188,9 @@ public class Common
// c.dispose();
//}
- List xel = new ArrayList();
+ List<XmlError> xel = new ArrayList<>();
- options.put(XmlOptions.ERROR_LISTENER, xel);
+ options.setErrorListener(xel);
boolean isValid = x.validate(options);
@@ -202,8 +199,9 @@ public class Common
errorTxt.append("Instance(" + i + "): ");
errorTxt.append(x.xmlText());
errorTxt.append("Errors: ");
- for (int j = 0; j < xel.size(); j++)
- errorTxt.append(xel.get(j) + "\n");
+ for (XmlError xmlError : xel) {
+ errorTxt.append(xmlError + "\n");
+ }
System.err.println(errorTxt.toString());
throw new Exception("Instance not valid\n" + errorTxt.toString());
}
@@ -217,14 +215,13 @@ public class Common
* @param XsdAsString
* @return
*/
- public static XmlObject compileXsdString(String XsdAsString)
- {
+ public static XmlObject compileXsdString(String XsdAsString) {
XmlObject xobj = null;
try {
xobj = XmlObject.Factory.parse(XsdAsString);
} catch (XmlException xme) {
if (!xme.getErrors().isEmpty()) {
- for (Iterator itr = xme.getErrors().iterator(); itr.hasNext();) {
+ for (Iterator itr = xme.getErrors().iterator(); itr.hasNext(); ) {
System.out.println("Parse Errors :" + itr.next());
}
}
@@ -241,14 +238,13 @@ public class Common
* @param XsdFilePath
* @return
*/
- public static XmlObject compileXsdFile(String XsdFilePath)
- {
+ public static XmlObject compileXsdFile(String XsdFilePath) {
XmlObject xobj = null;
try {
xobj = XmlObject.Factory.parse(new File(XsdFilePath));
} catch (XmlException xme) {
if (!xme.getErrors().isEmpty()) {
- for (Iterator itr = xme.getErrors().iterator(); itr.hasNext();) {
+ for (Iterator itr = xme.getErrors().iterator(); itr.hasNext(); ) {
System.out.println("Parse Errors :" + itr.next());
}
}
@@ -269,13 +265,12 @@ public class Common
* @throws Exception
*/
public static SchemaTypeLoader makeSchemaTypeLoader(String[] schemas)
- throws Exception
- {
+ throws Exception {
XmlObject[] schemaDocs = new XmlObject[schemas.length];
for (int i = 0; i < schemas.length; i++) {
schemaDocs[i] =
- XmlObject.Factory.parse(schemas[i]);
+ XmlObject.Factory.parse(schemas[i]);
}
return XmlBeans.loadXsd(schemaDocs);
@@ -287,36 +282,31 @@ public class Common
*
* @return true if java.version starts with 1.4
*/
- public static boolean isJDK14()
- {
+ public static boolean isJDK14() {
return System.getProperty("java.version").startsWith("1.4");
}
/**
* Convenience class for creating tests in a multithreaded env
*/
- public static abstract class TestThread extends Thread
- {
+ public static abstract class TestThread extends Thread {
protected Throwable _throwable;
protected boolean _result;
protected XmlOptions xm;
protected ArrayList errors;
- public TestThread()
- {
+ public TestThread() {
xm = new XmlOptions();
ArrayList errors = new ArrayList();
xm.setErrorListener(errors);
xm.setValidateOnSet();
}
- public Throwable getException()
- {
+ public Throwable getException() {
return _throwable;
}
- public boolean getResult()
- {
+ public boolean getResult() {
return _result;
}
Modified: xmlbeans/trunk/src/test/java/compile/scomp/detailed/XmlBeanCompilationTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/detailed/XmlBeanCompilationTests.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/compile/scomp/detailed/XmlBeanCompilationTests.java (original)
+++ xmlbeans/trunk/src/test/java/compile/scomp/detailed/XmlBeanCompilationTests.java Fri Aug 28 20:49:50 2020
@@ -37,7 +37,7 @@ import static org.junit.Assert.assertTru
* the same schematypesystem
*/
public class XmlBeanCompilationTests extends CompileTestBase {
- private final List<String> xm_errors = new ArrayList<String>();
+ private final List<XmlError> xm_errors = new ArrayList<>();
private final XmlOptions xm_opts = new XmlOptions();
public XmlBeanCompilationTests() {
@@ -47,8 +47,9 @@ public class XmlBeanCompilationTests ext
@After
public void tearDown() throws Exception {
- if (xm_errors.size() > 0)
+ if (xm_errors.size() > 0) {
xm_errors.clear();
+ }
}
/**
@@ -109,22 +110,30 @@ public class XmlBeanCompilationTests ext
SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans("apiCompile", null,
schemas, bind, XmlBeans.getBuiltinTypeSystem(), f, xm_opts);
- if (!bind.isIslookupPrefixForNamespace())
+ if (!bind.isIslookupPrefixForNamespace()) {
throw new Exception("isIslookupPrefixForNamespace not invoked");
- if (!bind.isIslookupPackageForNamespace())
+ }
+ if (!bind.isIslookupPackageForNamespace()) {
throw new Exception("isIslookupPackageForNamespace not invoked");
- if (!bind.isIslookupSuffixForNamespace())
+ }
+ if (!bind.isIslookupSuffixForNamespace()) {
throw new Exception("isIslookupSuffixForNamespace not invoked");
- if (!bind.isIslookupJavanameForQName())
+ }
+ if (!bind.isIslookupJavanameForQName()) {
throw new Exception("isIslookupJavanameForQName not invoked");
- if (!bind.isIsgetInterfaceExtensionsString())
+ }
+ if (!bind.isIsgetInterfaceExtensionsString()) {
throw new Exception("isIsgetInterfaceExtensionsString not invoked");
- if (!bind.isIsgetInterfaceExtensions())
+ }
+ if (!bind.isIsgetInterfaceExtensions()) {
throw new Exception("isIsgetInterfaceExtensions not invoked");
- if (!bind.isIsgetPrePostExtensions())
+ }
+ if (!bind.isIsgetPrePostExtensions()) {
throw new Exception("isIsgetPrePostExtensions not invoked");
- if (!bind.isIsgetPrePostExtensionsString())
+ }
+ if (!bind.isIsgetPrePostExtensionsString()) {
throw new Exception("isIsgetPrePostExtensionsString not invoked");
+ }
}
/**
@@ -160,9 +169,10 @@ public class XmlBeanCompilationTests ext
assertTrue("Errors should have been empty", err.isEmpty());
// find element in the type System
- if (!findGlobalElement(sts.globalElements(), sts1))
+ if (!findGlobalElement(sts.globalElements(), sts1)) {
throw new Exception(
"Could Not find Type from first Type System: " + sts1);
+ }
//SIMPLE INCR COMPILATION
sts = XmlBeans.compileXmlBeans(null,
@@ -171,13 +181,15 @@ public class XmlBeanCompilationTests ext
assertTrue("Errors should have been empty", err.isEmpty());
// find element in the type System
- if (!findGlobalElement(sts.globalElements(), sts1))
+ if (!findGlobalElement(sts.globalElements(), sts1)) {
throw new Exception("Could Not find Type from first Type System: " +
sts1);
+ }
- if (!findGlobalElement(sts.globalElements(), sts2))
+ if (!findGlobalElement(sts.globalElements(), sts2)) {
throw new Exception("Could Not find Type from 2nd Type System: " +
sts2);
+ }
System.out.println("Building over Existing");
//BUILDING OFF BASE SIMPLE INCR COMPILATION
@@ -187,13 +199,15 @@ public class XmlBeanCompilationTests ext
assertTrue("Errors should have been empty", err.isEmpty());
// find element in the type System
- if (!findGlobalElement(sts.globalElements(), sts1))
+ if (!findGlobalElement(sts.globalElements(), sts1)) {
throw new Exception("Could Not find Type from first Type System: " +
sts1);
+ }
- if (!findGlobalElement(sts.globalElements(), sts2))
+ if (!findGlobalElement(sts.globalElements(), sts2)) {
throw new Exception("Could Not find Type from 2nd Type System: " +
sts2);
+ }
//INCR COMPILATION WITH RECOVERABLE ERROR
err.clear();
@@ -201,17 +215,20 @@ public class XmlBeanCompilationTests ext
sts, schemas3, null,
XmlBeans.getBuiltinTypeSystem(), null, opt);
// find element in the type System
- if (!findGlobalElement(b.globalElements(), sts1))
+ if (!findGlobalElement(b.globalElements(), sts1)) {
throw new Exception("Could Not find Type from first Type System: " +
sts1);
+ }
- if (!findGlobalElement(b.globalElements(), sts2))
+ if (!findGlobalElement(b.globalElements(), sts2)) {
throw new Exception("Could Not find Type from 2nd Type System: " +
sts2);
+ }
- if (!findGlobalElement(b.globalElements(), sts3))
+ if (!findGlobalElement(b.globalElements(), sts3)) {
throw new Exception("Could Not find Type from 3rd Type System: " +
sts3);
+ }
printSTS(b);
@@ -228,12 +245,14 @@ public class XmlBeanCompilationTests ext
if ((xErr.getErrorCode().compareTo("src-resolve") == 0) &&
(xErr.getMessage().compareTo(
"type 'bType@http://baz' not found.") ==
- 0))
+ 0)) {
psom_expError = true;
+ }
}
}
- if (!psom_expError)
+ if (!psom_expError) {
throw new Exception("Error Code was not as Expected");
+ }
}
Modified: xmlbeans/trunk/src/test/java/xmlcursor/checkin/StoreTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/checkin/StoreTests.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/checkin/StoreTests.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/checkin/StoreTests.java Fri Aug 28 20:49:50 2020
@@ -142,14 +142,14 @@ public class StoreTests {
}
@Test
- public void testImplicitNamespaces() throws Exception {
- Map<String,String> namespaces = new HashMap<String,String>();
+ public void testImplicitNamespaces() {
+ Map<String, String> namespaces = new HashMap<>();
namespaces.put("foo", "foo.com");
namespaces.put("bar", "bar.com");
namespaces.put("", "default.com");
XmlOptions options = new XmlOptions();
- options.put(XmlOptions.SAVE_IMPLICIT_NAMESPACES, namespaces);
+ options.setSaveImplicitNamespaces(namespaces);
XmlObject x = XmlObject.Factory.newInstance();
XmlCursor c = x.newCursor();
@@ -178,19 +178,21 @@ public class StoreTests {
add("START_ELEMENT");
add(" namespaceURI: " + namespaceURI);
add(" localName: " + localName);
-// add( " qName: " + qName );
+// add( " qName: " + qName );
- TreeSet sortedAttrs = new TreeSet();
+ TreeSet<String> sortedAttrs = new TreeSet<>();
for (int i = 0; i < atts.getLength(); i++) {
String ln = atts.getLocalName(i);
String uri = atts.getURI(i);
String qname = atts.getQName(i);
- if (ln.equals("xmlns"))
+ if (ln.equals("xmlns")) {
continue;
- if (qname.startsWith("xmlns"))
+ }
+ if (qname.startsWith("xmlns")) {
continue;
+ }
// if (ln.equals( "xmlns" ))
// ln = "";
@@ -204,8 +206,9 @@ public class StoreTests {
atts.getValue(i));
}
- for (Iterator i = sortedAttrs.iterator(); i.hasNext(); )
- add(" Attr: " + i.next());
+ for (String sortedAttr : sortedAttrs) {
+ add(" Attr: " + sortedAttr);
+ }
}
public void endElement(
@@ -297,8 +300,9 @@ public class StoreTests {
private void add(String s, char[] buf, int off, int cch) {
_sb.append(s);
- if (buf != null)
+ if (buf != null) {
_sb.append(buf, off, cch);
+ }
_sb.append("\n");
}
@@ -315,7 +319,7 @@ public class StoreTests {
return _sb.toString();
}
- private StringBuilder _sb = new StringBuilder();
+ private final StringBuilder _sb = new StringBuilder();
}
private void doTestSaxSaver(String xml)
@@ -388,8 +392,9 @@ public class StoreTests {
char ch = xml.charAt(i);
if (ch == '<' && Character.isLetter(xml.charAt(i + 1))) {
- while (!c.currentTokenType().isStart())
+ while (!c.currentTokenType().isStart()) {
c.toNextToken();
+ }
assertTrue(c.currentTokenType().isStart());
@@ -409,8 +414,9 @@ public class StoreTests {
if (ch == '\n') {
line++;
col = 1;
- } else
+ } else {
col++;
+ }
}
}
@@ -445,17 +451,19 @@ public class StoreTests {
public void whitespace() {
int p = r.nextInt(100);
- if (p < 20)
+ if (p < 20) {
append('\t');
- else if (p < 40)
+ } else if (p < 40) {
append('\n');
- else
+ } else {
append(' ');
+ }
}
void whitespaces() {
- for (int i = r.nextInt(8); i > 0; i--)
+ for (int i = r.nextInt(8); i > 0; i--) {
whitespace();
+ }
}
char makeLetter() {
@@ -490,12 +498,13 @@ public class StoreTests {
for (int i = r.nextInt(20); i > 0; i--) {
int p = r.nextInt(100);
- if (p < 70)
+ if (p < 70) {
letter();
- else if (p < 74)
+ } else if (p < 74) {
charEntity();
- else
+ } else {
whitespace();
+ }
}
}
@@ -505,16 +514,18 @@ public class StoreTests {
for (; ; ) {
char ch = makeLetter();
- if (ch == 'x' || ch == 'X')
+ if (ch == 'x' || ch == 'X') {
continue;
+ }
name.append(ch);
break;
}
- for (int i = r.nextInt(20); i > 0; i--)
+ for (int i = r.nextInt(20); i > 0; i--) {
name.append(makeLetter());
+ }
return name.toString();
}
@@ -545,14 +556,15 @@ public class StoreTests {
for (; ; ) {
int p = r.nextInt(100);
- if (p < 20)
+ if (p < 20) {
break;
- else if (p < 50)
+ } else if (p < 50) {
whitespaces();
- else if (p < 70)
+ } else if (p < 70) {
comment();
- else
+ } else {
procinst();
+ }
}
}
@@ -583,13 +595,15 @@ public class StoreTests {
public void attribute() {
ncName();
- if (r.nextInt(100) == 0)
+ if (r.nextInt(100) == 0) {
whitespaces();
+ }
append('=');
- if (r.nextInt(100) == 0)
+ if (r.nextInt(100) == 0) {
whitespaces();
+ }
char q = r.nextInt(2) == 0 ? '\'' : '"';
@@ -611,34 +625,35 @@ public class StoreTests {
append('<');
append(name);
- if (r.nextInt(100) == 0)
+ if (r.nextInt(100) == 0) {
whitespaces();
+ }
- HashMap attrs = new HashMap();
+ HashMap<String,Object> attrs = new HashMap<>();
for (int i = r.nextInt(3); i > 0; i--) {
append(' ');
String aname;
- for (; ; ) {
+ do {
aname = makeNcName();
- if (!attrs.containsKey(aname))
- break;
- }
+ } while (attrs.containsKey(aname));
attrs.put(aname, null);
append(aname);
- if (r.nextInt(100) == 0)
+ if (r.nextInt(100) == 0) {
whitespaces();
+ }
append('=');
- if (r.nextInt(100) == 0)
+ if (r.nextInt(100) == 0) {
whitespaces();
+ }
char q = r.nextInt(2) == 0 ? '\'' : '"';
@@ -648,8 +663,9 @@ public class StoreTests {
append(q);
- if (r.nextInt(10) == 0)
+ if (r.nextInt(10) == 0) {
whitespaces();
+ }
}
append('>');
@@ -659,16 +675,18 @@ public class StoreTests {
append("</");
append(name);
- if (r.nextInt(100) == 0)
+ if (r.nextInt(100) == 0) {
whitespaces();
+ }
append('>');
}
}
public void document() {
- if (r.nextInt(2) == 0)
+ if (r.nextInt(2) == 0) {
xmlDecl();
+ }
whiteContent();
@@ -783,8 +801,9 @@ public class StoreTests {
n++;
- if (t == TokenType.NONE)
+ if (t == TokenType.NONE) {
break;
+ }
}
assertEquals(6, n);
@@ -797,18 +816,16 @@ public class StoreTests {
@Test
public void testConsistentTokenOrder()
throws Exception {
- ArrayList<TokenType> l = new ArrayList<TokenType>();
+ ArrayList<TokenType> l = new ArrayList<>();
XmlCursor c = XmlObject.Factory.parse(Common.XML_ATTR_TEXT, null).newCursor();
- for (; ; ) {
+ do {
// System.err.println(c.currentTokenType());
l.add(c.currentTokenType());
- if (c.toNextToken() == TokenType.NONE)
- break;
- }
+ } while (c.toNextToken() != TokenType.NONE);
c.toEndDoc();
// System.err.println("Reversing");
@@ -817,8 +834,9 @@ public class StoreTests {
// System.err.println(c.currentTokenType());
assertEquals(l.get(i), c.currentTokenType());
- if (c.toPrevToken() == TokenType.NONE)
+ if (c.toPrevToken() == TokenType.NONE) {
break;
+ }
}
}
@@ -954,48 +972,54 @@ public class StoreTests {
continue;
}
- if (n == 0)
+ if (n == 0) {
n = 1;
+ }
if (ch == 'c') {
- if (prev)
+ if (prev) {
assertEquals(c.toPrevChar(n), n);
- else
+ } else {
assertEquals(c.toNextChar(n), n);
+ }
} else if (ch == 't') {
while (n-- > 0) {
- if (prev)
+ if (prev) {
assertNotSame(c.toPrevToken(), TokenType.NONE);
- else
+ } else {
assertNotSame(c.toNextToken(), TokenType.NONE);
+ }
}
} else if (ch == 'p') {
- assertTrue(!prev);
+ assertFalse(prev);
- while (n-- > 0)
+ while (n-- > 0) {
assertTrue(c.toParent());
+ }
} else if (ch == 'r') {
- assertTrue(!prev);
+ assertFalse(prev);
assertEquals(1, n);
c.toEndDoc();
} else if (ch == 'b') {
- assertTrue(!prev);
+ assertFalse(prev);
assertEquals(1, n);
c.toStartDoc();
} else if (ch == 's') {
while (n-- > 0) {
- if (prev)
+ if (prev) {
assertTrue(c.toPrevSibling());
- else
+ } else {
assertTrue(c.toNextSibling());
+ }
}
} else if (ch == 'd') {
- assertTrue(!prev);
+ assertFalse(prev);
- while (n-- > 0)
+ while (n-- > 0) {
assertTrue(c.toFirstChild());
+ }
} else {
fail();
}
@@ -1025,9 +1049,7 @@ public class StoreTests {
XmlOptions options = new XmlOptions();
- options.put(
- XmlOptions.SAVE_SYNTHETIC_DOCUMENT_ELEMENT,
- new QName(null, "bar"));
+ options.setSaveSyntheticDocumentElement(new QName(null, "bar"));
assertTrue(
x.xmlText(options).equals("<bar>[TO]<foo>abcdef</foo>[FROM]</bar>") ||
@@ -1053,7 +1075,7 @@ public class StoreTests {
cFrom = navDoc(x, "d");
cTo = navNewCursor(cFrom, "t3c");
- assertTrue(!cFrom.moveXml(cTo));
+ assertFalse(cFrom.moveXml(cTo));
cFrom.insertChars("[FROM]");
cTo.insertChars("[TO]");
@@ -1433,9 +1455,7 @@ public class StoreTests {
XmlOptions options = new XmlOptions();
- options.put(
- XmlOptions.SAVE_SYNTHETIC_DOCUMENT_ELEMENT,
- new QName(null, "bar"));
+ options.setSaveSyntheticDocumentElement(new QName(null, "bar"));
x = XmlObject.Factory.parse(cTo.xmlText(options));
@@ -1451,9 +1471,7 @@ public class StoreTests {
options = new XmlOptions();
- options.put(
- XmlOptions.SAVE_SYNTHETIC_DOCUMENT_ELEMENT,
- new QName(null, "bar"));
+ options.setSaveSyntheticDocumentElement(new QName(null, "bar"));
x = XmlObject.Factory.parse(cTo.xmlText(options));
@@ -1556,8 +1574,7 @@ public class StoreTests {
XmlObject x;
XmlOptions options = new XmlOptions();
-
- options.put(XmlOptions.LOAD_REPLACE_DOCUMENT_ELEMENT, null);
+ options.setLoadReplaceDocumentElement(null);
x =
XmlObject.Factory.parse(
@@ -1584,7 +1601,7 @@ public class StoreTests {
XmlObject x;
XmlCursor cFrom, cTo;
- // Forward navigation
+ // Forward navigation
x = XmlObject.Factory.parse("<bar p='q' x='y'>ab<foo>xy</foo>cd</bar>");
@@ -1608,7 +1625,7 @@ public class StoreTests {
}
}
- // Backward navigation
+ // Backward navigation
x = XmlObject.Factory.parse("<bar p='q' x='y'>ab<foo>xy</foo>cd</bar>");
@@ -1619,12 +1636,13 @@ public class StoreTests {
assertEquals(0, cFrom.comparePosition(cTo));
assertTrue(cFrom.isAtSamePositionAs(cTo));
- if (cFrom.toPrevChar(1) == 1)
+ if (cFrom.toPrevChar(1) == 1) {
cTo.toPrevChar(1);
- else if (cFrom.toPrevToken() != TokenType.NONE)
+ } else if (cFrom.toPrevToken() != TokenType.NONE) {
cTo.toPrevToken();
- else
+ } else {
break;
+ }
}
//
@@ -1641,23 +1659,27 @@ public class StoreTests {
for (; ; ) {
if (cTo.isAtSamePositionAs(cFrom)) {
- assertTrue(!passed);
+ assertFalse(passed);
passed = true;
} else if (cTo.isLeftOf(cFrom)) {
- assertTrue(!passed);
+ assertFalse(passed);
} else {
assertTrue(passed);
assertTrue(cTo.isRightOf(cFrom));
}
- if (cTo.toNextChar(1) != 1)
- if (cTo.toNextToken() == TokenType.ENDDOC)
+ if (cTo.toNextChar(1) != 1) {
+ if (cTo.toNextToken() == TokenType.ENDDOC) {
break;
+ }
+ }
}
- if (cFrom.toNextChar(1) != 1)
- if (cFrom.toNextToken() == TokenType.ENDDOC)
+ if (cFrom.toNextChar(1) != 1) {
+ if (cFrom.toNextToken() == TokenType.ENDDOC) {
break;
+ }
+ }
}
}
@@ -1757,22 +1779,22 @@ public class StoreTests {
XmlObject x = XmlObject.Factory.parse("<a x='y'>eric<!----><?moo?></a>");
XmlCursor c = x.newCursor();
assertNull(c.getName());
- assertTrue(!c.toNextToken().isNone());
+ assertFalse(c.toNextToken().isNone());
assertEquals("a", c.getName().getLocalPart());
assertEquals(0, c.getName().getNamespaceURI().length());
- assertTrue(!c.toNextToken().isNone());
+ assertFalse(c.toNextToken().isNone());
assertEquals("x", c.getName().getLocalPart());
assertEquals(0, c.getName().getNamespaceURI().length());
- assertTrue(!c.toNextToken().isNone());
+ assertFalse(c.toNextToken().isNone());
assertNull(c.getName());
- assertTrue(!c.toNextToken().isNone());
+ assertFalse(c.toNextToken().isNone());
assertNull(c.getName());
- assertTrue(!c.toNextToken().isNone());
+ assertFalse(c.toNextToken().isNone());
assertEquals("moo", c.getName().getLocalPart());
assertEquals(0, c.getName().getNamespaceURI().length());
- assertTrue(!c.toNextToken().isNone());
+ assertFalse(c.toNextToken().isNone());
assertNull(c.getName());
- assertTrue(!c.toNextToken().isNone());
+ assertFalse(c.toNextToken().isNone());
assertNull(c.getName());
assertTrue(c.toNextToken().isNone());
}
@@ -1798,17 +1820,14 @@ public class StoreTests {
@Test
public void testNamespaceSubstitution()
throws Exception {
- HashMap<String, String> subs = new HashMap<String, String>();
+ HashMap<String, String> subs = new HashMap<>();
subs.put("foo", "moo");
subs.put("a", "b");
XmlOptions options = new XmlOptions();
- options.put(XmlOptions.LOAD_SUBSTITUTE_NAMESPACES, subs);
+ options.setLoadSubstituteNamespaces(subs);
- XmlObject x =
- XmlObject.Factory.parse(
- "<a xmlns='foo' xmlns:a='a' a:x='y'/>",
- options);
+ XmlObject x = XmlObject.Factory.parse("<a xmlns='foo' xmlns:a='a' a:x='y'/>", options);
XmlCursor c = x.newCursor();
@@ -1826,8 +1845,7 @@ public class StoreTests {
}
@Test
- public void testNamespaceInsertion()
- throws Exception {
+ public void testNamespaceInsertion() {
XmlObject x = XmlObject.Factory.newInstance();
XmlCursor c = x.newCursor();
@@ -1864,7 +1882,7 @@ public class StoreTests {
XmlCursor c = x.newCursor();
c.toFirstChild();
XmlObject fc = c.getObject();
- assertTrue(!fc.isNil());
+ assertFalse(fc.isNil());
fc.setNil();
assertTrue(fc.isNil());
assertEquals("<canBeNil xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>", x.xmlText());
@@ -1872,7 +1890,7 @@ public class StoreTests {
assertTrue(c.isAttr());
c.removeXml();
assertEquals("<canBeNil/>", x.xmlText());
- assertTrue(!fc.isNil());
+ assertFalse(fc.isNil());
}
@Test
@@ -1893,8 +1911,8 @@ public class StoreTests {
dotestParserErrors("<foo a></foo>");
dotestParserErrors("<foo>");
dotestParserErrors("</foo>");
- dotestParserErrors( "<foo><!-- -- --></foo>" );
- dotestParserErrors( "<foo><!-- ---></foo>" );
+ dotestParserErrors("<foo><!-- -- --></foo>");
+ dotestParserErrors("<foo><!-- ---></foo>");
dotestParser("<a b=\"x\n\ny\"/>", "<a b=\"x y\"/>");
}
@@ -1940,7 +1958,7 @@ public class StoreTests {
throws Exception {
String xml = "<a xmlns:a='aNS'><a:b/></a>";
- Map<String, String> map = new java.util.LinkedHashMap<String, String>();
+ Map<String, String> map = new LinkedHashMap<>();
map.put("b", "bNS");
map.put("c", "cNS");
map.put("a", "not-aNS");
@@ -1954,7 +1972,7 @@ public class StoreTests {
xml = "<a xmlns='aNS'><b/></a>";
- map = new java.util.LinkedHashMap<String, String>();
+ map = new LinkedHashMap<>();
map.put("b", "bNS");
map.put("c", "cNS");
map.put("", "not-aNS");
Modified: xmlbeans/trunk/src/test/java/xmlcursor/detailed/CursorVsObjectAttributeTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/detailed/CursorVsObjectAttributeTest.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/detailed/CursorVsObjectAttributeTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/detailed/CursorVsObjectAttributeTest.java Fri Aug 28 20:49:50 2020
@@ -14,7 +14,7 @@
*/
-package xmlcursor.detailed;
+package xmlcursor.detailed;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlCursor.TokenType;
@@ -28,14 +28,15 @@ import xmlcursor.common.Common;
import javax.xml.namespace.QName;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
public class CursorVsObjectAttributeTest {
@Test
public void testAttributeSet() throws Exception {
CarLocationMessageDocument clmDoc = CarLocationMessageDocument.Factory.parse(
- JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
+ JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
XmlCursor xc = clmDoc.newCursor();
xc.toFirstChild();
CarLocationMessage clm = (CarLocationMessage) xc.getObject();
@@ -50,8 +51,8 @@ public class CursorVsObjectAttributeTest
@Test
public void testAttributeUnsetRemove() throws Exception {
CarLocationMessageDocument clmDoc =
- (CarLocationMessageDocument) XmlObject.Factory.parse(
- JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
+ (CarLocationMessageDocument) XmlObject.Factory.parse(
+ JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
XmlCursor xc = clmDoc.newCursor();
xc.toFirstChild();
CarLocationMessage clm = (CarLocationMessage) xc.getObject();
@@ -68,11 +69,11 @@ public class CursorVsObjectAttributeTest
@Test
public void testAttributeInsert() throws Exception {
XmlOptions map = new XmlOptions();
- map.put(XmlOptions.LOAD_STRIP_WHITESPACE, "");
+ map.setLoadStripWhitespace();
CarLocationMessageDocument clmDoc =
- (CarLocationMessageDocument) XmlObject.Factory.parse(
- JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM), map);
+ (CarLocationMessageDocument) XmlObject.Factory.parse(
+ JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM), map);
XmlCursor xc = clmDoc.newCursor();
xc.toFirstChild();
CarLocationMessage clm = (CarLocationMessage) xc.getObject();
Modified: xmlbeans/trunk/src/test/java/xmlcursor/detailed/InsertNamespaceTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/detailed/InsertNamespaceTest.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/detailed/InsertNamespaceTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/detailed/InsertNamespaceTest.java Fri Aug 28 20:49:50 2020
@@ -24,7 +24,7 @@ import org.junit.Test;
import xmlcursor.common.BasicCursorTestCase;
import xmlcursor.common.Common;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
public class InsertNamespaceTest extends BasicCursorTestCase {
@@ -36,7 +36,7 @@ public class InsertNamespaceTest extends
m_xc.insertNamespace("prefix", "value");
m_xc.toStartDoc();
XmlOptions map = new XmlOptions();
- map.put(XmlOptions.SAVE_NAMESPACES_FIRST, "");
+ map.setSaveNamespacesFirst(true);
assertEquals("<foo xmlns:prefix=\"value\" attr0=\"val0\" attr1=\"val1\">text</foo>", m_xc.xmlText(map));
}
@@ -49,7 +49,7 @@ public class InsertNamespaceTest extends
m_xc.insertNamespace("prefix", "value");
m_xc.toStartDoc();
XmlOptions map = new XmlOptions();
- map.put(XmlOptions.SAVE_NAMESPACES_FIRST, "");
+ map.setSaveNamespacesFirst();
assertEquals("<foo xmlns:prefix=\"value\" attr0=\"val0\" attr1=\"val1\">text</foo>", m_xc.xmlText(map));
}
Modified: xmlbeans/trunk/src/test/java/xmlcursor/detailed/XmlLineNumberTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlcursor/detailed/XmlLineNumberTest.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlcursor/detailed/XmlLineNumberTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlcursor/detailed/XmlLineNumberTest.java Fri Aug 28 20:49:50 2020
@@ -25,8 +25,7 @@ import java.io.File;
import static org.junit.Assert.*;
-public class XmlLineNumberTest extends Common
-{
+public class XmlLineNumberTest extends Common {
public static final String xml =
"<people><person born=\"1912\" died=\"1954\" id=\"p342\">\n" +
" <name>\n" +
@@ -38,11 +37,12 @@ public class XmlLineNumberTest extends C
public static final String xmlFile =
XBEAN_CASE_ROOT + P + "xmlcursor" + P + "Employees.xml";
- /** test obtaining XmlLineNumber bookmark with option
- XmlOptions.setLoadLineNumbers() */
+ /**
+ * test obtaining XmlLineNumber bookmark with option
+ * XmlOptions.setLoadLineNumbers()
+ */
@Test
- public void testGetBookmark1() throws Exception
- {
+ public void testGetBookmark1() throws Exception {
File f = new File(xmlFile);
XmlOptions opt = new XmlOptions();
opt.setLoadLineNumbers();
@@ -58,20 +58,20 @@ public class XmlLineNumberTest extends C
assertEquals(17, ln.getLine());
c.toEndToken();
assertEquals(XmlCursor.TokenType.END, c.currentTokenType());
- ln =(XmlLineNumber) c.getBookmark(XmlLineNumber.class);
+ ln = (XmlLineNumber) c.getBookmark(XmlLineNumber.class);
// no bookmark at END
assertNull(ln);
}
- /** test obtaining XmlLineNumber bookmark with option
- XmlOptions.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT)
- */
+ /**
+ * test obtaining XmlLineNumber bookmark with option
+ * XmlOptions.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT)
+ */
@Test
- public void testGetBookmark2() throws Exception
- {
+ public void testGetBookmark2() throws Exception {
File f = new File(xmlFile);
XmlOptions opt = new XmlOptions();
- opt.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT);
+ opt.setLoadLineNumbersEndElement();
XmlObject xo = XmlObject.Factory.parse(f, opt);
XmlCursor c = xo.newCursor();
c.toFirstChild();
@@ -90,11 +90,12 @@ public class XmlLineNumberTest extends C
assertEquals(34, ln.getLine());
}
- /** test using XmlLineNumber to get line number, column, and offset
- - parsing xml from string */
+ /**
+ * test using XmlLineNumber to get line number, column, and offset
+ * - parsing xml from string
+ */
@Test
- public void testLineNumber1() throws Exception
- {
+ public void testLineNumber1() throws Exception {
XmlOptions opt = new XmlOptions().setLoadLineNumbers();
XmlObject xo = XmlObject.Factory.parse(xml, opt);
XmlCursor c = xo.newCursor();
@@ -116,13 +117,15 @@ public class XmlLineNumberTest extends C
assertEquals(14, ln.getColumn());
}
- /** test using XmlLineNumber to get line number, column, and offset
- - parsing xml from file */
+ /**
+ * test using XmlLineNumber to get line number, column, and offset
+ * - parsing xml from file
+ */
@Test
public void testLineNumber2() throws Exception {
File f = new File(xmlFile);
XmlOptions opt = new XmlOptions();
- opt.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT);
+ opt.setLoadLineNumbersEndElement();
XmlObject xo = XmlObject.Factory.parse(f, opt);
XmlCursor c = xo.newCursor();
c.toFirstContentToken();
Modified: xmlbeans/trunk/src/test/java/xmlobject/checkin/InstanceValidationTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlobject/checkin/InstanceValidationTests.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlobject/checkin/InstanceValidationTests.java (original)
+++ xmlbeans/trunk/src/test/java/xmlobject/checkin/InstanceValidationTests.java Fri Aug 28 20:49:50 2020
@@ -1210,8 +1210,9 @@ public class InstanceValidationTests {
do {
XmlObject obj = c.getObject();
- if (obj != null)
+ if (obj != null) {
obj.validate();
+ }
} while (!c.toNextToken().isNone());
@@ -1239,8 +1240,9 @@ public class InstanceValidationTests {
do {
XmlObject obj = c.getObject();
- if (obj != null)
+ if (obj != null) {
obj.validate();
+ }
} while (!c.toNextToken().isNone());
}
@@ -1862,7 +1864,7 @@ public class InstanceValidationTests {
assertNotNull(docSchema);
- options.put(XmlOptions.DOCUMENT_TYPE, docSchema);
+ options.setDocumentType(docSchema);
}
for (int i = 0; i < validInstances.length; i++) {
@@ -1876,9 +1878,9 @@ public class InstanceValidationTests {
c.dispose();
}
- List xel = new ArrayList();
+ List<XmlError> xel = new ArrayList<>();
- options.put(XmlOptions.ERROR_LISTENER, xel);
+ options.setErrorListener(xel);
boolean isValid = x.validate(options);
@@ -1887,7 +1889,9 @@ public class InstanceValidationTests {
System.err.println("Instance(" + i + "): ");
System.err.println(x.xmlText());
System.err.println("Errors: ");
- for (Object o : xel) System.err.println(o);
+ for (Object o : xel) {
+ System.err.println(o);
+ }
System.err.println();
}
Modified: xmlbeans/trunk/src/test/java/xmlobject/checkin/ValidateTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlobject/checkin/ValidateTest.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlobject/checkin/ValidateTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlobject/checkin/ValidateTest.java Fri Aug 28 20:49:50 2020
@@ -31,31 +31,31 @@ public class ValidateTest extends BasicC
@Test
public void testValidateTrue() throws Exception {
//m_xo = XmlObject.Factory.parse(Common.XML_PURCHASEORDER);
- m_xo = XmlObject.Factory.parse(
- JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
+ m_xo = XmlObject.Factory.parse(
+ JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
assertTrue(m_xo.validate());
}
@Test
public void testValidateTrueWithOptionDiscardDocElement() throws Exception {
XmlOptions map = new XmlOptions();
- map.put(XmlOptions.LOAD_REPLACE_DOCUMENT_ELEMENT, null);
+ map.setLoadReplaceDocumentElement(null);
m_xo = XmlObject.Factory.parse(
- JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO)
- , map);
+ JarUtil.getResourceFromJar(Common.TRANXML_FILE_XMLCURSOR_PO)
+ , map);
assertFalse(m_xo.validate(map));
}
@Test
public void testValidateFalseFixedAttr() throws Exception {
- m_xo = XmlObject.Factory.parse(
- JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
- String ns="declare namespace po=\"http://xbean.test/xmlcursor/PurchaseOrder\";";
- String exp_ns="xmlns:po=\"http://xbean.test/xmlcursor/PurchaseOrder\"";
+ m_xo = XmlObject.Factory.parse(
+ JarUtil.getResourceFromJar("xbean/xmlcursor/po.xml"));
+ String ns = "declare namespace po=\"http://xbean.test/xmlcursor/PurchaseOrder\";";
+ String exp_ns = "xmlns:po=\"http://xbean.test/xmlcursor/PurchaseOrder\"";
m_xc = m_xo.newCursor();
- m_xc.selectPath(ns+" $this//po:shipTo");
+ m_xc.selectPath(ns + " $this//po:shipTo");
QName name = new QName("country");
m_xc.setAttributeText(name, "UK");
XmlObject xo = m_xc.getObject();
Modified: xmlbeans/trunk/src/test/java/xmlobject/xmlloader/detailed/ParseTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlobject/xmlloader/detailed/ParseTest.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlobject/xmlloader/detailed/ParseTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlobject/xmlloader/detailed/ParseTest.java Fri Aug 28 20:49:50 2020
@@ -33,11 +33,11 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertNotNull;
public class ParseTest extends BasicCursorTestCase {
- private XmlOptions m_map = new XmlOptions();
+ private final XmlOptions m_map = new XmlOptions();
@Test
public void testLoadStripWhitespace() throws Exception {
- m_map.put(XmlOptions.LOAD_STRIP_WHITESPACE, "");
+ m_map.setLoadStripWhitespace();
m_xo = XmlObject.Factory.parse("<foo>01234 <bar>text</bar> chars \r\n</foo> ",
m_map);
m_xc = m_xo.newCursor();
@@ -47,8 +47,7 @@ public class ParseTest extends BasicCurs
@Test
public void testLoadDiscardDocumentElement() throws Exception {
- QName name = new QName("");
- m_map.put(XmlOptions.LOAD_REPLACE_DOCUMENT_ELEMENT, name);
+ m_map.setLoadReplaceDocumentElement(new QName(""));
XmlObject.Factory.parse("<foo>01234 <bar>text</bar> chars </foo> ", m_map);
}
@@ -68,8 +67,8 @@ public class ParseTest extends BasicCurs
@Test
public void testParsingDOMWithDTD() throws Exception {
final String svgDocumentString = "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n" +
- "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" +
- "<svg />";
+ "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" +
+ "<svg />";
assertNotNull(XmlObject.Factory.parse(svgDocumentString));
final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Modified: xmlbeans/trunk/src/test/java/xmltokensource/detailed/NewDomNodeTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmltokensource/detailed/NewDomNodeTest.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmltokensource/detailed/NewDomNodeTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmltokensource/detailed/NewDomNodeTest.java Fri Aug 28 20:49:50 2020
@@ -24,6 +24,8 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import xmlcursor.common.BasicCursorTestCase;
+import javax.xml.namespace.QName;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -74,9 +76,9 @@ public class NewDomNodeTest extends Basi
public void testNewDomNodeWithOptions() throws Exception {
m_xo = XmlObject.Factory.parse("<foo attr=\"val\" xmlns=\"ns\">01234 <bar>text</bar> chars </foo>");
XmlOptions map = new XmlOptions();
- map.put(XmlOptions.LOAD_STRIP_WHITESPACE, "");
- map.put(XmlOptions.LOAD_REPLACE_DOCUMENT_ELEMENT, "");
- map.put(XmlOptions.SAVE_NAMESPACES_FIRST, "");
+ map.setLoadStripComments();
+ map.setLoadReplaceDocumentElement(new QName(""));
+ map.setSaveNamespacesFirst();
Node doc = m_xo.newDomNode(map);
assertEquals(DOC, doc.getNodeName());
NodeList nl = doc.getChildNodes();
Modified: xmlbeans/trunk/src/test/java/xmltokensource/detailed/RoundTripLoaderTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmltokensource/detailed/RoundTripLoaderTest.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmltokensource/detailed/RoundTripLoaderTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmltokensource/detailed/RoundTripLoaderTest.java Fri Aug 28 20:49:50 2020
@@ -38,8 +38,8 @@ public class RoundTripLoaderTest extends
@Before
public void setUp() {
- m_map.put(XmlOptions.CHARACTER_ENCODING, "Big5");
- m_map.put(XmlOptions.SAVE_NAMESPACES_FIRST, "");
+ m_map.setCharacterEncoding("Big5");
+ m_map.setSaveNamespacesFirst();
}
private void _newDomNodeRoundTrip(XmlOptions map) throws Exception {
@@ -95,7 +95,7 @@ public class RoundTripLoaderTest extends
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_NESTED_SIBLINGS);
Reader reader = m_xo.newReader(map);
assertNotNull(reader);
- XmlOptions options = new XmlOptions(map);
+ XmlOptions options = new XmlOptions(map);
XmlObject xo = XmlObject.Factory.parse(reader, options);
m_xc = m_xo.newCursor();
XmlCursor xc1 = xo.newCursor();
@@ -111,11 +111,11 @@ public class RoundTripLoaderTest extends
* on this release? Bug? store.Cursor._newXMLInputStream
* ericvasilik (3:26:01 PM): This is not a v2 feature. ...
* but otherwise, we should disable XMLInputStream tests
- *
+ * <p>
* public void testNewReaderRoundTrip() throws Exception {
* _newReaderRoundTrip(null);
* }
- *
+ * <p>
* public void testNewReaderWithOptionsRoundTrip() throws Exception {
* _newReaderRoundTrip(m_map);
* }
Modified: xmlbeans/trunk/src/test/java/xmltokensource/detailed/XmlTextTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmltokensource/detailed/XmlTextTest.java?rev=1881284&r1=1881283&r2=1881284&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmltokensource/detailed/XmlTextTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmltokensource/detailed/XmlTextTest.java Fri Aug 28 20:49:50 2020
@@ -37,9 +37,9 @@ public class XmlTextTest extends BasicCu
public void testSAVENAMESPACESFIRST() throws Exception {
m_xo = XmlObject.Factory.parse("<foo attr0=\"val0\" xmlns=\"http://www.foo.org\">01234</foo>");
m_xc = m_xo.newCursor();
- m_map.put(XmlOptions.SAVE_NAMESPACES_FIRST, "");
+ m_map.setSaveNamespacesFirst();
assertEquals("<foo xmlns=\"http://www.foo.org\" attr0=\"val0\">01234</foo>",
- m_xc.xmlText(m_map));
+ m_xc.xmlText(m_map));
}
@Test
@@ -47,15 +47,14 @@ public class XmlTextTest extends BasicCu
m_xo = XmlObject.Factory.parse("<foo attr0=\"val0\" xmlns=\"http://www.foo.org\">01234</foo>");
m_xc = m_xo.newCursor();
assertEquals("<foo attr0=\"val0\" xmlns=\"http://www.foo.org\">01234</foo>",
- m_xc.xmlText(m_map));
+ m_xc.xmlText(m_map));
}
@Test
public void testSaveSyntheticDocumentElement() throws Exception {
m_xo = XmlObject.Factory.parse("<bar>text</bar>");
m_xc = m_xo.newCursor();
- m_map.put(XmlOptions.SAVE_SYNTHETIC_DOCUMENT_ELEMENT,
- new QName("foo"));
+ m_map.setSaveSyntheticDocumentElement(new QName("foo"));
assertEquals("<foo><bar>text</bar></foo>", m_xc.xmlText(m_map));
}
@@ -63,7 +62,7 @@ public class XmlTextTest extends BasicCu
public void testSavePrettyPrint() throws Exception {
m_xo = XmlObject.Factory.parse("<a><b><c> text </c></b></a>");
m_xc = m_xo.newCursor();
- m_map.put(XmlOptions.SAVE_PRETTY_PRINT, "");
+ m_map.setSavePrettyPrint();
String lnSep = System.getProperty("line.separator");
assertEquals("<a>" + lnSep + " <b>" + lnSep + " <c> text </c>" + lnSep + " </b>" + lnSep + "</a>", m_xc.xmlText(m_map));
}
@@ -72,8 +71,8 @@ public class XmlTextTest extends BasicCu
public void testSavePrettyPrintIndent3() throws Exception {
m_xo = XmlObject.Factory.parse("<a><b><c> text </c></b></a>");
m_xc = m_xo.newCursor();
- m_map.put(XmlOptions.SAVE_PRETTY_PRINT, "");
- m_map.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, new Integer(3));
+ m_map.setSavePrettyPrint();
+ m_map.setSavePrettyPrintIndent(3);
String lnSep = System.getProperty("line.separator");
assertEquals("<a>" + lnSep + " <b>" + lnSep + " <c> text </c>" + lnSep + " </b>" + lnSep + "</a>", m_xc.xmlText(m_map));
}
@@ -81,34 +80,34 @@ public class XmlTextTest extends BasicCu
@Test
public void testSavePrettyPrintIndentNeg1() throws Exception {
m_xc = XmlObject.Factory.parse("<a> \n <b> \n <c> text </c> \n </b> \n </a>").newCursor();
- m_map.put(XmlOptions.SAVE_PRETTY_PRINT, "");
- m_map.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, new Integer(-1));
+ m_map.setSavePrettyPrint();
+ m_map.setSavePrettyPrintIndent(-1);
assertEquals("<a><b><c> text </c></b></a>", m_xc.xmlText(m_map));
}
@Test
public void testDefaultNamespace() throws Exception {
m_xo = XmlObject.Factory.parse(
- JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
+ JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
m_xc = m_xo.newCursor();
m_xc.selectPath(Common.CLM_NS_XQUERY_DEFAULT + "$this//FleetID");
m_xc.toNextSelection();
- m_map.put(XmlOptions.SAVE_NAMESPACES_FIRST, "");
+ m_map.setSaveNamespacesFirst();
assertEquals("<FleetID xmlns=\"" + Common.CLM_NS + "\" " +
Common.CLM_XSI_NS +
">FLEETNAME</FleetID>",
- m_xc.xmlText(m_map));
+ m_xc.xmlText(m_map));
}
@Test
public void testSTARTDOCvsFirstChild() throws Exception {
m_xo = XmlObject.Factory.parse(
- JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
+ JarUtil.getResourceFromJar(Common.TRANXML_FILE_CLM));
m_xc = m_xo.newCursor();
XmlCursor xc1 = m_xo.newCursor();
xc1.toFirstChild();
try {
- assertEquals(m_xc.xmlText().replaceFirst("(?s)<!--.*-->",""), xc1.xmlText());
+ assertEquals(m_xc.xmlText().replaceFirst("(?s)<!--.*-->", ""), xc1.xmlText());
} finally {
xc1.dispose();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org