diff --git a/modello-plugins/modello-plugin-converters/src/test/java/org/codehaus/modello/plugin/converters/ConverterGeneratorTest.java b/modello-plugins/modello-plugin-converters/src/test/java/org/codehaus/modello/plugin/converters/ConverterGeneratorTest.java index 7b4d9db92..9db6cca97 100644 --- a/modello-plugins/modello-plugin-converters/src/test/java/org/codehaus/modello/plugin/converters/ConverterGeneratorTest.java +++ b/modello-plugins/modello-plugin-converters/src/test/java/org/codehaus/modello/plugin/converters/ConverterGeneratorTest.java @@ -54,12 +54,9 @@ public void testConverterGenerator() throws Throwable { generateConverterClasses(getXmlResourceReader("/features.mdo"), "1.0.0", "1.1.0"); - addDependency("org.codehaus.woodstox", "stax2-api"); - addDependency("com.fasterxml.woodstox", "woodstox-core"); - compileGeneratedSources(); - verifyCompiledGeneratedSources("ConvertersVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.converters.ConvertersVerifier"); } private void generateConverterClasses(Reader modelReader, String fromVersion, String toVersion) throws Throwable { diff --git a/modello-plugins/modello-plugin-converters/src/test/verifiers/converters/ConvertersVerifier.java b/modello-plugins/modello-plugin-converters/src/test/verifiers/converters/ConvertersVerifier.java index a1d664c3b..482a4e56b 100644 --- a/modello-plugins/modello-plugin-converters/src/test/verifiers/converters/ConvertersVerifier.java +++ b/modello-plugins/modello-plugin-converters/src/test/verifiers/converters/ConvertersVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.converters; + /* * Copyright (c) 2004, Codehaus.org * diff --git a/modello-plugins/modello-plugin-dom4j/src/test/java/org/codehaus/modello/plugin/dom4j/Dom4jGeneratorTest.java b/modello-plugins/modello-plugin-dom4j/src/test/java/org/codehaus/modello/plugin/dom4j/Dom4jGeneratorTest.java index 0a7351679..41ef1b342 100644 --- a/modello-plugins/modello-plugin-dom4j/src/test/java/org/codehaus/modello/plugin/dom4j/Dom4jGeneratorTest.java +++ b/modello-plugins/modello-plugin-dom4j/src/test/java/org/codehaus/modello/plugin/dom4j/Dom4jGeneratorTest.java @@ -93,8 +93,6 @@ public void testDom4jGenerator() throws Throwable { modello.generate(model, "dom4j-writer", parameters); modello.generate(model, "dom4j-reader", parameters); - addDependency("dom4j", "dom4j"); - compileGeneratedSources(); verifyCompiledGeneratedSources("org.codehaus.modello.generator.xml.dom4j.Dom4jVerifier"); diff --git a/modello-plugins/modello-plugin-dom4j/src/test/java/org/codehaus/modello/plugin/dom4j/FeaturesDom4jGeneratorTest.java b/modello-plugins/modello-plugin-dom4j/src/test/java/org/codehaus/modello/plugin/dom4j/FeaturesDom4jGeneratorTest.java index 36bff4fd9..911012c8b 100644 --- a/modello-plugins/modello-plugin-dom4j/src/test/java/org/codehaus/modello/plugin/dom4j/FeaturesDom4jGeneratorTest.java +++ b/modello-plugins/modello-plugin-dom4j/src/test/java/org/codehaus/modello/plugin/dom4j/FeaturesDom4jGeneratorTest.java @@ -54,8 +54,6 @@ public void testJavaGenerator() throws Throwable { modello.generate(model, "dom4j-writer", parameters); modello.generate(model, "dom4j-reader", parameters); - addDependency("dom4j", "dom4j"); - addDependency("org.xmlunit", "xmlunit-core"); compileGeneratedSources(8); verifyCompiledGeneratedSources("org.codehaus.modello.generator.xml.dom4j.Dom4jFeaturesVerifier"); diff --git a/modello-plugins/modello-plugin-jackson/src/test/java/org/codehaus/modello/plugin/jackson/JacksonGeneratorTest.java b/modello-plugins/modello-plugin-jackson/src/test/java/org/codehaus/modello/plugin/jackson/JacksonGeneratorTest.java index fd9e1d196..19edfa9e5 100644 --- a/modello-plugins/modello-plugin-jackson/src/test/java/org/codehaus/modello/plugin/jackson/JacksonGeneratorTest.java +++ b/modello-plugins/modello-plugin-jackson/src/test/java/org/codehaus/modello/plugin/jackson/JacksonGeneratorTest.java @@ -65,10 +65,6 @@ public void testJacksonGenerator() throws Throwable { modello.generate(model, "jackson-writer", parameters); modello.generate(model, "jackson-reader", parameters); - addDependency("com.fasterxml.jackson.core", "jackson-core"); - addDependency("com.fasterxml.jackson.core", "jackson-databind"); - // looks like jackson-databind requires jackson-annotations to run... - addDependency("com.fasterxml.jackson.core", "jackson-annotations"); compileGeneratedSources(8); // TODO: see why without this, version system property is set to "2.4.1" value after verify diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/AnnotationsJavaGeneratorTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/AnnotationsJavaGeneratorTest.java index 18f637a7c..a9d9146e3 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/AnnotationsJavaGeneratorTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/AnnotationsJavaGeneratorTest.java @@ -52,10 +52,8 @@ public void testJavaGeneratorWithAnnotations() throws Throwable { modello.generate(model, "java", parameters); - addDependency("javax.xml.bind", "jaxb-api"); - addDependency("javax.persistence", "persistence-api"); compileGeneratedSources(8); - verifyCompiledGeneratedSources("AnnotationsVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.AnnotationsVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/AssociationGeneratorTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/AssociationGeneratorTest.java index c527ccc26..b09db3616 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/AssociationGeneratorTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/AssociationGeneratorTest.java @@ -54,6 +54,6 @@ public void testJavaGenerator() throws Throwable { compileGeneratedSources(); - verifyCompiledGeneratedSources("OneToManyAssociationVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.OneToManyAssociationVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/BiDirectionalOverrideJavaGeneratorTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/BiDirectionalOverrideJavaGeneratorTest.java index 76f40b3d0..9c869502f 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/BiDirectionalOverrideJavaGeneratorTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/BiDirectionalOverrideJavaGeneratorTest.java @@ -50,6 +50,6 @@ public void testJavaGenerator() throws Throwable { compileGeneratedSources(); - verifyCompiledGeneratedSources("JavaVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.BidirectionalJavaVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/FeaturesJava5GeneratorTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/FeaturesJava5GeneratorTest.java index 2f06238af..b3e81b1e1 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/FeaturesJava5GeneratorTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/FeaturesJava5GeneratorTest.java @@ -54,6 +54,6 @@ public void testJavaGenerator() throws Throwable { compileGeneratedSources("features", 8); - verifyCompiledGeneratedSources("JavaVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.FeaturesJavaVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/FeaturesVersionJavaGeneratorTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/FeaturesVersionJavaGeneratorTest.java index 682e55d05..c3fde8cb3 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/FeaturesVersionJavaGeneratorTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/FeaturesVersionJavaGeneratorTest.java @@ -64,6 +64,6 @@ public void testJavaGenerator() throws Throwable { compileGeneratedSources(); - verifyCompiledGeneratedSources("JavaVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.FeaturesVersionJavaVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/InterfaceAssociationTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/InterfaceAssociationTest.java index b0c837d79..7c4e2737b 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/InterfaceAssociationTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/InterfaceAssociationTest.java @@ -29,6 +29,6 @@ public void testJavaGenerator() throws Throwable { compileGeneratedSources(8); - verifyCompiledGeneratedSources("InterfaceAssociationVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.InterfaceAssociationVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/JavaGeneratorTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/JavaGeneratorTest.java index 515de9f8c..363c2cb76 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/JavaGeneratorTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/JavaGeneratorTest.java @@ -54,6 +54,6 @@ public void testJavaGenerator() throws Throwable { compileGeneratedSources(); - verifyCompiledGeneratedSources("JavaVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.JavaVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/LocationsJavaGeneratorTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/LocationsJavaGeneratorTest.java index 74c19e5f6..e8d7c11bc 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/LocationsJavaGeneratorTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/LocationsJavaGeneratorTest.java @@ -54,6 +54,6 @@ public void testLocations() throws Throwable { compileGeneratedSources(8); - verifyCompiledGeneratedSources("JavaLocationsVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.JavaLocationsVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/PackageVersionJavaTest.java b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/PackageVersionJavaTest.java index 13c99077d..4b2847ad7 100644 --- a/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/PackageVersionJavaTest.java +++ b/modello-plugins/modello-plugin-java/src/test/java/org/codehaus/modello/plugin/java/PackageVersionJavaTest.java @@ -56,6 +56,6 @@ public void testThatTheCorrectVersionIsInThePackageName() throws Throwable { compileGeneratedSources(); - verifyCompiledGeneratedSources("PackageVersionVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.java.PackageVersionVerifier"); } } diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/annotations/AnnotationsVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/annotations/AnnotationsVerifier.java index cae847b22..2b69df8ea 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/annotations/AnnotationsVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/annotations/AnnotationsVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + import java.lang.annotation.Annotation; /* diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/bidirectional/JavaVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/bidirectional/BidirectionalJavaVerifier.java similarity index 91% rename from modello-plugins/modello-plugin-java/src/test/verifiers/bidirectional/JavaVerifier.java rename to modello-plugins/modello-plugin-java/src/test/verifiers/bidirectional/BidirectionalJavaVerifier.java index e7737d468..3c255623a 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/bidirectional/JavaVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/bidirectional/BidirectionalJavaVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + import org.codehaus.modello.plugin.java.Role; import org.codehaus.modello.tests.bidiroverride.BiRole; import org.codehaus.modello.verifier.Verifier; @@ -6,7 +8,7 @@ import java.util.List; -public class JavaVerifier +public class BidirectionalJavaVerifier extends Verifier { public void verify() diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/features-version/JavaVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/features-version/FeaturesVersionJavaVerifier.java similarity index 95% rename from modello-plugins/modello-plugin-java/src/test/verifiers/features-version/JavaVerifier.java rename to modello-plugins/modello-plugin-java/src/test/verifiers/features-version/FeaturesVersionJavaVerifier.java index d86844129..4e638037a 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/features-version/JavaVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/features-version/FeaturesVersionJavaVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + /* * Copyright (c) 2004, Codehaus.org * @@ -28,7 +30,7 @@ /** * @author Herve Boutemy */ -public class JavaVerifier +public class FeaturesVersionJavaVerifier extends Verifier { public void verify() diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/features/JavaVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/features/FeaturesJavaVerifier.java similarity index 99% rename from modello-plugins/modello-plugin-java/src/test/verifiers/features/JavaVerifier.java rename to modello-plugins/modello-plugin-java/src/test/verifiers/features/FeaturesJavaVerifier.java index 447d7c3bd..9564020b3 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/features/JavaVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/features/FeaturesJavaVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + /* * Copyright (c) 2004, Codehaus.org * @@ -68,7 +70,7 @@ /** * @author Herve Boutemy */ -public class JavaVerifier +public class FeaturesJavaVerifier extends Verifier { public void verify() diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/interfaceAssociationTest/InterfaceAssociationVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/interfaceAssociationTest/InterfaceAssociationVerifier.java index 1e12512f7..5ed6ac41f 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/interfaceAssociationTest/InterfaceAssociationVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/interfaceAssociationTest/InterfaceAssociationVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + import org.junit.jupiter.api.Assertions; import org.codehaus.modello.ifaceassociation.package1.IPerson; diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/java/JavaVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/java/JavaVerifier.java index aeffa4b81..c3ef6d4df 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/java/JavaVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/java/JavaVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + /* * Copyright (c) 2004, Codehaus.org * diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/locations/JavaLocationsVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/locations/JavaLocationsVerifier.java index f5eaa071d..91f9a8f13 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/locations/JavaLocationsVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/locations/JavaLocationsVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + /* * Copyright (c) 2004, Codehaus.org * diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/oneToManyAssociation/OneToManyAssociationVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/oneToManyAssociation/OneToManyAssociationVerifier.java index 4b574a7b8..eff940107 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/oneToManyAssociation/OneToManyAssociationVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/oneToManyAssociation/OneToManyAssociationVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + import org.codehaus.modello.association.package1.ListSetMapProperties; import org.codehaus.modello.association.package1.Person; import org.codehaus.modello.association.package2.Location; diff --git a/modello-plugins/modello-plugin-java/src/test/verifiers/packageversion/PackageVersionVerifier.java b/modello-plugins/modello-plugin-java/src/test/verifiers/packageversion/PackageVersionVerifier.java index a63dc60aa..6efa2e5fe 100644 --- a/modello-plugins/modello-plugin-java/src/test/verifiers/packageversion/PackageVersionVerifier.java +++ b/modello-plugins/modello-plugin-java/src/test/verifiers/packageversion/PackageVersionVerifier.java @@ -1,3 +1,5 @@ +package org.codehaus.modello.generator.java; + /* * Copyright (c) 2004, Codehaus.org * diff --git a/modello-plugins/modello-plugin-jdom/src/test/java/org/codehaus/modello/plugin/jdom/FeaturesJDOMGeneratorTest.java b/modello-plugins/modello-plugin-jdom/src/test/java/org/codehaus/modello/plugin/jdom/FeaturesJDOMGeneratorTest.java index 903bd2fb4..0653faf8c 100644 --- a/modello-plugins/modello-plugin-jdom/src/test/java/org/codehaus/modello/plugin/jdom/FeaturesJDOMGeneratorTest.java +++ b/modello-plugins/modello-plugin-jdom/src/test/java/org/codehaus/modello/plugin/jdom/FeaturesJDOMGeneratorTest.java @@ -54,8 +54,6 @@ public void testJavaGenerator() throws Throwable { modello.generate(model, "stax-reader", parameters); modello.generate(model, "jdom-writer", parameters); - addDependency("org.jdom", "jdom"); - addDependency("org.xmlunit", "xmlunit-core"); compileGeneratedSources(); verifyCompiledGeneratedSources("org.codehaus.modello.generator.xml.jdom.JDOMFeaturesVerifier"); diff --git a/modello-plugins/modello-plugin-jdom/src/test/java/org/codehaus/modello/plugin/jdom/RootClassnameJDOMGeneratorTest.java b/modello-plugins/modello-plugin-jdom/src/test/java/org/codehaus/modello/plugin/jdom/RootClassnameJDOMGeneratorTest.java index ec7b4b3a4..a0b3daba8 100644 --- a/modello-plugins/modello-plugin-jdom/src/test/java/org/codehaus/modello/plugin/jdom/RootClassnameJDOMGeneratorTest.java +++ b/modello-plugins/modello-plugin-jdom/src/test/java/org/codehaus/modello/plugin/jdom/RootClassnameJDOMGeneratorTest.java @@ -55,7 +55,6 @@ public void testJavaGenerator() throws Throwable { modello.generate(model, "java", parameters); modello.generate(model, "jdom-writer", parameters); - addDependency("org.jdom", "jdom"); compileGeneratedSources(); // If the code compiles successfully, the test passes diff --git a/modello-plugins/modello-plugin-sax/src/test/java/org/codehaus/modello/plugin/sax/SaxGeneratorTest.java b/modello-plugins/modello-plugin-sax/src/test/java/org/codehaus/modello/plugin/sax/SaxGeneratorTest.java index 939e54b29..896e68ecb 100644 --- a/modello-plugins/modello-plugin-sax/src/test/java/org/codehaus/modello/plugin/sax/SaxGeneratorTest.java +++ b/modello-plugins/modello-plugin-sax/src/test/java/org/codehaus/modello/plugin/sax/SaxGeneratorTest.java @@ -92,7 +92,6 @@ public void testXpp3Generator() throws Throwable { modello.generate(model, "java", parameters); modello.generate(model, "sax-writer", parameters); - addDependency("org.xmlunit", "xmlunit-core"); compileGeneratedSources(); // TODO: see why without this, version system property is set to "2.4.1" value after verify diff --git a/modello-plugins/modello-plugin-snakeyaml/src/test/java/org/codehaus/modello/plugin/snakeyaml/SnakeYamlGeneratorTest.java b/modello-plugins/modello-plugin-snakeyaml/src/test/java/org/codehaus/modello/plugin/snakeyaml/SnakeYamlGeneratorTest.java index fe7e78516..31fd26a3c 100644 --- a/modello-plugins/modello-plugin-snakeyaml/src/test/java/org/codehaus/modello/plugin/snakeyaml/SnakeYamlGeneratorTest.java +++ b/modello-plugins/modello-plugin-snakeyaml/src/test/java/org/codehaus/modello/plugin/snakeyaml/SnakeYamlGeneratorTest.java @@ -52,7 +52,6 @@ public void testYamlGenerator() throws Throwable { modello.generate(model, "snakeyaml-writer", parameters); modello.generate(model, "snakeyaml-reader", parameters); - addDependency("org.yaml", "snakeyaml"); compileGeneratedSources(); } } diff --git a/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/AbstractStaxGeneratorTestCase.java b/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/AbstractStaxGeneratorTestCase.java index ce4332c8d..62d679fd7 100644 --- a/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/AbstractStaxGeneratorTestCase.java +++ b/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/AbstractStaxGeneratorTestCase.java @@ -73,9 +73,6 @@ protected void verifyModel(Model model, String className, String[] versions) thr } } - addDependency("org.codehaus.woodstox", "stax2-api"); - addDependency("com.fasterxml.woodstox", "woodstox-core"); - compileGeneratedSources(); verifyCompiledGeneratedSources(className); diff --git a/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/FeaturesStaxDomGeneratorTest.java b/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/FeaturesStaxDomGeneratorTest.java index 3f805046a..e302d5a8a 100644 --- a/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/FeaturesStaxDomGeneratorTest.java +++ b/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/FeaturesStaxDomGeneratorTest.java @@ -55,15 +55,11 @@ public void testJavaGenerator() throws Throwable { modello.generate(model, "stax-writer", parameters); modello.generate(model, "stax-reader", parameters); - addDependency("org.codehaus.woodstox", "stax2-api"); - addDependency("com.fasterxml.woodstox", "woodstox-core"); - addDependency("org.xmlunit", "xmlunit-core"); - compileGeneratedSources(8); // TODO: see why without this, version system property is set to "2.4.1" value after verify System.setProperty("version", getModelloVersion()); - verifyCompiledGeneratedSources("org.codehaus.modello.generator.xml.stax.StaxFeaturesVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.xml.stax.StaxFeaturesDomVerifier"); } } diff --git a/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/FeaturesStaxGeneratorTest.java b/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/FeaturesStaxGeneratorTest.java index c53451aae..ef7dc1267 100644 --- a/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/FeaturesStaxGeneratorTest.java +++ b/modello-plugins/modello-plugin-stax/src/test/java/org/codehaus/modello/generator/xml/stax/FeaturesStaxGeneratorTest.java @@ -54,10 +54,6 @@ public void testJavaGenerator() throws Throwable { modello.generate(model, "stax-writer", parameters); modello.generate(model, "stax-reader", parameters); - addDependency("org.codehaus.woodstox", "stax2-api"); - addDependency("com.fasterxml.woodstox", "woodstox-core"); - addDependency("org.xmlunit", "xmlunit-core"); - compileGeneratedSources(8); // TODO: see why without this, version system property is set to "2.4.1" value after verify diff --git a/modello-plugins/modello-plugin-stax/src/test/verifiers/features-dom/StaxFeaturesVerifier.java b/modello-plugins/modello-plugin-stax/src/test/verifiers/features-dom/StaxFeaturesDomVerifier.java similarity index 99% rename from modello-plugins/modello-plugin-stax/src/test/verifiers/features-dom/StaxFeaturesVerifier.java rename to modello-plugins/modello-plugin-stax/src/test/verifiers/features-dom/StaxFeaturesDomVerifier.java index 010db54bd..7d48d11c4 100644 --- a/modello-plugins/modello-plugin-stax/src/test/verifiers/features-dom/StaxFeaturesVerifier.java +++ b/modello-plugins/modello-plugin-stax/src/test/verifiers/features-dom/StaxFeaturesDomVerifier.java @@ -53,7 +53,7 @@ /** * @author Herve Boutemy */ -public class StaxFeaturesVerifier +public class StaxFeaturesDomVerifier extends Verifier { public void verify() diff --git a/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/FeaturesXpp3DomGeneratorTest.java b/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/FeaturesXpp3DomGeneratorTest.java index 32cbb672a..b09747551 100644 --- a/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/FeaturesXpp3DomGeneratorTest.java +++ b/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/FeaturesXpp3DomGeneratorTest.java @@ -56,9 +56,8 @@ public void testJavaGenerator() throws Throwable { modello.generate(model, "xpp3-writer", parameters); modello.generate(model, "xpp3-reader", parameters); - addDependency("org.xmlunit", "xmlunit-core"); compileGeneratedSources(8); - verifyCompiledGeneratedSources("org.codehaus.modello.generator.xml.xpp3.Xpp3FeaturesVerifier"); + verifyCompiledGeneratedSources("org.codehaus.modello.generator.xml.xpp3.Xpp3FeaturesDomVerifier"); } } diff --git a/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/FeaturesXpp3GeneratorTest.java b/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/FeaturesXpp3GeneratorTest.java index 5670df65a..f91f9a729 100644 --- a/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/FeaturesXpp3GeneratorTest.java +++ b/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/FeaturesXpp3GeneratorTest.java @@ -54,7 +54,6 @@ public void testJavaGenerator() throws Throwable { modello.generate(model, "xpp3-writer", parameters); modello.generate(model, "xpp3-reader", parameters); - addDependency("org.xmlunit", "xmlunit-core"); compileGeneratedSources(8); verifyCompiledGeneratedSources("org.codehaus.modello.generator.xml.xpp3.Xpp3FeaturesVerifier"); diff --git a/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/Xpp3GeneratorTest.java b/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/Xpp3GeneratorTest.java index 4170edab9..9d4c652fd 100644 --- a/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/Xpp3GeneratorTest.java +++ b/modello-plugins/modello-plugin-xpp3/src/test/java/org/codehaus/modello/generator/xml/xpp3/Xpp3GeneratorTest.java @@ -95,7 +95,6 @@ public void testXpp3Generator() throws Throwable { modello.generate(model, "xpp3-writer", parameters); modello.generate(model, "xpp3-reader", parameters); - addDependency("org.xmlunit", "xmlunit-core"); compileGeneratedSources(8); // TODO: see why without this, version system property is set to "2.4.1" value after verify diff --git a/modello-plugins/modello-plugin-xpp3/src/test/verifiers/features-dom/Xpp3FeaturesVerifier.java b/modello-plugins/modello-plugin-xpp3/src/test/verifiers/features-dom/Xpp3FeaturesDomVerifier.java similarity index 99% rename from modello-plugins/modello-plugin-xpp3/src/test/verifiers/features-dom/Xpp3FeaturesVerifier.java rename to modello-plugins/modello-plugin-xpp3/src/test/verifiers/features-dom/Xpp3FeaturesDomVerifier.java index d0f1071c3..3e403f2df 100644 --- a/modello-plugins/modello-plugin-xpp3/src/test/verifiers/features-dom/Xpp3FeaturesVerifier.java +++ b/modello-plugins/modello-plugin-xpp3/src/test/verifiers/features-dom/Xpp3FeaturesDomVerifier.java @@ -51,7 +51,7 @@ /** * @author Herve Boutemy */ -public class Xpp3FeaturesVerifier +public class Xpp3FeaturesDomVerifier extends Verifier { public void verify() diff --git a/modello-plugins/pom.xml b/modello-plugins/pom.xml index bfff88e7f..31de7716c 100644 --- a/modello-plugins/pom.xml +++ b/modello-plugins/pom.xml @@ -61,28 +61,4 @@ test - - - - - - maven-dependency-plugin - - - copy-test-libs - - copy-dependencies - - process-test-resources - - ${project.build.directory}/test-libs - false - true - - - - - - - diff --git a/modello-test/pom.xml b/modello-test/pom.xml index 4bbdebe9d..8588b6a2d 100644 --- a/modello-test/pom.xml +++ b/modello-test/pom.xml @@ -12,9 +12,7 @@ Modello Test Package contains the basis to create Modello generator unit-tests, including sample models and xml files to test every feature for every plugin. - - 2.16.2 - + org.eclipse.sisu @@ -28,16 +26,6 @@ org.codehaus.plexus plexus-xml - - org.codehaus.plexus - plexus-compiler-javac - ${plexus.compiler.version} - - - org.codehaus.plexus - plexus-compiler-api - ${plexus.compiler.version} - org.codehaus.plexus plexus-testing diff --git a/modello-test/src/main/java/org/codehaus/modello/AbstractModelloJavaGeneratorTest.java b/modello-test/src/main/java/org/codehaus/modello/AbstractModelloJavaGeneratorTest.java index 56ab283d4..c7463bb3d 100755 --- a/modello-test/src/main/java/org/codehaus/modello/AbstractModelloJavaGeneratorTest.java +++ b/modello-test/src/main/java/org/codehaus/modello/AbstractModelloJavaGeneratorTest.java @@ -22,32 +22,43 @@ * SOFTWARE. */ -import javax.inject.Inject; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Properties; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.codehaus.modello.verifier.VerifierException; -import org.codehaus.plexus.compiler.Compiler; -import org.codehaus.plexus.compiler.CompilerConfiguration; -import org.codehaus.plexus.compiler.CompilerException; -import org.codehaus.plexus.compiler.CompilerMessage; -import org.codehaus.plexus.compiler.CompilerResult; import org.codehaus.plexus.util.FileUtils; import static org.codehaus.plexus.testing.PlexusExtension.getTestFile; import static org.codehaus.plexus.testing.PlexusExtension.getTestPath; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -60,15 +71,10 @@ * @see org.codehaus.modello.verifier.Verifier Verifier base class for verifiers */ public abstract class AbstractModelloJavaGeneratorTest extends AbstractModelloGeneratorTest { - private List dependencies = new ArrayList(); - private List urls = new ArrayList(); private List classPathElements = new ArrayList(); - @Inject - private Compiler compiler = null; // todo - protected AbstractModelloJavaGeneratorTest(String name) { super(name); } @@ -87,29 +93,6 @@ protected File getOutputClasses() { return new File(super.getOutputDirectory(), "classes"); } - protected void addDependency(String groupId, String artifactId) { - File dependencyFile = getDependencyFile(groupId, artifactId); - - dependencies.add(dependencyFile); - - addClassPathFile(dependencyFile); - } - - protected File getDependencyFile(String groupId, String artifactId) { - // NOTE: dependency version is managed by project POM and not selectable by test - - String libsDir = System.getProperty("tests.lib.dir", "target/test-libs"); - File dependencyFile = new File(libsDir, artifactId + ".jar"); - - assertTrue(dependencyFile.isFile(), "Can't find dependency: " + dependencyFile.getAbsolutePath()); - - return dependencyFile; - } - - public List getClasspath() { - return dependencies; - } - protected String getModelloVersion() throws IOException { Properties properties = new Properties(System.getProperties()); @@ -125,15 +108,15 @@ protected String getModelloVersion() throws IOException { return properties.getProperty("version"); } - protected void compileGeneratedSources() throws IOException, CompilerException { + protected void compileGeneratedSources() throws IOException { compileGeneratedSources(getName(), 8); } - protected void compileGeneratedSources(int minJavaSource) throws IOException, CompilerException { + protected void compileGeneratedSources(int minJavaSource) throws IOException { compileGeneratedSources(getName(), minJavaSource); } - protected void compileGeneratedSources(String verifierId, int minJavaSource) throws IOException, CompilerException { + protected void compileGeneratedSources(String verifierId, int minJavaSource) throws IOException { String runtimeVersion = System.getProperty("java.specification.version"); if (runtimeVersion.startsWith("1.")) { runtimeVersion = runtimeVersion.substring(2); @@ -151,54 +134,122 @@ protected void compileGeneratedSources(String verifierId, int minJavaSource) thr compileGeneratedSources(verifierId, javaSource); } - private void compileGeneratedSources(String verifierId, String javaSource) throws IOException, CompilerException { + private void compileGeneratedSources(String verifierId, String javaSource) throws IOException { File generatedSources = getOutputDirectory(); File destinationDirectory = getOutputClasses(); - addDependency("org.junit.jupiter", "junit-jupiter-api"); - addDependency("org.opentest4j", "opentest4j"); - addDependency("org.codehaus.plexus", "plexus-utils"); - addDependency("org.codehaus.plexus", "plexus-xml"); - // for plexus-xml 4 - // addDependency("org.apache.maven", "maven-api-xml"); - // addDependency("org.apache.maven", "maven-xml-impl"); - addDependency("org.codehaus.modello", "modello-test"); - - String[] classPathElements = new String[dependencies.size() + 2]; - classPathElements[0] = getTestPath("target/classes"); - classPathElements[1] = getTestPath("target/test-classes"); - - for (int i = 0; i < dependencies.size(); i++) { - classPathElements[i + 2] = ((File) dependencies.get(i)).getAbsolutePath(); - } + List classPath = new ArrayList<>(); + classPath.add(getTestPath("target/classes")); + classPath.add(getTestPath("target/test-classes")); + classPath.addAll(resolveTestClasspath()); + List sourceDirectories = new ArrayList<>(); File verifierDirectory = getTestFile("src/test/verifiers/" + verifierId); - String[] sourceDirectories; if (verifierDirectory.canRead()) { - sourceDirectories = new String[] {verifierDirectory.getAbsolutePath(), generatedSources.getAbsolutePath()}; - } else { - sourceDirectories = new String[] {generatedSources.getAbsolutePath()}; + sourceDirectories.add(verifierDirectory); + } + sourceDirectories.add(generatedSources); + + List sourceFiles = new ArrayList<>(); + for (File sourceDirectory : sourceDirectories) { + sourceFiles.addAll(findJavaSources(sourceDirectory)); + } + + // javac up to Java 8 refuses a -d that does not already exist; later versions create it + Files.createDirectories(destinationDirectory.toPath()); + + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + assertNotNull(javac, "No java compiler available - the tests need a JDK, not a JRE"); + + DiagnosticCollector diagnostics = new DiagnosticCollector<>(); + try (StandardJavaFileManager fileManager = javac.getStandardFileManager(diagnostics, null, null)) { + List options = Arrays.asList( + "-g", + "-classpath", + String.join(File.pathSeparator, classPath), + "-d", + destinationDirectory.getAbsolutePath(), + "-source", + javaSource, + "-target", + javaSource); + + javac.getTask( + null, + fileManager, + diagnostics, + options, + null, + fileManager.getJavaFileObjectsFromFiles(sourceFiles)) + .call(); } - CompilerConfiguration configuration = new CompilerConfiguration(); - configuration.setClasspathEntries(Arrays.asList(classPathElements)); - configuration.setSourceLocations(Arrays.asList(sourceDirectories)); - configuration.setOutputLocation(destinationDirectory.getAbsolutePath()); - configuration.setDebug(true); + List> errors = diagnostics.getDiagnostics().stream() + .filter(diagnostic -> diagnostic.getKind() == Diagnostic.Kind.ERROR) + .collect(Collectors.toList()); - configuration.setSourceVersion(javaSource); - configuration.setTargetVersion(javaSource); + assertEquals(0, errors.size(), "There was compilation errors: " + errors); + } - CompilerResult result = compiler.performCompile(configuration); + private static List findJavaSources(File directory) throws IOException { + if (!directory.isDirectory()) { + return new ArrayList<>(); + } + try (Stream paths = Files.walk(directory.toPath())) { + return paths.filter(path -> path.getFileName().toString().endsWith(".java")) + .map(Path::toFile) + .collect(Collectors.toList()); + } + } - List errors = new ArrayList(0); - for (CompilerMessage compilerMessage : result.getCompilerMessages()) { - if (compilerMessage.isError()) { - errors.add(compilerMessage); + /** + * Returns this module's test classpath, which is what the verifiers and the generated sources are compiled + * against. + *

+ * Surefire normally hands the forked JVM a manifest-only "booter" jar rather than a real classpath, so + * {@code java.class.path} on its own is a single jar whose {@code Class-Path} manifest entry holds the actual + * entries. Expanding that keeps this in step with whatever the POM declares, with no build step to copy jars + * around and no second list to maintain here. + */ + private static List resolveTestClasspath() { + List classPath = new ArrayList<>(); + for (String entry : System.getProperty("java.class.path", "").split(File.pathSeparator)) { + if (entry.isEmpty()) { + continue; } + classPath.add(entry); + // a jar may carry its own Class-Path, so keep both it and whatever it points at + classPath.addAll(expandManifestClassPath(new File(entry))); } + return classPath; + } - assertEquals(0, errors.size(), "There was compilation errors: " + errors); + private static List expandManifestClassPath(File jar) { + if (!jar.isFile() || !jar.getName().endsWith(".jar")) { + return new ArrayList<>(); + } + try (JarFile jarFile = new JarFile(jar)) { + Manifest manifest = jarFile.getManifest(); + if (manifest == null) { + return new ArrayList<>(); + } + String classPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH); + if (classPath == null || classPath.trim().isEmpty()) { + return new ArrayList<>(); + } + List entries = new ArrayList<>(); + for (String entry : classPath.trim().split("\\s+")) { + try { + entries.add(Paths.get(URI.create(entry)).toString()); + } catch (IllegalArgumentException | java.nio.file.FileSystemNotFoundException e) { + // a relative entry, resolved against the jar itself + entries.add(new File(jar.getParentFile(), entry).getAbsolutePath()); + } + } + return entries; + } catch (IOException e) { + throw new UncheckedIOException("Could not read the manifest of " + jar, e); + } } /** @@ -213,6 +264,14 @@ protected void verifyCompiledGeneratedSources(String verifierClassName) { addClassPathFile(getTestFile("target/test-classes")); + // the verifier runs in a classloader with no parent, so it needs the test classpath spelled out + for (String entry : resolveTestClasspath()) { + File file = new File(entry); + if (file.exists()) { + addClassPathFile(file); + } + } + ClassLoader oldCCL = Thread.currentThread().getContextClassLoader(); URLClassLoader classLoader = URLClassLoader.newInstance(urls.toArray(new URL[urls.size()]), null);