You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ma...@apache.org on 2012/03/16 15:40:18 UTC
svn commit: r1301552 - in
/ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl:
CachedRepositoryImplTest.java ModelTest.java
Author: marrs
Date: Fri Mar 16 14:40:18 2012
New Revision: 1301552
URL: http://svn.apache.org/viewvc?rev=1301552&view=rev
Log:
ACE-63 refactored some tests
Modified:
ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/CachedRepositoryImplTest.java
ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ModelTest.java
Modified: ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/CachedRepositoryImplTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/CachedRepositoryImplTest.java?rev=1301552&r1=1301551&r2=1301552&view=diff
==============================================================================
--- ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/CachedRepositoryImplTest.java (original)
+++ ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/CachedRepositoryImplTest.java Fri Mar 16 14:40:18 2012
@@ -121,5 +121,4 @@ public class CachedRepositoryImplTest {
inputBytes = AdminTestUtil.copy(input);
assert AdminTestUtil.byteArraysEqual(inputBytes, testContent) : "We got something different than 'initial' from getLocal: " + new String(inputBytes);
}
-
}
Modified: ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ModelTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ModelTest.java?rev=1301552&r1=1301551&r2=1301552&view=diff
==============================================================================
--- ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ModelTest.java (original)
+++ ace/trunk/ace-client-repository-impl/src/test/java/org/apache/ace/client/repository/impl/ModelTest.java Fri Mar 16 14:40:18 2012
@@ -65,12 +65,12 @@ import org.testng.annotations.Test;
public class ModelTest {
private ArtifactRepositoryImpl m_artifactRepository;
- private FeatureRepositoryImpl m_groupRepository;
- private Artifact2FeatureAssociationRepositoryImpl m_artifact2groupRepository;
- private DistributionRepositoryImpl m_licenseRepository;
- private Feature2DistributionAssociationRepositoryImpl m_group2licenseRepository;
- private TargetRepositoryImpl m_gatewayRepository;
- private Distribution2TargetAssociationRepositoryImpl m_license2gatewayRepository;
+ private FeatureRepositoryImpl m_featureRepository;
+ private Artifact2FeatureAssociationRepositoryImpl m_artifact2FeatureRepository;
+ private DistributionRepositoryImpl m_distributionRepository;
+ private Feature2DistributionAssociationRepositoryImpl m_feature2DistributionRepository;
+ private TargetRepositoryImpl m_targetRepository;
+ private Distribution2TargetAssociationRepositoryImpl m_distribution2TargetRepository;
private DeploymentVersionRepositoryImpl m_deploymentVersionRepository;
private RepositoryAdminImpl m_repositoryAdmin;
@@ -92,18 +92,18 @@ public class ModelTest {
TestUtils.configureObject(m_artifactRepository, LogService.class);
TestUtils.configureObject(m_artifactRepository, BundleContext.class, bc);
m_artifactRepository.addHelper(BundleHelper.MIMETYPE, m_bundleHelper);
- m_groupRepository = new FeatureRepositoryImpl(notifier);
- TestUtils.configureObject(m_groupRepository, BundleContext.class, bc);
- m_artifact2groupRepository = new Artifact2FeatureAssociationRepositoryImpl(m_artifactRepository, m_groupRepository, notifier);
- TestUtils.configureObject(m_artifact2groupRepository, BundleContext.class, bc);
- m_licenseRepository = new DistributionRepositoryImpl(notifier);
- TestUtils.configureObject(m_licenseRepository, BundleContext.class, bc);
- m_group2licenseRepository = new Feature2DistributionAssociationRepositoryImpl(m_groupRepository, m_licenseRepository, notifier);
- TestUtils.configureObject(m_group2licenseRepository, BundleContext.class, bc);
- m_gatewayRepository = new TargetRepositoryImpl(notifier);
- TestUtils.configureObject(m_gatewayRepository, BundleContext.class, bc);
- m_license2gatewayRepository = new Distribution2TargetAssociationRepositoryImpl(m_licenseRepository, m_gatewayRepository, notifier);
- TestUtils.configureObject(m_license2gatewayRepository, BundleContext.class, bc);
+ m_featureRepository = new FeatureRepositoryImpl(notifier);
+ TestUtils.configureObject(m_featureRepository, BundleContext.class, bc);
+ m_artifact2FeatureRepository = new Artifact2FeatureAssociationRepositoryImpl(m_artifactRepository, m_featureRepository, notifier);
+ TestUtils.configureObject(m_artifact2FeatureRepository, BundleContext.class, bc);
+ m_distributionRepository = new DistributionRepositoryImpl(notifier);
+ TestUtils.configureObject(m_distributionRepository, BundleContext.class, bc);
+ m_feature2DistributionRepository = new Feature2DistributionAssociationRepositoryImpl(m_featureRepository, m_distributionRepository, notifier);
+ TestUtils.configureObject(m_feature2DistributionRepository, BundleContext.class, bc);
+ m_targetRepository = new TargetRepositoryImpl(notifier);
+ TestUtils.configureObject(m_targetRepository, BundleContext.class, bc);
+ m_distribution2TargetRepository = new Distribution2TargetAssociationRepositoryImpl(m_distributionRepository, m_targetRepository, notifier);
+ TestUtils.configureObject(m_distribution2TargetRepository, BundleContext.class, bc);
m_deploymentVersionRepository = new DeploymentVersionRepositoryImpl(notifier);
TestUtils.configureObject(m_deploymentVersionRepository, BundleContext.class, bc);
@@ -111,12 +111,12 @@ public class ModelTest {
Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> repos = new HashMap<Class<? extends ObjectRepository>, ObjectRepositoryImpl>();
repos.put(ArtifactRepository.class, m_artifactRepository);
- repos.put(Artifact2FeatureAssociationRepository.class, m_artifact2groupRepository);
- repos.put(FeatureRepository.class, m_groupRepository);
- repos.put(Feature2DistributionAssociationRepository.class, m_group2licenseRepository);
- repos.put(DistributionRepository.class, m_licenseRepository);
- repos.put(Distribution2TargetAssociationRepository.class, m_license2gatewayRepository);
- repos.put(TargetRepository.class, m_gatewayRepository);
+ repos.put(Artifact2FeatureAssociationRepository.class, m_artifact2FeatureRepository);
+ repos.put(FeatureRepository.class, m_featureRepository);
+ repos.put(Feature2DistributionAssociationRepository.class, m_feature2DistributionRepository);
+ repos.put(DistributionRepository.class, m_distributionRepository);
+ repos.put(Distribution2TargetAssociationRepository.class, m_distribution2TargetRepository);
+ repos.put(TargetRepository.class, m_targetRepository);
repos.put(DeploymentVersionRepository.class, m_deploymentVersionRepository);
m_repositoryAdmin.initialize(repos);
@@ -125,61 +125,61 @@ public class ModelTest {
}
/**
- * The bundle object can test functionality coming from
+ * The artifact object can test functionality coming from
* RepositoryObjectImpl, and ArtifactRepository checks much of
* ObjectRepositoryImpl.
* @throws InvalidSyntaxException
*/
@Test( groups = { TestUtils.UNIT } )
- public void testBundleObjectAndRepository() throws InvalidSyntaxException {
- // Create a very simple bundle.
- ArtifactObject b = createBasicBundleObject("mybundle", "1.0.0");
+ public void testArtifactObjectAndRepository() throws InvalidSyntaxException {
+ // Create a very simple artifact.
+ ArtifactObject a = createBasicArtifactObject("myartifact", "1.0.0");
// Try to create an illegal one
try {
- createBasicBundleObject("");
- assert false : "Creating a bundle with an empty name is not allowed.";
+ createBasicArtifactObject("");
+ assert false : "Creating an artifact with an empty name is not allowed.";
}
catch (IllegalArgumentException iae) {
// expected
}
- // Even though the bundle is not yet associated to a group, try to get its groups.
- List<FeatureObject> groups = b.getFeatures();
+ // Even though the artifact is not yet associated to a feature, try to get its features.
+ List<FeatureObject> features = a.getFeatures();
- assert groups.size() == 0 : "The bundle is not associated, so it should not return any groups.";
+ assert features.size() == 0 : "The artifact is not associated, so it should not return any features.";
- assert b.getAttribute(BundleHelper.KEY_SYMBOLICNAME).equals("mybundle") : "We should be able to read an attribute we just put in ourselves.";
+ assert a.getAttribute(BundleHelper.KEY_SYMBOLICNAME).equals("myartifact") : "We should be able to read an attribute we just put in ourselves.";
- b.addTag("mytag", "myvalue");
+ a.addTag("mytag", "myvalue");
- assert b.getTag("mytag").equals("myvalue") : "We should be able to read an attribute we just put in ourselves.";
- assert b.getTag(BundleHelper.KEY_SYMBOLICNAME) == null : "We should not find an attribute value when asking for a tag.";
+ assert a.getTag("mytag").equals("myvalue") : "We should be able to read an attribute we just put in ourselves.";
+ assert a.getTag(BundleHelper.KEY_SYMBOLICNAME) == null : "We should not find an attribute value when asking for a tag.";
- b.addTag(BundleHelper.KEY_SYMBOLICNAME, "mytagname");
+ a.addTag(BundleHelper.KEY_SYMBOLICNAME, "mytagname");
- assert b.getTag(BundleHelper.KEY_SYMBOLICNAME).equals("mytagname") : "We can adds tags that have the same name as a bundle, but still return another value.";
+ assert a.getTag(BundleHelper.KEY_SYMBOLICNAME).equals("mytagname") : "We can adds tags that have the same name as a artifact, but still return another value.";
- Dictionary<String, Object> dict = b.getDictionary();
+ Dictionary<String, Object> dict = a.getDictionary();
assert dict.get("mytag") == "myvalue" : "The dictionary of the object should contain all tags.";
assert dict.get(BundleHelper.KEY_VERSION).equals("1.0.0") : "The dictionary of the object should contain all attributes; we found " + dict.get(BundleHelper.KEY_VERSION);
String[] foundNames = (String[]) dict.get(BundleHelper.KEY_SYMBOLICNAME);
assert foundNames.length == 2 : "For keys which are used both as a value and as a tag, we should get back both from the dictionary in an array.";
- assert (foundNames[0].equals("mybundle") && foundNames[1].equals("mytagname")) ||
- (foundNames[1].equals("mybundle") && foundNames[0].equals("mytagname")) : "The order is undefined, but we should find both the items we put in for '"+BundleHelper.KEY_SYMBOLICNAME+"'.";
+ assert (foundNames[0].equals("myartifact") && foundNames[1].equals("mytagname")) ||
+ (foundNames[1].equals("myartifact") && foundNames[0].equals("mytagname")) : "The order is undefined, but we should find both the items we put in for '"+BundleHelper.KEY_SYMBOLICNAME+"'.";
- assert m_artifactRepository.get().size() == 1 : "The repository should contain exactly one bundle.";
- assert m_artifactRepository.get().get(0).equals(b) : "The repository should contain exactly our bundle.";
+ assert m_artifactRepository.get().size() == 1 : "The repository should contain exactly one artifact.";
+ assert m_artifactRepository.get().get(0).equals(a) : "The repository should contain exactly our artifact.";
- ArtifactObject b2 = createBasicBundleObject("myotherbundle", "1");
+ ArtifactObject b2 = createBasicArtifactObject("myotherartifact", "1");
- assert m_artifactRepository.get(createLocalFilter("(" + BundleHelper.KEY_SYMBOLICNAME + "=mybundle)")).size() == 1 : "When filtering for our bundle, we should find only that.";
- assert m_artifactRepository.get(createLocalFilter("(" + BundleHelper.KEY_VERSION + "=1.0.0)")).size() == 2 : "When filtering for a version, we should find two bundles.";
+ assert m_artifactRepository.get(createLocalFilter("(" + BundleHelper.KEY_SYMBOLICNAME + "=myartifact)")).size() == 1 : "When filtering for our artifact, we should find only that.";
+ assert m_artifactRepository.get(createLocalFilter("(" + BundleHelper.KEY_VERSION + "=1.0.0)")).size() == 2 : "When filtering for a version, we should find two artifacts.";
try {
- createBasicBundleObject("mybundle", "1.0.0");
- assert false : "Adding a bundle which is identical to one already in the repository should be illegal.";
+ createBasicArtifactObject("myartifact", "1.0.0");
+ assert false : "Adding a artifact which is identical to one already in the repository should be illegal.";
}
catch (IllegalArgumentException iae) {
//expected
@@ -189,12 +189,12 @@ public class ModelTest {
b2.addAttribute("thenewattribute", "withsomevalue");
}
catch (UnsupportedOperationException uoe) {
- assert false : "Adding arbitrary attributes to a bundle object should be allowed.";
+ assert false : "Adding arbitrary attributes to a artifact object should be allowed.";
}
try {
- b2.addAttribute(BundleHelper.KEY_SYMBOLICNAME, "bundle.42");
- assert false : "Changing key attributes in a bundle should not be allowed.";
+ b2.addAttribute(BundleHelper.KEY_SYMBOLICNAME, "artifact.42");
+ assert false : "Changing key attributes in a artifact should not be allowed.";
}
catch (UnsupportedOperationException uoe) {
//expected
@@ -203,69 +203,69 @@ public class ModelTest {
try {
Map<String, String> attr = new HashMap<String, String>();
- attr.put(BundleHelper.KEY_NAME, "mynewbundle");
+ attr.put(BundleHelper.KEY_NAME, "mynewartifact");
Map<String, String> tags = new HashMap<String, String>();
m_artifactRepository.create(attr, tags);
- assert false : "Creating a bundle without specifying all mandatory atttributes should be illegal.";
+ assert false : "Creating a artifact without specifying all mandatory atttributes should be illegal.";
}
catch (IllegalArgumentException iae) {
//expected
}
- m_artifactRepository.remove(b);
+ m_artifactRepository.remove(a);
try {
- b.addTag("mytag", "myvalue");
+ a.addTag("mytag", "myvalue");
assert false : "Deleted objects are not allowed to be changed.";
}
catch (IllegalStateException ise) {
// expected
}
- assert m_artifactRepository.get().size() == 1 : "After removing our first bundle, the repository should contain one bundle.";
- assert m_artifactRepository.get().get(0).equals(b2) : "After removing our first bundle, the repository should contain only our second bundle.";
+ assert m_artifactRepository.get().size() == 1 : "After removing our first artifact, the repository should contain one artifact.";
+ assert m_artifactRepository.get().get(0).equals(b2) : "After removing our first artifact, the repository should contain only our second artifact.";
}
@Test( groups = { TestUtils.UNIT } )
public void testRepositorySerialization() {
- createBasicBundleObject("mybundle", "1");
- createBasicBundleObject("mybundle", "2");
+ createBasicArtifactObject("myartifact", "1");
+ createBasicArtifactObject("myartifact", "2");
// Write the store to a stream, reset the repository, and re-read it.
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- RepositorySet store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_artifact2groupRepository, m_groupRepository}, null, "", true);
+ RepositorySet store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_artifact2FeatureRepository, m_featureRepository}, null, "", true);
new RepositorySerializer(store).toXML(buffer);
initializeRepositoryAdmin();
- store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_artifact2groupRepository, m_groupRepository}, null, "", true);
+ store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_artifact2FeatureRepository, m_featureRepository}, null, "", true);
new RepositorySerializer(store).fromXML(new ByteArrayInputStream(buffer.toByteArray()));
- assert m_artifactRepository.get().size() == 2 : "We expect to find 2 bundles, but we find " + m_artifactRepository.get().size();
+ assert m_artifactRepository.get().size() == 2 : "We expect to find 2 artifacts, but we find " + m_artifactRepository.get().size();
}
@Test( groups = { TestUtils.UNIT } )
public void testSerialization() {
- ArtifactObject b1 = createBasicBundleObject("bundle1");
- ArtifactObject b2 = createBasicBundleObject("bundle2");
- ArtifactObject b3 = createBasicBundleObject("bundle3");
-
- FeatureObject g1 = createBasicGroupObject("group1");
- FeatureObject g2 = createBasicGroupObject("group2");
-
- m_artifact2groupRepository.create(b1, g1);
- m_artifact2groupRepository.create(b2, g2);
- m_artifact2groupRepository.create(b3, g2);
+ ArtifactObject b1 = createBasicArtifactObject("artifact1");
+ ArtifactObject b2 = createBasicArtifactObject("artifact2");
+ ArtifactObject b3 = createBasicArtifactObject("artifact3");
+
+ FeatureObject g1 = createBasicFeatureObject("feature1");
+ FeatureObject g2 = createBasicFeatureObject("feature2");
+
+ m_artifact2FeatureRepository.create(b1, g1);
+ m_artifact2FeatureRepository.create(b2, g2);
+ m_artifact2FeatureRepository.create(b3, g2);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- RepositorySet store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_groupRepository, m_artifact2groupRepository}, null, "", true);
+ RepositorySet store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_featureRepository, m_artifact2FeatureRepository}, null, "", true);
new RepositorySerializer(store).toXML(buffer);
initializeRepositoryAdmin();
- store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_groupRepository, m_artifact2groupRepository}, null, "", true);
+ store = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_artifactRepository, m_featureRepository, m_artifact2FeatureRepository}, null, "", true);
new RepositorySerializer(store).fromXML(new ByteArrayInputStream(buffer.toByteArray()));
- assert m_artifactRepository.get().size() == 3 : "We expect to find 3 bundles, but we find " + m_artifactRepository.get().size();
- assert m_groupRepository.get().size() == 2 : "We expect to find 2 groups, but we find " + m_groupRepository.get().size();
- assert m_artifact2groupRepository.get().size() == 3 : "We expect to find 3 associations, but we find " + m_artifact2groupRepository.get().size();
+ assert m_artifactRepository.get().size() == 3 : "We expect to find 3 artifacts, but we find " + m_artifactRepository.get().size();
+ assert m_featureRepository.get().size() == 2 : "We expect to find 2 features, but we find " + m_featureRepository.get().size();
+ assert m_artifact2FeatureRepository.get().size() == 3 : "We expect to find 3 associations, but we find " + m_artifact2FeatureRepository.get().size();
assert b1.isAssociated(g1, FeatureObject.class) : "After serialization, b1 should still be associated with g1.";
assert !b1.isAssociated(g2, FeatureObject.class) : "After serialization, b1 should not be associated with g1.";
assert !b2.isAssociated(g1, FeatureObject.class) : "After serialization, b2 should not be associated with g2.";
@@ -277,39 +277,39 @@ public class ModelTest {
@Test( groups = { TestUtils.UNIT } )
public void testModelFiltering() throws InvalidSyntaxException {
initializeRepositoryAdmin();
- // Create an empty bundle repository.
+ // Create an empty artifact repository.
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("myattribute", "theattribute");
attributes.put("name", "attname");
Map<String, String> tags = new HashMap<String, String>();
- assert m_groupRepository != null : "Something has gone wrong injecting the bundle repository.";
- FeatureObject g1 = m_groupRepository.create(attributes, tags);
+ assert m_featureRepository != null : "Something has gone wrong injecting the feature repository.";
+ FeatureObject g1 = m_featureRepository.create(attributes, tags);
g1.addTag("mytag", "thetag");
g1.addTag("name", "tagname");
g1.addTag("difficult", ")diffi)c*ul\\t");
- assert m_groupRepository.get(createLocalFilter("(myattribute=*)")).size() == 1 : "There should be a myattribute in b1.";
- assert m_groupRepository.get(createLocalFilter("(myattribute=theattribute)")).size() == 1 : "There should be myattribute=theattribute in b1.";
- assert m_groupRepository.get(createLocalFilter("(myattribute=thetag)")).size() == 0 : "There should not be myattribute=thetag in b1.";
- assert m_groupRepository.get(createLocalFilter("(mytag=*)")).size() == 1 : "There should be a mytag in b1.";
- assert m_groupRepository.get(createLocalFilter("(mytag=thetag)")).size() == 1 : "There should be mytag=thetag in b1.";
- assert m_groupRepository.get(createLocalFilter("(mytag=theattribute)")).size() == 0 : "There should not be mytag=theattribute in b1.";
-
- assert m_groupRepository.get(createLocalFilter("(name=*)")).size() == 1 : "There should be a name parameter in b1.";
- assert m_groupRepository.get(createLocalFilter("(name=attname)")).size() == 1 : "There should be a name=attname in b1.";
- assert m_groupRepository.get(createLocalFilter("(name=tagname)")).size() == 1 : "There should be a name=tagname in b1.";
- assert m_groupRepository.get(createLocalFilter("(name=thetag)")).size() == 0 : "There should not be name=thetag in b1.";
+ assert m_featureRepository.get(createLocalFilter("(myattribute=*)")).size() == 1 : "There should be a myattribute in b1.";
+ assert m_featureRepository.get(createLocalFilter("(myattribute=theattribute)")).size() == 1 : "There should be myattribute=theattribute in b1.";
+ assert m_featureRepository.get(createLocalFilter("(myattribute=thetag)")).size() == 0 : "There should not be myattribute=thetag in b1.";
+ assert m_featureRepository.get(createLocalFilter("(mytag=*)")).size() == 1 : "There should be a mytag in b1.";
+ assert m_featureRepository.get(createLocalFilter("(mytag=thetag)")).size() == 1 : "There should be mytag=thetag in b1.";
+ assert m_featureRepository.get(createLocalFilter("(mytag=theattribute)")).size() == 0 : "There should not be mytag=theattribute in b1.";
+
+ assert m_featureRepository.get(createLocalFilter("(name=*)")).size() == 1 : "There should be a name parameter in b1.";
+ assert m_featureRepository.get(createLocalFilter("(name=attname)")).size() == 1 : "There should be a name=attname in b1.";
+ assert m_featureRepository.get(createLocalFilter("(name=tagname)")).size() == 1 : "There should be a name=tagname in b1.";
+ assert m_featureRepository.get(createLocalFilter("(name=thetag)")).size() == 0 : "There should not be name=thetag in b1.";
try {
- m_groupRepository.get(createLocalFilter("(difficult=)diffi)c*ul\\t"));
+ m_featureRepository.get(createLocalFilter("(difficult=)diffi)c*ul\\t"));
assert false : "The non-escaped difficult string should raise an error.";
}
catch (InvalidSyntaxException ex) {
//expected
}
- assert m_groupRepository.get(createLocalFilter("(difficult=" + RepositoryUtil.escapeFilterValue(")diffi)c*ul\\t") + ")")).size() == 1 : "The 'difficult' string should be correctly escaped, and thus return exactly one match.";
+ assert m_featureRepository.get(createLocalFilter("(difficult=" + RepositoryUtil.escapeFilterValue(")diffi)c*ul\\t") + ")")).size() == 1 : "The 'difficult' string should be correctly escaped, and thus return exactly one match.";
}
/**
@@ -318,147 +318,147 @@ public class ModelTest {
@Test( groups = { TestUtils.UNIT } )
public void testAssociations() {
initializeRepositoryAdmin();
- // Create two, rather boring, bundles.
- ArtifactObject b1 = createBasicBundleObject("bundle1");
- ArtifactObject b2 = createBasicBundleObject("bundle2");
-
- // Create three groups.
- FeatureObject g1 = createBasicGroupObject("group1");
- FeatureObject g2 = createBasicGroupObject("group2");
- FeatureObject g3 = createBasicGroupObject("group3");
+ // Create two, rather boring, artifacts.
+ ArtifactObject b1 = createBasicArtifactObject("artifact1");
+ ArtifactObject b2 = createBasicArtifactObject("artifact2");
+
+ // Create three features.
+ FeatureObject g1 = createBasicFeatureObject("feature1");
+ FeatureObject g2 = createBasicFeatureObject("feature2");
+ FeatureObject g3 = createBasicFeatureObject("feature3");
// Create some associations.
- Artifact2FeatureAssociation b2g1 = m_artifact2groupRepository.create(b1, g2);
+ Artifact2FeatureAssociation b2g1 = m_artifact2FeatureRepository.create(b1, g2);
assert b2g1 != null;
- Artifact2FeatureAssociation b2g2 = m_artifact2groupRepository.create(b2, g1);
+ Artifact2FeatureAssociation b2g2 = m_artifact2FeatureRepository.create(b2, g1);
assert b2g2 != null;
- Artifact2FeatureAssociation b2g3 = m_artifact2groupRepository.create(b1, g3);
+ Artifact2FeatureAssociation b2g3 = m_artifact2FeatureRepository.create(b1, g3);
assert b2g3 != null;
- Artifact2FeatureAssociation b2g4 = m_artifact2groupRepository.create(b2, g3);
+ Artifact2FeatureAssociation b2g4 = m_artifact2FeatureRepository.create(b2, g3);
assert b2g4 != null;
// Do some basic checks on the repositories.
- assert m_artifactRepository.get().size() == 2 : "We should have two bundles in our repository; we found " + m_artifactRepository.get().size() + ".";
- assert m_groupRepository.get().size() == 3 : "We should have three groups in our repository; we found " + m_groupRepository.get().size() + ".";
- assert m_artifact2groupRepository.get().size() == 4 : "We should have four associations in our repository; we found " + m_artifact2groupRepository.get().size() + ".";
+ assert m_artifactRepository.get().size() == 2 : "We should have two artifacts in our repository; we found " + m_artifactRepository.get().size() + ".";
+ assert m_featureRepository.get().size() == 3 : "We should have three features in our repository; we found " + m_featureRepository.get().size() + ".";
+ assert m_artifact2FeatureRepository.get().size() == 4 : "We should have four associations in our repository; we found " + m_artifact2FeatureRepository.get().size() + ".";
- assert (b2g4.getLeft().size() == 1) && b2g4.getLeft().contains(b2) : "The left side of the fourth association should be bundle 2.";
- assert (b2g4.getRight().size() == 1) && b2g4.getRight().contains(g3) : "The right side of the fourth association should be group 3.";
+ assert (b2g4.getLeft().size() == 1) && b2g4.getLeft().contains(b2) : "The left side of the fourth association should be artifact 2.";
+ assert (b2g4.getRight().size() == 1) && b2g4.getRight().contains(g3) : "The right side of the fourth association should be feature 3.";
// Check the wiring: what is wired to what?
- List<FeatureObject> b1groups = b1.getFeatures();
- List<FeatureObject> b2groups = b2.getFeatures();
+ List<FeatureObject> b1features = b1.getFeatures();
+ List<FeatureObject> b2features = b2.getFeatures();
- List<ArtifactObject> g1bundles = g1.getArtifacts();
- List<ArtifactObject> g2bundles = g2.getArtifacts();
- List<ArtifactObject> g3bundles = g3.getArtifacts();
- List<DistributionObject> g1licenses = g1.getDistributions();
- List<DistributionObject> g2licenses = g2.getDistributions();
- List<DistributionObject> g3licenses = g3.getDistributions();
-
- assert g1licenses.size() == 0 : "Group one should not have any associations to licenses; we found " + g1licenses.size() + ".";
- assert g2licenses.size() == 0 : "Group two should not have any associations to licenses; we found " + g2licenses.size() + ".";
- assert g3licenses.size() == 0 : "Group three should not have any associations to licenses; we found " + g3licenses.size() + ".";
-
- List<FeatureObject> b1expectedGroups = new ArrayList<FeatureObject>();
- b1expectedGroups.add(g2);
- b1expectedGroups.add(g3);
- List<FeatureObject> b2expectedGroups = new ArrayList<FeatureObject>();
- b2expectedGroups.add(g1);
- b2expectedGroups.add(g3);
-
- List<ArtifactObject> g1expectedBundles = new ArrayList<ArtifactObject>();
- g1expectedBundles.add(b2);
- List<ArtifactObject> g2expectedBundles = new ArrayList<ArtifactObject>();
- g2expectedBundles.add(b1);
- List<ArtifactObject> g3expectedBundles = new ArrayList<ArtifactObject>();
- g3expectedBundles.add(b1);
- g3expectedBundles.add(b2);
-
- assert b1groups.containsAll(b1expectedGroups) && b1expectedGroups.containsAll(b1groups) : "b1 should be associated to exactly groups 2 and 3.";
- assert b2groups.containsAll(b2expectedGroups) && b2expectedGroups.containsAll(b2groups) : "b2 should be associated to exactly groups 1 and 3.";
-
- assert g1bundles.containsAll(g1expectedBundles) && g1expectedBundles.containsAll(g1bundles) : "g1 should be associated to exactly bundle 2.";
- assert g2bundles.containsAll(g2expectedBundles) && g2expectedBundles.containsAll(g2bundles) : "g2 should be associated to exactly bundle 1.";
- assert g3bundles.containsAll(g3expectedBundles) && g3expectedBundles.containsAll(g3bundles) : "g3 should be associated to exactly bundles 1 and 2.";
-
- m_artifact2groupRepository.remove(b2g4);
-
- b1groups = b1.getFeatures();
- b2groups = b2.getFeatures();
- g1bundles = g1.getArtifacts();
- g2bundles = g2.getArtifacts();
- g3bundles = g3.getArtifacts();
-
- b2expectedGroups.remove(g3);
- g3expectedBundles.remove(b2);
-
- assert b1groups.containsAll(b1expectedGroups) && b1expectedGroups.containsAll(b1groups) : "b1 should be associated to exactly groups 2 and 3.";
- assert b2groups.containsAll(b2expectedGroups) && b2expectedGroups.containsAll(b2groups) : "b2 should be associated to exactly group 1.";
-
- assert g1bundles.containsAll(g1expectedBundles) && g1expectedBundles.containsAll(g1bundles) : "g1 should be associated to exactly bundle 2.";
- assert g2bundles.containsAll(g2expectedBundles) && g2expectedBundles.containsAll(g2bundles) : "g2 should be associated to exactly bundle 1.";
- assert g3bundles.containsAll(g3expectedBundles) && g3expectedBundles.containsAll(g3bundles) : "g3 should be associated to exactly bundle 1.";
+ List<ArtifactObject> g1artifacts = g1.getArtifacts();
+ List<ArtifactObject> g2artifacts = g2.getArtifacts();
+ List<ArtifactObject> g3artifacts = g3.getArtifacts();
+ List<DistributionObject> g1distributions = g1.getDistributions();
+ List<DistributionObject> g2distributions = g2.getDistributions();
+ List<DistributionObject> g3distributions = g3.getDistributions();
+
+ assert g1distributions.size() == 0 : "Feature one should not have any associations to distributions; we found " + g1distributions.size() + ".";
+ assert g2distributions.size() == 0 : "Feature two should not have any associations to distributions; we found " + g2distributions.size() + ".";
+ assert g3distributions.size() == 0 : "Feature three should not have any associations to distributions; we found " + g3distributions.size() + ".";
+
+ List<FeatureObject> b1expectedFeatures = new ArrayList<FeatureObject>();
+ b1expectedFeatures.add(g2);
+ b1expectedFeatures.add(g3);
+ List<FeatureObject> b2expectedFeatures = new ArrayList<FeatureObject>();
+ b2expectedFeatures.add(g1);
+ b2expectedFeatures.add(g3);
+
+ List<ArtifactObject> g1expectedArtifacts = new ArrayList<ArtifactObject>();
+ g1expectedArtifacts.add(b2);
+ List<ArtifactObject> g2expectedArtifacts = new ArrayList<ArtifactObject>();
+ g2expectedArtifacts.add(b1);
+ List<ArtifactObject> g3expectedArtifacts = new ArrayList<ArtifactObject>();
+ g3expectedArtifacts.add(b1);
+ g3expectedArtifacts.add(b2);
+
+ assert b1features.containsAll(b1expectedFeatures) && b1expectedFeatures.containsAll(b1features) : "b1 should be associated to exactly features 2 and 3.";
+ assert b2features.containsAll(b2expectedFeatures) && b2expectedFeatures.containsAll(b2features) : "b2 should be associated to exactly features 1 and 3.";
+
+ assert g1artifacts.containsAll(g1expectedArtifacts) && g1expectedArtifacts.containsAll(g1artifacts) : "g1 should be associated to exactly artifact 2.";
+ assert g2artifacts.containsAll(g2expectedArtifacts) && g2expectedArtifacts.containsAll(g2artifacts) : "g2 should be associated to exactly artifact 1.";
+ assert g3artifacts.containsAll(g3expectedArtifacts) && g3expectedArtifacts.containsAll(g3artifacts) : "g3 should be associated to exactly artifacts 1 and 2.";
+
+ m_artifact2FeatureRepository.remove(b2g4);
+
+ b1features = b1.getFeatures();
+ b2features = b2.getFeatures();
+ g1artifacts = g1.getArtifacts();
+ g2artifacts = g2.getArtifacts();
+ g3artifacts = g3.getArtifacts();
+
+ b2expectedFeatures.remove(g3);
+ g3expectedArtifacts.remove(b2);
+
+ assert b1features.containsAll(b1expectedFeatures) && b1expectedFeatures.containsAll(b1features) : "b1 should be associated to exactly features 2 and 3.";
+ assert b2features.containsAll(b2expectedFeatures) && b2expectedFeatures.containsAll(b2features) : "b2 should be associated to exactly feature 1.";
+
+ assert g1artifacts.containsAll(g1expectedArtifacts) && g1expectedArtifacts.containsAll(g1artifacts) : "g1 should be associated to exactly artifact 2.";
+ assert g2artifacts.containsAll(g2expectedArtifacts) && g2expectedArtifacts.containsAll(g2artifacts) : "g2 should be associated to exactly artifact 1.";
+ assert g3artifacts.containsAll(g3expectedArtifacts) && g3expectedArtifacts.containsAll(g3artifacts) : "g3 should be associated to exactly artifact 1.";
}
/**
* Not a full-fledged testcase, but a quick test of the correctness of the
- * specified classes for groups, licenses and their associations. In essence,
+ * specified classes for features, distributions and their associations. In essence,
* this test 'touches' all code which uses generic code which has been tested
* by TestAssociations.
*/
@Test( groups = { TestUtils.UNIT } )
- public void TestGroup2LicenseAssociations() {
+ public void TestFeature2DistributionAssociations() {
initializeRepositoryAdmin();
- FeatureObject g1 = createBasicGroupObject("group1");
- DistributionObject l1 = createBasicLicenseObject("license1");
- Feature2DistributionAssociation g2l1 = m_group2licenseRepository.create(g1, l1);
+ FeatureObject f1 = createBasicFeatureObject("feature1");
+ DistributionObject d1 = createBasicDistributionObject("distribution1");
+ Feature2DistributionAssociation f2d1 = m_feature2DistributionRepository.create(f1, d1);
- assert (g2l1.getLeft().size() == 1) && g2l1.getLeft().contains(g1) : "Left side of the association should be our group.";
- assert (g2l1.getRight().size() == 1) && g2l1.getRight().contains(l1) : "Right side of the association should be our license.";
+ assert (f2d1.getLeft().size() == 1) && f2d1.getLeft().contains(f1) : "Left side of the association should be our feature.";
+ assert (f2d1.getRight().size() == 1) && f2d1.getRight().contains(d1) : "Right side of the association should be our distribution.";
- assert g1.getArtifacts().size() == 0 : "Group 1 should not be associated with any bundles; it is associated with " + g1.getArtifacts().size() + ".";
- assert g1.getDistributions().size() == 1 : "Group 1 should be associated with exactly one license; it is associated with " + g1.getDistributions().size() + ".";
+ assert f1.getArtifacts().size() == 0 : "Feature 1 should not be associated with any artifacts; it is associated with " + f1.getArtifacts().size() + ".";
+ assert f1.getDistributions().size() == 1 : "Feature 1 should be associated with exactly one distribution; it is associated with " + f1.getDistributions().size() + ".";
- assert l1.getFeatures().size() == 1 : "License 1 should be associated with exactly one group; it is associated with " + l1.getFeatures().size() + ".";
- assert l1.getTargets().size() == 0 : "License 1 should not be associated with any gateways; it is associated with " + l1.getTargets().size() + ".";
+ assert d1.getFeatures().size() == 1 : "Distribution 1 should be associated with exactly one feature; it is associated with " + d1.getFeatures().size() + ".";
+ assert d1.getTargets().size() == 0 : "Distribution 1 should not be associated with any targets; it is associated with " + d1.getTargets().size() + ".";
}
/**
* Not a full-fledged testcase, but a quick test of the correctness of the
- * specified classes for licenses, gateways and their associations. In essence,
+ * specified classes for distributions, targets and their associations. In essence,
* this test 'touches' all code which uses generic code which has been tested
* by TestAssociations.
*/
@Test( groups = { TestUtils.UNIT } )
- public void testLicense2GatewayAssociations() {
+ public void testDistribution2TargetAssociations() {
initializeRepositoryAdmin();
- DistributionObject l1 = createBasicLicenseObject("license1");
- TargetObject g1 = createBasicGatewayObject("gateway1");
- m_license2gatewayRepository.create(l1, g1);
+ DistributionObject d1 = createBasicDistributionObject("distribution1");
+ TargetObject t1 = createBasicTargetObject("target1");
+ m_distribution2TargetRepository.create(d1, t1);
- assert l1.getFeatures().size() == 0 : "License 1 should not be associated with any groups; it is associated with " + l1.getFeatures().size() + ".";
- assert l1.getTargets().size() == 1 : "License 1 should be associated with exactly one gateway; it is associated with " + l1.getTargets().size() + ".";
+ assert d1.getFeatures().size() == 0 : "Distribution 1 should not be associated with any features; it is associated with " + d1.getFeatures().size() + ".";
+ assert d1.getTargets().size() == 1 : "Distribution 1 should be associated with exactly one target; it is associated with " + d1.getTargets().size() + ".";
- assert g1.getDistributions().size() == 1 : "Gateway 1 should be associated with exactly one license; it is associated with " + g1.getDistributions().size() + ".";
+ assert t1.getDistributions().size() == 1 : "Target 1 should be associated with exactly one distribution; it is associated with " + t1.getDistributions().size() + ".";
}
@Test( groups = { TestUtils.UNIT } )
public void testGetAssociationsWith() {
initializeRepositoryAdmin();
- ArtifactObject b1 = createBasicBundleObject("bundle1");
- FeatureObject g1 = createBasicGroupObject("group1");
- Artifact2FeatureAssociation b2g1 = m_artifact2groupRepository.create(b1, g1);
+ ArtifactObject a1 = createBasicArtifactObject("artifact1");
+ FeatureObject f1 = createBasicFeatureObject("feature1");
+ Artifact2FeatureAssociation a2f1 = m_artifact2FeatureRepository.create(a1, f1);
- List<Artifact2FeatureAssociation> b1Associations = b1.getAssociationsWith(g1);
- List<Artifact2FeatureAssociation> g1Associations = g1.getAssociationsWith(b1);
+ List<Artifact2FeatureAssociation> b1Associations = a1.getAssociationsWith(f1);
+ List<Artifact2FeatureAssociation> g1Associations = f1.getAssociationsWith(a1);
- assert b1Associations.size() == 1 : "The bundle has exactly one association to the group, but it shows " + b1Associations.size() + ".";
- assert b1Associations.get(0) == b2g1 : "The bundle's association should be the one we created.";
+ assert b1Associations.size() == 1 : "The artifact has exactly one association to the feature, but it shows " + b1Associations.size() + ".";
+ assert b1Associations.get(0) == a2f1 : "The artifact's association should be the one we created.";
- assert g1Associations.size() == 1 : "The group has exactly one association to the bundle.";
- assert g1Associations.get(0) == b2g1 : "The group's association should be the one we created.";
+ assert g1Associations.size() == 1 : "The feature has exactly one association to the artifact.";
+ assert g1Associations.get(0) == a2f1 : "The feature's association should be the one we created.";
}
/**
@@ -466,35 +466,35 @@ public class ModelTest {
*/
@Test( groups = { TestUtils.UNIT } )
public void testEquals() {
- List<ArtifactObject> bundles = new ArrayList<ArtifactObject>();
- bundles.add(createBasicBundleObject("bundle1"));
- bundles.add(createBasicBundleObject("bundle2"));
- bundles.get(1).addTag("thetag", "thevalue");
- bundles.add(createBasicBundleObject("bundle3"));
+ List<ArtifactObject> artifacts = new ArrayList<ArtifactObject>();
+ artifacts.add(createBasicArtifactObject("artifact1"));
+ artifacts.add(createBasicArtifactObject("artifact2"));
+ artifacts.get(1).addTag("thetag", "thevalue");
+ artifacts.add(createBasicArtifactObject("artifact3"));
- List<ArtifactObject> backupBundles = new ArrayList<ArtifactObject>();
- backupBundles.addAll(bundles);
+ List<ArtifactObject> backupArtifacts = new ArrayList<ArtifactObject>();
+ backupArtifacts.addAll(artifacts);
- for (ArtifactObject b : backupBundles) {
- bundles.remove(b);
+ for (ArtifactObject b : backupArtifacts) {
+ artifacts.remove(b);
}
- assert bundles.size() == 0 : "The bundles list should be empty; if not, the ArtifactObject's equals() could be broken.";
+ assert artifacts.size() == 0 : "The artifacts list should be empty; if not, the ArtifactObject's equals() could be broken.";
}
@Test( groups = { TestUtils.UNIT } )
public void testDeploymentVersion() {
- DeploymentVersionObject version = createBasicDeploymentVersionObject("gateway1", "1", new String[] {"bundle1", "bundle2"});
+ DeploymentVersionObject version = createBasicDeploymentVersionObject("target1", "1", new String[] {"artifact1", "artifact2"});
- assert version.getDeploymentArtifacts().length == 2 : "We expect to find two bundles, but we find " + version.getDeploymentArtifacts().length;
- assert version.getDeploymentArtifacts()[0].getUrl().equals("bundle1");
- assert version.getDeploymentArtifacts()[1].getUrl().equals("bundle2");
+ assert version.getDeploymentArtifacts().length == 2 : "We expect to find two artifacts, but we find " + version.getDeploymentArtifacts().length;
+ assert version.getDeploymentArtifacts()[0].getUrl().equals("artifact1");
+ assert version.getDeploymentArtifacts()[1].getUrl().equals("artifact2");
((DeploymentArtifactImpl) version.getDeploymentArtifacts()[0]).addDirective("myDirective", "myValue");
try {
- createBasicDeploymentVersionObject("gateway1", "1", new String[] {"bundle1", "bundle2"});
- assert false : "Creating a deployment version with a gateway and version that already exists should not be allowed.";
+ createBasicDeploymentVersionObject("target1", "1", new String[] {"artifact1", "artifact2"});
+ assert false : "Creating a deployment version with a target and version that already exists should not be allowed.";
}
catch (IllegalArgumentException iae) {
// expected
@@ -517,44 +517,44 @@ public class ModelTest {
assert m_deploymentVersionRepository.get().size() == 1 : "The disallowed version should not be in the repository.";
assert m_deploymentVersionRepository.get().get(0).equals(version) : "Only our newly created version object should be in the repository.";
- assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts().length == 2 : "We expect to find two bundles, but we find " + m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts().length;
- assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts()[0].getUrl().equals("bundle1");
+ assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts().length == 2 : "We expect to find two artifacts, but we find " + m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts().length;
+ assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts()[0].getUrl().equals("artifact1");
assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts()[0].getKeys().length == 1 : "We expect to find one directive in the first artifact.";
assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts()[0].getDirective("myDirective").equals("myValue") : "The directive should be 'myValue'.";
- assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts()[1].getUrl().equals("bundle2");
+ assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts()[1].getUrl().equals("artifact2");
}
@Test( groups = { TestUtils.UNIT } )
public void testDeploymentRepository() {
- DeploymentVersionObject version11 = createBasicDeploymentVersionObject("gateway1", "1", new String[] {"bundle1", "bundle2"});
- DeploymentVersionObject version12 = createBasicDeploymentVersionObject("gateway1", "2", new String[] {"bundle3", "bundle4"});
- // Note the different order in adding the versions for gateway2.
- DeploymentVersionObject version22 = createBasicDeploymentVersionObject("gateway2", "2", new String[] {"bundleC", "bundleD"});
- DeploymentVersionObject version21 = createBasicDeploymentVersionObject("gateway2", "1", new String[] {"bundleA", "bundleB"});
-
- assert m_deploymentVersionRepository.getDeploymentVersions("NotMyGateway").size() == 0 : "The deployment repository should not return" +
- "any versions when we ask for a gateway that does not exist, but it returns " + m_deploymentVersionRepository.getDeploymentVersions("NotMyGateway").size();
-
- List<DeploymentVersionObject> for1 = m_deploymentVersionRepository.getDeploymentVersions("gateway1");
- assert for1.size() == 2 : "We expect two versions for gateway1, but we find " + for1.size();
- assert for1.get(0) == version11 : "The first version for gateway1 should be version11";
- assert for1.get(1) == version12 : "The second version for gateway1 should be version12";
-
- List<DeploymentVersionObject> for2 = m_deploymentVersionRepository.getDeploymentVersions("gateway2");
- assert for2.size() == 2 : "We expect two versions for gateway2, but we find " + for2.size();
- assert for2.get(0) == version21 : "The first version for gateway2 should be version21";
- assert for2.get(1) == version22 : "The second version for gateway2 should be version22";
-
- assert m_deploymentVersionRepository.getMostRecentDeploymentVersion("NotMyGateway") == null : "The most recent version for a non-existent gateway should not exist.";
- assert m_deploymentVersionRepository.getMostRecentDeploymentVersion("gateway1") == version12 : "The most recent version for gateway1 should be version12";
- assert m_deploymentVersionRepository.getMostRecentDeploymentVersion("gateway2") == version22 : "The most recent version for gateway2 should be version22";
+ DeploymentVersionObject version11 = createBasicDeploymentVersionObject("target1", "1", new String[] {"artifact1", "artifact2"});
+ DeploymentVersionObject version12 = createBasicDeploymentVersionObject("target1", "2", new String[] {"artifact3", "artifact4"});
+ // Note the different order in adding the versions for target2.
+ DeploymentVersionObject version22 = createBasicDeploymentVersionObject("target2", "2", new String[] {"artifactC", "artifactD"});
+ DeploymentVersionObject version21 = createBasicDeploymentVersionObject("target2", "1", new String[] {"artifactA", "artifactB"});
+
+ assert m_deploymentVersionRepository.getDeploymentVersions("NotMyTarget").size() == 0 : "The deployment repository should not return" +
+ "any versions when we ask for a target that does not exist, but it returns " + m_deploymentVersionRepository.getDeploymentVersions("NotMyTarget").size();
+
+ List<DeploymentVersionObject> for1 = m_deploymentVersionRepository.getDeploymentVersions("target1");
+ assert for1.size() == 2 : "We expect two versions for target1, but we find " + for1.size();
+ assert for1.get(0) == version11 : "The first version for target1 should be version11";
+ assert for1.get(1) == version12 : "The second version for target1 should be version12";
+
+ List<DeploymentVersionObject> for2 = m_deploymentVersionRepository.getDeploymentVersions("target2");
+ assert for2.size() == 2 : "We expect two versions for target2, but we find " + for2.size();
+ assert for2.get(0) == version21 : "The first version for target2 should be version21";
+ assert for2.get(1) == version22 : "The second version for target2 should be version22";
+
+ assert m_deploymentVersionRepository.getMostRecentDeploymentVersion("NotMyTarget") == null : "The most recent version for a non-existent target should not exist.";
+ assert m_deploymentVersionRepository.getMostRecentDeploymentVersion("target1") == version12 : "The most recent version for target1 should be version12";
+ assert m_deploymentVersionRepository.getMostRecentDeploymentVersion("target2") == version22 : "The most recent version for target2 should be version22";
}
@Test( groups = { TestUtils.UNIT } )
public void testDeploymentRepositoryFilter() {
- String gwId = "\\ ( * ) gateway1)";
- DeploymentVersionObject version1 = createBasicDeploymentVersionObject(gwId, "1", new String[] {"bundle1", "bundle2"});
+ String gwId = "\\ ( * ) target1)";
+ DeploymentVersionObject version1 = createBasicDeploymentVersionObject(gwId, "1", new String[] {"artifact1", "artifact2"});
List<DeploymentVersionObject> for1 = m_deploymentVersionRepository.getDeploymentVersions( gwId );
assert for1.size() == 1 : "We expect one version for" + gwId + ", but we find " + for1.size();
@@ -563,24 +563,24 @@ public class ModelTest {
@Test( groups = { TestUtils.UNIT } )
public void testAssociationsWithLists() {
- ArtifactObject b1 = createBasicBundleObject("b1");
- ArtifactObject b2 = createBasicBundleObject("b2");
- ArtifactObject b3 = createBasicBundleObject("b3");
- FeatureObject g1 = createBasicGroupObject("g1");
- FeatureObject g2 = createBasicGroupObject("g2");
- FeatureObject g3 = createBasicGroupObject("g3");
-
- List<ArtifactObject> bundles = new ArrayList<ArtifactObject>();
- bundles.add(b1);
- bundles.add(b2);
- List<FeatureObject> groups = new ArrayList<FeatureObject>();
- groups.add(g1);
- groups.add(g3);
+ ArtifactObject b1 = createBasicArtifactObject("b1");
+ ArtifactObject b2 = createBasicArtifactObject("b2");
+ ArtifactObject b3 = createBasicArtifactObject("b3");
+ FeatureObject g1 = createBasicFeatureObject("g1");
+ FeatureObject g2 = createBasicFeatureObject("g2");
+ FeatureObject g3 = createBasicFeatureObject("g3");
+
+ List<ArtifactObject> artifacts = new ArrayList<ArtifactObject>();
+ artifacts.add(b1);
+ artifacts.add(b2);
+ List<FeatureObject> features = new ArrayList<FeatureObject>();
+ features.add(g1);
+ features.add(g3);
- Artifact2FeatureAssociation bg = m_artifact2groupRepository.create(bundles, groups);
+ Artifact2FeatureAssociation bg = m_artifact2FeatureRepository.create(artifacts, features);
- assert bg.getLeft().size() == 2 : "We expect two bundles on the left side of the association.";
- assert bg.getRight().size() == 2 : "We expect two groups on the right side of the association.";
+ assert bg.getLeft().size() == 2 : "We expect two artifacts on the left side of the association.";
+ assert bg.getRight().size() == 2 : "We expect two features on the right side of the association.";
assert bg.getLeft().contains(b1) : "b1 should be on the left side of the association.";
assert bg.getLeft().contains(b2) : "b2 should be on the left side of the association.";
@@ -589,28 +589,28 @@ public class ModelTest {
assert !bg.getRight().contains(g2) : "g2 should not be on the right side of the association.";
assert bg.getRight().contains(g3) : "g3 should be on the right side of the association.";
- List<FeatureObject> foundGroups = b1.getFeatures();
- assert foundGroups.size() == 2 : "b1 should be associated with two groups.";
- assert foundGroups.contains(g1) : "b1 should be associated with g1";
- assert !foundGroups.contains(g2) : "b1 not should be associated with g2";
- assert foundGroups.contains(g3) : "b1 should be associated with g3";
-
- foundGroups = b3.getFeatures();
- assert foundGroups.size() == 0 : "b3 should not be associated with any groups.";
-
- List<ArtifactObject> foundBundles = g3.getArtifacts();
- assert foundBundles.size() == 2 : "g1 should be associated with two groups.";
- assert foundBundles.contains(b1) : "g1 should be associated with b1";
- assert foundBundles.contains(b2) : "g1 should be associated with b2";
- assert !foundBundles.contains(b3) : "g1 should not be associated with b3";
+ List<FeatureObject> foundFeatures = b1.getFeatures();
+ assert foundFeatures.size() == 2 : "b1 should be associated with two features.";
+ assert foundFeatures.contains(g1) : "b1 should be associated with g1";
+ assert !foundFeatures.contains(g2) : "b1 not should be associated with g2";
+ assert foundFeatures.contains(g3) : "b1 should be associated with g3";
+
+ foundFeatures = b3.getFeatures();
+ assert foundFeatures.size() == 0 : "b3 should not be associated with any features.";
+
+ List<ArtifactObject> foundArtifacts = g3.getArtifacts();
+ assert foundArtifacts.size() == 2 : "g1 should be associated with two features.";
+ assert foundArtifacts.contains(b1) : "g1 should be associated with b1";
+ assert foundArtifacts.contains(b2) : "g1 should be associated with b2";
+ assert !foundArtifacts.contains(b3) : "g1 should not be associated with b3";
}
@Test( groups = { TestUtils.UNIT } )
public void testAssociationsWithCardinality() {
- ArtifactObject b1 = createBasicBundleObject("b1");
- FeatureObject g1 = createBasicGroupObject("g1");
- FeatureObject g2 = createBasicGroupObject("g2");
- FeatureObject g3 = createBasicGroupObject("g3");
+ ArtifactObject b1 = createBasicArtifactObject("b1");
+ FeatureObject g1 = createBasicFeatureObject("g1");
+ FeatureObject g2 = createBasicFeatureObject("g2");
+ FeatureObject g3 = createBasicFeatureObject("g3");
Map<String, String> props = new HashMap<String, String>();
props.put(Association.LEFT_ENDPOINT, "(" + BundleHelper.KEY_SYMBOLICNAME + "=b1)");
@@ -620,8 +620,8 @@ public class ModelTest {
Map<String, String> tags = new HashMap<String, String>();
try {
- m_artifact2groupRepository.create(props, tags);
- assert false : "There are three matches for the group, but we have a cardinality of 2; we should expect a NPE because no comparator is provided.";
+ m_artifact2FeatureRepository.create(props, tags);
+ assert false : "There are three matches for the feature, but we have a cardinality of 2; we should expect a NPE because no comparator is provided.";
}
catch (NullPointerException npe) {
//expected
@@ -629,8 +629,8 @@ public class ModelTest {
props.put(Association.RIGHT_CARDINALITY, "3");
- Artifact2FeatureAssociation bg = m_artifact2groupRepository.create(props, tags);
- assert b1.getFeatures().size() == 3 : "The bundle should be associated to three groups.";
+ Artifact2FeatureAssociation bg = m_artifact2FeatureRepository.create(props, tags);
+ assert b1.getFeatures().size() == 3 : "The artifact should be associated to three features.";
assert (g1.getArtifacts().size() == 1) && g1.getArtifacts().contains(b1) : "g1 should be associated to only b1.";
assert (g2.getArtifacts().size() == 1) && g2.getArtifacts().contains(b1) : "g1 should be associated to only b1.";
assert (g3.getArtifacts().size() == 1) && g3.getArtifacts().contains(b1) : "g1 should be associated to only b1.";
@@ -640,11 +640,11 @@ public class ModelTest {
return FrameworkUtil.createFilter(filter);
}
- private ArtifactObject createBasicBundleObject(String symbolicName) {
- return createBasicBundleObject(symbolicName, null);
+ private ArtifactObject createBasicArtifactObject(String symbolicName) {
+ return createBasicArtifactObject(symbolicName, null);
}
- private ArtifactObject createBasicBundleObject(String symbolicName, String version) {
+ private ArtifactObject createBasicArtifactObject(String symbolicName, String version) {
Map<String, String> attr = new HashMap<String, String>();
attr.put(BundleHelper.KEY_SYMBOLICNAME, symbolicName);
attr.put(ArtifactObject.KEY_MIMETYPE, BundleHelper.MIMETYPE);
@@ -657,40 +657,40 @@ public class ModelTest {
return m_artifactRepository.create(attr, tags);
}
- private FeatureObject createBasicGroupObject(String name) {
+ private FeatureObject createBasicFeatureObject(String name) {
Map<String, String> attr = new HashMap<String, String>();
attr.put(FeatureObject.KEY_NAME, name);
Map<String, String> tags = new HashMap<String, String>();
- return m_groupRepository.create(attr, tags);
+ return m_featureRepository.create(attr, tags);
}
- private DistributionObject createBasicLicenseObject(String name) {
+ private DistributionObject createBasicDistributionObject(String name) {
Map<String, String> attr = new HashMap<String, String>();
attr.put(DistributionObject.KEY_NAME, name);
Map<String, String> tags = new HashMap<String, String>();
- return m_licenseRepository.create(attr, tags);
+ return m_distributionRepository.create(attr, tags);
}
- private TargetObject createBasicGatewayObject(String id) {
+ private TargetObject createBasicTargetObject(String id) {
Map<String, String> attr = new HashMap<String, String>();
attr.put(TargetObject.KEY_ID, id);
Map<String, String> tags = new HashMap<String, String>();
- return m_gatewayRepository.create(attr, tags);
+ return m_targetRepository.create(attr, tags);
}
- private DeploymentVersionObject createBasicDeploymentVersionObject(String gatewayID, String version, String[] bundles) {
+ private DeploymentVersionObject createBasicDeploymentVersionObject(String targetID, String version, String[] artifacts) {
Map<String, String> attr = new HashMap<String, String>();
- attr.put(DeploymentVersionObject.KEY_TARGETID, gatewayID);
+ attr.put(DeploymentVersionObject.KEY_TARGETID, targetID);
attr.put(DeploymentVersionObject.KEY_VERSION, version);
Map<String, String> tags = new HashMap<String, String>();
- List<DeploymentArtifactImpl> artifacts = new ArrayList<DeploymentArtifactImpl>();
- for (String s : bundles) {
- artifacts.add(new DeploymentArtifactImpl(s));
+ List<DeploymentArtifactImpl> deploymentArtifacts = new ArrayList<DeploymentArtifactImpl>();
+ for (String s : artifacts) {
+ deploymentArtifacts.add(new DeploymentArtifactImpl(s));
}
- return m_deploymentVersionRepository.create(attr, tags, artifacts.toArray(new DeploymentArtifact[0]));
+ return m_deploymentVersionRepository.create(attr, tags, deploymentArtifacts.toArray(new DeploymentArtifact[0]));
}
}