Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2011-05-06 10:48:31 -0400
committerChristopher Frost2011-05-06 10:48:31 -0400
commit8318ace7e55fccf28f8bd80e373572516ccac8f4 (patch)
tree27de432594e4ec2e12144a7259538f8a3e1af230 /org.eclipse.virgo.kernel.model
parentb64289cb4d0254debc54a2efc711448ca5ec6f0e (diff)
downloadorg.eclipse.virgo.kernel-8318ace7e55fccf28f8bd80e373572516ccac8f4.tar.gz
org.eclipse.virgo.kernel-8318ace7e55fccf28f8bd80e373572516ccac8f4.tar.xz
org.eclipse.virgo.kernel-8318ace7e55fccf28f8bd80e373572516ccac8f4.zip
Enhancing the tests of getArtifact in the ArtifactRepository to check for good Region behaviour
Diffstat (limited to 'org.eclipse.virgo.kernel.model')
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java4
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java82
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java2
3 files changed, 85 insertions, 3 deletions
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
index 30ad90ed..460bd07e 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/StubCompositeArtifact.java
@@ -29,9 +29,9 @@ public class StubCompositeArtifact implements CompositeArtifact {
this("test-name", "test-type", null);
}
- public StubCompositeArtifact(String name, String type, Region region) {
- this.name = name;
+ public StubCompositeArtifact(String type, String name, Region region) {
this.type = type;
+ this.name = name;
this.region = region;
}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
index 21e1658b..ad82a671 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/NotifyingArtifactRepositoryTests.java
@@ -14,12 +14,21 @@ package org.eclipse.virgo.kernel.model.internal;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.io.InputStream;
import java.util.Set;
import org.eclipse.virgo.kernel.model.Artifact;
import org.eclipse.virgo.kernel.model.StubCompositeArtifact;
+import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
+import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
import org.junit.Test;
@@ -64,7 +73,80 @@ public class NotifyingArtifactRepositoryTests {
Set<Artifact> artifacts2 = this.artifactRepository.getArtifacts();
assertNotSame(artifacts1, artifacts2);
}
+
+ @Test
+ public void getArtifact(){
+ Region stubRegion = new StubRegion();
+ Artifact stubArtifact = new StubCompositeArtifact("foo", "bar", null);
+ Artifact stubArtifact2 = new StubCompositeArtifact("foo2", "bar2", stubRegion);
+ this.artifactRepository.add(stubArtifact);
+ this.artifactRepository.add(stubArtifact2);
+ Artifact retrieved = this.artifactRepository.getArtifact("foo", "bar", new Version("0.1.0"), null);
+ assertNull(retrieved);
+ retrieved = this.artifactRepository.getArtifact("foo", "bar", Version.emptyVersion, null);
+ assertEquals(stubArtifact, retrieved);
+ retrieved = this.artifactRepository.getArtifact("foo", "bar", Version.emptyVersion, stubRegion);
+ assertNull(retrieved);
+ retrieved = this.artifactRepository.getArtifact("foo2", "bar2", Version.emptyVersion, stubRegion);
+ assertEquals(stubArtifact2, retrieved);
+ }
+
+ private static class StubRegion implements Region{
+
+ public String getName() {
+ return "region";
+ }
+
+ public void addBundle(Bundle bundle) throws BundleException {
+
+ }
+
+ public void addBundle(long bundleId) {
+
+ }
+
+ public Bundle installBundle(String location, InputStream input) throws BundleException {
+ return null;
+ }
+
+ public Bundle installBundle(String location) throws BundleException {
+ return null;
+ }
+
+ public Set<Long> getBundleIds() {
+ return null;
+ }
+
+ public boolean contains(Bundle bundle) {
+ return false;
+ }
+
+ public boolean contains(long bundleId) {
+ return false;
+ }
+
+ public Bundle getBundle(String symbolicName, Version version) {
+ return null;
+ }
+
+ public void connectRegion(Region headRegion, RegionFilter filter) throws BundleException {
+ }
+ public void removeBundle(Bundle bundle) {
+ }
+
+ public void removeBundle(long bundleId) {
+ }
+
+ public Set<FilteredRegion> getEdges() {
+ return null;
+ }
+
+ public void visitSubgraph(RegionDigraphVisitor visitor) {
+ }
+
+ }
+
private static class StubArtifactRepositoryListener implements ArtifactRepositoryListener {
private final boolean throwException;
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
index aacbe23a..707ec84c 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
@@ -81,7 +81,7 @@ public class BundleDependencyDeterminerTests {
QuasiFramework framework = createMock(QuasiFramework.class);
replay(quasiFrameworkFactory, regionDigraph, framework);
- Set<Artifact> dependents = this.determiner.getDependents(new StubCompositeArtifact("foo", "bar", regionB));
+ Set<Artifact> dependents = this.determiner.getDependents(new StubCompositeArtifact("bar", "foo", regionB));
assertEquals(Collections.<Artifact> emptySet(), dependents);
verify(quasiFrameworkFactory, regionDigraph, framework);

Back to the top