Modified: xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/som/common/SomTestBase.java Sun Feb 6 01:51:55 2022 @@ -30,7 +30,6 @@ package compile.scomp.som.common; import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.tool.Diff; -import org.junit.Assert; import javax.xml.namespace.QName; import java.io.File; @@ -41,7 +40,7 @@ import java.util.Objects; import java.util.stream.Stream; import static common.Common.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class SomTestBase { public static String casesRootDir = XBEAN_CASE_ROOT + P + "compile" + P + "som" + P; @@ -65,51 +64,51 @@ public class SomTestBase { assertNotNull(schematypesys.getName()); // # of global attributes - assertEquals("Incorrect Number of Global Attributes in STS " + schematypesys.getName(), expectedGlobalAttrs, schematypesys.globalAttributes().length); + assertEquals(expectedGlobalAttrs, schematypesys.globalAttributes().length, "Incorrect Number of Global Attributes in STS " + schematypesys.getName()); for (SchemaGlobalAttribute sga : schematypesys.globalAttributes()) { assertNotNull(sga.getName()); assertNotNull(sga.getType()); } // # of global elements - assertEquals("Incorrect Number of Global Elements in STS " + schematypesys.getName(), expectedGlobalElems, schematypesys.globalElements().length); + assertEquals(expectedGlobalElems, schematypesys.globalElements().length, "Incorrect Number of Global Elements in STS " + schematypesys.getName()); for (SchemaGlobalElement sge : schematypesys.globalElements()) { assertNotNull(sge.getName()); assertNotNull(sge.getType()); } // # of global Types - assertEquals("Incorrect Number of Global Types in STS " + schematypesys.getName(), expectedGlobalTypes, schematypesys.globalTypes().length); + assertEquals(expectedGlobalTypes, schematypesys.globalTypes().length, "Incorrect Number of Global Types in STS " + schematypesys.getName()); for (SchemaType st : schematypesys.globalTypes()) { assertNotNull(st.getName()); } // # of attribute Groups - assertEquals("Incorrect Number of Attribute Groups in STS " + schematypesys.getName(), expectedAttrGroups, schematypesys.attributeGroups().length); + assertEquals(expectedAttrGroups, schematypesys.attributeGroups().length, "Incorrect Number of Attribute Groups in STS " + schematypesys.getName()); for (SchemaAttributeGroup sag : schematypesys.attributeGroups()) { assertNotNull(sag.getName()); assertNotNull(sag.getTypeSystem()); } - assertNotNull("Invalid Model Groups Collection returned in STS ", schematypesys.documentTypes()); + assertNotNull(schematypesys.documentTypes(), "Invalid Model Groups Collection returned in STS "); for (SchemaModelGroup smg : schematypesys.modelGroups()) { assertNotNull(smg.getName()); assertNotNull(smg.getTypeSystem()); } - assertNotNull("Invalid Annotations Collection returned in STS ", schematypesys.annotations()); + assertNotNull(schematypesys.annotations(), "Invalid Annotations Collection returned in STS "); for (SchemaAnnotation sa : schematypesys.annotations()) { assertTrue(Stream.of(sa.getApplicationInformation()).allMatch(Objects::nonNull)); assertTrue(Stream.of(sa.getUserInformation()).allMatch(Objects::nonNull)); } - assertNotNull("Invalid Attribute Types Collection returned in STS ", schematypesys.attributeTypes()); + assertNotNull(schematypesys.attributeTypes(), "Invalid Attribute Types Collection returned in STS "); for (SchemaType st : schematypesys.attributeTypes()) { assertTrue(st.isAnonymousType() || st.getName() != null); assertNotNull(st.getTypeSystem()); } - assertNotNull("Invalid Document Types Collection returned in STS ", schematypesys.documentTypes()); + assertNotNull(schematypesys.documentTypes(), "Invalid Document Types Collection returned in STS "); for (SchemaType st : schematypesys.documentTypes()) { assertTrue(st.isAnonymousType() || st.getName() != null); assertNotNull(st.getTypeSystem()); @@ -248,7 +247,7 @@ public class SomTestBase { String sFileWithPath = casesRootDir + P + sFileName; //System.out.println("getTestCaseFile() Opening File : " + sFileWithPath); File schemaFile = new File(sFileWithPath); - Assert.assertNotNull("Schema File " + sFileWithPath + " Loading failed", schemaFile); + assertNotNull(schemaFile, "Schema File " + sFileWithPath + " Loading failed"); return (schemaFile); } @@ -287,14 +286,14 @@ public class SomTestBase { if (sBaseSourceName != null) { xsdModifiedObj.documentProperties().setSourceName(sBaseSourceName); } - Assert.assertNotNull("Xml Object creation failed", xsdModifiedObj); + assertNotNull(xsdModifiedObj, "Xml Object creation failed"); XmlObject[] xobjArr = new XmlObject[]{xsdModifiedObj}; SchemaTypeSystem returnSTS = XmlBeans.compileXmlBeans(sSTSName, baseSchema, xobjArr, null, builtin, null, options); - Assert.assertNotNull("Schema Type System created is Null.", returnSTS); + assertNotNull(returnSTS, "Schema Type System created is Null."); // validate the XmlObject created - assertTrue("Return Value for Validate()", xsdModifiedObj.validate()); + assertTrue(xsdModifiedObj.validate(), "Return Value for Validate()"); return returnSTS; } @@ -304,9 +303,9 @@ public class SomTestBase { for (File file : Objects.requireNonNull(dirToClean.listFiles())) { if (file.isDirectory()) { deleteDirRecursive(file); - assertTrue("Output Directory " + file + " Deletion Failed ", file.delete()); + assertTrue(file.delete(), "Output Directory " + file + " Deletion Failed "); } else if (file.isFile()) { - assertTrue("Output File " + file + " Deletion Failed ", file.delete()); + assertTrue(file.delete(), "Output File " + file + " Deletion Failed "); } } }
Modified: xmlbeans/trunk/src/test/java/compile/scomp/som/detailed/PartialSOMDetailedTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/som/detailed/PartialSOMDetailedTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/compile/scomp/som/detailed/PartialSOMDetailedTest.java (original) +++ xmlbeans/trunk/src/test/java/compile/scomp/som/detailed/PartialSOMDetailedTest.java Sun Feb 6 01:51:55 2022 @@ -19,23 +19,23 @@ import org.apache.xmlbeans.SchemaTypeSys import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +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.IOException; import java.util.ArrayList; import java.util.Date; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class PartialSOMDetailedTest extends SomTestBase { // inherited methods - @Before + @BeforeEach public void setUp() throws Exception { // initialize the built in schema type builtin = XmlBeans.getBuiltinTypeSystem(); @@ -59,13 +59,13 @@ public class PartialSOMDetailedTest exte deleteDirRecursive(new File(somOutputRootDir)); } - @After + @AfterEach public void tearDown() { errors.clear(); } @Test - public void testAddDataTypesList() throws IOException, XmlException { + void testAddDataTypesList() throws IOException, XmlException { System.out.println("Inside test case testAddDataTypesList()"); // Step 1 : create a PSOM from an incomplete/invalid xsd (datatypes.xsd) with unresolved references to various types @@ -74,31 +74,26 @@ public class PartialSOMDetailedTest exte null, "BaseSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // recovearble errors should exist - assertTrue("No Recovered Errors for Invalid Schema", - printRecoveredErrors()); + assertTrue(printRecoveredErrors(), "No Recovered Errors for Invalid Schema"); // Walk thro the SOM (pass #Elems, #Attr, #Types, #AttrGroups) inspectSOM(baseSTS, 12, 1, 4, 1); // Test for saving of the PSOM - should not be able to save - assertFalse("Partial SOM " + baseSTS.getName() + "Save successful - should fail!", - checkPSOMSave(baseSTS)); + assertFalse(checkPSOMSave(baseSTS), "Partial SOM " + baseSTS.getName() + "Save successful - should fail!"); // instance validation - should fail - assertFalse("Validation against instance Success - should fail ", - validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS)); + assertFalse(validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS), "Validation against instance Success - should fail "); // validate unresolved types - the ListType should resolve to 'anyType' - assertEquals("Unresolved List Type should be 'anyType'", - anyType, - getElementType(baseSTS, "testListTypeElem")); + assertEquals(anyType, getElementType(baseSTS, "testListTypeElem"), "Unresolved List Type should be 'anyType'"); } @Test - public void testDeleteReusableGroups() throws IOException, XmlException { + void testDeleteReusableGroups() throws IOException, XmlException { System.out.println("Inside test case testDeleteSubstitutionGroups()"); // Step 1: read in a clean XSD groups_added.xsd @@ -107,80 +102,67 @@ public class PartialSOMDetailedTest exte null, "BaseSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // there should be NO recovearble errors - assertFalse("Recovered Errors for Valid Schema", - printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "Recovered Errors for Valid Schema"); // the tests - Walk thro the valid SOM inspectSOM(baseSTS, 7, 0, 5, 1); // Test for saving of the SOM - should go thro - assertTrue("SOM " + baseSTS.getName() + "Save failed!", - checkPSOMSave(baseSTS)); + assertTrue(checkPSOMSave(baseSTS), "SOM " + baseSTS.getName() + "Save failed!"); // instance validation - should be ok - assertTrue("Validation against instance failed", - validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS)); + assertTrue(validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS), "Validation against instance failed"); // verify named model groups - assertTrue("Attribute Group 'AttributeGroup' should exist", - getAttributeGroup(baseSTS, "AttributeGroup")); - assertTrue("Model Group 'NamedModelGroup' should exist", - getModelGroup(baseSTS, "NamedModelGroup")); + assertTrue(getAttributeGroup(baseSTS, "AttributeGroup"), "Attribute Group 'AttributeGroup' should exist"); + assertTrue(getModelGroup(baseSTS, "NamedModelGroup"), "Model Group 'NamedModelGroup' should exist"); // step2: load an invalid PSOM by deleting the ModelGroup and AttributeGroup definitions commented SchemaTypeSystem modifiedSTS = createNewSTS("reusable_grps.xsd_", baseSTS, "ModifiedSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", modifiedSTS); + assertNotNull(modifiedSTS, "Schema Type System created is Null."); // Recovered Errors, Test for saving of the SOM printRecoveredErrors(); - assertFalse("SOM " + modifiedSTS.getName() + "Save Success - should fail!", - checkPSOMSave(modifiedSTS)); + assertFalse(checkPSOMSave(modifiedSTS), "SOM " + modifiedSTS.getName() + "Save Success - should fail!"); // the tests - Walk thro the valid SOM inspectSOM(modifiedSTS, 7, 0, 5, 0); // instance validation - should fail - assertFalse("Validation against instance failed", - validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS)); + assertFalse(validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS), "Validation against instance failed"); // named model groups - assertFalse("Attribute Group 'AttributeGroup' should not exist", - getAttributeGroup(modifiedSTS, "AttributeGroup")); - assertFalse("Model Group 'NamedModelGroup' should not exist", - getModelGroup(modifiedSTS, "NamedModelGroup")); + assertFalse(getAttributeGroup(modifiedSTS, "AttributeGroup"), "Attribute Group 'AttributeGroup' should not exist"); + assertFalse(getModelGroup(modifiedSTS, "NamedModelGroup"), "Model Group 'NamedModelGroup' should not exist"); // step 3: create a PSOM with the original xsd SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd_", modifiedSTS, "FinalSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", finalSTS); + assertNotNull(finalSTS, "Schema Type System created is Null."); // Test for saving of the SOM - should go thro - assertTrue("SOM " + finalSTS.getName() + "Save failed!", - checkPSOMSave(finalSTS)); + assertTrue(checkPSOMSave(finalSTS), "SOM " + finalSTS.getName() + "Save failed!"); // instance validation - should be ok - assertTrue("Validation against instance failed", - validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), finalSTS)); + assertTrue(validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), finalSTS), "Validation against instance failed"); // verify named model groups types - assertTrue("Attribute Group 'AttributeGroup' should exist", - getAttributeGroup(baseSTS, "AttributeGroup")); - assertTrue("Model Group 'NamedModelGroup' should exist", - getModelGroup(baseSTS, "NamedModelGroup")); + assertTrue(getAttributeGroup(baseSTS, "AttributeGroup"), "Attribute Group 'AttributeGroup' should exist"); + assertTrue(getModelGroup(baseSTS, "NamedModelGroup"), "Model Group 'NamedModelGroup' should exist"); // compare this to the original schema here assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS")); } @Test - public void testModifyDataTypesList() throws IOException, XmlException { + void testModifyDataTypesList() throws IOException, XmlException { System.out.println("Inside test case testModifyDataTypes()"); // 1. remove one of the constituent types for the union and test to see if union is anySimpleType @@ -191,33 +173,24 @@ public class PartialSOMDetailedTest exte null, "BaseSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // there should be NO recovearble errors - assertFalse("Recovered Errors for Valid Schema", - printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "Recovered Errors for Valid Schema"); // the tests - Walk thro the valid SOM inspectSOM(baseSTS, 13, 1, 15, 1); // Recovered Errors, Test for saving of the SOM - should go thro - assertTrue("SOM " + baseSTS.getName() + "Save failed!", - checkPSOMSave(baseSTS)); + assertTrue(checkPSOMSave(baseSTS), "SOM " + baseSTS.getName() + "Save failed!"); // instance validation - should be ok - assertTrue("Validation against instance failed", - validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS)); + assertTrue(validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS), "Validation against instance failed"); // check types before modify - assertEquals("Unresolved Simple Type should be 'attachmentTypes'", - "attachmentTypes", - getElementType(baseSTS, "testAtomicTypeElem")); - assertEquals("Unresolved List Type should be 'attchmentExtensionListTypes'", - "attchmentExtensionListTypes", - getElementType(baseSTS, "testListTypeElem")); - assertEquals("Unresolved Simple Type should be 'union.attachmentUnionType", - "union.attachmentUnionType", - getElementType(baseSTS, "testUnionTypeElem")); + assertEquals("attachmentTypes", getElementType(baseSTS, "testAtomicTypeElem"), "Unresolved Simple Type should be 'attachmentTypes'"); + assertEquals("attchmentExtensionListTypes", getElementType(baseSTS, "testListTypeElem"), "Unresolved List Type should be 'attchmentExtensionListTypes'"); + assertEquals("union.attachmentUnionType", getElementType(baseSTS, "testUnionTypeElem"), "Unresolved Simple Type should be 'union.attachmentUnionType"); //Step 2 : modify types from the schema - should result in STS with unresolved refs @@ -225,67 +198,53 @@ public class PartialSOMDetailedTest exte baseSTS, "ModifiedSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", modifiedSTS); + assertNotNull(modifiedSTS, "Schema Type System created is Null."); // test the PSOM created :walk thro the PSOM, look for # of elements,attributes,types & attribute groups inspectSOM(modifiedSTS, 13, 1, 13, 1); // Test for saving of the PSOM - should not be able to save - assertFalse("PSOM " + modifiedSTS.getName() + " Save should fail", - checkPSOMSave(modifiedSTS)); + assertFalse(checkPSOMSave(modifiedSTS), "PSOM " + modifiedSTS.getName() + " Save should fail"); // validate unresolved types // list and union types are of type "anyType" and not "anySimpleType // https://stackoverflow.com/questions/37801268/what-are-the-restrictions-of-xsdanysimpletype-on-xsdanytype-and-where-are-the - assertEquals("Unresolved Simple Type - Atomic should be 'anyType'", - anyType, - getElementType(modifiedSTS, "testAtomicTypeElem")); - assertEquals("Unresolved List Type should be 'anyType'", - anyType, - getElementType(modifiedSTS, "testListTypeElem")); + assertEquals(anyType, getElementType(modifiedSTS, "testAtomicTypeElem"), "Unresolved Simple Type - Atomic should be 'anyType'"); + assertEquals(anyType, getElementType(modifiedSTS, "testListTypeElem"), "Unresolved List Type should be 'anyType'"); // assertEquals("Unresolved Simple Type - Union should be 'anySimpleType'", // anySimpleType, // getElementType(modifiedSTS, "testUnionTypeElem")); // validate against an xml valid instance - should fail - assertFalse("Validation against instance should Failed ", - validateInstance(getTestCaseFile("instance_simple_types_invalid.xml"), modifiedSTS)); + assertFalse(validateInstance(getTestCaseFile("instance_simple_types_invalid.xml"), modifiedSTS), "Validation against instance should Failed "); // step 3: reload the original STS SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd_", modifiedSTS, "FinalSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", finalSTS); + assertNotNull(finalSTS, "Schema Type System created is Null."); // walk the SOM inspectSOM(finalSTS, 13, 1, 15, 1); // validate successful save - assertTrue("SOM " + finalSTS.getName() + "Save failed", - checkPSOMSave(finalSTS)); // should be able to save as its a valid SOM + assertTrue(checkPSOMSave(finalSTS), "SOM " + finalSTS.getName() + "Save failed"); // should be able to save as its a valid SOM // validate instance - should validate - assertTrue("Validation against instance Failed ", - validateInstance(getTestCaseFile("instance_simple_types_valid.xml"), finalSTS)); + assertTrue(validateInstance(getTestCaseFile("instance_simple_types_valid.xml"), finalSTS), "Validation against instance Failed "); // check types after modify - assertEquals("Unresolved Simple Type should be 'attachmentTypes'", - "attachmentTypes", - getElementType(finalSTS, "testAtomicTypeElem")); - assertEquals("Unresolved List Type should be 'attchmentExtensionListTypes'", - "attchmentExtensionListTypes", - getElementType(finalSTS, "testListTypeElem")); - assertEquals("Unresolved Simple Type should be 'union.attachmentUnionType", - "union.attachmentUnionType", - getElementType(finalSTS, "testUnionTypeElem")); + assertEquals("attachmentTypes", getElementType(finalSTS, "testAtomicTypeElem"), "Unresolved Simple Type should be 'attachmentTypes'"); + assertEquals("attchmentExtensionListTypes", getElementType(finalSTS, "testListTypeElem"), "Unresolved List Type should be 'attchmentExtensionListTypes'"); + assertEquals("union.attachmentUnionType", getElementType(finalSTS, "testUnionTypeElem"), "Unresolved Simple Type should be 'union.attachmentUnionType"); // compare this to the original schema here assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS")); } @Test - public void testDeleteDerivedTypes() throws IOException, XmlException { + void testDeleteDerivedTypes() throws IOException, XmlException { System.out.println("Inside test case testDeleteDerivedTypes()"); // Step 1: read in a clean XSD derived_types_added.xsd with base and derived types to create a base schema with no unresolved components @@ -294,59 +253,51 @@ public class PartialSOMDetailedTest exte null, "BaseSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // there should be NO recovearble errors - assertFalse("Recovered Errors for Valid Schema", - printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "Recovered Errors for Valid Schema"); // the tests - Walk thro the valid SOM inspectSOM(baseSTS, 13, 0, 14, 0); // Recovered Errors, Test for saving of the SOM - should go thro - assertTrue("Valid SOM " + baseSTS.getName() + "Save failed!", - checkPSOMSave(baseSTS)); + assertTrue(checkPSOMSave(baseSTS), "Valid SOM " + baseSTS.getName() + "Save failed!"); // instance validation - should be ok - assertTrue("Validation against instance failed", - validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), baseSTS)); + assertTrue(validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), baseSTS), "Validation against instance failed"); // check types before deletion of base types - assertEquals("Elem Type should be 'RestrictionSimpleContentBaseType'", - "RestrictionSimpleContentBaseType", getElementType(baseSTS, "RestrictionSimpleContentBaseTypeElem")); + assertEquals("RestrictionSimpleContentBaseType", getElementType(baseSTS, "RestrictionSimpleContentBaseTypeElem"), "Elem Type should be 'RestrictionSimpleContentBaseType'"); // Step 2: create invalid PSOM with base type removed SchemaTypeSystem modifiedSTS = createNewSTS("derived_types.xsd_", baseSTS, "ModifiedSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", modifiedSTS); + assertNotNull(modifiedSTS, "Schema Type System created is Null."); // recovearble errors - assertTrue("No Recovered Errors for Invalid PSOM", - printRecoveredErrors()); + assertTrue(printRecoveredErrors(), "No Recovered Errors for Invalid PSOM"); // the tests - Walk thro the valid SOM inspectSOM(modifiedSTS, 13, 0, 9, 0); // Recovered Errors, Test for saving of the SOM - assertFalse("SOM " + modifiedSTS.getName() + "Save Success - should fail!", checkPSOMSave(modifiedSTS)); + assertFalse(checkPSOMSave(modifiedSTS), "SOM " + modifiedSTS.getName() + "Save Success - should fail!"); // instance validation - should fail - assertFalse("Validation against instance failed", - validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS)); + assertFalse(validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS), "Validation against instance failed"); // check types - base should be 'anyType' // Restriction Complex Content Base type commented - assertEquals("Elem Type should be 'anyType'", - anyType, - getElementType(modifiedSTS, "RestrictionBaseComplexContentTypeElem")); + assertEquals(anyType, getElementType(modifiedSTS, "RestrictionBaseComplexContentTypeElem"), "Elem Type should be 'anyType'"); } @Test - public void testModifyReusableGroups() throws IOException, XmlException { + void testModifyReusableGroups() throws IOException, XmlException { System.out.println("Inside test case testModifyReusableGroups()"); // Step 1: read in a clean XSD groups_added.xsd @@ -355,86 +306,71 @@ public class PartialSOMDetailedTest exte null, "BaseSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // there should be NO recovearble errors - assertFalse("Recovered Errors for Valid Schema", - printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "Recovered Errors for Valid Schema"); // the tests - Walk thro the valid SOM inspectSOM(baseSTS, 7, 0, 5, 2); // Test for saving of the SOM - should go thro - assertTrue("SOM " + baseSTS.getName() + "Save failed!", - checkPSOMSave(baseSTS)); + assertTrue(checkPSOMSave(baseSTS), "SOM " + baseSTS.getName() + "Save failed!"); // instance validation - should be ok - assertTrue("Validation against instance failed", - validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS)); + assertTrue(validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS), "Validation against instance failed"); // verify named model groups - assertTrue("Model Group 'NamedModelGroup' should exist ", - getModelGroup(baseSTS, "NamedModelGroup")); - assertTrue("Attribute Group 'AttributeGroup' should exist", - getAttributeGroup(baseSTS, "AttributeGroup")); + assertTrue(getModelGroup(baseSTS, "NamedModelGroup"), "Model Group 'NamedModelGroup' should exist "); + assertTrue(getAttributeGroup(baseSTS, "AttributeGroup"), "Attribute Group 'AttributeGroup' should exist"); // step2: load a modified xsd with type of head elem in subs grp changed SchemaTypeSystem modifiedSTS = createNewSTS("reusable_grps_modified.xsd_", baseSTS, "ModifiedSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", modifiedSTS); + assertNotNull(modifiedSTS, "Schema Type System created is Null."); // Recovered Errors, Test for saving of the SOM , invalid since grp definitions are commented out printRecoveredErrors(); - assertFalse("SOM " + modifiedSTS.getName() + "Save Success - should fail!", - checkPSOMSave(modifiedSTS)); + assertFalse(checkPSOMSave(modifiedSTS), "SOM " + modifiedSTS.getName() + "Save Success - should fail!"); // the tests - Walk thro the valid SOM inspectSOM(modifiedSTS, 7, 0, 5, 1); // instance validation - should fail - assertFalse("Validation against instance failed", - validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS)); + assertFalse(validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS), "Validation against instance failed"); // verify named model groups - assertEquals("Elem Type should be 'ModelGrpType'", - "ModelGrpType", - getElementType(modifiedSTS, "ModelGrpTypeElem")); - assertTrue("Elem Type should be 'AttributeGroup'", - getAttributeGroup(modifiedSTS, "AttributeGroup")); + assertEquals("ModelGrpType", getElementType(modifiedSTS, "ModelGrpTypeElem"), "Elem Type should be 'ModelGrpType'"); + assertTrue(getAttributeGroup(modifiedSTS, "AttributeGroup"), "Elem Type should be 'AttributeGroup'"); // step3 : reload the original xsd SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd_", modifiedSTS, "FinalSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", finalSTS); + assertNotNull(finalSTS, "Schema Type System created is Null."); // Test for saving of the SOM - should go thro - assertTrue("SOM " + finalSTS.getName() + "Save failed!", - checkPSOMSave(finalSTS)); + assertTrue(checkPSOMSave(finalSTS), "SOM " + finalSTS.getName() + "Save failed!"); // instance validation - should be ok - assertTrue("Validation against instance failed", - validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), finalSTS)); + assertTrue(validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), finalSTS), "Validation against instance failed"); // the tests - Walk thro the valid SOM inspectSOM(finalSTS, 7, 0, 5, 2); // verify named model groups - assertEquals("Elem Type should be 'ModelGrpType'", - "ModelGrpType", - getElementType(finalSTS, "ModelGrpTypeElem")); - assertTrue("Elem Type should be 'AttributeGroup'", - getAttributeGroup(finalSTS, "AttributeGroup")); + assertEquals("ModelGrpType", getElementType(finalSTS, "ModelGrpTypeElem"), "Elem Type should be 'ModelGrpType'"); + assertTrue(getAttributeGroup(finalSTS, "AttributeGroup"), "Elem Type should be 'AttributeGroup'"); // compare this to the original schema here assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS")); } @Test - public void testModifyDerivedTypes() throws IOException, XmlException { + void testModifyDerivedTypes() throws IOException, XmlException { System.out.println("Inside test case testModifyDerivedTypes()"); // Step 1: read in a clean XSD derived_types_added.xsd @@ -443,65 +379,38 @@ public class PartialSOMDetailedTest exte null, "BaseSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // there should be NO recovearble errors - assertFalse("Recovered Errors for Valid Schema", - printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "Recovered Errors for Valid Schema"); // the tests - Walk thro the valid SOM inspectSOM(baseSTS, 13, 0, 14, 0); // Recovered Errors, Test for saving of the SOM - should go thro - assertTrue("Valid SOM " + baseSTS.getName() + "Save failed!", - checkPSOMSave(baseSTS)); + assertTrue(checkPSOMSave(baseSTS), "Valid SOM " + baseSTS.getName() + "Save failed!"); // instance validation - should be ok - assertTrue("Validation against instance failed", - validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), baseSTS)); + assertTrue(validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), baseSTS), "Validation against instance failed"); // check types before deletion of base types - assertEquals("Elem Type should be 'ExtensionBaseType' (base)", - "ExtensionBaseType", - getElementType(baseSTS, "ExtensionBaseTypeElem")); - assertEquals("Elem Type should be 'ExtensionDerivedComplexContentType' (derived)", - "ExtensionDerivedComplexContentType", - getElementType(baseSTS, "ExtensionDerivedComplexContentTypeElem")); - - assertEquals("Elem Type should be 'ExtensionBaseMixedContentType' (base)", - "ExtensionBaseMixedContentType", - getElementType(baseSTS, "ExtensionBaseMixedContentTypElem")); - assertEquals("Elem Type should be 'ExtensionDerivedMixedContentType' (derived)", - "ExtensionDerivedMixedContentType", - getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem")); - - assertEquals("Elem Type should be 'RestrictionSimpleContentBaseType'", - "RestrictionSimpleContentBaseType", - getElementType(baseSTS, "RestrictionSimpleContentBaseTypeElem")); - assertEquals("Elem Type should be 'RestrictionSimpleContentDerivedType'", - "RestrictionSimpleContentDerivedType", - getElementType(baseSTS, "RestrictionSimpleContentDerivedTypeElem")); - - assertEquals("Elem Type should be 'RestrictionBaseComplexContentType'", - "RestrictionBaseComplexContentType", - getElementType(baseSTS, "RestrictionBaseComplexContentTypeElem")); - assertEquals("Elem Type should be 'RestrictionDerivedComplexContentType'", - "RestrictionDerivedComplexContentType", - getElementType(baseSTS, "RestrictionDerivedComplexContentTypeElem")); - - assertEquals("Elem Type should be 'RestrictionBaseMixedContentType'", - "RestrictionBaseMixedContentType", - getElementType(baseSTS, "RestrictionBaseMixedContentTypeElem")); - assertEquals("Elem Type should be 'RestrictionDerivedMixedContentType'", - "RestrictionDerivedMixedContentType", - getElementType(baseSTS, "RestrictionDerivedMixedContentTypeElem")); - - assertEquals("Elem Type should be 'RestrictionBaseEmptyContentType'", - "RestrictionBaseEmptyContentType", - getElementType(baseSTS, "RestrictionBaseEmptyContentTypeElem")); - assertEquals("Elem Type should be 'RestrictionDerivedEmptyContentType'", - "RestrictionDerivedEmptyContentType", - getElementType(baseSTS, "RestrictionDerivedEmptyContentTypeElem")); + assertEquals("ExtensionBaseType", getElementType(baseSTS, "ExtensionBaseTypeElem"), "Elem Type should be 'ExtensionBaseType' (base)"); + assertEquals("ExtensionDerivedComplexContentType", getElementType(baseSTS, "ExtensionDerivedComplexContentTypeElem"), "Elem Type should be 'ExtensionDerivedComplexContentType' (derived)"); + + assertEquals("ExtensionBaseMixedContentType", getElementType(baseSTS, "ExtensionBaseMixedContentTypElem"), "Elem Type should be 'ExtensionBaseMixedContentType' (base)"); + assertEquals("ExtensionDerivedMixedContentType", getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem"), "Elem Type should be 'ExtensionDerivedMixedContentType' (derived)"); + + assertEquals("RestrictionSimpleContentBaseType", getElementType(baseSTS, "RestrictionSimpleContentBaseTypeElem"), "Elem Type should be 'RestrictionSimpleContentBaseType'"); + assertEquals("RestrictionSimpleContentDerivedType", getElementType(baseSTS, "RestrictionSimpleContentDerivedTypeElem"), "Elem Type should be 'RestrictionSimpleContentDerivedType'"); + + assertEquals("RestrictionBaseComplexContentType", getElementType(baseSTS, "RestrictionBaseComplexContentTypeElem"), "Elem Type should be 'RestrictionBaseComplexContentType'"); + assertEquals("RestrictionDerivedComplexContentType", getElementType(baseSTS, "RestrictionDerivedComplexContentTypeElem"), "Elem Type should be 'RestrictionDerivedComplexContentType'"); + + assertEquals("RestrictionBaseMixedContentType", getElementType(baseSTS, "RestrictionBaseMixedContentTypeElem"), "Elem Type should be 'RestrictionBaseMixedContentType'"); + assertEquals("RestrictionDerivedMixedContentType", getElementType(baseSTS, "RestrictionDerivedMixedContentTypeElem"), "Elem Type should be 'RestrictionDerivedMixedContentType'"); + + assertEquals("RestrictionBaseEmptyContentType", getElementType(baseSTS, "RestrictionBaseEmptyContentTypeElem"), "Elem Type should be 'RestrictionBaseEmptyContentType'"); + assertEquals("RestrictionDerivedEmptyContentType", getElementType(baseSTS, "RestrictionDerivedEmptyContentTypeElem"), "Elem Type should be 'RestrictionDerivedEmptyContentType'"); // step 2 : change the base types now : derived_types_modified.xsd @@ -509,18 +418,17 @@ public class PartialSOMDetailedTest exte baseSTS, "ModifiedSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", modifiedSTS); + assertNotNull(modifiedSTS, "Schema Type System created is Null."); // no recovearble errors just added another type - assertFalse("valid PSOM", printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "valid PSOM"); // the tests - Walk thro the valid SOM //inspectSOM(modifiedSTS, 13, 0, 14, 0); inspectSOM(modifiedSTS, 13, 0, 17, 0); // instance validation - should fail - assertFalse("Validation against instance success - should fail", - validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS)); + assertFalse(validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS), "Validation against instance success - should fail"); // now validate instance with new base type - this should go thro // TODO resolve this validation @@ -530,7 +438,7 @@ public class PartialSOMDetailedTest exte } @Test - public void testNameSpacesImportFile() throws IOException, XmlException { + void testNameSpacesImportFile() throws IOException, XmlException { System.out.println("Inside test case testNameSpacesImportFile()"); // Step 1: read in an xsd that imports from another xsd file providing file name only @@ -543,14 +451,14 @@ public class PartialSOMDetailedTest exte "BaseSchemaTS", null); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // there should be NO recovearble errors this should not be a partial Schema - assertFalse("Recovered Errors for Valid Schema", printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "Recovered Errors for Valid Schema"); } @Test - public void testNameSpacesWithInclude() throws IOException, XmlException { + void testNameSpacesWithInclude() throws IOException, XmlException { System.out.println("Inside test case testNameSpacesWithInclude()"); // Step 1: read in an xsd that includes another namespace in xsd file namespaces2.xsd @@ -560,13 +468,13 @@ public class PartialSOMDetailedTest exte "BaseSchemaTS", null); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // there should be NO recovearble errors - this should not be a partial Schema - assertFalse("Recovered Errors for Valid Schema", printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "Recovered Errors for Valid Schema"); // Test for saving of the SOM - should go thro - assertTrue("Valid SOM " + baseSTS.getName() + "Save failed!", checkPSOMSave(baseSTS)); + assertTrue(checkPSOMSave(baseSTS), "Valid SOM " + baseSTS.getName() + "Save failed!"); // the tests - Walk thro the valid SOM inspectSOM(baseSTS, 2, 0, 1, 0); @@ -575,7 +483,7 @@ public class PartialSOMDetailedTest exte } @Test - @Ignore + @Disabled public void testNameSpacesImportFileWithPath() throws IOException, XmlException { System.out.println("Inside test case testNameSpacesImportFileWithPath()"); @@ -586,13 +494,13 @@ public class PartialSOMDetailedTest exte "BaseSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", baseSTS); + assertNotNull(baseSTS, "Schema Type System created is Null."); // there should be NO recovearble errors - this should not be a partial Schema - assertFalse("Recovered Errors for Valid Schema", printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "Recovered Errors for Valid Schema"); // Test for saving of the SOM - should go thro - assertTrue("Valid SOM " + baseSTS.getName() + "Save failed!", checkPSOMSave(baseSTS)); + assertTrue(checkPSOMSave(baseSTS), "Valid SOM " + baseSTS.getName() + "Save failed!"); // the tests - Walk thro the valid SOM inspectSOM(baseSTS, 1, 0, 0, 0); @@ -602,10 +510,10 @@ public class PartialSOMDetailedTest exte baseSTS, "ModifiedSchemaTS", sBaseSourceName); - assertNotNull("Schema Type System created is Null.", modifiedSTS); + assertNotNull(modifiedSTS, "Schema Type System created is Null."); // no recovearble errors just added another type - assertFalse("valid PSOM", printRecoveredErrors()); + assertFalse(printRecoveredErrors(), "valid PSOM"); // the tests - Walk thro the valid SOM inspectSOM(modifiedSTS, 2, 0, 1, 0); Modified: xmlbeans/trunk/src/test/java/dom/checkin/AttributeSyncTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/AttributeSyncTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/AttributeSyncTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/AttributeSyncTest.java Sun Feb 6 01:51:55 2022 @@ -17,10 +17,10 @@ package dom.checkin; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public class AttributeSyncTest extends AttributeTest { - @Before + @BeforeEach public void setUp() throws Exception { super.loadSync(); super.moveToNode(); Modified: xmlbeans/trunk/src/test/java/dom/checkin/AttributeTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/AttributeTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/AttributeTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/AttributeTest.java Sun Feb 6 01:51:55 2022 @@ -19,95 +19,96 @@ package dom.checkin; import dom.common.DomUtils; import dom.common.NodeWithChildrenTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class AttributeTest extends NodeWithChildrenTest { public AttributeTest() { String sDTD = "<?xml version=\"1.0\"?>" + - "<!DOCTYPE foodoc [" + - "<!ELEMENT foo>" + - "<!ATTLIST foo at_spec CDATA \"0\">" + - "]>"; + "<!DOCTYPE foodoc [" + + "<!ELEMENT foo>" + + "<!ATTLIST foo at_spec CDATA \"0\">" + + "]>"; sXml = "<foo xmlns:extra=\"bea.org\" xmlns:myns=\"uri:foo\" at0=\"val0\" myns:at0=\"val01\" at2=\"val2\" at3=\"val3\" at4=\"val4\">some text</foo>"; - if (bDTD) + if (bDTD) { sXml = sDTD + sXml; + } sXmlNS = - "<foo xmlns:myns=\"uri:foo\" at0=\"val0\" myns:at0=\"val01\" at2=\"val2\" at3=\"val3\" at4=\"val4\"/>"; + "<foo xmlns:myns=\"uri:foo\" at0=\"val0\" myns:at0=\"val01\" at2=\"val2\" at3=\"val3\" at4=\"val4\"/>"; } @Test - public void testNodeName() { + void testNodeName() { String sExpected = "myns:at0"; assertEquals(sExpected, m_node.getNodeName()); } @Test - public void testGetName() { + void testGetName() { String sExpected = "myns:at0"; assertEquals(sExpected, ((Attr) m_node).getName()); } @Test - public void testNodeType() { + void testNodeType() { assertEquals(Node.ATTRIBUTE_NODE, m_node.getNodeType()); } @Test - public void testNodeValue() { + void testNodeValue() { assertEquals("val01", m_node.getNodeValue()); } //following are null here @Test - public void testNextSibling() { - assertEquals(null, m_node.getNextSibling()); + void testNextSibling() { + assertNull(m_node.getNextSibling()); } @Test - public void testPreviousSibling() { - assertEquals(null, m_node.getPreviousSibling()); + void testPreviousSibling() { + assertNull(m_node.getPreviousSibling()); } @Test - public void testParent() { - assertEquals(null, m_node.getParentNode()); + void testParent() { + assertNull(m_node.getParentNode()); } @Test - public void testPrefix() { + protected void testPrefix() { assertEquals("myns", m_node.getPrefix()); } @Test - public void testNamespaceUri() { + protected void testNamespaceUri() { assertEquals("uri:foo", m_node.getNamespaceURI()); } @Test - public void testLocalName() { + protected void testLocalName() { assertEquals("at0", m_node.getLocalName()); } @Test - public void testAppendChild() { + protected void testAppendChild() { //elt Node newChild = m_doc.createElement("foo"); try { m_node.appendChild(newChild); - fail("Cannot append an element children to attributes " + - m_node.getChildNodes().getLength()); - } - catch (DOMException de) { + Assertions.fail("Cannot append an element children to attributes " + + m_node.getChildNodes().getLength()); + } catch (DOMException de) { assertEquals(DOMException.HIERARCHY_REQUEST_ERR, de.code); } @@ -122,32 +123,31 @@ public class AttributeTest extends NodeW } @Test - public void testCloneNode() { - Attr cloned, - cloned1; + protected void testCloneNode() { + Attr cloned, cloned1; cloned = (Attr) m_node.cloneNode(true); - assertEquals(true, DomUtils.compareNodesDeep(m_node, cloned)); - assertEquals(false, m_node == cloned); + assertTrue(DomUtils.compareNodesDeep(m_node, cloned)); + assertNotSame(m_node, cloned); -//TODO + // TODO cloned1 = (Attr) m_node.cloneNode(false); - // assertEquals(m_node.getChildNodes(), ); - assertEquals(true, DomUtils.compareNodesShallow(m_node, cloned)); + // assertEquals(m_node.getChildNodes(), ); + assertTrue(DomUtils.compareNodesShallow(m_node, cloned)); if (bDTD) { - assertEquals(false, cloned.getSpecified()); - assertEquals(false, ((Attr) m_node).getSpecified()); + assertFalse(cloned.getSpecified()); + assertFalse(((Attr) m_node).getSpecified()); m_node = m_doc.getAttributes().getNamedItem("at_spec"); cloned = (Attr) m_node.cloneNode(true); cloned1 = (Attr) m_node.cloneNode(false); assertEquals(cloned, cloned1); - assertEquals(true, m_node.equals(cloned)); - assertEquals(false, m_node == cloned); - assertEquals(true, cloned.getSpecified()); - assertEquals(false, ((Attr) m_node).getSpecified()); + assertEquals(m_node, cloned); + assertNotSame(m_node, cloned); + assertTrue(cloned.getSpecified()); + assertFalse(((Attr) m_node).getSpecified()); } } @@ -167,22 +167,22 @@ public class AttributeTest extends NodeW * } */ @Test - public void testGetChildNodes() { + protected void testGetChildNodes() { assertEquals(1, m_node.getChildNodes().getLength()); } @Test - public void testFirstChild() { + protected void testFirstChild() { assertEquals("val01", ((Text) m_node.getFirstChild()).getData()); } @Test - public void testLastChild() { + protected void testLastChild() { assertEquals("val01", ((Text) m_node.getLastChild()).getData()); } @Test - public void testInsertBefore() { + protected void testInsertBefore() { Node newChild = m_doc.createElement("foo"); assertEquals(1, m_node.getChildNodes().getLength()); @@ -190,8 +190,7 @@ public class AttributeTest extends NodeW try { m_node.insertBefore(newChild, textNode); - } - catch (DOMException de) { + } catch (DOMException de) { assertEquals(DOMException.HIERARCHY_REQUEST_ERR, de.code); } @@ -202,7 +201,7 @@ public class AttributeTest extends NodeW } @Test - public void testRemoveChild() { + void testRemoveChild() { //attr w/o a value Element owner = (Element) ((Attr) m_node).getOwnerElement(); m_node.removeChild(m_node.getFirstChild()); @@ -211,33 +210,33 @@ public class AttributeTest extends NodeW } @Test - public void testReplaceChild() { + void testReplaceChild() { //assertFalse(m_node.hasChildNodes()); Node newChild = m_doc.createElement("foo"); assertEquals(1, m_node.getChildNodes().getLength()); try { m_node.replaceChild(newChild, m_node.getFirstChild()); - fail("can not put an element under an attr"); - } - catch (DOMException de) { + Assertions.fail("can not put an element under an attr"); + } catch (DOMException de) { assertEquals(DOMException.HIERARCHY_REQUEST_ERR, de.code); } newChild = m_doc.createTextNode("realnewval"); assertEquals(1, m_node.getChildNodes().getLength()); m_node.replaceChild(newChild, m_node.getFirstChild()); - if (!"realnewval".equals(((Attr) m_node).getValue())) - fail(" Expected realnewval but got " + ((Attr) m_node).getValue()); + if (!"realnewval".equals(((Attr) m_node).getValue())) { + Assertions.fail(" Expected realnewval but got " + ((Attr) m_node).getValue()); + } } @Test - public void testGetOwnerElement() { + void testGetOwnerElement() { assertEquals("foo", ((Attr) m_node).getOwnerElement().getLocalName()); - Node newNode = m_doc.createAttributeNS("foo1:org", "name"); - assertEquals(null, ((Attr) newNode).getOwnerElement()); + Attr newNode = m_doc.createAttributeNS("foo1:org", "name"); + assertNull(newNode.getOwnerElement()); newNode = m_doc.createAttribute("name"); - assertEquals(null, ((Attr) newNode).getOwnerElement()); + assertNull(newNode.getOwnerElement()); } /*Not implem @@ -251,31 +250,31 @@ public class AttributeTest extends NodeW } */ @Test - public void testSetValue() { + void testSetValue() { String newVal = "new<spec\u042Fchar"; ((Attr) m_node).setValue(newVal); assertEquals(newVal, ((Attr) m_node).getValue()); } @Test - public void testSetValueNull() { + void testSetValueNull() { ((Attr) m_node).setValue("foo"); String newVal = ""; ((Attr) m_node).setValue(newVal); - assertEquals(true, ((Attr) m_node).hasChildNodes()); + assertTrue(((Attr) m_node).hasChildNodes()); newVal = null; ((Attr) m_node).setValue(newVal); - assertEquals(true, ((Attr) m_node).hasChildNodes()); + assertTrue(((Attr) m_node).hasChildNodes()); } @Test - public void testGetValue() { + void testGetValue() { assertEquals("val01", ((Attr) m_node).getValue()); } @Test - public void testInsertBeforeDocFrag() { + protected void testInsertBeforeDocFrag() { DocumentFragment child = m_doc.createDocumentFragment(); child.appendChild(m_doc.createTextNode("foo1")); Node target = m_node.getFirstChild(); @@ -283,15 +282,14 @@ public class AttributeTest extends NodeW } @Test - public void testAppendChildDocFrag() { + protected void testAppendChildDocFrag() { DocumentFragment child = m_doc.createDocumentFragment(); child.appendChild(m_doc.createTextNode("foo")); super.testAppendChild(child); - } @Test - public void testReplaceChildDocFrag() { + protected void testReplaceChildDocFrag() { DocumentFragment child = m_doc.createDocumentFragment(); child.appendChild(m_doc.createElement("foo")); @@ -299,22 +297,20 @@ public class AttributeTest extends NodeW Node toReplace = m_node.getFirstChild(); try { super.testReplaceChild(child, toReplace); - fail("cannot insert element in attr"); - } - catch (DOMException de) { + Assertions.fail("cannot insert element in attr"); + } catch (DOMException de) { assertEquals(DOMException.HIERARCHY_REQUEST_ERR, de.code); } } @Test - public void testInsertBeforeNullTarget() { + protected void testInsertBeforeNullTarget() { Node child = m_doc.createElementNS("org.foo.www", "foonode"); try { super.testInsertBefore(child, null); - fail("cannot insert element in attr"); - } - catch (DOMException de) { + Assertions.fail("cannot insert element in attr"); + } catch (DOMException de) { assertEquals(DOMException.HIERARCHY_REQUEST_ERR, de.code); } child = m_doc.createTextNode("foonode"); @@ -322,25 +318,24 @@ public class AttributeTest extends NodeW } @Test - public void testInsertExistingNode() { - Node toInsert=m_doc.getFirstChild(); + void testInsertExistingNode() { + Node toInsert = m_doc.getFirstChild(); //elt under attr try { super.testInsertExistingNode(toInsert); - fail("Shouldn't work for attrs"); - } - catch (DOMException de) { + Assertions.fail("Shouldn't work for attrs"); + } catch (DOMException de) { assertEquals(DOMException.HIERARCHY_REQUEST_ERR, de.code); } toInsert = m_doc.getFirstChild().getFirstChild(); //some text - super.testInsertBefore(toInsert, m_node.getFirstChild()); + super.testInsertBefore(toInsert, m_node.getFirstChild()); assertEquals("some text", m_node.getFirstChild().getNodeValue()); assertEquals(2, m_node.getChildNodes().getLength()); } @Test - public void testSetNodeValue() { + void testSetNodeValue() { m_node.appendChild(m_doc.createTextNode("bar"));//attr w/ two values int nCount = m_node.getChildNodes().getLength(); m_node.setNodeValue("blah"); @@ -349,16 +344,17 @@ public class AttributeTest extends NodeW } @Test - public void testAppendChildExisting() { + void testAppendChildExisting() { Node child = m_doc.getFirstChild().getFirstChild();//some text - if (child == m_node) + if (child == m_node) { child = m_doc.getLastChild(); + } //if still the same, SOL super.testAppendChild(child); } @Test - public void testSetPrefix() { + protected void testSetPrefix() { String newPrefix = "yana"; //should clear it m_node.setPrefix(newPrefix); assertEquals("yana:at0", m_node.getNodeName()); @@ -373,45 +369,41 @@ public class AttributeTest extends NodeW } @Test - public void testInsertBeforeInvalidRefNode() { + void testInsertBeforeInvalidRefNode() { Node child = m_doc.createTextNode("foonode"); Node target = m_doc.createElement("foo"); try { super.testInsertBefore(child, target); - fail("Insert cannot happen"); - } - catch (DOMException de) { + Assertions.fail("Insert cannot happen"); + } catch (DOMException de) { System.err.println(de.getMessage() + " " + de.code); assertEquals(DOMException.NOT_FOUND_ERR, de.code); } } @Test - public void testDomLevel1() { + void testDomLevel1() { Attr at = m_doc.createAttribute("foobar"); - assertNull("L1 prefix null", at.getPrefix()); - assertNull("L1 LocalName null", at.getLocalName()); - assertNull("L1 Uri null", at.getNamespaceURI()); - try - { + assertNull(at.getPrefix(), "L1 prefix null"); + assertNull(at.getLocalName(), "L1 LocalName null"); + assertNull(at.getNamespaceURI(), "L1 Uri null"); + try { at.setPrefix("foo"); - fail("L1 prefix null"); - } - catch (DOMException de) - { + Assertions.fail("L1 prefix null"); + } catch (DOMException de) { assertEquals(DOMException.NAMESPACE_ERR, de.code); } } @Test - public void moveToNode() { + void moveToNode() { m_node = m_doc.getFirstChild(); m_node = ((Element) m_node).getAttributeNodeNS("uri:foo", "at0"); assertEquals("val01", m_node.getNodeValue()); assertTrue(m_node instanceof Attr); } - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); moveToNode(); Modified: xmlbeans/trunk/src/test/java/dom/checkin/CDataSectionSyncTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/CDataSectionSyncTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/CDataSectionSyncTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/CDataSectionSyncTest.java Sun Feb 6 01:51:55 2022 @@ -15,11 +15,10 @@ package dom.checkin; - -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public class CDataSectionSyncTest extends CDataSectionTest { - @Before + @BeforeEach public void setUp() throws Exception { super.loadSync(); super.moveToNode(); Modified: xmlbeans/trunk/src/test/java/dom/checkin/CDataSectionTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/CDataSectionTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/CDataSectionTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/CDataSectionTest.java Sun Feb 6 01:51:55 2022 @@ -16,12 +16,12 @@ package dom.checkin; import dom.common.CharacterDataTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.CDATASection; import org.w3c.dom.Node; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CDataSectionTest extends CharacterDataTest { @@ -41,43 +41,42 @@ sXml="<script>"+ } @Test - public void testNodeName() { + void testNodeName() { assertEquals("#cdata-section", m_node.getNodeName()); } @Test - public void testNodeType() { + void testNodeType() { assertEquals(Node.CDATA_SECTION_NODE, m_node.getNodeType()); } @Test - public void testNodeValue() { - assertEquals("function matchwo(a,b){\"+\n\t \"return 0 }", - m_node.getNodeValue()); + void testNodeValue() { + assertEquals("function matchwo(a,b){\"+\n\t \"return 0 }", m_node.getNodeValue()); } @Test - public void testNextSibling() { + void testNextSibling() { Node nxtSibling = m_node.getNextSibling(); assertEquals("foobar", nxtSibling.getNodeValue()); } @Test - public void testPreviousSibling() { + void testPreviousSibling() { Node prSibling = m_node.getPreviousSibling(); assertEquals(null, prSibling); } @Test - public void testParent() { + void testParent() { Node parent = m_node.getParentNode(); assertEquals(m_doc.getFirstChild(), parent); assertEquals("script", parent.getLocalName()); } @Test - public void testSetNodeValue() { + void testSetNodeValue() { m_node.setNodeValue("new CDATA"); assertEquals("new CDATA", m_node.getNodeValue()); } @@ -93,7 +92,7 @@ sXml="<script>"+ } - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); moveToNode(); Modified: xmlbeans/trunk/src/test/java/dom/checkin/CommentSyncTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/CommentSyncTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/CommentSyncTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/CommentSyncTest.java Sun Feb 6 01:51:55 2022 @@ -16,12 +16,11 @@ package dom.checkin; - -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public class CommentSyncTest extends CommentTest { - @Before + @BeforeEach public void setUp() throws Exception { super.loadSync(); super.moveToNode(); Modified: xmlbeans/trunk/src/test/java/dom/checkin/CommentTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/CommentTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/CommentTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/CommentTest.java Sun Feb 6 01:51:55 2022 @@ -17,13 +17,13 @@ package dom.checkin; import dom.common.CharacterDataTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Node; import org.w3c.dom.Text; import xmlcursor.common.Common; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CommentTest extends CharacterDataTest { @@ -35,24 +35,22 @@ public class CommentTest extends Charact } @Test - public void testNodeName() { + void testNodeName() { assertEquals("#comment", m_node.getNodeName()); } @Test - public void testNodeValue() { - System.out.println("Comment testNodeValue"); + void testNodeValue() { assertEquals(" comment text ", m_node.getNodeValue()); - System.out.println("Comment testNodeValue DONE"); } @Test - public void testNodeType() { + void testNodeType() { assertEquals(Node.COMMENT_NODE, m_node.getNodeType()); } @Test - public void testNextSibling() { + void testNextSibling() { Node nxtSibling = m_node.getNextSibling(); assertEquals("foo", nxtSibling.getLocalName()); assertEquals(m_doc.getChildNodes().item(1), nxtSibling); @@ -61,19 +59,19 @@ public class CommentTest extends Charact } @Test - public void testPreviousSibling() { + void testPreviousSibling() { Node prSibling = m_node.getPreviousSibling(); assertEquals(null, prSibling); } @Test - public void testParent() { + void testParent() { Node parent = m_node.getParentNode(); assertEquals(m_doc, parent); } @Test - public void testSetNodeValue() { + void testSetNodeValue() { m_node.setNodeValue("new comment"); assertEquals("new comment", m_doc.getFirstChild().getNodeValue()); } @@ -84,7 +82,7 @@ public class CommentTest extends Charact } - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); moveToNode(); Modified: xmlbeans/trunk/src/test/java/dom/checkin/DirtyCacheTests.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/DirtyCacheTests.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/DirtyCacheTests.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/DirtyCacheTests.java Sun Feb 6 01:51:55 2022 @@ -16,7 +16,7 @@ package dom.checkin; import org.apache.xmlbeans.XmlCursor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Node; import xbean.dom.complexTypeTest.ElementT; import xbean.dom.complexTypeTest.EltTypeDocument; @@ -26,12 +26,12 @@ import xbean.dom.dumbNS.RootDocument; import java.math.BigInteger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class DirtyCacheTests { @Test - public void testDirtyValue() throws Exception { + void testDirtyValue() throws Exception { EltTypeDocument o = EltTypeDocument.Factory.newInstance(); ElementT t = o.addNewEltType(); t.setChild1(new BigInteger("30")); @@ -47,7 +47,7 @@ public class DirtyCacheTests { } @Test - public void testDirtyValue1() throws Exception { + void testDirtyValue1() throws Exception { MixedTypeDocument o = MixedTypeDocument.Factory.newInstance(); MixedT testElt = o.addNewMixedType(); assertNull(testElt.getChild1()); @@ -74,7 +74,7 @@ public class DirtyCacheTests { } @Test - public void testDirtyValue2() throws Exception { + void testDirtyValue2() throws Exception { RootDocument o = RootDocument.Factory.newInstance(); RootDocument.Root testElt = o.addNewRoot(); testElt.setB(new BigInteger("5")); Modified: xmlbeans/trunk/src/test/java/dom/checkin/DocumentFragmentSyncTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/DocumentFragmentSyncTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/DocumentFragmentSyncTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/DocumentFragmentSyncTest.java Sun Feb 6 01:51:55 2022 @@ -16,11 +16,10 @@ package dom.checkin; - -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public class DocumentFragmentSyncTest extends DocumentFragmentTest { - @Before + @BeforeEach public void setUp() throws Exception { super.loadSync(); super.moveToNode(); Modified: xmlbeans/trunk/src/test/java/dom/checkin/DocumentFragmentTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/DocumentFragmentTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/DocumentFragmentTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/DocumentFragmentTest.java Sun Feb 6 01:51:55 2022 @@ -17,11 +17,11 @@ package dom.checkin; import dom.common.NodeWithChildrenTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Node; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DocumentFragmentTest extends NodeWithChildrenTest { @@ -37,53 +37,53 @@ public class DocumentFragmentTest extend } @Test - public void testNodeName() { + void testNodeName() { assertEquals("#document-fragment", m_node.getNodeName()); } @Test - public void testNodeType() { + void testNodeType() { assertEquals(Node.DOCUMENT_FRAGMENT_NODE, m_node.getNodeType()); } @Test - public void testNodeValue() { + void testNodeValue() { assertNull(m_node.getNodeValue()); } @Test - public void testNextSibling() { + void testNextSibling() { assertNull(m_node.getNextSibling()); } @Test - public void testPreviousSibling() { + void testPreviousSibling() { assertNotNull(m_node); assertNull(m_node.getPreviousSibling()); } @Test - public void testParent() { + void testParent() { assertNull(m_node.getParentNode()); } @Test - public void testGetChildNodes() { + protected void testGetChildNodes() { assertEquals(1, m_node.getChildNodes().getLength()); } @Test - public void testFirstChild() { + protected void testFirstChild() { assertEquals("foo", m_node.getFirstChild().getNodeName()); } @Test - public void testLastChild() { + protected void testLastChild() { assertEquals("foo", m_node.getLastChild().getNodeName()); } @Test - public void testInsertExisitingNode() { + void testInsertExisitingNode() { Node child = m_doc.getFirstChild().getFirstChild();//some text if (child == m_node) child = m_doc.getLastChild(); @@ -91,21 +91,21 @@ public class DocumentFragmentTest extend } @Test - public void testAppendChildExisting() { + void testAppendChildExisting() { Node child = m_doc.getFirstChild().getFirstChild();//some text if (child == m_node) child = m_doc.getLastChild(); //if still the same, SOL super.testAppendChildExisting(child); } - + public void moveToNode() { m_node = m_doc.createDocumentFragment(); m_node.appendChild(m_doc.createElement("foo")); } - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); moveToNode(); Modified: xmlbeans/trunk/src/test/java/dom/checkin/DocumentSyncTest.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/dom/checkin/DocumentSyncTest.java?rev=1897795&r1=1897794&r2=1897795&view=diff ============================================================================== --- xmlbeans/trunk/src/test/java/dom/checkin/DocumentSyncTest.java (original) +++ xmlbeans/trunk/src/test/java/dom/checkin/DocumentSyncTest.java Sun Feb 6 01:51:55 2022 @@ -15,12 +15,11 @@ package dom.checkin; - -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public class DocumentSyncTest extends DocumentTest { - @Before + @BeforeEach public void setUp() throws Exception { super.loadSync(); super.moveToNode(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org