o Updated tests to use non-deprecated API

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@746407 13f79535-47bb-0310-9956-ffa450edef68
master
Benjamin Bentmann 2009-02-20 22:55:44 +00:00
parent 5f9cec0836
commit 7f49d49717
4 changed files with 40 additions and 36 deletions

View File

@ -23,6 +23,7 @@ import junit.framework.TestCase;
import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.component.repository.ComponentDependency;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
@ -91,7 +92,7 @@ public abstract class AbstractGeneratorTestCase
FileUtils.deleteDirectory( destinationDirectory ); FileUtils.deleteDirectory( destinationDirectory );
destinationDirectory.mkdir(); destinationDirectory.mkdir();
generator.execute( destinationDirectory, pluginDescriptor ); generator.execute( destinationDirectory, new DefaultPluginToolsRequest( null, pluginDescriptor ) );
validate( destinationDirectory ); validate( destinationDirectory );

View File

@ -26,34 +26,5 @@ package org.apache.maven.tools.plugin.generator;
public class PluginHelpGeneratorTest public class PluginHelpGeneratorTest
extends AbstractGeneratorTestCase extends AbstractGeneratorTestCase
{ {
public void testToText() // inherits tests from base class
throws Exception
{
String javadoc = null;
assertEquals( "", PluginHelpGenerator.toText( javadoc ) );
javadoc = "";
assertEquals( "", PluginHelpGenerator.toText( javadoc ) );
// line breaks
javadoc = "Line1\nLine2";
assertEquals( "Line1 Line2", PluginHelpGenerator.toText( javadoc ) );
javadoc = "Line1\rLine2";
assertEquals( "Line1 Line2", PluginHelpGenerator.toText( javadoc ) );
javadoc = "Line1\r\nLine2";
assertEquals( "Line1 Line2", PluginHelpGenerator.toText( javadoc ) );
javadoc = "Line1<br>Line2";
assertEquals( "Line1\nLine2", PluginHelpGenerator.toText( javadoc ) );
// true HTML
javadoc = "Generates <i>something</i> for the project.";
assertEquals( "Generates something for the project.", PluginHelpGenerator.toText( javadoc ) );
// wrong HTML
javadoc = "Generates <i>something</i> <b> for the project.";
assertEquals( "Generates something for the project.", PluginHelpGenerator.toText( javadoc ) );
// javadoc inline tags
javadoc = "Generates {@code something} for the project.";
assertEquals( "Generates something for the project.", PluginHelpGenerator.toText( javadoc ) );
}
} }

View File

@ -26,6 +26,7 @@ import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
import org.apache.maven.tools.plugin.extractor.ExtractionException; import org.apache.maven.tools.plugin.extractor.ExtractionException;
import java.io.File; import java.io.File;
@ -80,7 +81,7 @@ public class DefaultMojoScannerTest
{ {
PluginDescriptor pluginDescriptor = createPluginDescriptor(); PluginDescriptor pluginDescriptor = createPluginDescriptor();
scanner.populatePluginDescriptor( project, pluginDescriptor ); scanner.populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
checkResult( pluginDescriptor, extractors.keySet() ); checkResult( pluginDescriptor, extractors.keySet() );
} }
@ -97,7 +98,7 @@ public class DefaultMojoScannerTest
PluginDescriptor pluginDescriptor = createPluginDescriptor(); PluginDescriptor pluginDescriptor = createPluginDescriptor();
scanner.setActiveExtractors( activeExtractors ); scanner.setActiveExtractors( activeExtractors );
scanner.populatePluginDescriptor( project, pluginDescriptor ); scanner.populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
checkResult( pluginDescriptor, Arrays.asList( new String[]{"one", "three"} ) ); checkResult( pluginDescriptor, Arrays.asList( new String[]{"one", "three"} ) );
} }
@ -108,7 +109,7 @@ public class DefaultMojoScannerTest
PluginDescriptor pluginDescriptor = createPluginDescriptor(); PluginDescriptor pluginDescriptor = createPluginDescriptor();
scanner.setActiveExtractors( null ); scanner.setActiveExtractors( null );
scanner.populatePluginDescriptor( project, pluginDescriptor ); scanner.populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
checkResult( pluginDescriptor, extractors.keySet() ); checkResult( pluginDescriptor, extractors.keySet() );
} }
@ -121,7 +122,7 @@ public class DefaultMojoScannerTest
scanner.setActiveExtractors( Collections.EMPTY_SET ); scanner.setActiveExtractors( Collections.EMPTY_SET );
try try
{ {
scanner.populatePluginDescriptor( project, pluginDescriptor ); scanner.populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
fail( "Expected exception" ); fail( "Expected exception" );
} }
catch (InvalidPluginDescriptorException e) catch (InvalidPluginDescriptorException e)
@ -144,7 +145,7 @@ public class DefaultMojoScannerTest
try try
{ {
scanner.populatePluginDescriptor( project, pluginDescriptor ); scanner.populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
fail( "No error for unknown extractor" ); fail( "No error for unknown extractor" );
} }
catch ( ExtractionException e ) catch ( ExtractionException e )

View File

@ -205,4 +205,35 @@ public class PluginUtilsTest
assertEquals( "label", PluginUtils.decodeJavadocTags( javadoc ) ); assertEquals( "label", PluginUtils.decodeJavadocTags( javadoc ) );
} }
public void testToText()
throws Exception
{
String javadoc = null;
assertEquals( "", PluginUtils.toText( javadoc ) );
javadoc = "";
assertEquals( "", PluginUtils.toText( javadoc ) );
// line breaks
javadoc = "Line1\nLine2";
assertEquals( "Line1 Line2", PluginUtils.toText( javadoc ) );
javadoc = "Line1\rLine2";
assertEquals( "Line1 Line2", PluginUtils.toText( javadoc ) );
javadoc = "Line1\r\nLine2";
assertEquals( "Line1 Line2", PluginUtils.toText( javadoc ) );
javadoc = "Line1<br>Line2";
assertEquals( "Line1\nLine2", PluginUtils.toText( javadoc ) );
// true HTML
javadoc = "Generates <i>something</i> for the project.";
assertEquals( "Generates something for the project.", PluginUtils.toText( javadoc ) );
// wrong HTML
javadoc = "Generates <i>something</i> <b> for the project.";
assertEquals( "Generates something for the project.", PluginUtils.toText( javadoc ) );
// javadoc inline tags
javadoc = "Generates {@code something} for the project.";
assertEquals( "Generates something for the project.", PluginUtils.toText( javadoc ) );
}
} }