o fixed svn properties
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@628492 13f79535-47bb-0310-9956-ffa450edef68master
parent
cc94792fbd
commit
2a64c902b4
|
|
@ -1,78 +1,78 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<model>
|
||||
<id>pluginRequirements</id>
|
||||
<name>PluginRequirements</name>
|
||||
<description><![CDATA[Model to specify plugin requirements.]]></description>
|
||||
<defaults>
|
||||
<default>
|
||||
<key>package</key>
|
||||
<value>org.apache.maven.plugin.plugin</value>
|
||||
</default>
|
||||
</defaults>
|
||||
<classes>
|
||||
<class>
|
||||
<name>Requirements</name>
|
||||
<description>Plugin requirements.</description>
|
||||
<version>1.0.0</version>
|
||||
<fields>
|
||||
<field>
|
||||
<name>maven</name>
|
||||
<description>The minimum version of Maven to run this plugin.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<identifier>true</identifier>
|
||||
<defaultValue>2.0</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>jdk</name>
|
||||
<description>The minimum version of the JDK to run this plugin.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<identifier>true</identifier>
|
||||
</field>
|
||||
<field>
|
||||
<name>memory</name>
|
||||
<description>The minimum memory needed to run this plugin.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>diskSpace</name>
|
||||
<description>The minimum diskSpace needed to run this plugin.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>others</name>
|
||||
<description>Others requirements properties.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>Properties</type>
|
||||
<association xml.mapStyle="inline">
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
</classes>
|
||||
</model>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<model>
|
||||
<id>pluginRequirements</id>
|
||||
<name>PluginRequirements</name>
|
||||
<description><![CDATA[Model to specify plugin requirements.]]></description>
|
||||
<defaults>
|
||||
<default>
|
||||
<key>package</key>
|
||||
<value>org.apache.maven.plugin.plugin</value>
|
||||
</default>
|
||||
</defaults>
|
||||
<classes>
|
||||
<class>
|
||||
<name>Requirements</name>
|
||||
<description>Plugin requirements.</description>
|
||||
<version>1.0.0</version>
|
||||
<fields>
|
||||
<field>
|
||||
<name>maven</name>
|
||||
<description>The minimum version of Maven to run this plugin.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<identifier>true</identifier>
|
||||
<defaultValue>2.0</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>jdk</name>
|
||||
<description>The minimum version of the JDK to run this plugin.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<identifier>true</identifier>
|
||||
</field>
|
||||
<field>
|
||||
<name>memory</name>
|
||||
<description>The minimum memory needed to run this plugin.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>diskSpace</name>
|
||||
<description>The minimum diskSpace needed to run this plugin.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>others</name>
|
||||
<description>Others requirements properties.</description>
|
||||
<version>1.0.0</version>
|
||||
<type>Properties</type>
|
||||
<association xml.mapStyle="inline">
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
</classes>
|
||||
</model>
|
||||
|
|
|
|||
|
|
@ -1,484 +1,484 @@
|
|||
package org.apache.maven.plugin.testing;
|
||||
|
||||
/*
|
||||
* 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.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.DefaultArtifact;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub;
|
||||
import org.codehaus.plexus.archiver.Archiver;
|
||||
import org.codehaus.plexus.archiver.ArchiverException;
|
||||
import org.codehaus.plexus.archiver.manager.ArchiverManager;
|
||||
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
|
||||
import org.codehaus.plexus.archiver.war.WarArchiver;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.codehaus.plexus.util.ReflectionUtils;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/**
|
||||
* This class creates artifacts to be used for testing purposes. It can optionally create actual files on the local disk
|
||||
* for things like copying. It can create these files as archives with named files inside to be used for testing things
|
||||
* like unpack. Also provided are some utility methods to quickly get a set of artifacts distinguished by various things
|
||||
* like group,artifact,type,scope, etc It was originally developed for the dependency plugin, but can be useful in other
|
||||
* plugins that need to simulate artifacts for unit tests.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
*/
|
||||
public class ArtifactStubFactory
|
||||
{
|
||||
File workingDir;
|
||||
|
||||
boolean createFiles;
|
||||
|
||||
File srcFile;
|
||||
|
||||
boolean createUnpackableFile;
|
||||
|
||||
ArchiverManager archiverManager;
|
||||
|
||||
/**
|
||||
* Default constructor. This should be used only if real files aren't needed...just the artifact objects
|
||||
*/
|
||||
public ArtifactStubFactory()
|
||||
{
|
||||
this.workingDir = null;
|
||||
this.createFiles = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is to be used if files are needed and to set a working dir
|
||||
*
|
||||
* @param workingDir
|
||||
* @param createFiles
|
||||
*/
|
||||
public ArtifactStubFactory( File workingDir, boolean createFiles )
|
||||
{
|
||||
this.workingDir = new File( workingDir, "localTestRepo" );
|
||||
this.createFiles = createFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* If set, the file will be created as a zip/jar/war with a file inside that can be checked to exist after
|
||||
* unpacking.
|
||||
*
|
||||
* @param archiverManager
|
||||
*/
|
||||
public void setUnpackableFile( ArchiverManager archiverManager )
|
||||
{
|
||||
this.createUnpackableFile = true;
|
||||
this.archiverManager = archiverManager;
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, String version )
|
||||
throws IOException
|
||||
{
|
||||
return createArtifact( groupId, artifactId, version, Artifact.SCOPE_COMPILE, "jar", "" );
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, String version, String scope )
|
||||
throws IOException
|
||||
{
|
||||
return createArtifact( groupId, artifactId, version, scope, "jar", "" );
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||
String classifier )
|
||||
throws IOException
|
||||
{
|
||||
VersionRange vr = VersionRange.createFromVersion( version );
|
||||
return createArtifact( groupId, artifactId, vr, scope, type, classifier, false );
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String scope,
|
||||
String type, String classifier, boolean optional )
|
||||
throws IOException
|
||||
{
|
||||
ArtifactHandler ah = new DefaultArtifactHandlerStub( type, classifier );
|
||||
|
||||
Artifact artifact =
|
||||
new DefaultArtifact( groupId, artifactId, versionRange, scope, type, classifier, ah, optional );
|
||||
|
||||
// i have no idea why this needs to be done manually when isSnapshot is able to figure it out.
|
||||
artifact.setRelease( !artifact.isSnapshot() );
|
||||
|
||||
if ( createFiles )
|
||||
{
|
||||
setArtifactFile( artifact,this.workingDir,this.srcFile,this.createUnpackableFile );
|
||||
}
|
||||
return artifact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new empty file and attaches it to the artifact.
|
||||
*
|
||||
* @param artifact to attach the file to.
|
||||
* @param workingDir where to locate the new file
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setArtifactFile( Artifact artifact, File workingDir )
|
||||
throws IOException
|
||||
{
|
||||
setArtifactFile( artifact, workingDir, null, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyies the srcFile to the workingDir and then attaches it to the artifact. If srcFile is null, a new empty file
|
||||
* will be created.
|
||||
*
|
||||
* @param artifact to attach
|
||||
* @param workingDir where to copy the srcFile.
|
||||
* @param srcFile file to be attached.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setArtifactFile( Artifact artifact, File workingDir, File srcFile )
|
||||
throws IOException
|
||||
{
|
||||
setArtifactFile( artifact, workingDir, srcFile, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unpackable file (zip,jar etc) containing an empty file.
|
||||
*
|
||||
* @param artifact to attach
|
||||
* @param workingDir where to create the file.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setUnpackableArtifactFile( Artifact artifact, File workingDir )
|
||||
throws IOException
|
||||
{
|
||||
setArtifactFile( artifact, workingDir, null, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unpackable file (zip,jar etc) containing the srcFile. If srcFile is null, a new empty file will be
|
||||
* created.
|
||||
*
|
||||
* @param artifact to attach
|
||||
* @param workingDir where to create the file.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setUnpackableArtifactFile( Artifact artifact, File workingDir, File srcFile )
|
||||
throws IOException
|
||||
{
|
||||
setArtifactFile( artifact, workingDir, srcFile, true );
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a file that can be copied or unpacked based on the passed in artifact
|
||||
*/
|
||||
private void setArtifactFile( Artifact artifact, File workingDir, File srcFile, boolean createUnpackableFile )
|
||||
throws IOException
|
||||
{
|
||||
if ( workingDir == null )
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"The workingDir must be set." );
|
||||
}
|
||||
|
||||
String fileName = getFormattedFileName( artifact, false );
|
||||
|
||||
File theFile = new File( workingDir, fileName );
|
||||
theFile.getParentFile().mkdirs();
|
||||
|
||||
if ( srcFile == null )
|
||||
{
|
||||
theFile.createNewFile();
|
||||
}
|
||||
else if ( createUnpackableFile )
|
||||
{
|
||||
try
|
||||
{
|
||||
createUnpackableFile( artifact, theFile );
|
||||
}
|
||||
catch ( NoSuchArchiverException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch ( ArchiverException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FileUtils.copyFile( srcFile, theFile );
|
||||
}
|
||||
|
||||
artifact.setFile( theFile );
|
||||
}
|
||||
|
||||
static public String getUnpackableFileName( Artifact artifact )
|
||||
{
|
||||
return "" + artifact.getGroupId() + "-" + artifact.getArtifactId() + "-" + artifact.getVersion() + "-" +
|
||||
artifact.getClassifier() + "-" + artifact.getType() + ".txt";
|
||||
}
|
||||
|
||||
public void createUnpackableFile( Artifact artifact, File destFile )
|
||||
throws NoSuchArchiverException, ArchiverException, IOException
|
||||
{
|
||||
Archiver archiver = archiverManager.getArchiver( destFile );
|
||||
|
||||
archiver.setDestFile( destFile );
|
||||
archiver.addFile( srcFile, getUnpackableFileName( artifact ) );
|
||||
|
||||
try
|
||||
{
|
||||
setVariableValueToObject( archiver, "logger", new SilentLog() );
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
{
|
||||
System.out.println( "Unable to override logger with silent log." );
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ( archiver instanceof WarArchiver )
|
||||
{
|
||||
WarArchiver war = (WarArchiver) archiver;
|
||||
// the use of this is counter-intuitive:
|
||||
// http://jira.codehaus.org/browse/PLX-286
|
||||
war.setIgnoreWebxml( false );
|
||||
}
|
||||
archiver.createArchive();
|
||||
}
|
||||
|
||||
public Artifact getReleaseArtifact()
|
||||
throws IOException
|
||||
{
|
||||
return createArtifact( "testGroupId", "release", "1.0" );
|
||||
}
|
||||
|
||||
public Artifact getSnapshotArtifact()
|
||||
throws IOException
|
||||
{
|
||||
return createArtifact( "testGroupId", "snapshot", "2.0-SNAPSHOT" );
|
||||
}
|
||||
|
||||
public Set getReleaseAndSnapshotArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( getReleaseArtifact() );
|
||||
set.add( getSnapshotArtifact() );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getScopedArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "compile", "1.0", Artifact.SCOPE_COMPILE ) );
|
||||
set.add( createArtifact( "g", "provided", "1.0", Artifact.SCOPE_PROVIDED ) );
|
||||
set.add( createArtifact( "g", "test", "1.0", Artifact.SCOPE_TEST ) );
|
||||
set.add( createArtifact( "g", "runtime", "1.0", Artifact.SCOPE_RUNTIME ) );
|
||||
set.add( createArtifact( "g", "system", "1.0", Artifact.SCOPE_SYSTEM ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getTypedArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "war", null ) );
|
||||
set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", null ) );
|
||||
set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "sources", null ) );
|
||||
set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "zip", null ) );
|
||||
set.add( createArtifact( "g", "e", "1.0", Artifact.SCOPE_COMPILE, "rar", null ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getClassifiedArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "jar", "one" ) );
|
||||
set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", "two" ) );
|
||||
set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "jar", "three" ) );
|
||||
set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "jar", "four" ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getTypedArchiveArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "war", null ) );
|
||||
set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", null ) );
|
||||
set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "zip", null ) );
|
||||
set.add( createArtifact( "g", "e", "1.0", Artifact.SCOPE_COMPILE, "rar", null ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getArtifactArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "one", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "g", "two", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "g", "three", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "g", "four", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getGroupIdArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "one", "group-one", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "two", "group-two", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "three", "group-three", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "four", "group-four", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getMixedArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.addAll( getTypedArtifacts() );
|
||||
set.addAll( getScopedArtifacts() );
|
||||
set.addAll( getReleaseAndSnapshotArtifacts() );
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the createFiles.
|
||||
*/
|
||||
public boolean isCreateFiles()
|
||||
{
|
||||
return this.createFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createFiles The createFiles to set.
|
||||
*/
|
||||
public void setCreateFiles( boolean createFiles )
|
||||
{
|
||||
this.createFiles = createFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the workingDir.
|
||||
*/
|
||||
public File getWorkingDir()
|
||||
{
|
||||
return this.workingDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param workingDir The workingDir to set.
|
||||
*/
|
||||
public void setWorkingDir( File workingDir )
|
||||
{
|
||||
this.workingDir = workingDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the srcFile.
|
||||
*/
|
||||
public File getSrcFile()
|
||||
{
|
||||
return this.srcFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param srcFile The srcFile to set.
|
||||
*/
|
||||
public void setSrcFile( File srcFile )
|
||||
{
|
||||
this.srcFile = srcFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* convience method to set values to variables in objects that don't have setters
|
||||
*
|
||||
* @param object
|
||||
* @param variable
|
||||
* @param value
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
public static void setVariableValueToObject( Object object, String variable, Object value )
|
||||
throws IllegalAccessException
|
||||
{
|
||||
Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( variable, object.getClass() );
|
||||
|
||||
field.setAccessible( true );
|
||||
|
||||
field.set( object, value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the file name. If removeVersion is set, then the file name must be reconstructed from the artifactId,
|
||||
* Classifier (if used) and Type. Otherwise, this method returns the artifact file name.
|
||||
*
|
||||
* @param artifact File to be formatted.
|
||||
* @param removeVersion Specifies if the version should be removed from the file name.
|
||||
* @return Formatted file name in the format artifactId-[version]-[classifier].[type]
|
||||
*/
|
||||
public static String getFormattedFileName( Artifact artifact, boolean removeVersion )
|
||||
{
|
||||
String destFileName = null;
|
||||
|
||||
// if there is a file and we aren't stripping the version, just get the
|
||||
// name directly
|
||||
if ( artifact.getFile() != null && !removeVersion )
|
||||
{
|
||||
destFileName = artifact.getFile().getName();
|
||||
}
|
||||
else
|
||||
// if offline
|
||||
{
|
||||
String versionString = null;
|
||||
if ( !removeVersion )
|
||||
{
|
||||
versionString = "-" + artifact.getVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
versionString = "";
|
||||
}
|
||||
|
||||
String classifierString = "";
|
||||
|
||||
if ( StringUtils.isNotEmpty( artifact.getClassifier() ) )
|
||||
{
|
||||
classifierString = "-" + artifact.getClassifier();
|
||||
}
|
||||
|
||||
destFileName =
|
||||
artifact.getArtifactId() + versionString + classifierString + "." +
|
||||
artifact.getArtifactHandler().getExtension();
|
||||
}
|
||||
return destFileName;
|
||||
}
|
||||
|
||||
}
|
||||
package org.apache.maven.plugin.testing;
|
||||
|
||||
/*
|
||||
* 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.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.DefaultArtifact;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub;
|
||||
import org.codehaus.plexus.archiver.Archiver;
|
||||
import org.codehaus.plexus.archiver.ArchiverException;
|
||||
import org.codehaus.plexus.archiver.manager.ArchiverManager;
|
||||
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
|
||||
import org.codehaus.plexus.archiver.war.WarArchiver;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.codehaus.plexus.util.ReflectionUtils;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/**
|
||||
* This class creates artifacts to be used for testing purposes. It can optionally create actual files on the local disk
|
||||
* for things like copying. It can create these files as archives with named files inside to be used for testing things
|
||||
* like unpack. Also provided are some utility methods to quickly get a set of artifacts distinguished by various things
|
||||
* like group,artifact,type,scope, etc It was originally developed for the dependency plugin, but can be useful in other
|
||||
* plugins that need to simulate artifacts for unit tests.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
*/
|
||||
public class ArtifactStubFactory
|
||||
{
|
||||
File workingDir;
|
||||
|
||||
boolean createFiles;
|
||||
|
||||
File srcFile;
|
||||
|
||||
boolean createUnpackableFile;
|
||||
|
||||
ArchiverManager archiverManager;
|
||||
|
||||
/**
|
||||
* Default constructor. This should be used only if real files aren't needed...just the artifact objects
|
||||
*/
|
||||
public ArtifactStubFactory()
|
||||
{
|
||||
this.workingDir = null;
|
||||
this.createFiles = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is to be used if files are needed and to set a working dir
|
||||
*
|
||||
* @param workingDir
|
||||
* @param createFiles
|
||||
*/
|
||||
public ArtifactStubFactory( File workingDir, boolean createFiles )
|
||||
{
|
||||
this.workingDir = new File( workingDir, "localTestRepo" );
|
||||
this.createFiles = createFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* If set, the file will be created as a zip/jar/war with a file inside that can be checked to exist after
|
||||
* unpacking.
|
||||
*
|
||||
* @param archiverManager
|
||||
*/
|
||||
public void setUnpackableFile( ArchiverManager archiverManager )
|
||||
{
|
||||
this.createUnpackableFile = true;
|
||||
this.archiverManager = archiverManager;
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, String version )
|
||||
throws IOException
|
||||
{
|
||||
return createArtifact( groupId, artifactId, version, Artifact.SCOPE_COMPILE, "jar", "" );
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, String version, String scope )
|
||||
throws IOException
|
||||
{
|
||||
return createArtifact( groupId, artifactId, version, scope, "jar", "" );
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||
String classifier )
|
||||
throws IOException
|
||||
{
|
||||
VersionRange vr = VersionRange.createFromVersion( version );
|
||||
return createArtifact( groupId, artifactId, vr, scope, type, classifier, false );
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String scope,
|
||||
String type, String classifier, boolean optional )
|
||||
throws IOException
|
||||
{
|
||||
ArtifactHandler ah = new DefaultArtifactHandlerStub( type, classifier );
|
||||
|
||||
Artifact artifact =
|
||||
new DefaultArtifact( groupId, artifactId, versionRange, scope, type, classifier, ah, optional );
|
||||
|
||||
// i have no idea why this needs to be done manually when isSnapshot is able to figure it out.
|
||||
artifact.setRelease( !artifact.isSnapshot() );
|
||||
|
||||
if ( createFiles )
|
||||
{
|
||||
setArtifactFile( artifact,this.workingDir,this.srcFile,this.createUnpackableFile );
|
||||
}
|
||||
return artifact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new empty file and attaches it to the artifact.
|
||||
*
|
||||
* @param artifact to attach the file to.
|
||||
* @param workingDir where to locate the new file
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setArtifactFile( Artifact artifact, File workingDir )
|
||||
throws IOException
|
||||
{
|
||||
setArtifactFile( artifact, workingDir, null, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyies the srcFile to the workingDir and then attaches it to the artifact. If srcFile is null, a new empty file
|
||||
* will be created.
|
||||
*
|
||||
* @param artifact to attach
|
||||
* @param workingDir where to copy the srcFile.
|
||||
* @param srcFile file to be attached.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setArtifactFile( Artifact artifact, File workingDir, File srcFile )
|
||||
throws IOException
|
||||
{
|
||||
setArtifactFile( artifact, workingDir, srcFile, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unpackable file (zip,jar etc) containing an empty file.
|
||||
*
|
||||
* @param artifact to attach
|
||||
* @param workingDir where to create the file.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setUnpackableArtifactFile( Artifact artifact, File workingDir )
|
||||
throws IOException
|
||||
{
|
||||
setArtifactFile( artifact, workingDir, null, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unpackable file (zip,jar etc) containing the srcFile. If srcFile is null, a new empty file will be
|
||||
* created.
|
||||
*
|
||||
* @param artifact to attach
|
||||
* @param workingDir where to create the file.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void setUnpackableArtifactFile( Artifact artifact, File workingDir, File srcFile )
|
||||
throws IOException
|
||||
{
|
||||
setArtifactFile( artifact, workingDir, srcFile, true );
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a file that can be copied or unpacked based on the passed in artifact
|
||||
*/
|
||||
private void setArtifactFile( Artifact artifact, File workingDir, File srcFile, boolean createUnpackableFile )
|
||||
throws IOException
|
||||
{
|
||||
if ( workingDir == null )
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"The workingDir must be set." );
|
||||
}
|
||||
|
||||
String fileName = getFormattedFileName( artifact, false );
|
||||
|
||||
File theFile = new File( workingDir, fileName );
|
||||
theFile.getParentFile().mkdirs();
|
||||
|
||||
if ( srcFile == null )
|
||||
{
|
||||
theFile.createNewFile();
|
||||
}
|
||||
else if ( createUnpackableFile )
|
||||
{
|
||||
try
|
||||
{
|
||||
createUnpackableFile( artifact, theFile );
|
||||
}
|
||||
catch ( NoSuchArchiverException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch ( ArchiverException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FileUtils.copyFile( srcFile, theFile );
|
||||
}
|
||||
|
||||
artifact.setFile( theFile );
|
||||
}
|
||||
|
||||
static public String getUnpackableFileName( Artifact artifact )
|
||||
{
|
||||
return "" + artifact.getGroupId() + "-" + artifact.getArtifactId() + "-" + artifact.getVersion() + "-" +
|
||||
artifact.getClassifier() + "-" + artifact.getType() + ".txt";
|
||||
}
|
||||
|
||||
public void createUnpackableFile( Artifact artifact, File destFile )
|
||||
throws NoSuchArchiverException, ArchiverException, IOException
|
||||
{
|
||||
Archiver archiver = archiverManager.getArchiver( destFile );
|
||||
|
||||
archiver.setDestFile( destFile );
|
||||
archiver.addFile( srcFile, getUnpackableFileName( artifact ) );
|
||||
|
||||
try
|
||||
{
|
||||
setVariableValueToObject( archiver, "logger", new SilentLog() );
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
{
|
||||
System.out.println( "Unable to override logger with silent log." );
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ( archiver instanceof WarArchiver )
|
||||
{
|
||||
WarArchiver war = (WarArchiver) archiver;
|
||||
// the use of this is counter-intuitive:
|
||||
// http://jira.codehaus.org/browse/PLX-286
|
||||
war.setIgnoreWebxml( false );
|
||||
}
|
||||
archiver.createArchive();
|
||||
}
|
||||
|
||||
public Artifact getReleaseArtifact()
|
||||
throws IOException
|
||||
{
|
||||
return createArtifact( "testGroupId", "release", "1.0" );
|
||||
}
|
||||
|
||||
public Artifact getSnapshotArtifact()
|
||||
throws IOException
|
||||
{
|
||||
return createArtifact( "testGroupId", "snapshot", "2.0-SNAPSHOT" );
|
||||
}
|
||||
|
||||
public Set getReleaseAndSnapshotArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( getReleaseArtifact() );
|
||||
set.add( getSnapshotArtifact() );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getScopedArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "compile", "1.0", Artifact.SCOPE_COMPILE ) );
|
||||
set.add( createArtifact( "g", "provided", "1.0", Artifact.SCOPE_PROVIDED ) );
|
||||
set.add( createArtifact( "g", "test", "1.0", Artifact.SCOPE_TEST ) );
|
||||
set.add( createArtifact( "g", "runtime", "1.0", Artifact.SCOPE_RUNTIME ) );
|
||||
set.add( createArtifact( "g", "system", "1.0", Artifact.SCOPE_SYSTEM ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getTypedArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "war", null ) );
|
||||
set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", null ) );
|
||||
set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "sources", null ) );
|
||||
set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "zip", null ) );
|
||||
set.add( createArtifact( "g", "e", "1.0", Artifact.SCOPE_COMPILE, "rar", null ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getClassifiedArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "jar", "one" ) );
|
||||
set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", "two" ) );
|
||||
set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "jar", "three" ) );
|
||||
set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "jar", "four" ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getTypedArchiveArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "war", null ) );
|
||||
set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", null ) );
|
||||
set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "zip", null ) );
|
||||
set.add( createArtifact( "g", "e", "1.0", Artifact.SCOPE_COMPILE, "rar", null ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getArtifactArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "g", "one", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "g", "two", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "g", "three", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "g", "four", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getGroupIdArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.add( createArtifact( "one", "group-one", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "two", "group-two", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "three", "group-three", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
set.add( createArtifact( "four", "group-four", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set getMixedArtifacts()
|
||||
throws IOException
|
||||
{
|
||||
Set set = new HashSet();
|
||||
set.addAll( getTypedArtifacts() );
|
||||
set.addAll( getScopedArtifacts() );
|
||||
set.addAll( getReleaseAndSnapshotArtifacts() );
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the createFiles.
|
||||
*/
|
||||
public boolean isCreateFiles()
|
||||
{
|
||||
return this.createFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createFiles The createFiles to set.
|
||||
*/
|
||||
public void setCreateFiles( boolean createFiles )
|
||||
{
|
||||
this.createFiles = createFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the workingDir.
|
||||
*/
|
||||
public File getWorkingDir()
|
||||
{
|
||||
return this.workingDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param workingDir The workingDir to set.
|
||||
*/
|
||||
public void setWorkingDir( File workingDir )
|
||||
{
|
||||
this.workingDir = workingDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the srcFile.
|
||||
*/
|
||||
public File getSrcFile()
|
||||
{
|
||||
return this.srcFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param srcFile The srcFile to set.
|
||||
*/
|
||||
public void setSrcFile( File srcFile )
|
||||
{
|
||||
this.srcFile = srcFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* convience method to set values to variables in objects that don't have setters
|
||||
*
|
||||
* @param object
|
||||
* @param variable
|
||||
* @param value
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
public static void setVariableValueToObject( Object object, String variable, Object value )
|
||||
throws IllegalAccessException
|
||||
{
|
||||
Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( variable, object.getClass() );
|
||||
|
||||
field.setAccessible( true );
|
||||
|
||||
field.set( object, value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the file name. If removeVersion is set, then the file name must be reconstructed from the artifactId,
|
||||
* Classifier (if used) and Type. Otherwise, this method returns the artifact file name.
|
||||
*
|
||||
* @param artifact File to be formatted.
|
||||
* @param removeVersion Specifies if the version should be removed from the file name.
|
||||
* @return Formatted file name in the format artifactId-[version]-[classifier].[type]
|
||||
*/
|
||||
public static String getFormattedFileName( Artifact artifact, boolean removeVersion )
|
||||
{
|
||||
String destFileName = null;
|
||||
|
||||
// if there is a file and we aren't stripping the version, just get the
|
||||
// name directly
|
||||
if ( artifact.getFile() != null && !removeVersion )
|
||||
{
|
||||
destFileName = artifact.getFile().getName();
|
||||
}
|
||||
else
|
||||
// if offline
|
||||
{
|
||||
String versionString = null;
|
||||
if ( !removeVersion )
|
||||
{
|
||||
versionString = "-" + artifact.getVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
versionString = "";
|
||||
}
|
||||
|
||||
String classifierString = "";
|
||||
|
||||
if ( StringUtils.isNotEmpty( artifact.getClassifier() ) )
|
||||
{
|
||||
classifierString = "-" + artifact.getClassifier();
|
||||
}
|
||||
|
||||
destFileName =
|
||||
artifact.getArtifactId() + versionString + classifierString + "." +
|
||||
artifact.getArtifactHandler().getExtension();
|
||||
}
|
||||
return destFileName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,328 +1,328 @@
|
|||
package org.apache.maven.plugin.testing;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.plugin.logging.Log;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
/**
|
||||
* This logger implements both types of logs currently in use. It can be injected where needed
|
||||
* to turn off logs during testing where they aren't desired.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id: SilentLog.java 546355 2007-06-12 02:00:02Z brianf $
|
||||
*/
|
||||
public class SilentLog
|
||||
implements Log, Logger
|
||||
{
|
||||
/**
|
||||
* @return <code>false</code>
|
||||
* @see org.apache.maven.plugin.logging.Log#isDebugEnabled()
|
||||
*/
|
||||
public boolean isDebugEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence)
|
||||
*/
|
||||
public void debug( CharSequence content )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence, java.lang.Throwable)
|
||||
*/
|
||||
public void debug( CharSequence content, Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable)
|
||||
*/
|
||||
public void debug( Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>
|
||||
* @see org.apache.maven.plugin.logging.Log#isInfoEnabled()
|
||||
*/
|
||||
public boolean isInfoEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence)
|
||||
*/
|
||||
public void info( CharSequence content )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence, java.lang.Throwable)
|
||||
*/
|
||||
public void info( CharSequence content, Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable)
|
||||
*/
|
||||
public void info( Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#isWarnEnabled()
|
||||
*/
|
||||
public boolean isWarnEnabled()
|
||||
{
|
||||
// nop
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence)
|
||||
*/
|
||||
public void warn( CharSequence content )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence, java.lang.Throwable)
|
||||
*/
|
||||
public void warn( CharSequence content, Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable)
|
||||
*/
|
||||
public void warn( Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>
|
||||
* @see org.apache.maven.plugin.logging.Log#isErrorEnabled()
|
||||
*/
|
||||
public boolean isErrorEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence)
|
||||
*/
|
||||
public void error( CharSequence content )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence, java.lang.Throwable)
|
||||
*/
|
||||
public void error( CharSequence content, Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable)
|
||||
*/
|
||||
public void error( Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#debug(java.lang.String)
|
||||
*/
|
||||
public void debug( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#debug(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void debug( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#info(java.lang.String)
|
||||
*/
|
||||
public void info( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#info(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void info( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#warn(java.lang.String)
|
||||
*/
|
||||
public void warn( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#warn(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void warn( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#error(java.lang.String)
|
||||
*/
|
||||
public void error( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#error(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void error( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#fatalError(java.lang.String)
|
||||
*/
|
||||
public void fatalError( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#fatalError(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void fatalError( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>
|
||||
* @see org.codehaus.plexus.logging.Logger#isFatalErrorEnabled()
|
||||
*/
|
||||
public boolean isFatalErrorEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>
|
||||
* @see org.codehaus.plexus.logging.Logger#getChildLogger(java.lang.String)
|
||||
*/
|
||||
public Logger getChildLogger( String name )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>0</code>
|
||||
* @see org.codehaus.plexus.logging.Logger#getThreshold()
|
||||
*/
|
||||
public int getThreshold()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>
|
||||
* @see org.codehaus.plexus.logging.Logger#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package org.apache.maven.plugin.testing;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.plugin.logging.Log;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
/**
|
||||
* This logger implements both types of logs currently in use. It can be injected where needed
|
||||
* to turn off logs during testing where they aren't desired.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SilentLog
|
||||
implements Log, Logger
|
||||
{
|
||||
/**
|
||||
* @return <code>false</code>
|
||||
* @see org.apache.maven.plugin.logging.Log#isDebugEnabled()
|
||||
*/
|
||||
public boolean isDebugEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence)
|
||||
*/
|
||||
public void debug( CharSequence content )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence, java.lang.Throwable)
|
||||
*/
|
||||
public void debug( CharSequence content, Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable)
|
||||
*/
|
||||
public void debug( Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>
|
||||
* @see org.apache.maven.plugin.logging.Log#isInfoEnabled()
|
||||
*/
|
||||
public boolean isInfoEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence)
|
||||
*/
|
||||
public void info( CharSequence content )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence, java.lang.Throwable)
|
||||
*/
|
||||
public void info( CharSequence content, Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable)
|
||||
*/
|
||||
public void info( Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#isWarnEnabled()
|
||||
*/
|
||||
public boolean isWarnEnabled()
|
||||
{
|
||||
// nop
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence)
|
||||
*/
|
||||
public void warn( CharSequence content )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence, java.lang.Throwable)
|
||||
*/
|
||||
public void warn( CharSequence content, Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable)
|
||||
*/
|
||||
public void warn( Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>
|
||||
* @see org.apache.maven.plugin.logging.Log#isErrorEnabled()
|
||||
*/
|
||||
public boolean isErrorEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence)
|
||||
*/
|
||||
public void error( CharSequence content )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence, java.lang.Throwable)
|
||||
*/
|
||||
public void error( CharSequence content, Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable)
|
||||
*/
|
||||
public void error( Throwable error )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#debug(java.lang.String)
|
||||
*/
|
||||
public void debug( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#debug(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void debug( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#info(java.lang.String)
|
||||
*/
|
||||
public void info( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#info(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void info( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#warn(java.lang.String)
|
||||
*/
|
||||
public void warn( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#warn(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void warn( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#error(java.lang.String)
|
||||
*/
|
||||
public void error( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#error(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void error( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#fatalError(java.lang.String)
|
||||
*/
|
||||
public void fatalError( String message )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.codehaus.plexus.logging.Logger#fatalError(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
public void fatalError( String message, Throwable throwable )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>
|
||||
* @see org.codehaus.plexus.logging.Logger#isFatalErrorEnabled()
|
||||
*/
|
||||
public boolean isFatalErrorEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>
|
||||
* @see org.codehaus.plexus.logging.Logger#getChildLogger(java.lang.String)
|
||||
*/
|
||||
public Logger getChildLogger( String name )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>0</code>
|
||||
* @see org.codehaus.plexus.logging.Logger#getThreshold()
|
||||
*/
|
||||
public int getThreshold()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>
|
||||
* @see org.codehaus.plexus.logging.Logger#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,210 +1,210 @@
|
|||
package org.apache.maven.plugin.testing.stubs;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
|
||||
/**
|
||||
* Minimal artifact handler used by the stub factory to create unpackable archives.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id: $
|
||||
*/
|
||||
public class DefaultArtifactHandlerStub
|
||||
implements ArtifactHandler
|
||||
{
|
||||
private String extension;
|
||||
|
||||
private String type;
|
||||
|
||||
private String classifier;
|
||||
|
||||
private String directory;
|
||||
|
||||
private String packaging;
|
||||
|
||||
private boolean includesDependencies;
|
||||
|
||||
private String language;
|
||||
|
||||
private boolean addedToClasspath;
|
||||
|
||||
/**
|
||||
* @param t the artifact handler type
|
||||
* @param c the artifact handler classifier
|
||||
*/
|
||||
public DefaultArtifactHandlerStub( String t, String c )
|
||||
{
|
||||
type = t;
|
||||
classifier = c;
|
||||
if ( t.equals( "test-jar" ) )
|
||||
{
|
||||
extension = "jar";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param t the artifact handler type
|
||||
*/
|
||||
public DefaultArtifactHandlerStub( String type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getExtension()
|
||||
{
|
||||
if ( extension == null )
|
||||
{
|
||||
extension = type;
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the artifact handler type
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getClassifier()
|
||||
{
|
||||
return classifier;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getDirectory()
|
||||
{
|
||||
if ( directory == null )
|
||||
{
|
||||
directory = getPackaging() + "s";
|
||||
}
|
||||
return directory;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getPackaging()
|
||||
{
|
||||
if ( packaging == null )
|
||||
{
|
||||
packaging = type;
|
||||
}
|
||||
return packaging;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean isIncludesDependencies()
|
||||
{
|
||||
return includesDependencies;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLanguage()
|
||||
{
|
||||
if ( language == null )
|
||||
{
|
||||
language = "none";
|
||||
}
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean isAddedToClasspath()
|
||||
{
|
||||
return addedToClasspath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theAddedToClasspath
|
||||
* The addedToClasspath to set.
|
||||
*/
|
||||
public void setAddedToClasspath( boolean theAddedToClasspath )
|
||||
{
|
||||
this.addedToClasspath = theAddedToClasspath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theClassifier
|
||||
* The classifier to set.
|
||||
*/
|
||||
public void setClassifier( String theClassifier )
|
||||
{
|
||||
this.classifier = theClassifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theDirectory
|
||||
* The directory to set.
|
||||
*/
|
||||
public void setDirectory( String theDirectory )
|
||||
{
|
||||
this.directory = theDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theExtension
|
||||
* The extension to set.
|
||||
*/
|
||||
public void setExtension( String theExtension )
|
||||
{
|
||||
this.extension = theExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theIncludesDependencies
|
||||
* The includesDependencies to set.
|
||||
*/
|
||||
public void setIncludesDependencies( boolean theIncludesDependencies )
|
||||
{
|
||||
this.includesDependencies = theIncludesDependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theLanguage
|
||||
* The language to set.
|
||||
*/
|
||||
public void setLanguage( String theLanguage )
|
||||
{
|
||||
this.language = theLanguage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param thePackaging
|
||||
* The packaging to set.
|
||||
*/
|
||||
public void setPackaging( String thePackaging )
|
||||
{
|
||||
this.packaging = thePackaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theType
|
||||
* The type to set.
|
||||
*/
|
||||
public void setType( String theType )
|
||||
{
|
||||
this.type = theType;
|
||||
}
|
||||
}
|
||||
package org.apache.maven.plugin.testing.stubs;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
|
||||
/**
|
||||
* Minimal artifact handler used by the stub factory to create unpackable archives.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DefaultArtifactHandlerStub
|
||||
implements ArtifactHandler
|
||||
{
|
||||
private String extension;
|
||||
|
||||
private String type;
|
||||
|
||||
private String classifier;
|
||||
|
||||
private String directory;
|
||||
|
||||
private String packaging;
|
||||
|
||||
private boolean includesDependencies;
|
||||
|
||||
private String language;
|
||||
|
||||
private boolean addedToClasspath;
|
||||
|
||||
/**
|
||||
* @param t the artifact handler type
|
||||
* @param c the artifact handler classifier
|
||||
*/
|
||||
public DefaultArtifactHandlerStub( String t, String c )
|
||||
{
|
||||
type = t;
|
||||
classifier = c;
|
||||
if ( t.equals( "test-jar" ) )
|
||||
{
|
||||
extension = "jar";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param t the artifact handler type
|
||||
*/
|
||||
public DefaultArtifactHandlerStub( String type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getExtension()
|
||||
{
|
||||
if ( extension == null )
|
||||
{
|
||||
extension = type;
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the artifact handler type
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getClassifier()
|
||||
{
|
||||
return classifier;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getDirectory()
|
||||
{
|
||||
if ( directory == null )
|
||||
{
|
||||
directory = getPackaging() + "s";
|
||||
}
|
||||
return directory;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getPackaging()
|
||||
{
|
||||
if ( packaging == null )
|
||||
{
|
||||
packaging = type;
|
||||
}
|
||||
return packaging;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean isIncludesDependencies()
|
||||
{
|
||||
return includesDependencies;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String getLanguage()
|
||||
{
|
||||
if ( language == null )
|
||||
{
|
||||
language = "none";
|
||||
}
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean isAddedToClasspath()
|
||||
{
|
||||
return addedToClasspath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theAddedToClasspath
|
||||
* The addedToClasspath to set.
|
||||
*/
|
||||
public void setAddedToClasspath( boolean theAddedToClasspath )
|
||||
{
|
||||
this.addedToClasspath = theAddedToClasspath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theClassifier
|
||||
* The classifier to set.
|
||||
*/
|
||||
public void setClassifier( String theClassifier )
|
||||
{
|
||||
this.classifier = theClassifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theDirectory
|
||||
* The directory to set.
|
||||
*/
|
||||
public void setDirectory( String theDirectory )
|
||||
{
|
||||
this.directory = theDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theExtension
|
||||
* The extension to set.
|
||||
*/
|
||||
public void setExtension( String theExtension )
|
||||
{
|
||||
this.extension = theExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theIncludesDependencies
|
||||
* The includesDependencies to set.
|
||||
*/
|
||||
public void setIncludesDependencies( boolean theIncludesDependencies )
|
||||
{
|
||||
this.includesDependencies = theIncludesDependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theLanguage
|
||||
* The language to set.
|
||||
*/
|
||||
public void setLanguage( String theLanguage )
|
||||
{
|
||||
this.language = theLanguage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param thePackaging
|
||||
* The packaging to set.
|
||||
*/
|
||||
public void setPackaging( String thePackaging )
|
||||
{
|
||||
this.packaging = thePackaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theType
|
||||
* The type to set.
|
||||
*/
|
||||
public void setType( String theType )
|
||||
{
|
||||
this.type = theType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,89 +1,89 @@
|
|||
package org.apache.maven.plugin.testing.stubs;
|
||||
|
||||
/*
|
||||
* 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.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactCollector;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.resolver.ResolutionNode;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id: $
|
||||
*/
|
||||
public class StubArtifactCollector
|
||||
implements ArtifactCollector
|
||||
{
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public StubArtifactCollector()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public ArtifactResolutionResult collect( Set theArtifacts, Artifact theOriginatingArtifact,
|
||||
ArtifactRepository theLocalRepository, List theRemoteRepositories,
|
||||
ArtifactMetadataSource theSource, ArtifactFilter theFilter,
|
||||
List theListeners )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
Set nodes = new HashSet();
|
||||
ArtifactResolutionResult arr = new ArtifactResolutionResult();
|
||||
|
||||
Iterator iter = theArtifacts.iterator();
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
nodes.add( new ResolutionNode( (Artifact) iter.next(), theRemoteRepositories ) );
|
||||
}
|
||||
arr.setArtifactResolutionNodes( nodes );
|
||||
return arr;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public ArtifactResolutionResult collect( Set theArtifacts, Artifact theOriginatingArtifact, Map theManagedVersions,
|
||||
ArtifactRepository theLocalRepository, List theRemoteRepositories,
|
||||
ArtifactMetadataSource theSource, ArtifactFilter theFilter,
|
||||
List theListeners )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
Set nodes = new HashSet();
|
||||
ArtifactResolutionResult arr = new ArtifactResolutionResult();
|
||||
|
||||
Iterator iter = theArtifacts.iterator();
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
nodes.add( new ResolutionNode( (Artifact) iter.next(), theRemoteRepositories ) );
|
||||
}
|
||||
arr.setArtifactResolutionNodes( nodes );
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
package org.apache.maven.plugin.testing.stubs;
|
||||
|
||||
/*
|
||||
* 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.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactCollector;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.resolver.ResolutionNode;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class StubArtifactCollector
|
||||
implements ArtifactCollector
|
||||
{
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public StubArtifactCollector()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public ArtifactResolutionResult collect( Set theArtifacts, Artifact theOriginatingArtifact,
|
||||
ArtifactRepository theLocalRepository, List theRemoteRepositories,
|
||||
ArtifactMetadataSource theSource, ArtifactFilter theFilter,
|
||||
List theListeners )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
Set nodes = new HashSet();
|
||||
ArtifactResolutionResult arr = new ArtifactResolutionResult();
|
||||
|
||||
Iterator iter = theArtifacts.iterator();
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
nodes.add( new ResolutionNode( (Artifact) iter.next(), theRemoteRepositories ) );
|
||||
}
|
||||
arr.setArtifactResolutionNodes( nodes );
|
||||
return arr;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public ArtifactResolutionResult collect( Set theArtifacts, Artifact theOriginatingArtifact, Map theManagedVersions,
|
||||
ArtifactRepository theLocalRepository, List theRemoteRepositories,
|
||||
ArtifactMetadataSource theSource, ArtifactFilter theFilter,
|
||||
List theListeners )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
Set nodes = new HashSet();
|
||||
ArtifactResolutionResult arr = new ArtifactResolutionResult();
|
||||
|
||||
Iterator iter = theArtifacts.iterator();
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
nodes.add( new ResolutionNode( (Artifact) iter.next(), theRemoteRepositories ) );
|
||||
}
|
||||
arr.setArtifactResolutionNodes( nodes );
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,173 +1,173 @@
|
|||
package org.apache.maven.plugin.testing.stubs;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id: $
|
||||
*/
|
||||
public class StubArtifactRepository
|
||||
implements ArtifactRepository
|
||||
{
|
||||
String baseDir = null;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param dir the basedir
|
||||
*/
|
||||
public StubArtifactRepository( String dir )
|
||||
{
|
||||
baseDir = dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the <code>artifactId</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#pathOf(org.apache.maven.artifact.Artifact)
|
||||
*/
|
||||
public String pathOf( Artifact artifact )
|
||||
{
|
||||
return artifact.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#pathOfRemoteRepositoryMetadata(org.apache.maven.artifact.metadata.ArtifactMetadata)
|
||||
*/
|
||||
public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the filename of this metadata on the local repository.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#pathOfLocalRepositoryMetadata(org.apache.maven.artifact.metadata.ArtifactMetadata, org.apache.maven.artifact.repository.ArtifactRepository)
|
||||
*/
|
||||
public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
|
||||
{
|
||||
return metadata.getLocalFilename( repository );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getUrl()
|
||||
*/
|
||||
public String getUrl()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>basedir</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getBasedir()
|
||||
*/
|
||||
public String getBasedir()
|
||||
{
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getProtocol()
|
||||
*/
|
||||
public String getProtocol()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getId()
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getSnapshots()
|
||||
*/
|
||||
public ArtifactRepositoryPolicy getSnapshots()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getReleases()
|
||||
*/
|
||||
public ArtifactRepositoryPolicy getReleases()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getLayout()
|
||||
*/
|
||||
public ArtifactRepositoryLayout getLayout()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getKey()
|
||||
*/
|
||||
public String getKey()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#isUniqueVersion()
|
||||
*/
|
||||
public boolean isUniqueVersion()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#setBlacklisted(boolean)
|
||||
*/
|
||||
public void setBlacklisted( boolean blackListed )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#isBlacklisted()
|
||||
*/
|
||||
public boolean isBlacklisted()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package org.apache.maven.plugin.testing.stubs;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class StubArtifactRepository
|
||||
implements ArtifactRepository
|
||||
{
|
||||
String baseDir = null;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param dir the basedir
|
||||
*/
|
||||
public StubArtifactRepository( String dir )
|
||||
{
|
||||
baseDir = dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the <code>artifactId</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#pathOf(org.apache.maven.artifact.Artifact)
|
||||
*/
|
||||
public String pathOf( Artifact artifact )
|
||||
{
|
||||
return artifact.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#pathOfRemoteRepositoryMetadata(org.apache.maven.artifact.metadata.ArtifactMetadata)
|
||||
*/
|
||||
public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the filename of this metadata on the local repository.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#pathOfLocalRepositoryMetadata(org.apache.maven.artifact.metadata.ArtifactMetadata, org.apache.maven.artifact.repository.ArtifactRepository)
|
||||
*/
|
||||
public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
|
||||
{
|
||||
return metadata.getLocalFilename( repository );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getUrl()
|
||||
*/
|
||||
public String getUrl()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>basedir</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getBasedir()
|
||||
*/
|
||||
public String getBasedir()
|
||||
{
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getProtocol()
|
||||
*/
|
||||
public String getProtocol()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getId()
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getSnapshots()
|
||||
*/
|
||||
public ArtifactRepositoryPolicy getSnapshots()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getReleases()
|
||||
*/
|
||||
public ArtifactRepositoryPolicy getReleases()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getLayout()
|
||||
*/
|
||||
public ArtifactRepositoryLayout getLayout()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#getKey()
|
||||
*/
|
||||
public String getKey()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#isUniqueVersion()
|
||||
*/
|
||||
public boolean isUniqueVersion()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#setBlacklisted(boolean)
|
||||
*/
|
||||
public void setBlacklisted( boolean blackListed )
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>false</code>.
|
||||
* @see org.apache.maven.artifact.repository.ArtifactRepository#isBlacklisted()
|
||||
*/
|
||||
public boolean isBlacklisted()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,188 +1,188 @@
|
|||
package org.apache.maven.plugin.testing.stubs;
|
||||
|
||||
/*
|
||||
* 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.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.plugin.testing.ArtifactStubFactory;
|
||||
|
||||
/**
|
||||
* Stub resolver. The constructor allows the specification of the exception to throw so that handling can be tested too.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id: $
|
||||
*/
|
||||
public class StubArtifactResolver
|
||||
implements ArtifactResolver
|
||||
{
|
||||
|
||||
boolean throwArtifactResolutionException;
|
||||
|
||||
boolean throwArtifactNotFoundException;
|
||||
|
||||
ArtifactStubFactory factory;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param factory
|
||||
* @param throwArtifactResolutionException
|
||||
* @param throwArtifactNotFoundException
|
||||
*/
|
||||
public StubArtifactResolver( ArtifactStubFactory factory, boolean throwArtifactResolutionException,
|
||||
boolean throwArtifactNotFoundException )
|
||||
{
|
||||
this.throwArtifactNotFoundException = throwArtifactNotFoundException;
|
||||
this.throwArtifactResolutionException = throwArtifactResolutionException;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates dummy file and sets it in the artifact to simulate resolution
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolve(org.apache.maven.artifact.Artifact,
|
||||
* java.util.List,
|
||||
* org.apache.maven.artifact.repository.ArtifactRepository)
|
||||
*/
|
||||
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
if ( !this.throwArtifactNotFoundException && !this.throwArtifactResolutionException )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( factory != null )
|
||||
{
|
||||
factory.setArtifactFile( artifact, factory.getWorkingDir() );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( "IOException: " + e.getMessage(), artifact, e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( throwArtifactResolutionException )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Catch!", artifact );
|
||||
}
|
||||
|
||||
throw new ArtifactNotFoundException( "Catch!", artifact );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository, org.apache.maven.artifact.metadata.ArtifactMetadataSource)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
List remoteRepositories, ArtifactRepository localRepository,
|
||||
ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository, org.apache.maven.artifact.metadata.ArtifactMetadataSource, java.util.List)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
List remoteRepositories, ArtifactRepository localRepository,
|
||||
ArtifactMetadataSource source, List listeners )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source,
|
||||
ArtifactFilter filter )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter, java.util.List)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source,
|
||||
ArtifactFilter filter, List listeners )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveAlways(org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository)
|
||||
*/
|
||||
public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
// nop
|
||||
}
|
||||
}
|
||||
package org.apache.maven.plugin.testing.stubs;
|
||||
|
||||
/*
|
||||
* 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.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.plugin.testing.ArtifactStubFactory;
|
||||
|
||||
/**
|
||||
* Stub resolver. The constructor allows the specification of the exception to throw so that handling can be tested too.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class StubArtifactResolver
|
||||
implements ArtifactResolver
|
||||
{
|
||||
|
||||
boolean throwArtifactResolutionException;
|
||||
|
||||
boolean throwArtifactNotFoundException;
|
||||
|
||||
ArtifactStubFactory factory;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param factory
|
||||
* @param throwArtifactResolutionException
|
||||
* @param throwArtifactNotFoundException
|
||||
*/
|
||||
public StubArtifactResolver( ArtifactStubFactory factory, boolean throwArtifactResolutionException,
|
||||
boolean throwArtifactNotFoundException )
|
||||
{
|
||||
this.throwArtifactNotFoundException = throwArtifactNotFoundException;
|
||||
this.throwArtifactResolutionException = throwArtifactResolutionException;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates dummy file and sets it in the artifact to simulate resolution
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolve(org.apache.maven.artifact.Artifact,
|
||||
* java.util.List,
|
||||
* org.apache.maven.artifact.repository.ArtifactRepository)
|
||||
*/
|
||||
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
if ( !this.throwArtifactNotFoundException && !this.throwArtifactResolutionException )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( factory != null )
|
||||
{
|
||||
factory.setArtifactFile( artifact, factory.getWorkingDir() );
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( "IOException: " + e.getMessage(), artifact, e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( throwArtifactResolutionException )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Catch!", artifact );
|
||||
}
|
||||
|
||||
throw new ArtifactNotFoundException( "Catch!", artifact );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository, org.apache.maven.artifact.metadata.ArtifactMetadataSource)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
List remoteRepositories, ArtifactRepository localRepository,
|
||||
ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository, org.apache.maven.artifact.metadata.ArtifactMetadataSource, java.util.List)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
List remoteRepositories, ArtifactRepository localRepository,
|
||||
ArtifactMetadataSource source, List listeners )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source,
|
||||
ArtifactFilter filter )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code>.
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveTransitively(java.util.Set, org.apache.maven.artifact.Artifact, java.util.Map, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List, org.apache.maven.artifact.metadata.ArtifactMetadataSource, org.apache.maven.artifact.resolver.filter.ArtifactFilter, java.util.List)
|
||||
*/
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source,
|
||||
ArtifactFilter filter, List listeners )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, do nothing.
|
||||
*
|
||||
* @see org.apache.maven.artifact.resolver.ArtifactResolver#resolveAlways(org.apache.maven.artifact.Artifact, java.util.List, org.apache.maven.artifact.repository.ArtifactRepository)
|
||||
*/
|
||||
public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
// nop
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
package org.apache.maven.plugin.testing;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ArtifactStubFactoryTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testVersionChecks() throws IOException
|
||||
{
|
||||
ArtifactStubFactory factory = new ArtifactStubFactory();
|
||||
assertTrue(factory.getReleaseArtifact().isRelease());
|
||||
assertFalse(factory.getReleaseArtifact().isSnapshot());
|
||||
assertTrue(factory.getSnapshotArtifact().isSnapshot());
|
||||
assertFalse(factory.getSnapshotArtifact().isRelease());
|
||||
|
||||
}
|
||||
|
||||
public void testCreateFiles() throws IOException
|
||||
{
|
||||
ArtifactStubFactory factory = new ArtifactStubFactory();
|
||||
assertFalse(factory.isCreateFiles());
|
||||
}
|
||||
}
|
||||
package org.apache.maven.plugin.testing;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ArtifactStubFactoryTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testVersionChecks() throws IOException
|
||||
{
|
||||
ArtifactStubFactory factory = new ArtifactStubFactory();
|
||||
assertTrue(factory.getReleaseArtifact().isRelease());
|
||||
assertFalse(factory.getReleaseArtifact().isSnapshot());
|
||||
assertTrue(factory.getSnapshotArtifact().isSnapshot());
|
||||
assertFalse(factory.getSnapshotArtifact().isRelease());
|
||||
|
||||
}
|
||||
|
||||
public void testCreateFiles() throws IOException
|
||||
{
|
||||
ArtifactStubFactory factory = new ArtifactStubFactory();
|
||||
assertFalse(factory.isCreateFiles());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +1,81 @@
|
|||
package org.apache.maven.plugin.testing;
|
||||
|
||||
/*
|
||||
* 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 junit.framework.TestCase;
|
||||
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
public class TestSilentLog
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
public void testLog()
|
||||
{
|
||||
Log log = new SilentLog();
|
||||
String text = new String( "Text" );
|
||||
Throwable e = new RuntimeException();
|
||||
log.debug( text );
|
||||
log.debug( text, e );
|
||||
log.debug( e );
|
||||
log.info( text );
|
||||
log.info( text, e );
|
||||
log.info( e );
|
||||
log.warn( text );
|
||||
log.warn( text, e );
|
||||
log.warn( e );
|
||||
log.error( text );
|
||||
log.error( text, e );
|
||||
log.error( e );
|
||||
log.isDebugEnabled();
|
||||
log.isErrorEnabled();
|
||||
log.isWarnEnabled();
|
||||
log.isInfoEnabled();
|
||||
}
|
||||
|
||||
public void testLogger()
|
||||
{
|
||||
Logger log = new SilentLog();
|
||||
String text = new String( "Text" );
|
||||
Throwable e = new RuntimeException();
|
||||
|
||||
log.debug( text );
|
||||
log.debug( text, e );
|
||||
log.error( text );
|
||||
log.error( text, e );
|
||||
log.warn( text );
|
||||
log.warn( text, e );
|
||||
log.info( text );
|
||||
log.info( text, e );
|
||||
|
||||
log.fatalError( text );
|
||||
log.fatalError( text, e );
|
||||
log.getChildLogger( text );
|
||||
log.getName();
|
||||
log.getThreshold();
|
||||
log.isDebugEnabled();
|
||||
log.isErrorEnabled();
|
||||
log.isFatalErrorEnabled();
|
||||
log.isInfoEnabled();
|
||||
log.isWarnEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
package org.apache.maven.plugin.testing;
|
||||
|
||||
/*
|
||||
* 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 junit.framework.TestCase;
|
||||
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
public class TestSilentLog
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
public void testLog()
|
||||
{
|
||||
Log log = new SilentLog();
|
||||
String text = new String( "Text" );
|
||||
Throwable e = new RuntimeException();
|
||||
log.debug( text );
|
||||
log.debug( text, e );
|
||||
log.debug( e );
|
||||
log.info( text );
|
||||
log.info( text, e );
|
||||
log.info( e );
|
||||
log.warn( text );
|
||||
log.warn( text, e );
|
||||
log.warn( e );
|
||||
log.error( text );
|
||||
log.error( text, e );
|
||||
log.error( e );
|
||||
log.isDebugEnabled();
|
||||
log.isErrorEnabled();
|
||||
log.isWarnEnabled();
|
||||
log.isInfoEnabled();
|
||||
}
|
||||
|
||||
public void testLogger()
|
||||
{
|
||||
Logger log = new SilentLog();
|
||||
String text = new String( "Text" );
|
||||
Throwable e = new RuntimeException();
|
||||
|
||||
log.debug( text );
|
||||
log.debug( text, e );
|
||||
log.error( text );
|
||||
log.error( text, e );
|
||||
log.warn( text );
|
||||
log.warn( text, e );
|
||||
log.info( text );
|
||||
log.info( text, e );
|
||||
|
||||
log.fatalError( text );
|
||||
log.fatalError( text, e );
|
||||
log.getChildLogger( text );
|
||||
log.getName();
|
||||
log.getThreshold();
|
||||
log.isDebugEnabled();
|
||||
log.isErrorEnabled();
|
||||
log.isFatalErrorEnabled();
|
||||
log.isInfoEnabled();
|
||||
log.isWarnEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue