|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.maven.plugin.testing.ArtifactStubFactory
public class ArtifactStubFactory
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.
| Constructor Summary | |
|---|---|
ArtifactStubFactory()
Default constructor. |
|
ArtifactStubFactory(File workingDir,
boolean createFiles)
This constructor is to be used if files are needed and to set a working dir |
|
| Method Summary | |
|---|---|
org.apache.maven.artifact.Artifact |
createArtifact(String groupId,
String artifactId,
String version)
|
org.apache.maven.artifact.Artifact |
createArtifact(String groupId,
String artifactId,
String version,
String scope)
|
org.apache.maven.artifact.Artifact |
createArtifact(String groupId,
String artifactId,
String version,
String scope,
String type,
String classifier)
|
org.apache.maven.artifact.Artifact |
createArtifact(String groupId,
String artifactId,
org.apache.maven.artifact.versioning.VersionRange versionRange,
String scope,
String type,
String classifier,
boolean optional)
|
void |
createUnpackableFile(org.apache.maven.artifact.Artifact artifact,
File destFile)
|
Set |
getArtifactArtifacts()
|
Set |
getClassifiedArtifacts()
|
static String |
getFormattedFileName(org.apache.maven.artifact.Artifact artifact,
boolean removeVersion)
Builds the file name. |
Set |
getGroupIdArtifacts()
|
Set |
getMixedArtifacts()
|
Set |
getReleaseAndSnapshotArtifacts()
|
org.apache.maven.artifact.Artifact |
getReleaseArtifact()
|
Set |
getScopedArtifacts()
|
org.apache.maven.artifact.Artifact |
getSnapshotArtifact()
|
File |
getSrcFile()
|
Set |
getTypedArchiveArtifacts()
|
Set |
getTypedArtifacts()
|
static String |
getUnpackableFileName(org.apache.maven.artifact.Artifact artifact)
|
File |
getWorkingDir()
|
boolean |
isCreateFiles()
|
void |
setArtifactFile(org.apache.maven.artifact.Artifact artifact,
File workingDir)
Creates a new empty file and attaches it to the artifact. |
void |
setArtifactFile(org.apache.maven.artifact.Artifact artifact,
File workingDir,
File srcFile)
Copyies the srcFile to the workingDir and then attaches it to the artifact. |
void |
setCreateFiles(boolean createFiles)
|
void |
setSrcFile(File srcFile)
|
void |
setUnpackableArtifactFile(org.apache.maven.artifact.Artifact artifact,
File workingDir)
Creates an unpackable file (zip,jar etc) containing an empty file. |
void |
setUnpackableArtifactFile(org.apache.maven.artifact.Artifact artifact,
File workingDir,
File srcFile)
Creates an unpackable file (zip,jar etc) containing the srcFile. |
void |
setUnpackableFile(org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager)
If set, the file will be created as a zip/jar/war with a file inside that can be checked to exist after unpacking. |
static void |
setVariableValueToObject(Object object,
String variable,
Object value)
Convenience method to set values to variables in objects that don't have setters |
void |
setWorkingDir(File workingDir)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArtifactStubFactory()
public ArtifactStubFactory(File workingDir,
boolean createFiles)
workingDir - createFiles - | Method Detail |
|---|
public void setUnpackableFile(org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager)
archiverManager -
public org.apache.maven.artifact.Artifact createArtifact(String groupId,
String artifactId,
String version)
throws IOException
groupId - artifactId - version -
DefaultArtifact instance for the given parameters
IOException - if anycreateArtifact(String, String, String, String, String, String)
public org.apache.maven.artifact.Artifact createArtifact(String groupId,
String artifactId,
String version,
String scope)
throws IOException
groupId - artifactId - version - scope -
DefaultArtifact instance for the given parameters
IOException - if anycreateArtifact(String, String, String, String, String, String)
public org.apache.maven.artifact.Artifact createArtifact(String groupId,
String artifactId,
String version,
String scope,
String type,
String classifier)
throws IOException
groupId - artifactId - version - scope - type - classifier -
DefaultArtifact instance for the given parameters
IOException - if anycreateArtifact(String, String, VersionRange, String, String, String, boolean)
public org.apache.maven.artifact.Artifact createArtifact(String groupId,
String artifactId,
org.apache.maven.artifact.versioning.VersionRange versionRange,
String scope,
String type,
String classifier,
boolean optional)
throws IOException
groupId - not nullartifactId - not nullversionRange - not nullscope - not nulltype - not nullclassifier - optional - not null
DefaultArtifact instance
IOException - if any
public void setArtifactFile(org.apache.maven.artifact.Artifact artifact,
File workingDir)
throws IOException
artifact - to attach the file to.workingDir - where to locate the new file
IOException
public void setArtifactFile(org.apache.maven.artifact.Artifact artifact,
File workingDir,
File srcFile)
throws IOException
artifact - to attachworkingDir - where to copy the srcFile.srcFile - file to be attached.
IOException
public void setUnpackableArtifactFile(org.apache.maven.artifact.Artifact artifact,
File workingDir)
throws IOException
artifact - to attachworkingDir - where to create the file.
IOException
public void setUnpackableArtifactFile(org.apache.maven.artifact.Artifact artifact,
File workingDir,
File srcFile)
throws IOException
artifact - to attachworkingDir - where to create the file.srcFile -
IOException - if anypublic static String getUnpackableFileName(org.apache.maven.artifact.Artifact artifact)
artifact -
public void createUnpackableFile(org.apache.maven.artifact.Artifact artifact,
File destFile)
throws org.codehaus.plexus.archiver.manager.NoSuchArchiverException,
org.codehaus.plexus.archiver.ArchiverException,
IOException
artifact - destFile -
org.codehaus.plexus.archiver.manager.NoSuchArchiverException
org.codehaus.plexus.archiver.ArchiverException - if any
IOException - if any
public org.apache.maven.artifact.Artifact getReleaseArtifact()
throws IOException
DefaultArtifact instance for testGroupId:release:jar:1.0
IOException - if any
public org.apache.maven.artifact.Artifact getSnapshotArtifact()
throws IOException
DefaultArtifact instance for testGroupId:snapshot:jar:2.0-SNAPSHOT
IOException - if any
public Set getReleaseAndSnapshotArtifacts()
throws IOException
DefaultArtifact, i.e.:
testGroupId:snapshot:jar:2.0-SNAPSHOT, testGroupId:release:jar:1.0
IOException - if anygetReleaseArtifact(),
getSnapshotArtifact()
public Set getScopedArtifacts()
throws IOException
DefaultArtifact, i.e.:
g:provided:jar:1.0, g:compile:jar:1.0, g:system:jar:1.0, g:test:jar:1.0, g:runtime:jar:1.0
IOException - if any
public Set getTypedArtifacts()
throws IOException
DefaultArtifact, i.e.:
g:d:zip:1.0, g:a:war:1.0, g:b:jar:1.0, g:c:sources:1.0, g:e:rar:1.0
IOException - if any
public Set getClassifiedArtifacts()
throws IOException
DefaultArtifact, i.e.:
g:c:jar:three:1.0, g:b:jar:two:1.0, g:d:jar:four:1.0, g:a:jar:one:1.0
IOException - if any
public Set getTypedArchiveArtifacts()
throws IOException
DefaultArtifact, i.e.:
g:d:zip:1.0, g:a:war:1.0, g:b:jar:1.0, g:e:rar:1.0
IOException - if any
public Set getArtifactArtifacts()
throws IOException
DefaultArtifact, i.e.:
g:one:jar:a:1.0, g:two:jar:a:1.0, g:four:jar:a:1.0, g:three:jar:a:1.0
IOException - if any
public Set getGroupIdArtifacts()
throws IOException
DefaultArtifact, i.e.:
one:group-one:jar:a:1.0, three:group-three:jar:a:1.0, four:group-four:jar:a:1.0,
two:group-two:jar:a:1.0
IOException - if any
public Set getMixedArtifacts()
throws IOException
DefaultArtifact
IOException - if anygetTypedArtifacts(),
getScopedArtifacts(),
getReleaseAndSnapshotArtifacts()public boolean isCreateFiles()
public void setCreateFiles(boolean createFiles)
createFiles - The createFiles to set.public File getWorkingDir()
public void setWorkingDir(File workingDir)
workingDir - The workingDir to set.public File getSrcFile()
public void setSrcFile(File srcFile)
srcFile - The srcFile to set.
public static void setVariableValueToObject(Object object,
String variable,
Object value)
throws IllegalAccessException
object - variable - value -
IllegalAccessException
public static String getFormattedFileName(org.apache.maven.artifact.Artifact artifact,
boolean removeVersion)
artifact - File to be formatted.removeVersion - Specifies if the version should be removed from the file name.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||