fixed errors reported by Checkstyle

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@813612 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Herve Boutemy 2009-09-10 21:58:39 +00:00
parent 388fcd100e
commit b82977a18c
13 changed files with 230 additions and 183 deletions

View File

@ -1,18 +1,22 @@
package org.apache.maven.execution; package org.apache.maven.execution;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license * Licensed to the Apache Software Foundation (ASF) under one
* agreements. See the NOTICE file distributed with this work for additional information regarding * or more contributor license agreements. See the NOTICE file
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * distributed with this work for additional information
* "License"); you may not use this file except in compliance with the License. You may obtain a * regarding copyright ownership. The ASF licenses this file
* copy of the License at * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * Unless required by applicable law or agreed to in writing,
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * software distributed under the License is distributed on an
* or implied. See the License for the specific language governing permissions and limitations under * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* the License. * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ */
import java.io.File; import java.io.File;
@ -129,7 +133,9 @@ public class DefaultMavenExecutionRequest
*/ */
private boolean noSnapshotUpdates; private boolean noSnapshotUpdates;
public DefaultMavenExecutionRequest() { } public DefaultMavenExecutionRequest()
{
}
public static MavenExecutionRequest copy( MavenExecutionRequest original ) public static MavenExecutionRequest copy( MavenExecutionRequest original )
{ {

View File

@ -61,9 +61,9 @@ private static void decomposeParameterIntoUserInstructions( MojoDescriptor mojo,
if ( param.isEditable() ) if ( param.isEditable() )
{ {
messageBuffer.append( "Inside the definition for plugin \'" + mojo.getPluginDescriptor().getArtifactId() + messageBuffer.append( "Inside the definition for plugin \'" + mojo.getPluginDescriptor().getArtifactId()
"\' specify the following:\n\n<configuration>\n ...\n <" + param.getName() + ">VALUE</" + + "\' specify the following:\n\n<configuration>\n ...\n <" + param.getName() + ">VALUE</"
param.getName() + ">\n</configuration>" ); + param.getName() + ">\n</configuration>" );
String alias = param.getAlias(); String alias = param.getAlias();
if ( StringUtils.isNotEmpty( alias ) && !alias.equals( param.getName() ) ) if ( StringUtils.isNotEmpty( alias ) && !alias.equals( param.getName() ) )

View File

@ -42,8 +42,8 @@ public InvalidProjectVersionException( String projectId, String locationInPom, S
private static String formatMessage( String projectId, String locationInPom, String offendingVersion, private static String formatMessage( String projectId, String locationInPom, String offendingVersion,
InvalidVersionSpecificationException cause ) InvalidVersionSpecificationException cause )
{ {
return "Invalid version: " + offendingVersion + " found for: " + locationInPom + " in project: " + projectId + return "Invalid version: " + offendingVersion + " found for: " + locationInPom + " in project: " + projectId
". Reason: " + cause.getMessage(); + ". Reason: " + cause.getMessage();
} }
public String getOffendingVersion() public String getOffendingVersion()

View File

@ -43,8 +43,8 @@ public SettingsConfigurationException( String message, Throwable cause )
public SettingsConfigurationException( String message, Throwable cause, int lineNumber, int columnNumber ) public SettingsConfigurationException( String message, Throwable cause, int lineNumber, int columnNumber )
{ {
super( message + ( lineNumber > 0 ? "\n Line: " + lineNumber : "" ) + super( message + ( lineNumber > 0 ? "\n Line: " + lineNumber : "" )
( columnNumber > 0 ? "\n Column: " + columnNumber : "" ), cause ); + ( columnNumber > 0 ? "\n Column: " + columnNumber : "" ), cause );
this.lineNumber = lineNumber; this.lineNumber = lineNumber;
this.columnNumber = columnNumber; this.columnNumber = columnNumber;
} }

View File

@ -19,7 +19,6 @@
* under the License. * under the License.
*/ */
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -33,7 +32,6 @@
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionRequest;
@ -74,7 +72,9 @@ public void setUp()
} }
@Override @Override
protected void tearDown() throws Exception { protected void tearDown()
throws Exception
{
factory = null; factory = null;
super.tearDown(); super.tearDown();
} }

View File

@ -35,7 +35,9 @@ protected void setUp()
} }
@Override @Override
protected void tearDown() throws Exception { protected void tearDown()
throws Exception
{
repositorySystem = null; repositorySystem = null;
super.tearDown(); super.tearDown();
} }

View File

@ -67,16 +67,18 @@ public void testDependencyManagementOverridesTransitiveDependencyVersion()
assertEquals( pom0Basedir, project1.getParent().getBasedir().getCanonicalFile() ); assertEquals( pom0Basedir, project1.getParent().getBasedir().getCanonicalFile() );
Set set = project1.getArtifacts(); Set set = project1.getArtifacts();
assertNotNull("No artifacts", set); assertNotNull( "No artifacts", set );
assertTrue("No Artifacts", set.size() > 0); assertTrue( "No Artifacts", set.size() > 0 );
assertTrue("Set size should be 3, is " + set.size(), set.size() == 3); assertTrue( "Set size should be 3, is " + set.size(), set.size() == 3 );
Iterator iter = set.iterator(); Iterator iter = set.iterator();
while (iter.hasNext()) { while ( iter.hasNext() )
Artifact artifact = (Artifact)iter.next(); {
System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + Artifact artifact = (Artifact) iter.next();
" Optional=" + (artifact.isOptional() ? "true" : "false")); System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
artifact.getVersion().equals( "1.0" ) );
} }
} }

