Skip to content

Commit

Permalink
Test updates for fixed dependency equality
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Jul 17, 2012
1 parent 31d301f commit 5381f5c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
*/
public class MavenDependencyAdapterTest
{
org.apache.maven.model.Dependency mvn;
Dependency dep;
org.apache.maven.model.Dependency mvnDep;
Dependency forgeDep;

public MavenDependencyAdapterTest()
{
dep = DependencyBuilder.create()
forgeDep = DependencyBuilder.create()
.setArtifactId("seam-forge")
.setGroupId("org.jboss.forge")
.addExclusion()
Expand All @@ -55,28 +55,28 @@ public MavenDependencyAdapterTest()
.setVersion("9")
.setPackagingType(PackagingType.WAR);

mvn = new org.apache.maven.model.Dependency();
mvn.setArtifactId("seam-forge");
mvn.setGroupId("org.jboss.forge");
mvn.setVersion("9");
mvn.setScope("ComPiLe");
mvnDep = new org.apache.maven.model.Dependency();
mvnDep.setArtifactId("seam-forge");
mvnDep.setGroupId("org.jboss.forge");
mvnDep.setVersion("9");
mvnDep.setScope("ComPiLe");

Exclusion ex1 = new Exclusion();
ex1.setArtifactId("sub-module");
ex1.setGroupId("org.jboss.forge");
mvn.addExclusion(ex1);
mvnDep.addExclusion(ex1);

Exclusion ex2 = new Exclusion();
ex2.setArtifactId("sub-module-2");
ex2.setGroupId("org.jboss.forge");
mvn.addExclusion(ex2);
mvnDep.addExclusion(ex2);
}

@Test
public void testConvertFromMVNToForge() throws Exception
{
MavenDependencyAdapter toForge = new MavenDependencyAdapter(mvn);
MavenDependencyAdapter toMvn = new MavenDependencyAdapter(dep);
MavenDependencyAdapter toForge = new MavenDependencyAdapter(mvnDep);
MavenDependencyAdapter toMvn = new MavenDependencyAdapter(forgeDep);

assertEquals(toForge.getArtifactId(), toMvn.getArtifactId());
assertEquals(toForge.getGroupId(), toMvn.getGroupId());
Expand All @@ -88,8 +88,8 @@ public void testConvertFromMVNToForge() throws Exception
@Test
public void testExclusionsConvertProperly() throws Exception
{
MavenDependencyAdapter toForge = new MavenDependencyAdapter(mvn);
MavenDependencyAdapter toMvn = new MavenDependencyAdapter(dep);
MavenDependencyAdapter toForge = new MavenDependencyAdapter(mvnDep);
MavenDependencyAdapter toMvn = new MavenDependencyAdapter(forgeDep);

assertEquals(toForge.getExcludedDependencies(), toMvn.getExcludedDependencies());
assertEquals(toForge.getExclusions().get(0).getArtifactId(), toMvn.getExclusions().get(0).getArtifactId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ public boolean equals(Object o)
}

boolean artifactIdEquals = artifactId != null ? artifactId.equals(that.getArtifactId())
: that.getArtifactId() != null;
boolean groupIdEquals = groupId != null ? groupId.equals(that.getGroupId()) : that.getGroupId() != null;
boolean packagingTypeEquals = packagingType != null ? !packagingType.equals(that.getPackagingType()) : that
.getPackagingType() != null;
boolean scopeTypeEquals = scopeType != null ? scopeType.equals(that.getScopeType()) : that.getScopeType() != null;
boolean versionEquals = version != null ? version.equals(that.getVersion()) : that.getVersion() != null;
: that.getArtifactId() == null;
boolean groupIdEquals = groupId != null ? groupId.equals(that.getGroupId()) : that.getGroupId() == null;
boolean packagingTypeEquals = packagingType != null ? packagingType.equals(that.getPackagingType()) : that
.getPackagingType() == null;
boolean scopeTypeEquals = scopeType != null ? scopeType.equals(that.getScopeType()) : that.getScopeType() == null;
boolean versionEquals = version != null ? version.equals(that.getVersion()) : that.getVersion() == null;
boolean classifierEquals = classifier != null ? classifier.equals(that.getClassifier())
: that.getClassifier() != null;
: that.getClassifier() == null;

return artifactIdEquals && exclusionsEqual && groupIdEquals && packagingTypeEquals && scopeTypeEquals
&& versionEquals && classifierEquals;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.jboss.forge.project.dependencies;

import junit.framework.Assert;

import org.jboss.forge.project.packaging.PackagingType;
import org.junit.Test;

public class DependencyImplTest
{

@Test
public void testEqualityEmpty()
{
DependencyImpl left = new DependencyImpl();
DependencyImpl right = new DependencyImpl();

Assert.assertEquals(left, right);
}

@Test
public void testEquality()
{
DependencyImpl left = new DependencyImpl();
left.setArtifactId("org.test.dep");
left.setGroupId("org.test");

DependencyImpl right = new DependencyImpl();
right.setArtifactId("org.test.dep");
right.setGroupId("org.test");

Assert.assertEquals(left, right);
}

@Test
public void testEquality2()
{
DependencyImpl left = new DependencyImpl();
left.setArtifactId("weld-api-bom");
left.setGroupId("org.jboss.weld");
left.setPackagingType(PackagingType.BASIC);
left.setScopeType(ScopeType.IMPORT);
left.setVersion("1.1.Final");

DependencyImpl right = new DependencyImpl();
right.setArtifactId("weld-api-bom");
right.setGroupId("org.jboss.weld");
right.setPackagingType(PackagingType.BASIC);
right.setScopeType(ScopeType.IMPORT);
right.setVersion("1.1.Final");

Assert.assertEquals(left, right);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.forge.shell.Shell;
import org.jboss.forge.test.AbstractShellTest;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -28,6 +29,7 @@ public void testRunScriptNonHttpUrl() throws Exception
shell.execute("run-url new_file_invented.script");
}

@Ignore
@Test(expected = UnknownHostException.class)
public void testRunScriptNotHostHttpUrl() throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public static void after()
@Before
public void beforeTest() throws Exception
{
shell.setOutputStream(output);
shell.setAnsiSupported(false);
shell.setCurrentResource(createTempFolder());
beanManager.fireEvent(new Startup());
beanManager.fireEvent(new PostStartup());
shell.setVerbose(true);
shell.setExceptionHandlingEnabled(false);
shell.setOutputStream(output);
shell.setAnsiSupported(false);

resetInputQueue();
}
Expand Down

0 comments on commit 5381f5c

Please sign in to comment.