|
||||||||||
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(java.io.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(java.lang.String groupId,
java.lang.String artifactId,
java.lang.String version)
|
org.apache.maven.artifact.Artifact |
createArtifact(java.lang.String groupId,
java.lang.String artifactId,
java.lang.String version,
java.lang.String scope)
|
org.apache.maven.artifact.Artifact |
createArtifact(java.lang.String groupId,
java.lang.String artifactId,
java.lang.String version,
java.lang.String scope,
java.lang.String type,
java.lang.String classifier)
|
org.apache.maven.artifact.Artifact |
createArtifact(java.lang.String groupId,
java.lang.String artifactId,
org.apache.maven.artifact.versioning.VersionRange versionRange,
java.lang.String scope,
java.lang.String type,
java.lang.String classifier,
boolean optional)
|
void |
createUnpackableFile(org.apache.maven.artifact.Artifact artifact,
java.io.File destFile)
|
java.util.Set |
getArtifactArtifacts()
|
java.util.Set |
getClassifiedArtifacts()
|
static java.lang.String |
getFormattedFileName(org.apache.maven.artifact.Artifact artifact,
boolean removeVersion)
Builds the file name. |
java.util.Set |
getGroupIdArtifacts()
|
java.util.Set |
getMixedArtifacts()
|
java.util.Set |
getReleaseAndSnapshotArtifacts()
|
org.apache.maven.artifact.Artifact |
getReleaseArtifact()
|
java.util.Set |
getScopedArtifacts()
|
org.apache.maven.artifact.Artifact |
getSnapshotArtifact()
|
java.io.File |
getSrcFile()
|
java.util.Set |
getTypedArchiveArtifacts()
|
java.util.Set |
getTypedArtifacts()
|
static java.lang.String |
getUnpackableFileName(org.apache.maven.artifact.Artifact artifact)
|
java.io.File |
getWorkingDir()
|
boolean |
isCreateFiles()
|
void |
setArtifactFile(org.apache.maven.artifact.Artifact artifact,
java.io.File workingDir)
Creates a new empty file and attaches it to the artifact. |
void |
setArtifactFile(org.apache.maven.artifact.Artifact artifact,
java.io.File workingDir,
java.io.File srcFile)
Copyies the srcFile to the workingDir and then attaches it to the artifact. |
void |
setCreateFiles(boolean createFiles)
|
void |
setSrcFile(java.io.File srcFile)
|
void |
setUnpackableArtifactFile(org.apache.maven.artifact.Artifact artifact,
java.io.File workingDir)
Creates an unpackable file (zip,jar etc) containing an empty file. |
void |
setUnpackableArtifactFile(org.apache.maven.artifact.Artifact artifact,
java.io.File workingDir,
java.io.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(java.lang.Object object,
java.lang.String variable,
java.lang.Object value)
Convenience method to set values to variables in objects that don't have setters |
void |
setWorkingDir(java.io.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(java.io.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(java.lang.String groupId, java.lang.String artifactId, java.lang.String version) throws java.io.IOException
groupId
- artifactId
- version
-
DefaultArtifact
instance for the given parameters
java.io.IOException
- if anycreateArtifact(String, String, String, String, String, String)
public org.apache.maven.artifact.Artifact createArtifact(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String scope) throws java.io.IOException
groupId
- artifactId
- version
- scope
-
DefaultArtifact
instance for the given parameters
java.io.IOException
- if anycreateArtifact(String, String, String, String, String, String)
public org.apache.maven.artifact.Artifact createArtifact(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String scope, java.lang.String type, java.lang.String classifier) throws java.io.IOException
groupId
- artifactId
- version
- scope
- type
- classifier
-
DefaultArtifact
instance for the given parameters
java.io.IOException
- if anycreateArtifact(String, String, VersionRange, String, String, String, boolean)
public org.apache.maven.artifact.Artifact createArtifact(java.lang.String groupId, java.lang.String artifactId, org.apache.maven.artifact.versioning.VersionRange versionRange, java.lang.String scope, java.lang.String type, java.lang.String classifier, boolean optional) throws java.io.IOException
groupId
- not nullartifactId
- not nullversionRange
- not nullscope
- not nulltype
- not nullclassifier
- optional
- not null
DefaultArtifact
instance
java.io.IOException
- if anypublic void setArtifactFile(org.apache.maven.artifact.Artifact artifact, java.io.File workingDir) throws java.io.IOException
artifact
- to attach the file to.workingDir
- where to locate the new file
java.io.IOException
public void setArtifactFile(org.apache.maven.artifact.Artifact artifact, java.io.File workingDir, java.io.File srcFile) throws java.io.IOException
artifact
- to attachworkingDir
- where to copy the srcFile.srcFile
- file to be attached.
java.io.IOException
public void setUnpackableArtifactFile(org.apache.maven.artifact.Artifact artifact, java.io.File workingDir) throws java.io.IOException
artifact
- to attachworkingDir
- where to create the file.
java.io.IOException
public void setUnpackableArtifactFile(org.apache.maven.artifact.Artifact artifact, java.io.File workingDir, java.io.File srcFile) throws java.io.IOException
artifact
- to attachworkingDir
- where to create the file.srcFile
-
java.io.IOException
- if anypublic static java.lang.String getUnpackableFileName(org.apache.maven.artifact.Artifact artifact)
artifact
-
public void createUnpackableFile(org.apache.maven.artifact.Artifact artifact, java.io.File destFile) throws org.codehaus.plexus.archiver.manager.NoSuchArchiverException, org.codehaus.plexus.archiver.ArchiverException, java.io.IOException
artifact
- destFile
-
org.codehaus.plexus.archiver.manager.NoSuchArchiverException
org.codehaus.plexus.archiver.ArchiverException
- if any
java.io.IOException
- if anypublic org.apache.maven.artifact.Artifact getReleaseArtifact() throws java.io.IOException
DefaultArtifact
instance for testGroupId:release:jar:1.0
java.io.IOException
- if anypublic org.apache.maven.artifact.Artifact getSnapshotArtifact() throws java.io.IOException
DefaultArtifact
instance for testGroupId:snapshot:jar:2.0-SNAPSHOT
java.io.IOException
- if anypublic java.util.Set getReleaseAndSnapshotArtifacts() throws java.io.IOException
DefaultArtifact
, i.e.:
testGroupId:snapshot:jar:2.0-SNAPSHOT, testGroupId:release:jar:1.0
java.io.IOException
- if anygetReleaseArtifact()
,
getSnapshotArtifact()
public java.util.Set getScopedArtifacts() throws java.io.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
java.io.IOException
- if anypublic java.util.Set getTypedArtifacts() throws java.io.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
java.io.IOException
- if anypublic java.util.Set getClassifiedArtifacts() throws java.io.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
java.io.IOException
- if anypublic java.util.Set getTypedArchiveArtifacts() throws java.io.IOException
DefaultArtifact
, i.e.:
g:d:zip:1.0, g:a:war:1.0, g:b:jar:1.0, g:e:rar:1.0
java.io.IOException
- if anypublic java.util.Set getArtifactArtifacts() throws java.io.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
java.io.IOException
- if anypublic java.util.Set getGroupIdArtifacts() throws java.io.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
java.io.IOException
- if anypublic java.util.Set getMixedArtifacts() throws java.io.IOException
DefaultArtifact
java.io.IOException
- if anygetTypedArtifacts()
,
getScopedArtifacts()
,
getReleaseAndSnapshotArtifacts()
public boolean isCreateFiles()
public void setCreateFiles(boolean createFiles)
createFiles
- The createFiles to set.public java.io.File getWorkingDir()
public void setWorkingDir(java.io.File workingDir)
workingDir
- The workingDir to set.public java.io.File getSrcFile()
public void setSrcFile(java.io.File srcFile)
srcFile
- The srcFile to set.public static void setVariableValueToObject(java.lang.Object object, java.lang.String variable, java.lang.Object value) throws java.lang.IllegalAccessException
object
- variable
- value
-
java.lang.IllegalAccessException
public static java.lang.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 |