View File

@ -63,16 +63,16 @@ public void testDependencyManagement()
assertEquals( pom0Basedir, project1.getParent().getBasedir().getCanonicalFile() ); assertEquals( pom0Basedir, project1.getParent().getBasedir().getCanonicalFile() );
Set set = project1.getArtifacts(); Set set = project1.getArtifacts();
assertNotNull("No artifacts", set); assertNotNull( "No artifacts", set );
assertTrue("No Artifacts", set.size() > 0); assertTrue( "No Artifacts", set.size() > 0 );
Iterator iter = set.iterator(); Iterator iter = set.iterator();
while (iter.hasNext()) while ( iter.hasNext() )
{ {
Artifact artifact = (Artifact)iter.next(); Artifact artifact = (Artifact) iter.next();
System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " "
artifact.getVersion() + " Scope: " + artifact.getScope()); + artifact.getVersion() + " Scope: " + artifact.getScope() );
assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals( "1.0" ) );
} }
} }

View File

@ -63,17 +63,18 @@ public void testDependencyManagement()
assertEquals( pom0Basedir, project1.getParent().getBasedir().getCanonicalFile() ); assertEquals( pom0Basedir, project1.getParent().getBasedir().getCanonicalFile() );
Set set = project1.getArtifacts(); Set set = project1.getArtifacts();
assertNotNull("No artifacts", set); assertNotNull( "No artifacts", set );
assertTrue("No Artifacts", set.size() > 0); assertTrue( "No Artifacts", set.size() > 0 );
Iterator iter = set.iterator(); Iterator iter = set.iterator();
assertTrue("Set size should be 4, is " + set.size(), set.size() == 4); assertTrue( "Set size should be 4, is " + set.size(), set.size() == 4 );
while (iter.hasNext()) while ( iter.hasNext() )
{ {
Artifact artifact = (Artifact)iter.next(); Artifact artifact = (Artifact) iter.next();
System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
" Optional=" + (artifact.isOptional() ? "true" : "false")); + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
artifact.getVersion().equals( "1.0" ) );
} }
} }

View File

@ -62,19 +62,20 @@ public void testDependencyManagement()
MavenProject project1 = getProjectWithDependencies( pom1 ); MavenProject project1 = getProjectWithDependencies( pom1 );
assertEquals( pom0Basedir, project1.getParent().getBasedir().getCanonicalFile() ); assertEquals( pom0Basedir, project1.getParent().getBasedir().getCanonicalFile() );
System.out.println("Project " + project1.getId() + " " + project1); System.out.println( "Project " + project1.getId() + " " + project1 );
Set set = project1.getArtifacts(); Set set = project1.getArtifacts();
assertNotNull("No artifacts", set); assertNotNull( "No artifacts", set );
assertTrue("No Artifacts", set.size() > 0); assertTrue( "No Artifacts", set.size() > 0 );
Iterator iter = set.iterator(); Iterator iter = set.iterator();
assertTrue("Set size should be 4, is " + set.size(), set.size() == 4); assertTrue( "Set size should be 4, is " + set.size(), set.size() == 4 );
while (iter.hasNext()) while ( iter.hasNext() )
{ {
Artifact artifact = (Artifact)iter.next(); Artifact artifact = (Artifact) iter.next();
System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + System.out.println( "Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion()
" Optional=" + (artifact.isOptional() ? "true" : "false")); + " Optional=" + ( artifact.isOptional() ? "true" : "false" ) );
assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); assertTrue( "Incorrect version for " + artifact.getDependencyConflictId(),
artifact.getVersion().equals( "1.0" ) );
} }
} }

