code formatting

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1160072 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Herve Boutemy 2011-08-21 22:02:29 +00:00
parent 6262c73a6b
commit 85da703d29
2 changed files with 50 additions and 45 deletions

View File

@ -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 errors", 0, collector.getErrors().size() );
assertEquals( "Expected no warnings", 0, collector.getWarnings().size() ); assertEquals( "Expected no warnings", 0, collector.getWarnings().size() );
assertEquals( "Expected no fatals", 0, collector.getFatals().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( "Errors", numErrors, collector.getErrors().size() );
assertEquals( "Warnings", numWarnings, collector.getWarnings().size() ); assertEquals( "Warnings", numWarnings, collector.getWarnings().size() );
assertEquals( "Fatals", numFatals, collector.getFatals().size() ); assertEquals( "Fatals", numFatals, collector.getFatals().size() );
} }
private ModelBuildingRequest createModelBuildingRequest(Properties p) { private ModelBuildingRequest createModelBuildingRequest( Properties p )
{
ModelBuildingRequest config = new DefaultModelBuildingRequest(); ModelBuildingRequest config = new DefaultModelBuildingRequest();
if (p!= null) config.setSystemProperties( p); if (p!= null) config.setSystemProperties( p);
return config; return config;
@ -100,9 +104,10 @@ public abstract class AbstractModelInterpolatorTest
Date secondTestDate = cal.getTime(); Date secondTestDate = cal.getTime();
SimpleDateFormat format = new SimpleDateFormat( AbstractStringBasedModelInterpolator.DEFAULT_BUILD_TIMESTAMP_FORMAT ); SimpleDateFormat format =
assertEquals( "19761111-0016", format.format( firstTestDate ) ); new SimpleDateFormat( AbstractStringBasedModelInterpolator.DEFAULT_BUILD_TIMESTAMP_FORMAT );
assertEquals( "19761111-2316", format.format( secondTestDate ) ); assertEquals( "19761111-0016", format.format( firstTestDate ) );
assertEquals( "19761111-2316", format.format( secondTestDate ) );
} }
public void testShouldNotThrowExceptionOnReferenceToNonExistentValue() public void testShouldNotThrowExceptionOnReferenceToNonExistentValue()
@ -169,7 +174,6 @@ public abstract class AbstractModelInterpolatorTest
assertProblemFree( collector ); assertProblemFree( collector );
assertEquals( "test/somepath", out.getScm().getConnection() ); assertEquals( "test/somepath", out.getScm().getConnection() );
} }
@ -188,7 +192,9 @@ public abstract class AbstractModelInterpolatorTest
ModelInterpolator interpolator = createInterpolator(); 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() ); assertEquals( orgName + " Tools", out.getName() );
} }
@ -207,8 +213,8 @@ public abstract class AbstractModelInterpolatorTest
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), Model out =
collector ); interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector );
assertColllectorState(0, 0, 1, collector ); assertColllectorState(0, 0, 1, collector );
@ -244,10 +250,9 @@ public abstract class AbstractModelInterpolatorTest
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), Model out =
collector ); interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector );
assertProblemFree( collector ); assertProblemFree( collector );
assertEquals( "${something}", ( out.getDependencies().get( 0 ) ).getVersion() ); assertEquals( "${something}", ( out.getDependencies().get( 0 ) ).getVersion() );
} }
@ -267,15 +272,15 @@ public abstract class AbstractModelInterpolatorTest
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), Model out =
collector ); interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector );
assertColllectorState( 0, 0, 2, collector ); assertColllectorState( 0, 0, 2, collector );
assertEquals( "foo-3.8.1", ( out.getDependencies().get( 0 ) ).getVersion() ); assertEquals( "foo-3.8.1", ( out.getDependencies().get( 0 ) ).getVersion() );
} }
public void testBasedir() public void testBasedir()
throws Exception throws Exception
{ {
Model model = new Model(); Model model = new Model();
@ -291,9 +296,8 @@ public void testBasedir()
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest(context), collector ); Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector );
assertProblemFree( collector ); assertProblemFree( collector );
assertEquals( "file://localhost/myBasedir/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() ); assertEquals( "file://localhost/myBasedir/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() );
} }
@ -314,9 +318,8 @@ public void testBasedir()
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest(context), collector ); Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector );
assertProblemFree( collector ); assertProblemFree( collector );
assertEquals( "myBaseUri/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() ); assertEquals( "myBaseUri/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() );
} }
@ -339,10 +342,9 @@ public void testBasedir()
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), Model out =
collector ); interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector );
assertProblemFree( collector ); assertProblemFree( collector );
assertEquals( "/path/to/home", out.getProperties().getProperty( "outputDirectory" ) ); assertEquals( "/path/to/home", out.getProperties().getProperty( "outputDirectory" ) );
} }
@ -361,10 +363,9 @@ public void testBasedir()
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), Model out =
collector ); interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector );
assertProblemFree( collector ); assertProblemFree( collector );
assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${env.DOES_NOT_EXIST}" ); assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${env.DOES_NOT_EXIST}" );
} }
@ -383,10 +384,9 @@ public void testBasedir()
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel( model, new File("."), createModelBuildingRequest(context), Model out =
collector ); interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), collector );
assertProblemFree( collector ); assertProblemFree( collector );
assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${DOES_NOT_EXIST}" ); assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${DOES_NOT_EXIST}" );
} }
@ -419,7 +419,7 @@ public void testBasedir()
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); 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 ); assertColllectorState( 0, 0, 2, collector );
@ -444,7 +444,7 @@ public void testBasedir()
ModelInterpolator interpolator = createInterpolator(); ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector(); 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 ); assertProblemFree( collector );
@ -461,5 +461,4 @@ public void testBasedir()
protected abstract ModelInterpolator createInterpolator() protected abstract ModelInterpolator createInterpolator()
throws Exception; throws Exception;
} }

