Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SHRINKRES-328] Resolve test framework issues #192

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void notEqualsByGroupIdValue() {
final String classifier = "classifier";
final MavenCoordinate coordinate1 = new MavenCoordinateImpl(groupId, artifactId, version, packaging, classifier);
final MavenCoordinate coordinate2 = new MavenCoordinateImpl("wrong", artifactId, version, packaging, classifier);
Assert.assertFalse(coordinate1.equals(coordinate2));
Assert.assertNotEquals(coordinate1, coordinate2);
}

@Test
Expand All @@ -60,7 +60,7 @@ public void notEqualsByArtifactIdValue() {
final String classifier = "classifier";
final MavenCoordinate coordinate1 = new MavenCoordinateImpl(groupId, artifactId, version, packaging, classifier);
final MavenCoordinate coordinate2 = new MavenCoordinateImpl(groupId, "wrong", version, packaging, classifier);
Assert.assertFalse(coordinate1.equals(coordinate2));
Assert.assertNotEquals(coordinate1, coordinate2);
}

@Test
Expand All @@ -85,7 +85,7 @@ public void notEqualsByPackagingValue() {
final MavenCoordinate coordinate1 = new MavenCoordinateImpl(groupId, artifactId, version, packaging, classifier);
final MavenCoordinate coordinate2 = new MavenCoordinateImpl(groupId, artifactId, version, PackagingType.EAR,
classifier);
Assert.assertFalse(coordinate1.equals(coordinate2));
Assert.assertNotEquals(coordinate1, coordinate2);
}

@Test
Expand All @@ -97,7 +97,7 @@ public void notEqualsByClassifierValue() {
final String classifier = "classifier";
final MavenCoordinate coordinate1 = new MavenCoordinateImpl(groupId, artifactId, version, packaging, classifier);
final MavenCoordinate coordinate2 = new MavenCoordinateImpl(groupId, artifactId, version, packaging, "wrong");
Assert.assertFalse(coordinate1.equals(coordinate2));
Assert.assertNotEquals(coordinate1, coordinate2);
}