View File

@ -1,10 +1,28 @@
package org.apache.maven.settings; package org.apache.maven.settings;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.model.Profile; import org.apache.maven.model.Profile;
import org.apache.maven.project.DefaultProjectBuilder; import org.apache.maven.project.DefaultProjectBuilder;
@ -22,9 +40,9 @@
public class PomConstructionWithSettingsTest public class PomConstructionWithSettingsTest
extends PlexusTestCase extends PlexusTestCase
{ {
private static String BASE_DIR = "src/test"; private static final String BASE_DIR = "src/test";
private static String BASE_POM_DIR = BASE_DIR + "/resources-settings"; private static final String BASE_POM_DIR = BASE_DIR + "/resources-settings";
private DefaultProjectBuilder projectBuilder; private DefaultProjectBuilder projectBuilder;
@ -41,7 +59,9 @@ protected void setUp()
} }
@Override @Override
protected void tearDown() throws Exception { protected void tearDown()
throws Exception
{
projectBuilder = null; projectBuilder = null;
super.tearDown(); super.tearDown();
@ -57,25 +77,25 @@ public void testSettingsNoPom() throws Exception
public void testPomAndSettingsInterpolation() throws Exception public void testPomAndSettingsInterpolation() throws Exception
{ {
PomTestWrapper pom = buildPom( "test-pom-and-settings-interpolation" ); PomTestWrapper pom = buildPom( "test-pom-and-settings-interpolation" );
assertEquals("applied", pom.getValue( "properties/settingsProfile" ) ); assertEquals( "applied", pom.getValue( "properties/settingsProfile" ) );
assertEquals("applied", pom.getValue( "properties/pomProfile" ) ); assertEquals( "applied", pom.getValue( "properties/pomProfile" ) );
assertEquals("settings", pom.getValue( "properties/pomVsSettings" ) ); assertEquals( "settings", pom.getValue( "properties/pomVsSettings" ) );
assertEquals("settings", pom.getValue( "properties/pomVsSettingsInterpolated" ) ); assertEquals( "settings", pom.getValue( "properties/pomVsSettingsInterpolated" ) );
} }
/**MNG-4107 */ /**MNG-4107 */
public void testRepositories() throws Exception public void testRepositories() throws Exception
{ {
PomTestWrapper pom = buildPom( "repositories" ); PomTestWrapper pom = buildPom( "repositories" );
assertEquals("maven-core-it-0", pom.getValue( "repositories[1]/id" )); assertEquals( "maven-core-it-0", pom.getValue( "repositories[1]/id" ) );
} }
private PomTestWrapper buildPom( String pomPath ) private PomTestWrapper buildPom( String pomPath )
throws Exception throws Exception
{ {
File pomFile = new File( testDirectory + File.separator + pomPath , "pom.xml" ); File pomFile = new File( testDirectory + File.separator + pomPath, "pom.xml" );
File settingsFile = new File( testDirectory + File.separator + pomPath, "settings.xml" ); File settingsFile = new File( testDirectory + File.separator + pomPath, "settings.xml" );
Settings settings = readSettingsFile(settingsFile); Settings settings = readSettingsFile( settingsFile );
ProjectBuildingRequest config = new DefaultProjectBuildingRequest(); ProjectBuildingRequest config = new DefaultProjectBuildingRequest();
@ -85,15 +105,17 @@ private PomTestWrapper buildPom( String pomPath )
config.addProfile( profile ); config.addProfile( profile );
} }
String localRepoUrl = System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" ); String localRepoUrl =
System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" );
localRepoUrl = "file://" + localRepoUrl; localRepoUrl = "file://" + localRepoUrl;
config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), null, null ) ); config.setLocalRepository( repositorySystem.createArtifactRepository( "local", localRepoUrl,
new DefaultRepositoryLayout(), null, null ) );
config.setActiveProfileIds( settings.getActiveProfiles() ); config.setActiveProfileIds( settings.getActiveProfiles() );
return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() ); return new PomTestWrapper( pomFile, projectBuilder.build( pomFile, config ).getProject() );
} }
private static Settings readSettingsFile(File settingsFile) private static Settings readSettingsFile( File settingsFile )
throws IOException, XmlPullParserException throws IOException, XmlPullParserException
{ {
Settings settings = null; Settings settings = null;

View File

@ -29,41 +29,49 @@
* *
* @author mkleint * @author mkleint
*/ */
public class DefaultSettingsValidatorTest extends TestCase { public class DefaultSettingsValidatorTest
extends TestCase
{
public DefaultSettingsValidatorTest(String testName) { public DefaultSettingsValidatorTest( String testName )
super(testName); {
super( testName );
} }
protected void setUp() throws Exception { protected void setUp()
throws Exception
{
super.setUp(); super.setUp();
} }
protected void tearDown() throws Exception { protected void tearDown()
throws Exception
{
super.tearDown(); super.tearDown();
} }
public void testValidate() { public void testValidate()
{
Settings model = new Settings(); Settings model = new Settings();
Profile prof = new Profile(); Profile prof = new Profile();
prof.setId("xxx"); prof.setId( "xxx" );
model.addProfile(prof); model.addProfile( prof );
DefaultSettingsValidator instance = new DefaultSettingsValidator(); DefaultSettingsValidator instance = new DefaultSettingsValidator();
SettingsValidationResult result = instance.validate(model); SettingsValidationResult result = instance.validate( model );
assertEquals(0, result.getMessageCount()); assertEquals( 0, result.getMessageCount() );
Repository repo = new Repository(); Repository repo = new Repository();
prof.addRepository(repo); prof.addRepository( repo );
result = instance.validate(model); result = instance.validate( model );
assertEquals(2, result.getMessageCount()); assertEquals( 2, result.getMessageCount() );
repo.setUrl("http://xxx.xxx.com"); repo.setUrl( "http://xxx.xxx.com" );
result = instance.validate(model); result = instance.validate( model );
assertEquals(1, result.getMessageCount()); assertEquals( 1, result.getMessageCount() );
repo.setId("xxx"); repo.setId( "xxx" );
result = instance.validate(model); result = instance.validate( model );
assertEquals(0, result.getMessageCount()); assertEquals( 0, result.getMessageCount() );
} }

View File

@ -25,37 +25,42 @@
* *
* @author mkleint * @author mkleint
*/ */
public class RequirementMatcherFactoryTest extends TestCase { public class RequirementMatcherFactoryTest
extends TestCase
{
public RequirementMatcherFactoryTest(String testName) { public RequirementMatcherFactoryTest( String testName )
super(testName); {
super( testName );
} }
/** /**
* Test of createExactMatcher method, of class RequirementMatcherFactory. * Test of createExactMatcher method, of class RequirementMatcherFactory.
*/ */
public void testCreateExactMatcher() { public void testCreateExactMatcher()
{
RequirementMatcher matcher; RequirementMatcher matcher;
matcher = RequirementMatcherFactory.createExactMatcher("foo"); matcher = RequirementMatcherFactory.createExactMatcher( "foo" );
assertFalse(matcher.matches("bar")); assertFalse( matcher.matches( "bar" ) );
assertFalse(matcher.matches("foobar")); assertFalse( matcher.matches( "foobar" ) );
assertFalse(matcher.matches("foob")); assertFalse( matcher.matches( "foob" ) );
assertTrue(matcher.matches("foo")); assertTrue( matcher.matches( "foo" ) );
} }
/** /**
* Test of createVersionMatcher method, of class RequirementMatcherFactory. * Test of createVersionMatcher method, of class RequirementMatcherFactory.
*/ */
public void testCreateVersionMatcher() { public void testCreateVersionMatcher()
{
RequirementMatcher matcher; RequirementMatcher matcher;
matcher = RequirementMatcherFactory.createVersionMatcher("1.5.2"); matcher = RequirementMatcherFactory.createVersionMatcher( "1.5.2" );
assertFalse(matcher.matches("1.5")); assertFalse( matcher.matches( "1.5" ) );
assertTrue(matcher.matches("1.5.2")); assertTrue( matcher.matches( "1.5.2" ) );
assertFalse(matcher.matches("[1.4,1.5)")); assertFalse( matcher.matches( "[1.4,1.5)" ) );
assertFalse(matcher.matches("[1.5,1.5.2)")); assertFalse( matcher.matches( "[1.5,1.5.2)" ) );
assertFalse(matcher.matches("(1.5.2,1.6)")); assertFalse( matcher.matches( "(1.5.2,1.6)" ) );
assertTrue(matcher.matches("(1.4,1.5.2]")); assertTrue( matcher.matches( "(1.4,1.5.2]" ) );
assertTrue(matcher.matches("(1.5,)")); assertTrue( matcher.matches( "(1.5,)" ) );
} }
} }