View File

@ -89,7 +89,8 @@ public class StringSearchModelInterpolatorTest
assertEquals( "value2", values[1] ); assertEquals( "value2", values[1] );
} }
private ModelBuildingRequest createModelBuildingRequest(Properties p) { private ModelBuildingRequest createModelBuildingRequest(Properties p)
{
ModelBuildingRequest config = new DefaultModelBuildingRequest(); ModelBuildingRequest config = new DefaultModelBuildingRequest();
config.setSystemProperties( p); config.setSystemProperties( p);
return config; return config;
@ -186,7 +187,7 @@ public class StringSearchModelInterpolatorTest
p.setProperty( "key", "value" ); p.setProperty( "key", "value" );
p.setProperty( "key2", "value2" ); p.setProperty( "key2", "value2" );
List values = Collections.unmodifiableList( Collections.singletonList( "${key}" ) ); List<String> values = Collections.unmodifiableList( Collections.singletonList( "${key}" ) );
ObjectWithListField obj = new ObjectWithListField( values ); 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 Model model = new Model();
final Properties p = new Properties(); final Properties p = new Properties();
@ -365,7 +368,8 @@ public class StringSearchModelInterpolatorTest
final CountDownLatch countDownLatch = new CountDownLatch(1); final CountDownLatch countDownLatch = new CountDownLatch(1);
List<Future<SimpleProblemCollector>> futures = new ArrayList<Future<SimpleProblemCollector>>(); List<Future<SimpleProblemCollector>> futures = new ArrayList<Future<SimpleProblemCollector>>();
for (int i = 0; i < numItems; i++){ for ( int i = 0; i < numItems; i++ )
{
Callable<SimpleProblemCollector> future = new Callable<SimpleProblemCollector>() { Callable<SimpleProblemCollector> future = new Callable<SimpleProblemCollector>() {
public SimpleProblemCollector call() throws Exception { public SimpleProblemCollector call() throws Exception {
final ObjectWithMixedProtection obj = getValueList(); final ObjectWithMixedProtection obj = getValueList();
@ -382,7 +386,8 @@ public class StringSearchModelInterpolatorTest
new Thread( task).start(); new Thread( task).start();
} }
countDownLatch.countDown(); // Start all the threads countDownLatch.countDown(); // Start all the threads
for(Future<SimpleProblemCollector> result : futures){ for ( Future<SimpleProblemCollector> result : futures )
{
SimpleProblemCollector problemCollector = result.get(); // ArrayIndexOutOfBoundsException are typical indication of threading issues SimpleProblemCollector problemCollector = result.get(); // ArrayIndexOutOfBoundsException are typical indication of threading issues
assertProblemFree( problemCollector ); assertProblemFree( problemCollector );
@ -444,7 +449,8 @@ public class StringSearchModelInterpolatorTest
List<?> values3; List<?> values3;
private String fooBar; private String fooBar;
private ObjectWithMixedProtection(List<?> values1, List<?> values2, List<?> values3) { private ObjectWithMixedProtection( List<?> values1, List<?> values2, List<?> values3 )
{
this.values1 = values1; this.values1 = values1;
this.values2 = values2; this.values2 = values2;
this.values3 = values3; this.values3 = values3;