@Test
Expand All @@ -109,7 +109,7 @@ public void equalHashCodes() {
final String classifier = "classifier";
final MavenCoordinate coordinate1 = new MavenCoordinateImpl(groupId, artifactId, version, packaging, classifier);
final MavenCoordinate coordinate2 = new MavenCoordinateImpl(groupId, artifactId, version, packaging, classifier);
Assert.assertTrue(coordinate1.hashCode() == coordinate2.hashCode());
Assert.assertEquals(coordinate1.hashCode(), coordinate2.hashCode());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public void equalsByValue() {
public void notEqualsByGroupIdValue() {
final MavenDependencyExclusion exclusion1 = new MavenDependencyExclusionImpl("groupId", "artifactId");
final MavenDependencyExclusion exclusion2 = new MavenDependencyExclusionImpl("groupId2", "artifactId");
Assert.assertFalse(exclusion1.equals(exclusion2));
Assert.assertNotEquals(exclusion1, exclusion2);
}

@Test
public void notEqualsByArtifactIdValue() {
final MavenDependencyExclusion exclusion1 = new MavenDependencyExclusionImpl("groupId", "artifactId");
final MavenDependencyExclusion exclusion2 = new MavenDependencyExclusionImpl("groupId", "artifactId2");
Assert.assertFalse(exclusion1.equals(exclusion2));
Assert.assertNotEquals(exclusion1, exclusion2);
}

@Test
Expand All @@ -55,7 +55,7 @@ public void equalHashCodes() {
final String artifactId = "artifactId";
final MavenDependencyExclusion exclusion1 = new MavenDependencyExclusionImpl(groupId, artifactId);
final MavenDependencyExclusion exclusion2 = new MavenDependencyExclusionImpl(groupId, artifactId);
Assert.assertTrue(exclusion1.hashCode() == exclusion2.hashCode());
Assert.assertEquals(exclusion1.hashCode(), exclusion2.hashCode());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jboss.shrinkwrap.resolver.impl.maven.embedded.invoker.equipped;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,10 @@ public void testGAemptyTCV() {
@Test(expected = IllegalArgumentException.class)
public void testGAemptyTemptyCV() {
Artifact artifact = new DefaultArtifact("g:a:::1");
Assert.assertEquals("g", artifact.getGroupId());
Assert.assertEquals("a", artifact.getArtifactId());
Assert.assertEquals("1", artifact.getVersion());
Assert.assertEquals("sources", artifact.getClassifier());
Assert.assertEquals("jar", artifact.getExtension());
}

@Test(expected = CoordinateParseException.class)
public void test2GAemptyTemptyCV() {
MavenCoordinateParser dependency = MavenCoordinateParser.parse("g:a:::1");
Assert.assertEquals("g", dependency.getGroupId());
Assert.assertEquals("a", dependency.getArtifactId());
Assert.assertEquals("1", dependency.getVersion());
Assert.assertEquals("sources", dependency.getClassifier());
Assert.assertEquals("jar", dependency.getPackaging());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void notEqualsByValueExclusions() {
final MavenDependencyExclusion exclusion2 = new MavenDependencyExclusionImpl("wrong", "artifactId2");
final MavenDependency dependency1 = new MavenDependencyImpl(coordinate, scope, optional, exclusion1);
final MavenDependency dependency2 = new MavenDependencyImpl(coordinate, scope, optional, exclusion2);
Assert.assertTrue(dependency1.equals(dependency2));
Assert.assertEquals(dependency1, dependency2);
}

@Test
Expand All @@ -88,7 +88,7 @@ public void notEqualsByValueExclusionsMismatchThis() {
final MavenDependencyExclusion exclusion = new MavenDependencyExclusionImpl("groupId1", "artifactId1");
final MavenDependency dependency1 = new MavenDependencyImpl(coordinate, scope, optional);
final MavenDependency dependency2 = new MavenDependencyImpl(coordinate, scope, optional, exclusion);
Assert.assertTrue(dependency1.equals(dependency2));
Assert.assertEquals(dependency1, dependency2);
}

@Test
Expand All @@ -99,7 +99,7 @@ public void notEqualsByValueExclusionsMismatchThat() {
final MavenDependencyExclusion exclusion = new MavenDependencyExclusionImpl("groupId1", "artifactId1");
final MavenDependency dependency1 = new MavenDependencyImpl(coordinate, scope, optional, exclusion);
final MavenDependency dependency2 = new MavenDependencyImpl(coordinate, scope, optional);
Assert.assertTrue(dependency1.equals(dependency2));
Assert.assertEquals(dependency1, dependency2);
}

@Test
Expand All @@ -110,7 +110,7 @@ public void notEqualsByValueCoordinate() {
final MavenDependency dependency1 = new MavenDependencyImpl(coordinate, scope, optional);
final MavenDependency dependency2 = new MavenDependencyImpl(new MavenCoordinateImpl("g", "a", "v", null, "c"),
scope, optional);
Assert.assertFalse(dependency1.equals(dependency2));
Assert.assertNotEquals(dependency1, dependency2);
}

@Test
Expand All @@ -120,7 +120,7 @@ public void notEqualsByValueScope() {
final boolean optional = true;
final MavenDependency dependency1 = new MavenDependencyImpl(coordinate, scope, optional);
final MavenDependency dependency2 = new MavenDependencyImpl(coordinate, ScopeType.IMPORT, optional);
Assert.assertTrue(dependency1.equals(dependency2));
Assert.assertEquals(dependency1, dependency2);
}

@Test
Expand All @@ -130,7 +130,7 @@ public void notEqualsByValueOptional() {
final boolean optional = true;
final MavenDependency dependency1 = new MavenDependencyImpl(coordinate, scope, optional);
final MavenDependency dependency2 = new MavenDependencyImpl(coordinate, scope, false);
Assert.assertTrue(dependency1.equals(dependency2));
Assert.assertEquals(dependency1, dependency2);
}

@Test
Expand All @@ -142,7 +142,7 @@ public void equalHashCodes() {
final MavenDependencyExclusion exclusion2 = new MavenDependencyExclusionImpl("groupId2", "artifactId2");
final MavenDependency dependency1 = new MavenDependencyImpl(coordinate, scope, optional, exclusion1, exclusion2);
final MavenDependency dependency2 = new MavenDependencyImpl(coordinate, scope, optional, exclusion1, exclusion2);
Assert.assertTrue(dependency1.hashCode() == dependency2.hashCode());
Assert.assertEquals(dependency1.hashCode(), dependency2.hashCode());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ public void packageDirectoriesWithClasses() throws IOException {
mockedArtResult.setArtifact(testPomArtifactMock);

MavenResolvedArtifact mavenResolvedArtifact = MavenResolvedArtifactImpl.fromArtifactResult(mockedArtResult);
ZipFile outputZipFile = new ZipFile(mavenResolvedArtifact.asFile());
try (ZipFile outputZipFile = new ZipFile(mavenResolvedArtifact.asFile())) {

//Check if existing files are in zip.
Assert.assertNotNull(outputZipFile.getEntry("a/a.file"));
//Check if existing files are in zip.
Assert.assertNotNull(outputZipFile.getEntry("a/a.file"));

//Check if directories are not separately contained
Assert.assertNull(outputZipFile.getEntry("b/c" + File.separator));

//Check if non-existing items are null !
Assert.assertNull(outputZipFile.getEntry("a/non-exist" + File.separator));
//Check if directories are not separately contained
Assert.assertNull(outputZipFile.getEntry("b/c" + File.separator));

//Check if non-existing items are null !
Assert.assertNull(outputZipFile.getEntry("a/non-exist" + File.separator));
}
}

/**
Expand All @@ -93,13 +93,13 @@ public void packageWar() throws IOException {
mockedArtResult.setArtifact(testPomArtifactMock);

MavenResolvedArtifact mavenResolvedArtifact = MavenResolvedArtifactImpl.fromArtifactResult(mockedArtResult);
ZipFile outputZipFile = new ZipFile(mavenResolvedArtifact.asFile());

//Check if the included files were taken from the "target/Artifact.artifactId-Artifact.version" directory
Assert.assertNotNull(outputZipFile.getEntry("special/a.file"));
try (ZipFile outputZipFile = new ZipFile(mavenResolvedArtifact.asFile())) {

//Check if the default "target/classes" directory was not included
Assert.assertNull(outputZipFile.getEntry("a/a.file"));
//Check if the included files were taken from the "target/Artifact.artifactId-Artifact.version" directory
Assert.assertNotNull(outputZipFile.getEntry("special/a.file"));

//Check if the default "target/classes" directory was not included
Assert.assertNull(outputZipFile.getEntry("a/a.file"));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jboss.shrinkwrap.resolver.impl.maven.integration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.File;

Expand Down Expand Up @@ -69,18 +71,18 @@ public void asMavenResolvedArtifact() {

assertEquals("jar", resolvedArtifactInfos[0].getExtension());
assertEquals("1.0.0", resolvedArtifactInfos[0].getResolvedVersion());
assertEquals(false, resolvedArtifactInfos[0].isSnapshotVersion());
assertFalse(resolvedArtifactInfos[0].isSnapshotVersion());
assertEquals("jar", resolvedArtifactInfos[0].getExtension());
assertEquals(false, resolvedArtifactInfos[0].isOptional());
assertFalse(resolvedArtifactInfos[0].isOptional());
assertEquals(originalCoordinateA, resolvedArtifactInfos[0].getCoordinate());

new ValidationUtil("test-deps-b-1.0.0.jar").validate(resolvedArtifactInfos[1].as(File.class));

assertEquals("jar", resolvedArtifactInfos[1].getExtension());
assertEquals("1.0.0", resolvedArtifactInfos[1].getResolvedVersion());
assertEquals(false, resolvedArtifactInfos[1].isSnapshotVersion());
assertFalse(resolvedArtifactInfos[1].isSnapshotVersion());
assertEquals("jar", resolvedArtifactInfos[1].getExtension());
assertEquals(false, resolvedArtifactInfos[1].isOptional());
assertFalse(resolvedArtifactInfos[1].isOptional());
assertEquals(originalCoordinateB, resolvedArtifactInfos[1].getCoordinate());
}

Expand All @@ -102,9 +104,9 @@ public void asSingleResolvedArtifactInfo() {

assertEquals("jar", resolvedArtifact.getExtension());
assertEquals("1.0.0", resolvedArtifact.getResolvedVersion());
assertEquals(false, resolvedArtifact.isSnapshotVersion());
assertFalse(resolvedArtifact.isSnapshotVersion());
assertEquals("jar", resolvedArtifact.getExtension());
assertEquals(false, resolvedArtifact.isOptional());
assertFalse(resolvedArtifact.isOptional());
assertEquals(originalCoordinate, resolvedArtifact.getCoordinate());
}

Expand Down Expand Up @@ -159,26 +161,26 @@ public void resolvedArtifactInfoDependencies() {

assertEquals("jar", resolvedArtifact.getExtension());
assertEquals("1.0.0", resolvedArtifact.getResolvedVersion());
assertEquals(false, resolvedArtifact.isSnapshotVersion());
assertFalse(resolvedArtifact.isSnapshotVersion());
assertEquals("jar", resolvedArtifact.getExtension());
assertEquals(false, resolvedArtifact.isOptional());
assertFalse(resolvedArtifact.isOptional());
assertEquals(originalCoordinate, resolvedArtifact.getCoordinate());

final MavenArtifactInfo child1 = resolvedArtifact.getDependencies()[0];
assertEquals("jar", child1.getExtension());
assertEquals("1.0.0", child1.getResolvedVersion());
assertEquals(false, child1.isSnapshotVersion());
assertFalse(child1.isSnapshotVersion());
assertEquals("jar", child1.getExtension());
assertEquals(false, child1.isOptional());
assertFalse(child1.isOptional());
assertEquals(child1Coordinate, child1.getCoordinate());
assertEquals(ScopeType.COMPILE, child1.getScope());

final MavenArtifactInfo child2 = resolvedArtifact.getDependencies()[1];
assertEquals("jar", child2.getExtension());
assertEquals("1.0.0", child2.getResolvedVersion());
assertEquals(false, child2.isSnapshotVersion());
assertFalse(child2.isSnapshotVersion());
assertEquals("jar", child2.getExtension());
assertEquals(false, child2.isOptional());
assertFalse(child2.isOptional());
assertEquals(child2Coordinate, child2.getCoordinate());
assertEquals(ScopeType.RUNTIME, child2.getScope());
}
Expand Down Expand Up @@ -234,17 +236,17 @@ public MavenResolutionFilter[] getResolutionFilters() {

assertEquals("jar", resolvedArtifact.getExtension());
assertEquals("1.0.0", resolvedArtifact.getResolvedVersion());
assertEquals(false, resolvedArtifact.isSnapshotVersion());
assertFalse(resolvedArtifact.isSnapshotVersion());
assertEquals("jar", resolvedArtifact.getExtension());
assertEquals(false, resolvedArtifact.isOptional());
assertFalse(resolvedArtifact.isOptional());
assertEquals(originalCoordinate, resolvedArtifact.getCoordinate());

final MavenArtifactInfo child1 = resolvedArtifact.getDependencies()[0];
assertEquals("jar", child1.getExtension());
assertEquals("1.0.0", child1.getResolvedVersion());
assertEquals(false, child1.isSnapshotVersion());
assertFalse(child1.isSnapshotVersion());
assertEquals("jar", child1.getExtension());
assertEquals(true, child1.isOptional());
assertTrue(child1.isOptional());
assertEquals(child1Coordinate, child1.getCoordinate());
assertEquals(ScopeType.COMPILE, child1.getScope());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ public void packagedArtifactShouldNotContainBackslashes() throws Exception {
File file = resolver.resolve("org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven")
.withoutTransitivity().asSingleFile();

JarFile jarFile = new JarFile(file);

Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String entryName = entry.getName();
Assert.assertFalse("There are not backslashes in created JAR", entryName.contains("\\"));
try (JarFile jarFile = new JarFile(file)) {
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String entryName = entry.getName();
Assert.assertFalse("There are not backslashes in created JAR", entryName.contains("\\"));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void resolveProvidedDependency() {
Assert.assertNotNull(dependencies);
// http://search.maven.org/remotecontent?filepath=org/jboss/xnio/xnio-api/3.1.0.Beta7/xnio-api-3.1.0.Beta7.pom
// there should be org.jboss.logging:jboss-logging and org.jboss.logmanager:jboss-logmanager as provided
Assert.assertTrue(dependencies.length == 2);
Assert.assertEquals(2, dependencies.length);
}

/**
Expand Down