-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHRINKRES-230 refactoring and changed a test case to test the issue
The preceding commits fixed the issue, so this commit just refactor the implementation - mainly the test case to not change the visibility of the inner class MavenResolvedArtifactImpl.PackageDirHelper
- Loading branch information
1 parent
7fdc237
commit cb9ac81
Showing
8 changed files
with
106 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
...aven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/PackageDirHelperTestCase.java
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
.../java/org/jboss/shrinkwrap/resolver/impl/maven/PackageDirectoriesWithClassesTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.jboss.shrinkwrap.resolver.impl.maven; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.zip.ZipFile; | ||
|
||
import org.eclipse.aether.artifact.Artifact; | ||
import org.eclipse.aether.artifact.ArtifactProperties; | ||
import org.eclipse.aether.graph.DefaultDependencyNode; | ||
import org.eclipse.aether.graph.Dependency; | ||
import org.eclipse.aether.resolution.ArtifactRequest; | ||
import org.eclipse.aether.resolution.ArtifactResult; | ||
import org.jboss.shrinkwrap.resolver.api.maven.MavenResolvedArtifact; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
/** | ||
* This test case simulates behavior of an IDE - in IDE an artifact, that is also another module loaded in the IDE, | ||
* is not fetched from local/remote repository, but is referenced to the location of the module's directory. | ||
* The module's pom.xml file is taken as the artifact's pom and the subdirectories containing the compiled classes | ||
* are packaged into a zip archive. This zip archive is then returned as a resulting artifact file. | ||
* | ||
* NOTE: this testcase is in the {@code util} package because of visibility of | ||
* {@link MavenResolvedArtifactImpl#fromArtifactResult(ArtifactResult)} method | ||
* | ||
* @author <a href="mailto:mjobanek@redhat.com">Matous Jobanek</a> | ||
* @author <a href="mailto:olivts@free.fr">Olivier Spieser</a> | ||
* | ||
*/ | ||
public class PackageDirectoriesWithClassesTestCase { | ||
|
||
/** | ||
* Test zip archive creation from directory located in. Check if directory entries are added to the archive. | ||
*/ | ||
@Test | ||
public void packageDirectoriesWithClasses() throws IOException { | ||
File artifactFile = new File( | ||
System.getProperty("user.dir") + "/target/repository/org/jboss/shrinkwrap/test/test-pom/1.0.0/pom.xml"); | ||
|
||
Artifact testPomArtifactMock = Mockito.mock(Artifact.class); | ||
Mockito.when(testPomArtifactMock.getGroupId()).thenReturn("org.jboss.shrinkwrap.test"); | ||
Mockito.when(testPomArtifactMock.getArtifactId()).thenReturn("test-pom"); | ||
Mockito.when(testPomArtifactMock.getExtension()).thenReturn("xml"); | ||
Mockito.when(testPomArtifactMock.getClassifier()).thenReturn(""); | ||
Mockito.when(testPomArtifactMock.getVersion()).thenReturn("1.0.0"); | ||
Mockito.when(testPomArtifactMock.getFile()).thenReturn(artifactFile); | ||
Mockito.when(testPomArtifactMock.getProperty(ArtifactProperties.TYPE, testPomArtifactMock.getExtension())) | ||
.thenReturn("pom"); | ||
|
||
ArtifactRequest artifactRequest = new ArtifactRequest(); | ||
artifactRequest.setDependencyNode(new DefaultDependencyNode(new Dependency(testPomArtifactMock, "test"))); | ||
ArtifactResult mockedArtResult = new ArtifactResult(artifactRequest); | ||
mockedArtResult.setArtifact(testPomArtifactMock); | ||
|
||
MavenResolvedArtifact mavenResolvedArtifact = MavenResolvedArtifactImpl.fromArtifactResult(mockedArtResult); | ||
ZipFile outputZipFile = new ZipFile(mavenResolvedArtifact.asFile()); | ||
|
||
//Check if existing files and folders and in zip. | ||
Assert.assertNotNull(outputZipFile.getEntry("b/c")); | ||
Assert.assertNotNull(outputZipFile.getEntry("a/a.file")); | ||
|
||
//Check if non existing items are null ! | ||
Assert.assertNull(outputZipFile.getEntry("a/non-exist/")); | ||
|
||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
impl-maven/src/test/resources/repository/org/jboss/shrinkwrap/test/test-pom/1.0.0/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<!-- Model Version --> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<!-- Artifact Configuration --> | ||
<groupId>org.jboss.shrinkwrap.test</groupId> | ||
<artifactId>test-pom</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>pom</packaging> | ||
|
||
</project> |
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
...src/test/resources/repository/org/jboss/shrinkwrap/test/test-pom/maven-metadata-local.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<metadata> | ||
<groupId>org.jboss.shrinkwrap.test</groupId> | ||
<artifactId>test-pom</artifactId> | ||
<versioning> | ||
<release>1.0.0</release> | ||
<versions> | ||
<version>1.0.0</version> | ||
</versions> | ||
<lastUpdated>20140920183335</lastUpdated> | ||
</versioning> | ||
</metadata> |