diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java index dd06ff4e05..080a0704c8 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/AbstractModelInterpolatorTest.java @@ -59,19 +59,23 @@ public abstract class AbstractModelInterpolatorTest } - protected void assertProblemFree(SimpleProblemCollector collector){ - + protected void assertProblemFree( SimpleProblemCollector collector ) + { assertEquals( "Expected no errors", 0, collector.getErrors().size() ); assertEquals( "Expected no warnings", 0, collector.getWarnings().size() ); assertEquals( "Expected no fatals", 0, collector.getFatals().size() ); } - protected void assertColllectorState(int numFatals, int numErrors, int numWarnings, SimpleProblemCollector collector){ + + protected void assertColllectorState( int numFatals, int numErrors, int numWarnings, + SimpleProblemCollector collector ) + { assertEquals( "Errors", numErrors, collector.getErrors().size() ); assertEquals( "Warnings", numWarnings, collector.getWarnings().size() ); assertEquals( "Fatals", numFatals, collector.getFatals().size() ); } - private ModelBuildingRequest createModelBuildingRequest(Properties p) { + private ModelBuildingRequest createModelBuildingRequest( Properties p ) + { ModelBuildingRequest config = new DefaultModelBuildingRequest(); if (p!= null) config.setSystemProperties( p); return config; @@ -100,9 +104,10 @@ public abstract class AbstractModelInterpolatorTest Date secondTestDate = cal.getTime(); - SimpleDateFormat format = new SimpleDateFormat( AbstractStringBasedModelInterpolator.DEFAULT_BUILD_TIMESTAMP_FORMAT ); - assertEquals( "19761111-0016", format.format( firstTestDate ) ); - assertEquals( "19761111-2316", format.format( secondTestDate ) ); + SimpleDateFormat format = + new SimpleDateFormat( AbstractStringBasedModelInterpolator.DEFAULT_BUILD_TIMESTAMP_FORMAT ); + assertEquals( "19761111-0016", format.format( firstTestDate ) ); + assertEquals( "19761111-2316", format.format( secondTestDate ) ); } public void testShouldNotThrowExceptionOnReferenceToNonExistentValue() @@ -169,7 +174,6 @@ public abstract class AbstractModelInterpolatorTest assertProblemFree( collector ); - assertEquals( "test/somepath", out.getScm().getConnection() ); } @@ -188,7 +192,9 @@ public abstract class AbstractModelInterpolatorTest ModelInterpolator interpolator = createInterpolator(); - Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), new SimpleProblemCollector() ); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), + new SimpleProblemCollector() ); assertEquals( orgName + " Tools", out.getName() ); } @@ -207,8 +213,8 @@ public abstract class AbstractModelInterpolatorTest ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), - collector ); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); assertColllectorState(0, 0, 1, collector ); @@ -244,10 +250,9 @@ public abstract class AbstractModelInterpolatorTest ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), - collector ); - assertProblemFree( collector ); - + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); assertEquals( "${something}", ( out.getDependencies().get( 0 ) ).getVersion() ); } @@ -267,15 +272,15 @@ public abstract class AbstractModelInterpolatorTest ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), - collector ); + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); assertColllectorState( 0, 0, 2, collector ); assertEquals( "foo-3.8.1", ( out.getDependencies().get( 0 ) ).getVersion() ); } -public void testBasedir() + public void testBasedir() throws Exception { Model model = new Model(); @@ -291,9 +296,8 @@ public void testBasedir() ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest(context), collector ); - assertProblemFree( collector ); - + Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); assertEquals( "file://localhost/myBasedir/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() ); } @@ -314,9 +318,8 @@ public void testBasedir() ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest(context), collector ); - assertProblemFree( collector ); - + Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); assertEquals( "myBaseUri/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() ); } @@ -339,10 +342,9 @@ public void testBasedir() ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), - collector ); - assertProblemFree( collector ); - + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); assertEquals( "/path/to/home", out.getProperties().getProperty( "outputDirectory" ) ); } @@ -361,10 +363,9 @@ public void testBasedir() ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), - collector ); - assertProblemFree( collector ); - + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${env.DOES_NOT_EXIST}" ); } @@ -383,10 +384,9 @@ public void testBasedir() ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), - collector ); - assertProblemFree( collector ); - + Model out = + interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector ); + assertProblemFree( collector ); assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${DOES_NOT_EXIST}" ); } @@ -419,7 +419,7 @@ public void testBasedir() ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest(context), collector ); + Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector ); assertColllectorState( 0, 0, 2, collector ); @@ -444,7 +444,7 @@ public void testBasedir() ModelInterpolator interpolator = createInterpolator(); final SimpleProblemCollector collector = new SimpleProblemCollector(); - Model result = interpolator.interpolateModel( model, basedir, createModelBuildingRequest(context), collector ); + Model result = interpolator.interpolateModel( model, basedir, createModelBuildingRequest( context ), collector ); assertProblemFree( collector ); @@ -461,5 +461,4 @@ public void testBasedir() protected abstract ModelInterpolator createInterpolator() throws Exception; - } diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java index 4691f673a4..0ca62aa235 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringSearchModelInterpolatorTest.java @@ -89,7 +89,8 @@ public class StringSearchModelInterpolatorTest assertEquals( "value2", values[1] ); } - private ModelBuildingRequest createModelBuildingRequest(Properties p) { + private ModelBuildingRequest createModelBuildingRequest(Properties p) + { ModelBuildingRequest config = new DefaultModelBuildingRequest(); config.setSystemProperties( p); return config; @@ -186,7 +187,7 @@ public class StringSearchModelInterpolatorTest p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); - List values = Collections.unmodifiableList( Collections.singletonList( "${key}" ) ); + List values = Collections.unmodifiableList( Collections.singletonList( "${key}" ) ); ObjectWithListField obj = new ObjectWithListField( values ); @@ -348,7 +349,9 @@ public class StringSearchModelInterpolatorTest } - public void testConcurrentInterpolation() throws Exception { + public void testConcurrentInterpolation() + throws Exception + { final Model model = new Model(); final Properties p = new Properties(); @@ -365,7 +368,8 @@ public class StringSearchModelInterpolatorTest final CountDownLatch countDownLatch = new CountDownLatch(1); List> futures = new ArrayList>(); - for (int i = 0; i < numItems; i++){ + for ( int i = 0; i < numItems; i++ ) + { Callable future = new Callable() { public SimpleProblemCollector call() throws Exception { final ObjectWithMixedProtection obj = getValueList(); @@ -382,7 +386,8 @@ public class StringSearchModelInterpolatorTest new Thread( task).start(); } countDownLatch.countDown(); // Start all the threads - for(Future result : futures){ + for ( Future result : futures ) + { SimpleProblemCollector problemCollector = result.get(); // ArrayIndexOutOfBoundsException are typical indication of threading issues assertProblemFree( problemCollector ); @@ -444,7 +449,8 @@ public class StringSearchModelInterpolatorTest List values3; private String fooBar; - private ObjectWithMixedProtection(List values1, List values2, List values3) { + private ObjectWithMixedProtection( List values1, List values2, List values3 ) + { this.values1 = values1; this.values2 = values2; this.values3 = values3;