You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ja...@apache.org on 2013/10/10 16:11:14 UTC

svn commit: r1530984 [4/5] - in /ace/trunk: org.apache.ace.agent.itest/ org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/ org.apache.ace.agent.update.itest/ org.apache.ace.agent.update.itest/conf/ org.apache.ace.agent.update.itest/src/org/apac...

Modified: ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java (original)
+++ ace/trunk/org.apache.ace.client.repository/test/org/apache/ace/client/repository/impl/ModelTest.java Thu Oct 10 14:11:13 2013
@@ -18,6 +18,10 @@
  */
 package org.apache.ace.client.repository.impl;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -47,6 +51,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.repository.DistributionRepository;
 import org.apache.ace.client.repository.repository.Feature2DistributionAssociationRepository;
 import org.apache.ace.client.repository.repository.FeatureRepository;
+import org.apache.ace.client.repository.repository.RepositoryConfiguration;
 import org.apache.ace.client.repository.repository.TargetRepository;
 import org.apache.ace.test.utils.TestUtils;
 import org.osgi.framework.BundleContext;
@@ -59,7 +64,6 @@ import org.osgi.service.prefs.Preference
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-
 /**
  * Test class for the object model used </code>org.apache.ace.client.repository<code>.
  */
@@ -76,77 +80,16 @@ public class ModelTest {
     private RepositoryAdminImpl m_repositoryAdmin;
 
     private BundleHelperImpl m_bundleHelper = new BundleHelperImpl();
+    private BundleContext m_mockBundleContext;
+    private ChangeNotifier m_mockChangeNotifier;
 
-
-    @BeforeMethod(alwaysRun = true)
-    private void initializeRepositoryAdmin() {
-        BundleContext bc = TestUtils.createMockObjectAdapter(BundleContext.class, new Object() {
-            @SuppressWarnings("unused")
-            public Filter createFilter(String filter) throws InvalidSyntaxException {
-                return createLocalFilter(filter);
-            }
-        });
-
-        ChangeNotifier notifier = TestUtils.createNullObject(ChangeNotifier.class);
-
-        m_artifactRepository = new ArtifactRepositoryImpl(notifier);
-        TestUtils.configureObject(m_artifactRepository, LogService.class);
-        TestUtils.configureObject(m_artifactRepository, BundleContext.class, bc);
-        m_artifactRepository.addHelper(BundleHelper.MIMETYPE, m_bundleHelper);
-        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);
-
-        m_repositoryAdmin = new RepositoryAdminImpl("testSessionID");
-
-        Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> repos = new HashMap<Class<? extends ObjectRepository>, ObjectRepositoryImpl>();
-        repos.put(ArtifactRepository.class, m_artifactRepository);
-        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);
-        TestUtils.configureObject(m_repositoryAdmin, Preferences.class);
-        TestUtils.configureObject(m_repositoryAdmin, PreferencesService.class);
-    }
-
-    /**
-     * Tests that we can create artifacts which contain a certain size (estimate). See ACE-384.
-     */
-    @Test( groups = { TestUtils.UNIT } )
-    public void testArtifactObjectSize() {
-        ArtifactObject artifactWithSize = createBasicArtifactObject("myartifact", "1.0.0", "10");
-        assert artifactWithSize.getSize() == 10 : "The artifact did not have a valid size?!";
-        
-        ArtifactObject artifactWithoutSize = createBasicArtifactObject("artifactWithoutSize", "1.0.0", null);
-        assert artifactWithoutSize.getSize() == -1L : "The artifact did have a size?!";
-
-        ArtifactObject artifactWithInvalidSize = createBasicArtifactObject("artifactWithInvalidSize", "1.0.0", "xyz");
-        assert artifactWithInvalidSize.getSize() == -1L : "The artifact did have a size?!";
-    }
-    
     /**
-     * The artifact object can test functionality coming from
-     * RepositoryObjectImpl, and ArtifactRepository checks much of
-     * ObjectRepositoryImpl.
+     * The artifact object can test functionality coming from RepositoryObjectImpl, and ArtifactRepository checks much
+     * of ObjectRepositoryImpl.
+     * 
      * @throws InvalidSyntaxException
      */
-    @Test( groups = { TestUtils.UNIT } )
+    @Test(groups = { TestUtils.UNIT })
     public void testArtifactObjectAndRepository() throws InvalidSyntaxException {
         // Create a very simple artifact.
         ArtifactObject a = createBasicArtifactObject("myartifact", "1.0.0", "1");
@@ -169,7 +112,7 @@ public class ModelTest {
 
         a.addTag("mytag", "myvalue");
 
-        assert a.getTag("mytag").equals("myvalue")  : "We should be able to read an attribute we just put in ourselves.";
+        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.";
 
         a.addTag(BundleHelper.KEY_SYMBOLICNAME, "mytagname");
@@ -183,7 +126,7 @@ public class ModelTest {
         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("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+"'.";
+            (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 artifact.";
         assert m_artifactRepository.get().get(0).equals(a) : "The repository should contain exactly our artifact.";
@@ -198,7 +141,7 @@ public class ModelTest {
             assert false : "Adding a artifact which is identical to one already in the repository should be illegal.";
         }
         catch (IllegalArgumentException iae) {
-            //expected
+            // expected
         }
 
         try {
@@ -213,10 +156,9 @@ public class ModelTest {
             assert false : "Changing key attributes in a artifact should not be allowed.";
         }
         catch (UnsupportedOperationException uoe) {
-            //expected
+            // expected
         }
 
-
         try {
             Map<String, String> attr = new HashMap<String, String>();
             attr.put(BundleHelper.KEY_NAME, "mynewartifact");
@@ -225,10 +167,9 @@ public class ModelTest {
             assert false : "Creating a artifact without specifying all mandatory atttributes should be illegal.";
         }
         catch (IllegalArgumentException iae) {
-            //expected
+            // expected
         }
 
-
         m_artifactRepository.remove(a);
 
         try {
@@ -243,95 +184,25 @@ public class ModelTest {
         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() throws IOException {
-        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_artifact2FeatureRepository, m_featureRepository}, null, "", true);
-        new RepositorySerializer(store).toXML(buffer);
-        initializeRepositoryAdmin();
-        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 artifacts, but we find " + m_artifactRepository.get().size();
-    }
-
-    @Test( groups = { TestUtils.UNIT } )
-    public void testSerialization() throws IOException {
-        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_featureRepository, m_artifact2FeatureRepository}, null, "", true);
-        new RepositorySerializer(store).toXML(buffer);
-        initializeRepositoryAdmin();
-        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 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.";
-        assert b2.isAssociated(g2, FeatureObject.class) : "After serialization, b2 should still be associated with g2.";
-        assert !b3.isAssociated(g1, FeatureObject.class) : "After serialization, b3 should not be associated with g2.";
-        assert b3.isAssociated(g2, FeatureObject.class) : "After serialization, b3 should still be associated with g2.";
-    }
-
-    @Test( groups = { TestUtils.UNIT } )
-    public void testModelFiltering() throws InvalidSyntaxException {
-        initializeRepositoryAdmin();
-        // 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_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_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.";
+    /**
+     * Tests that we can create artifacts which contain a certain size (estimate). See ACE-384.
+     */
+    @Test(groups = { TestUtils.UNIT })
+    public void testArtifactObjectSize() {
+        ArtifactObject artifactWithSize = createBasicArtifactObject("myartifact", "1.0.0", "10");
+        assert artifactWithSize.getSize() == 10 : "The artifact did not have a valid size?!";
 
-        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.";
+        ArtifactObject artifactWithoutSize = createBasicArtifactObject("artifactWithoutSize", "1.0.0", null);
+        assert artifactWithoutSize.getSize() == -1L : "The artifact did have a size?!";
 
-        try {
-            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_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.";
+        ArtifactObject artifactWithInvalidSize = createBasicArtifactObject("artifactWithInvalidSize", "1.0.0", "xyz");
+        assert artifactWithInvalidSize.getSize() == -1L : "The artifact did have a size?!";
     }
 
     /**
      * Tests the behavior when associating stuff, and removing associations.
      */
-    @Test( groups = { TestUtils.UNIT } )
+    @Test(groups = { TestUtils.UNIT })
     public void testAssociations() {
         initializeRepositoryAdmin();
         // Create two, rather boring, artifacts.
@@ -417,100 +288,133 @@ public class ModelTest {
         assert g3artifacts.containsAll(g3expectedArtifacts) && g3expectedArtifacts.containsAll(g3artifacts) : "g3 should be associated to exactly artifact 1.";
     }
 
+    @Test(groups = { TestUtils.UNIT })
+    public void testAssociationsWithCardinality() {
+        ArtifactObject a1 = createBasicArtifactObject("a1");
+        FeatureObject f1 = createBasicFeatureObject("f1");
+        FeatureObject f2 = createBasicFeatureObject("f2");
+        FeatureObject f3 = createBasicFeatureObject("f3");
 
-    /**
-     * Not a full-fledged testcase, but a quick test of the correctness of the
-     * 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 TestFeature2DistributionAssociations() {
-        initializeRepositoryAdmin();
-        FeatureObject f1 = createBasicFeatureObject("feature1");
-        DistributionObject d1 = createBasicDistributionObject("distribution1");
-        Feature2DistributionAssociation f2d1 = m_feature2DistributionRepository.create(f1, d1);
-
-        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 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() + ".";
+        Map<String, String> props = new HashMap<String, String>();
+        props.put(Association.LEFT_ENDPOINT, "(" + BundleHelper.KEY_SYMBOLICNAME + "=a1)");
+        props.put(Association.LEFT_CARDINALITY, "1");
+        props.put(Association.RIGHT_ENDPOINT, "(" + FeatureObject.KEY_NAME + "=f*)");
+        props.put(Association.RIGHT_CARDINALITY, "2");
+        Map<String, String> tags = new HashMap<String, String>();
 
-        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() + ".";
-    }
+        try {
+            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
+        }
 
-    /**
-     * Not a full-fledged testcase, but a quick test of the correctness of the
-     * 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 testDistribution2TargetAssociations() {
-        initializeRepositoryAdmin();
-        DistributionObject d1 = createBasicDistributionObject("distribution1");
-        TargetObject t1 = createBasicTargetObject("target1");
-        m_distribution2TargetRepository.create(d1, t1);
+        props.put(Association.RIGHT_CARDINALITY, "3");
 
-        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() + ".";
+        Artifact2FeatureAssociation bg = m_artifact2FeatureRepository.create(props, tags);
+        assert bg != null : "Assocating artifact to feature failed?!";
 
-        assert t1.getDistributions().size() == 1 : "Target 1 should be associated with exactly one distribution; it is associated with " + t1.getDistributions().size() + ".";
+        assert a1.getFeatures().size() == 3 : "The artifact should be associated to three features.";
+        assert (f1.getArtifacts().size() == 1) && f1.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
+        assert (f2.getArtifacts().size() == 1) && f2.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
+        assert (f3.getArtifacts().size() == 1) && f3.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
     }
 
-    @Test( groups = { TestUtils.UNIT } )
-    public void testGetAssociationsWith() {
-        initializeRepositoryAdmin();
-        ArtifactObject a1 = createBasicArtifactObject("artifact1");
-        FeatureObject f1 = createBasicFeatureObject("feature1");
-        Artifact2FeatureAssociation a2f1 = m_artifact2FeatureRepository.create(a1, f1);
+    @Test(groups = { TestUtils.UNIT })
+    public void testAssociationsWithLists() {
+        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<Artifact2FeatureAssociation> b1Associations = a1.getAssociationsWith(f1);
-        List<Artifact2FeatureAssociation> g1Associations = f1.getAssociationsWith(a1);
+        List<ArtifactObject> artifacts = new ArrayList<ArtifactObject>();
+        artifacts.add(b1);
+        artifacts.add(b2);
+        List<FeatureObject> features = new ArrayList<FeatureObject>();
+        features.add(g1);
+        features.add(g3);
 
-        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.";
+        Artifact2FeatureAssociation bg = m_artifact2FeatureRepository.create(artifacts, features);
 
-        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.";
-    }
+        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.";
 
-    /**
-     * Tests the correctness of the equals() in RepositoryObject.
-     */
-    @Test( groups = { TestUtils.UNIT } )
-    public void testEquals() {
-        List<ArtifactObject> artifacts = new ArrayList<ArtifactObject>();
-        artifacts.add(createBasicArtifactObject("artifact1"));
-        artifacts.add(createBasicArtifactObject("artifact2"));
-        artifacts.get(1).addTag("thetag", "thevalue");
-        artifacts.add(createBasicArtifactObject("artifact3"));
+        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.";
+        assert !bg.getLeft().contains(b3) : "b3 should not be on the left side of the association.";
+        assert bg.getRight().contains(g1) : "g1 should be on the right side of the association.";
+        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<ArtifactObject> backupArtifacts = new ArrayList<ArtifactObject>();
-        backupArtifacts.addAll(artifacts);
+        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";
 
-        for (ArtifactObject b : backupArtifacts) {
-            artifacts.remove(b);
-        }
+        foundFeatures = b3.getFeatures();
+        assert foundFeatures.size() == 0 : "b3 should not be associated with any features.";
 
-        assert artifacts.size() == 0 : "The artifacts list should be empty; if not, the ArtifactObject's equals() could be broken.";
+        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 testDeploymentVersion() throws IOException {
-        DeploymentVersionObject version = createBasicDeploymentVersionObject("target1", "1", new String[] {"artifact1", "artifact2"});
+    @Test(groups = { TestUtils.UNIT })
+    public void testDeploymentRepository() {
+        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 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");
+        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();
 
-        ((DeploymentArtifactImpl) version.getDeploymentArtifacts()[0]).addDirective("myDirective", "myValue");
+        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";
 
-        try {
-            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.";
+        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 = "\\ ( * ) 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();
+        assert for1.get(0) == version1 : "The only version for" + gwId + "should be version1";
+    }
+
+    @Test(groups = { TestUtils.UNIT })
+    public void testDeploymentVersion() throws IOException {
+        DeploymentVersionObject version = createBasicDeploymentVersionObject("target1", "1", new String[] { "artifact1", "artifact2" });
+
+        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("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
@@ -520,16 +424,15 @@ public class ModelTest {
         assert m_deploymentVersionRepository.get().get(0) == version : "Only our newly created version object should be in the repository.";
 
         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-        RepositorySet deployment = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_deploymentVersionRepository}, null, "", true);
+        RepositorySet deployment = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] { m_deploymentVersionRepository }, null, "", true);
         new RepositorySerializer(deployment).toXML(buffer);
         initializeRepositoryAdmin();
 
         assert m_deploymentVersionRepository.get().size() == 0;
 
-        deployment = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] {m_deploymentVersionRepository}, null, "", true);
+        deployment = new RepositorySet(null, null, null, null, new ObjectRepositoryImpl[] { m_deploymentVersionRepository }, null, "", true);
         new RepositorySerializer(deployment).fromXML(new ByteArrayInputStream(buffer.toByteArray()));
 
-
         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.";
 
@@ -540,122 +443,263 @@ public class ModelTest {
         assert m_deploymentVersionRepository.get().get(0).getDeploymentArtifacts()[1].getUrl().equals("artifact2");
     }
 
-    @Test( groups = { TestUtils.UNIT } )
-    public void testDeploymentRepository() {
-        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";
+    /**
+     * Not a full-fledged testcase, but a quick test of the correctness of the 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 testDistribution2TargetAssociations() {
+        initializeRepositoryAdmin();
+        DistributionObject d1 = createBasicDistributionObject("distribution1");
+        TargetObject t1 = createBasicTargetObject("target1");
+        m_distribution2TargetRepository.create(d1, t1);
 
-        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 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 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";
+        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 testDeploymentRepositoryFilter() {
+    /**
+     * Tests the correctness of the equals() in RepositoryObject.
+     */
+    @Test(groups = { TestUtils.UNIT })
+    public void testEquals() {
+        List<ArtifactObject> artifacts = new ArrayList<ArtifactObject>();
+        artifacts.add(createBasicArtifactObject("artifact1"));
+        artifacts.add(createBasicArtifactObject("artifact2"));
+        artifacts.get(1).addTag("thetag", "thevalue");
+        artifacts.add(createBasicArtifactObject("artifact3"));
 
-        String gwId = "\\ ( * ) target1)";
-        DeploymentVersionObject version1 = createBasicDeploymentVersionObject(gwId, "1", new String[] {"artifact1", "artifact2"});
+        List<ArtifactObject> backupArtifacts = new ArrayList<ArtifactObject>();
+        backupArtifacts.addAll(artifacts);
 
-        List<DeploymentVersionObject> for1 = m_deploymentVersionRepository.getDeploymentVersions( gwId );
-        assert for1.size() == 1 : "We expect one version for" + gwId + ", but we find " + for1.size();
-        assert for1.get(0) == version1 : "The only version for" + gwId +  "should be version1";
+        for (ArtifactObject b : backupArtifacts) {
+            artifacts.remove(b);
+        }
+
+        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 testAssociationsWithLists() {
-        ArtifactObject b1 = createBasicArtifactObject("b1");
-        ArtifactObject b2 = createBasicArtifactObject("b2");
-        ArtifactObject b3 = createBasicArtifactObject("b3");
-        FeatureObject g1 = createBasicFeatureObject("g1");
-        FeatureObject g2 = createBasicFeatureObject("g2");
-        FeatureObject g3 = createBasicFeatureObject("g3");
+    /**
+     * Not a full-fledged testcase, but a quick test of the correctness of the 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 TestFeature2DistributionAssociations() {
+        initializeRepositoryAdmin();
+        FeatureObject f1 = createBasicFeatureObject("feature1");
+        DistributionObject d1 = createBasicDistributionObject("distribution1");
+        Feature2DistributionAssociation f2d1 = m_feature2DistributionRepository.create(f1, d1);
 
-        List<ArtifactObject> artifacts = new ArrayList<ArtifactObject>();
-        artifacts.add(b1);
-        artifacts.add(b2);
-        List<FeatureObject> features = new ArrayList<FeatureObject>();
-        features.add(g1);
-        features.add(g3);
+        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.";
 
-        Artifact2FeatureAssociation bg = m_artifact2FeatureRepository.create(artifacts, features);
+        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 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 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() + ".";
+    }
 
-        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.";
-        assert !bg.getLeft().contains(b3) : "b3 should not be on the left side of the association.";
-        assert bg.getRight().contains(g1) : "g1 should be on the right side of the association.";
-        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.";
+    @Test(groups = { TestUtils.UNIT })
+    public void testGetAssociationsWith() {
+        initializeRepositoryAdmin();
+        ArtifactObject a1 = createBasicArtifactObject("artifact1");
+        FeatureObject f1 = createBasicFeatureObject("feature1");
+        Artifact2FeatureAssociation a2f1 = m_artifact2FeatureRepository.create(a1, f1);
 
-        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";
+        List<Artifact2FeatureAssociation> b1Associations = a1.getAssociationsWith(f1);
+        List<Artifact2FeatureAssociation> g1Associations = f1.getAssociationsWith(a1);
 
-        foundFeatures = b3.getFeatures();
-        assert foundFeatures.size() == 0 : "b3 should not be associated with any features.";
+        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.";
 
-        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";
+        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.";
     }
 
-    @Test( groups = { TestUtils.UNIT } )
-    public void testAssociationsWithCardinality() {
-        ArtifactObject a1 = createBasicArtifactObject("a1");
-        FeatureObject f1 = createBasicFeatureObject("f1");
-        FeatureObject f2 = createBasicFeatureObject("f2");
-        FeatureObject f3 = createBasicFeatureObject("f3");
+    @Test(groups = { TestUtils.UNIT })
+    public void testLimitedNumberOfDeploymentVersions() throws IOException {
+        RepositoryConfigurationImpl repoConfig = new RepositoryConfigurationImpl();
+        repoConfig.setDeploymentVersionLimit(3); // only keep the 3 most recent deployment versions...
+
+        m_deploymentVersionRepository = new DeploymentVersionRepositoryImpl(m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_deploymentVersionRepository, BundleContext.class, m_mockBundleContext);
+
+        // Add several bundles, but not enough to get any deployment version purged...
+        DeploymentVersionObject target1_v1 = createBasicDeploymentVersionObject("target1", "1", new String[] { "artifact1", "artifact2" });
+        DeploymentVersionObject target1_v2 = createBasicDeploymentVersionObject("target1", "2", new String[] { "artifact1", "artifact2" });
+        DeploymentVersionObject target1_v3 = createBasicDeploymentVersionObject("target1", "3", new String[] { "artifact1", "artifact2" });
+        DeploymentVersionObject target2_v1 = createBasicDeploymentVersionObject("target2", "1", new String[] { "artifact3", "artifact4" });
+        DeploymentVersionObject target2_v2 = createBasicDeploymentVersionObject("target2", "2", new String[] { "artifact3", "artifact5" });
+
+        List<DeploymentVersionObject> repo = m_deploymentVersionRepository.get();
+        // All created deployment versions should be present...
+        assertEquals(repo.size(), 5);
+        assertTrue(repo.contains(target1_v1));
+        assertTrue(repo.contains(target1_v2));
+        assertTrue(repo.contains(target1_v3));
+        assertTrue(repo.contains(target2_v1));
+        assertTrue(repo.contains(target2_v2));
+
+        // Add a new deployment version, which should cause the oldest (= version 1) of target1 to be purged...
+        DeploymentVersionObject target1_v4 = createBasicDeploymentVersionObject("target1", "4", new String[] { "artifact1", "artifact2" });
+
+        repo = m_deploymentVersionRepository.get();
+        // Still 5 deployment versions, without version 1 of target1...
+        assertEquals(repo.size(), 5);
+        assertFalse(repo.contains(target1_v1));
+        assertTrue(repo.contains(target1_v2));
+        assertTrue(repo.contains(target1_v3));
+        assertTrue(repo.contains(target1_v4));
+        assertTrue(repo.contains(target2_v1));
+        assertTrue(repo.contains(target2_v2));
+
+        // Add yet another deployment version, which should cause the oldest (= version 2) of target1 to be purged...
+        DeploymentVersionObject target1_v5 = createBasicDeploymentVersionObject("target1", "5", new String[] { "artifact1", "artifact2" });
+
+        repo = m_deploymentVersionRepository.get();
+        // Still 5 deployment versions, without versions 1 & 2 of target1...
+        assertEquals(repo.size(), 5);
+        assertFalse(repo.contains(target1_v1));
+        assertFalse(repo.contains(target1_v2));
+        assertTrue(repo.contains(target1_v3));
+        assertTrue(repo.contains(target1_v4));
+        assertTrue(repo.contains(target1_v5));
+        assertTrue(repo.contains(target2_v1));
+        assertTrue(repo.contains(target2_v2));
+    }
 
-        Map<String, String> props = new HashMap<String, String>();
-        props.put(Association.LEFT_ENDPOINT, "(" + BundleHelper.KEY_SYMBOLICNAME + "=a1)");
-        props.put(Association.LEFT_CARDINALITY, "1");
-        props.put(Association.RIGHT_ENDPOINT, "(" + FeatureObject.KEY_NAME + "=f*)");
-        props.put(Association.RIGHT_CARDINALITY, "2");
+    @Test(groups = { TestUtils.UNIT })
+    public void testModelFiltering() throws InvalidSyntaxException {
+        initializeRepositoryAdmin();
+        // 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_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_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_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.";
+            m_featureRepository.get(createLocalFilter("(difficult=)diffi)c*ul\\t"));
+            assert false : "The non-escaped difficult string should raise an error.";
         }
-        catch (NullPointerException npe) {
-            //expected
+        catch (InvalidSyntaxException ex) {
+            // expected
         }
+        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.";
+    }
 
-        props.put(Association.RIGHT_CARDINALITY, "3");
+    @Test(groups = { TestUtils.UNIT })
+    public void testRepositorySerialization() throws IOException {
+        createBasicArtifactObject("myartifact", "1");
+        createBasicArtifactObject("myartifact", "2");
 
-        Artifact2FeatureAssociation bg = m_artifact2FeatureRepository.create(props, tags);
-        assert bg != null : "Assocating artifact to feature failed?!";
-        
-        assert a1.getFeatures().size() == 3 : "The artifact should be associated to three features.";
-        assert (f1.getArtifacts().size() == 1) && f1.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
-        assert (f2.getArtifacts().size() == 1) && f2.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
-        assert (f3.getArtifacts().size() == 1) && f3.getArtifacts().contains(a1) : "g1 should be associated to only b1.";
+        // 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_artifact2FeatureRepository, m_featureRepository }, null, "", true);
+        new RepositorySerializer(store).toXML(buffer);
+        initializeRepositoryAdmin();
+        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 artifacts, but we find " + m_artifactRepository.get().size();
     }
 
-    private Filter createLocalFilter(String filter) throws InvalidSyntaxException {
-        return FrameworkUtil.createFilter(filter);
+    @Test(groups = { TestUtils.UNIT })
+    public void testSerialization() throws IOException {
+        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_featureRepository, m_artifact2FeatureRepository }, null, "", true);
+        new RepositorySerializer(store).toXML(buffer);
+        initializeRepositoryAdmin();
+        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 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.";
+        assert b2.isAssociated(g2, FeatureObject.class) : "After serialization, b2 should still be associated with g2.";
+        assert !b3.isAssociated(g1, FeatureObject.class) : "After serialization, b3 should not be associated with g2.";
+        assert b3.isAssociated(g2, FeatureObject.class) : "After serialization, b3 should still be associated with g2.";
+    }
+
+    @Test(groups = { TestUtils.UNIT })
+    public void testUnlimitedNumberOfDeploymentVersions() throws IOException {
+        RepositoryConfiguration repoConfig = new RepositoryConfigurationImpl();
+
+        m_deploymentVersionRepository = new DeploymentVersionRepositoryImpl(m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_deploymentVersionRepository, BundleContext.class, m_mockBundleContext);
+
+        DeploymentVersionObject target1_v1 = createBasicDeploymentVersionObject("target1", "1", new String[] { "artifact1", "artifact2" });
+        DeploymentVersionObject target1_v2 = createBasicDeploymentVersionObject("target1", "2", new String[] { "artifact1", "artifact2" });
+        DeploymentVersionObject target1_v3 = createBasicDeploymentVersionObject("target1", "3", new String[] { "artifact1", "artifact2" });
+        DeploymentVersionObject target2_v1 = createBasicDeploymentVersionObject("target2", "1", new String[] { "artifact3", "artifact4" });
+        DeploymentVersionObject target2_v2 = createBasicDeploymentVersionObject("target2", "2", new String[] { "artifact3", "artifact5" });
+
+        List<DeploymentVersionObject> repo = m_deploymentVersionRepository.get();
+        assertEquals(repo.size(), 5);
+        assertTrue(repo.contains(target1_v1));
+        assertTrue(repo.contains(target1_v2));
+        assertTrue(repo.contains(target1_v3));
+        assertTrue(repo.contains(target2_v1));
+        assertTrue(repo.contains(target2_v2));
+
+        DeploymentVersionObject target1_v4 = createBasicDeploymentVersionObject("target1", "4", new String[] { "artifact1", "artifact2" });
+
+        repo = m_deploymentVersionRepository.get();
+        assertEquals(repo.size(), 6);
+        assertTrue(repo.contains(target1_v1));
+        assertTrue(repo.contains(target1_v2));
+        assertTrue(repo.contains(target1_v3));
+        assertTrue(repo.contains(target1_v4));
+        assertTrue(repo.contains(target2_v1));
+        assertTrue(repo.contains(target2_v2));
+
+        DeploymentVersionObject target1_v5 = createBasicDeploymentVersionObject("target1", "5", new String[] { "artifact1", "artifact2" });
+
+        repo = m_deploymentVersionRepository.get();
+        assertEquals(repo.size(), 7);
+        assertTrue(repo.contains(target1_v1));
+        assertTrue(repo.contains(target1_v2));
+        assertTrue(repo.contains(target1_v3));
+        assertTrue(repo.contains(target1_v4));
+        assertTrue(repo.contains(target1_v5));
+        assertTrue(repo.contains(target2_v1));
+        assertTrue(repo.contains(target2_v2));
     }
 
     private ArtifactObject createBasicArtifactObject(String symbolicName) {
@@ -681,12 +725,17 @@ public class ModelTest {
         return m_artifactRepository.create(attr, tags);
     }
 
-    private FeatureObject createBasicFeatureObject(String name) {
+    private DeploymentVersionObject createBasicDeploymentVersionObject(String targetID, String version, String[] artifacts) {
         Map<String, String> attr = new HashMap<String, String>();
-        attr.put(FeatureObject.KEY_NAME, name);
+        attr.put(DeploymentVersionObject.KEY_TARGETID, targetID);
+        attr.put(DeploymentVersionObject.KEY_VERSION, version);
         Map<String, String> tags = new HashMap<String, String>();
 
-        return m_featureRepository.create(attr, tags);
+        List<DeploymentArtifactImpl> deploymentArtifacts = new ArrayList<DeploymentArtifactImpl>();
+        for (String s : artifacts) {
+            deploymentArtifacts.add(new DeploymentArtifactImpl(s, -1L));
+        }
+        return m_deploymentVersionRepository.create(attr, tags, deploymentArtifacts.toArray(new DeploymentArtifact[0]));
     }
 
     private DistributionObject createBasicDistributionObject(String name) {
@@ -697,6 +746,14 @@ public class ModelTest {
         return m_distributionRepository.create(attr, tags);
     }
 
+    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_featureRepository.create(attr, tags);
+    }
+
     private TargetObject createBasicTargetObject(String id) {
         Map<String, String> attr = new HashMap<String, String>();
         attr.put(TargetObject.KEY_ID, id);
@@ -705,16 +762,56 @@ public class ModelTest {
         return m_targetRepository.create(attr, tags);
     }
 
-    private DeploymentVersionObject createBasicDeploymentVersionObject(String targetID, String version, String[] artifacts) {
-        Map<String, String> attr = new HashMap<String, String>();
-        attr.put(DeploymentVersionObject.KEY_TARGETID, targetID);
-        attr.put(DeploymentVersionObject.KEY_VERSION, version);
-        Map<String, String> tags = new HashMap<String, String>();
+    private Filter createLocalFilter(String filter) throws InvalidSyntaxException {
+        return FrameworkUtil.createFilter(filter);
+    }
 
-        List<DeploymentArtifactImpl> deploymentArtifacts = new ArrayList<DeploymentArtifactImpl>();
-        for (String s : artifacts) {
-            deploymentArtifacts.add(new DeploymentArtifactImpl(s, -1L));
-        }
-        return m_deploymentVersionRepository.create(attr, tags, deploymentArtifacts.toArray(new DeploymentArtifact[0]));
+    @BeforeMethod(alwaysRun = true)
+    private void initializeRepositoryAdmin() {
+        m_mockBundleContext = TestUtils.createMockObjectAdapter(BundleContext.class, new Object() {
+            @SuppressWarnings("unused")
+            public Filter createFilter(String filter) throws InvalidSyntaxException {
+                return createLocalFilter(filter);
+            }
+        });
+
+        m_mockChangeNotifier = TestUtils.createNullObject(ChangeNotifier.class);
+
+        RepositoryConfiguration repoConfig = new RepositoryConfigurationImpl();
+
+        m_artifactRepository = new ArtifactRepositoryImpl(m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_artifactRepository, LogService.class);
+        TestUtils.configureObject(m_artifactRepository, BundleContext.class, m_mockBundleContext);
+        m_artifactRepository.addHelper(BundleHelper.MIMETYPE, m_bundleHelper);
+        m_featureRepository = new FeatureRepositoryImpl(m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_featureRepository, BundleContext.class, m_mockBundleContext);
+        m_artifact2FeatureRepository = new Artifact2FeatureAssociationRepositoryImpl(m_artifactRepository, m_featureRepository, m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_artifact2FeatureRepository, BundleContext.class, m_mockBundleContext);
+        m_distributionRepository = new DistributionRepositoryImpl(m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_distributionRepository, BundleContext.class, m_mockBundleContext);
+        m_feature2DistributionRepository = new Feature2DistributionAssociationRepositoryImpl(m_featureRepository, m_distributionRepository, m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_feature2DistributionRepository, BundleContext.class, m_mockBundleContext);
+        m_targetRepository = new TargetRepositoryImpl(m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_targetRepository, BundleContext.class, m_mockBundleContext);
+        m_distribution2TargetRepository = new Distribution2TargetAssociationRepositoryImpl(m_distributionRepository, m_targetRepository, m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_distribution2TargetRepository, BundleContext.class, m_mockBundleContext);
+        m_deploymentVersionRepository = new DeploymentVersionRepositoryImpl(m_mockChangeNotifier, repoConfig);
+        TestUtils.configureObject(m_deploymentVersionRepository, BundleContext.class, m_mockBundleContext);
+
+        m_repositoryAdmin = new RepositoryAdminImpl("testSessionID", repoConfig);
+
+        Map<Class<? extends ObjectRepository>, ObjectRepositoryImpl> repos = new HashMap<Class<? extends ObjectRepository>, ObjectRepositoryImpl>();
+        repos.put(ArtifactRepository.class, m_artifactRepository);
+        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);
+        TestUtils.configureObject(m_repositoryAdmin, Preferences.class);
+        TestUtils.configureObject(m_repositoryAdmin, PreferencesService.class);
     }
 }

Modified: ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.client.rest.itest/bnd.bnd Thu Oct 10 14:11:13 2013
@@ -1,5 +1,6 @@
 Test-Cases: ${classes;CONCRETE;EXTENDS;org.apache.ace.it.IntegrationTestBase}
--buildpath: osgi.core,\
+-buildpath: \
+	osgi.core,\
 	osgi.cmpn,\
 	junit.osgi,\
 	biz.aQute.bnd,\
@@ -29,6 +30,8 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 -runfw: org.apache.felix.framework;version='[4,5)'
 -runvm: -ea
 -runbundles: osgi.cmpn,\
+	com.sun.jersey.client,\
+	com.sun.jersey.core,\
 	org.apache.felix.dependencymanager,\
 	org.apache.felix.configadmin,\
 	org.apache.felix.eventadmin,\
@@ -42,8 +45,6 @@ Test-Cases: ${classes;CONCRETE;EXTENDS;o
 	org.apache.felix.gogo.command,\
 	org.apache.felix.gogo.runtime,\
 	org.apache.felix.gogo.shell,\
-	com.sun.jersey.client,\
-	com.sun.jersey.core,\
 	org.apache.ace.test;version=latest,\
 	org.apache.ace.http.listener;version=latest,\
 	org.apache.ace.authentication.api;version=latest,\

Modified: ace/trunk/org.apache.ace.client.rest.itest/src/org/apache/ace/client/rest/itest/RESTClientTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.rest.itest/src/org/apache/ace/client/rest/itest/RESTClientTest.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.rest.itest/src/org/apache/ace/client/rest/itest/RESTClientTest.java (original)
+++ ace/trunk/org.apache.ace.client.rest.itest/src/org/apache/ace/client/rest/itest/RESTClientTest.java Thu Oct 10 14:11:13 2013
@@ -30,6 +30,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.client.repository.object.ArtifactObject;
 import org.apache.ace.http.listener.constants.HttpConstants;
 import org.apache.ace.it.IntegrationTestBase;
+import org.apache.ace.test.constants.TestConstants;
 import org.apache.ace.test.utils.FileUtils;
 import org.apache.felix.dm.Component;
 import org.osgi.framework.Bundle;
@@ -58,6 +59,7 @@ public class RESTClientTest extends Inte
     public static final String PROCESSOR = "org.osgi.deployment.rp.autoconf";
 
     private static final String STOREPATH = "generated/store";
+    private static final String HOST = "http://localhost:" + TestConstants.PORT;
 
     private static boolean m_hasBeenSetup = false;
     private static int m_testRunCount = 0;
@@ -102,7 +104,7 @@ public class RESTClientTest extends Inte
         Client client = Client.create();
         client.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
         try {
-            WebResource r = client.resource("http://localhost:8080/client/work");
+            WebResource r = client.resource(HOST.concat("/client/work"));
             try {
                 r.post(String.class, "");
                 fail("We should have been redirected to a new workspace.");
@@ -110,7 +112,7 @@ public class RESTClientTest extends Inte
             catch (UniformInterfaceException e) {
                 ClientResponse response = e.getResponse();
                 URI location = response.getLocation();
-                assertTrue(location.toString().startsWith("http://localhost:8080/client/work/rest-"));
+                assertTrue(location.toString().startsWith(HOST.concat("/client/work/rest-")));
                 WebResource r2 = client.resource(location);
                 r2.get(String.class);
                 r2.delete();
@@ -165,7 +167,7 @@ public class RESTClientTest extends Inte
                 w2.post();
                 w2.delete();
             }
-            WebResource t1versions = client.resource("http://localhost:8080/deployment/bar.t1/versions");
+            WebResource t1versions = client.resource(HOST.concat("/deployment/bar.t1/versions"));
             assertEquals("1.0.0\n", t1versions.get(String.class));
         }
         catch (Exception e) {
@@ -229,7 +231,7 @@ public class RESTClientTest extends Inte
             w2.post();
             w2.delete();
 
-            WebResource t1versions = client.resource("http://localhost:8080/deployment/foo.t1/versions");
+            WebResource t1versions = client.resource(HOST.concat("/deployment/foo.t1/versions"));
             assertEquals("1.0.0\n", t1versions.get(String.class));
         }
         catch (Exception e) {
@@ -288,7 +290,7 @@ public class RESTClientTest extends Inte
             assertResources(gson, w2, "target", 3);
             w2.delete();
 
-            WebResource t1versions = client.resource("http://localhost:8080/deployment/t4/versions");
+            WebResource t1versions = client.resource(HOST.concat("/deployment/t4/versions"));
             assertEquals("1.0.0\n", t1versions.get(String.class));
         }
         catch (Exception e) {
@@ -354,8 +356,12 @@ public class RESTClientTest extends Inte
     }
 
     private void configureServer() throws IOException {
+        configure("org.apache.ace.client.repository",
+            "obrlocation", HOST.concat("/obr/"));
+
         configure("org.apache.ace.client.rest",
             "org.apache.ace.server.servlet.endpoint", "/client",
+            "repository.url", HOST.concat("/repository"),
             "authentication.enabled", "false");
 
         configure("org.apache.ace.deployment.servlet",
@@ -374,12 +380,12 @@ public class RESTClientTest extends Inte
             "fileLocation", STOREPATH);
 
         configure("org.apache.ace.deployment.provider.repositorybased",
-            "url", "http://localhost:8080/repository",
+            "url", HOST.concat("/repository"),
             "name", "deployment",
             "customer", "apache");
 
         configure("org.apache.ace.discovery.property",
-            "serverURL", "http://localhost:8080");
+            "serverURL", HOST);
 
         configure("org.apache.ace.identification.property",
             "targetID", "target-test");
@@ -418,7 +424,7 @@ public class RESTClientTest extends Inte
             "master", "true");
 
         configure("org.apache.ace.configurator.useradmin.task.UpdateUserAdminTask",
-            "repositoryLocation", "http://localhost:8080/repository",
+            "repositoryLocation", HOST.concat("/repository"),
             "repositoryCustomer", "apache",
             "repositoryName", "user");
     }
@@ -497,7 +503,6 @@ public class RESTClientTest extends Inte
     }
 
     /** Create a user so we can log in to the server. */
-    @SuppressWarnings("unchecked")
     private void createServerUser() {
         User user = (User) m_user.createRole("d", Role.USER);
         user.getProperties().put("username", "d");
@@ -551,7 +556,7 @@ public class RESTClientTest extends Inte
 
     /** Creates a new workspace. */
     private WebResource createWorkspace(Client c) {
-        WebResource r = c.resource("http://localhost:8080/client/work");
+        WebResource r = c.resource(HOST.concat("/client/work"));
         try {
             r.post(String.class, "");
             fail("We should have been redirected to a new workspace.");

Modified: ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/RESTClientServlet.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/RESTClientServlet.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/RESTClientServlet.java (original)
+++ ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/RESTClientServlet.java Thu Oct 10 14:11:13 2013
@@ -34,18 +34,9 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.ace.authentication.api.AuthenticationService;
-import org.apache.ace.client.repository.RepositoryAdmin;
 import org.apache.ace.client.repository.RepositoryObject;
 import org.apache.ace.client.repository.SessionFactory;
-import org.apache.ace.client.repository.repository.Artifact2FeatureAssociationRepository;
-import org.apache.ace.client.repository.repository.ArtifactRepository;
-import org.apache.ace.client.repository.repository.Distribution2TargetAssociationRepository;
-import org.apache.ace.client.repository.repository.DistributionRepository;
-import org.apache.ace.client.repository.repository.Feature2DistributionAssociationRepository;
-import org.apache.ace.client.repository.repository.FeatureRepository;
-import org.apache.ace.client.repository.repository.TargetRepository;
 import org.apache.ace.client.repository.stateful.StatefulTargetObject;
-import org.apache.ace.client.repository.stateful.StatefulTargetRepository;
 import org.apache.ace.feedback.Event;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
@@ -74,8 +65,6 @@ public class RESTClientServlet extends H
     private static final String KEY_USE_AUTHENTICATION = "authentication.enabled";
     /** URL of the repository to talk to. */
     private static final String KEY_REPOSITORY_URL = "repository.url";
-    /** URL of the OBR to talk to. */
-    private static final String KEY_OBR_URL = "obr.url";
     /** Name of the customer. */
     private static final String KEY_CUSTOMER_NAME = "customer.name";
     /** Name of the store repository. */
@@ -109,7 +98,6 @@ public class RESTClientServlet extends H
     
     private boolean m_useAuthentication;
     private String m_repositoryURL;
-    private String m_obrURL;
     private String m_customerName;
     private String m_storeRepositoryName;
     private String m_targetRepositoryName;
@@ -170,7 +158,6 @@ public class RESTClientServlet extends H
         synchronized (m_workspaces) {
             m_useAuthentication = Boolean.valueOf(useAuth);
             m_repositoryURL = getProperty(properties, KEY_REPOSITORY_URL, "http://localhost:8080/repository");
-            m_obrURL = getProperty(properties, KEY_OBR_URL, "http://localhost:8080/obr/");
             m_customerName = getProperty(properties, KEY_CUSTOMER_NAME, "apache");
             m_storeRepositoryName = getProperty(properties, KEY_STORE_REPOSITORY_NAME, "shop");
             m_targetRepositoryName = getProperty(properties, KEY_DISTRIBUTION_REPOSITORY_NAME, "target");
@@ -463,7 +450,7 @@ public class RESTClientServlet extends H
 
         synchronized (m_workspaces) {
             sessionID = "rest-" + m_sessionID++;
-            workspace = new Workspace(sessionID, m_repositoryURL, m_obrURL, m_customerName, m_storeRepositoryName, m_targetRepositoryName, m_deploymentRepositoryName, m_serverUser);
+            workspace = new Workspace(sessionID, m_repositoryURL, m_customerName, m_storeRepositoryName, m_targetRepositoryName, m_deploymentRepositoryName);
             m_workspaces.put(sessionID, workspace);
 
             component = m_dm.createComponent().setImplementation(workspace);
@@ -773,7 +760,7 @@ public class RESTClientServlet extends H
 
         synchronized (m_workspaces) {
             sessionID = "shell-" + m_sessionID++;
-            workspace = new Workspace(sessionID, m_repositoryURL, m_obrURL, storeCustomerName, m_storeRepositoryName, targetCustomerName, m_targetRepositoryName, deploymentCustomerName, m_deploymentRepositoryName, m_serverUser);
+            workspace = new Workspace(sessionID, m_repositoryURL, storeCustomerName, m_storeRepositoryName, targetCustomerName, m_targetRepositoryName, deploymentCustomerName, m_deploymentRepositoryName);
             m_workspaces.put(sessionID, workspace);
 
             component = m_dm.createComponent().setImplementation(workspace);

Modified: ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java (original)
+++ ace/trunk/org.apache.ace.client.rest/src/org/apache/ace/client/rest/Workspace.java Thu Oct 10 14:11:13 2013
@@ -66,14 +66,12 @@ public class Workspace {
     
     private final String m_sessionID;
     private final URL m_repositoryURL;
-    private final URL m_obrURL;
     private final String m_storeCustomerName;
     private final String m_distributionCustomerName;
     private final String m_deploymentCustomerName;
     private final String m_storeRepositoryName;
     private final String m_distributionRepositoryName;
     private final String m_deploymentRepositoryName;
-    private final String m_serverUser;
 
     private volatile BundleContext m_context;
     private volatile DependencyManager m_manager;
@@ -87,21 +85,19 @@ public class Workspace {
     private volatile Distribution2TargetAssociationRepository m_distribution2TargetAssociationRepository;
     private volatile LogService m_log;
 
-    public Workspace(String sessionID, String repositoryURL, String obrURL, String customerName, String storeRepositoryName, String distributionRepositoryName, String deploymentRepositoryName, String serverUser) throws MalformedURLException {
-    	this(sessionID, repositoryURL, obrURL, customerName, storeRepositoryName, customerName, distributionRepositoryName, customerName, deploymentRepositoryName, serverUser);
+    public Workspace(String sessionID, String repositoryURL, String customerName, String storeRepositoryName, String distributionRepositoryName, String deploymentRepositoryName) throws MalformedURLException {
+    	this(sessionID, repositoryURL, customerName, storeRepositoryName, customerName, distributionRepositoryName, customerName, deploymentRepositoryName);
     }
 
-    public Workspace(String sessionID, String repositoryURL, String obrURL, String storeCustomerName, String storeRepositoryName, String distributionCustomerName, String distributionRepositoryName, String deploymentCustomerName, String deploymentRepositoryName, String serverUser) throws MalformedURLException {
+    public Workspace(String sessionID, String repositoryURL, String storeCustomerName, String storeRepositoryName, String distributionCustomerName, String distributionRepositoryName, String deploymentCustomerName, String deploymentRepositoryName) throws MalformedURLException {
         m_sessionID = sessionID;
         m_repositoryURL = new URL(repositoryURL);
-        m_obrURL = new URL(obrURL);
         m_storeCustomerName = storeCustomerName;
         m_distributionCustomerName = deploymentCustomerName;
         m_deploymentCustomerName = deploymentCustomerName;
         m_storeRepositoryName = storeRepositoryName;
         m_distributionRepositoryName = distributionRepositoryName;
         m_deploymentRepositoryName = deploymentRepositoryName;
-        m_serverUser = serverUser;
     }
     
     /**
@@ -149,8 +145,8 @@ public class Workspace {
     public boolean login(User user) {
         try {
             RepositoryAdminLoginContext context = m_repositoryAdmin.createLoginContext(user);
-            
-            context.setObrBase(m_obrURL)
+
+            context
                 .add(context.createShopRepositoryContext()
                     .setLocation(m_repositoryURL)
                     .setCustomer(m_storeCustomerName)
@@ -202,15 +198,16 @@ public class Workspace {
     }
 
     public List<RepositoryObject> getRepositoryObjects(String entityType) {
-        List list = getObjectRepository(entityType).get();
+        List<RepositoryObject> list = getObjectRepository(entityType).get();
         if (list != null) {
             return list;
         }
         else {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
     }
 
+    @SuppressWarnings("unchecked")
     public RepositoryObject addRepositoryObject(String entityType, Map<String, String> attributes, Map<String, String> tags) throws IllegalArgumentException {
         if (TARGET.equals(entityType)) {
             return ((StatefulTargetRepository) getObjectRepository(TARGET)).preregister(attributes, tags);
@@ -353,8 +350,8 @@ public class Workspace {
         }
     }
 
-    private Map getAttributes(RepositoryObject object) {
-        Map result = new HashMap();
+    private Map<String, String> getAttributes(RepositoryObject object) {
+        Map<String, String> result = new HashMap<String, String>();
         for (Enumeration<String> keys = object.getAttributeKeys(); keys.hasMoreElements();) {
             String key = keys.nextElement();
             result.put(key, object.getAttribute(key));
@@ -396,6 +393,7 @@ public class Workspace {
         return null;
     }
     
+    @SuppressWarnings("unchecked")
     public void deleteRepositoryObject(String entityType, String entityId) {
         ObjectRepository objectRepository = getObjectRepository(entityType);
         RepositoryObject repositoryObject = objectRepository.get(entityId);

Modified: ace/trunk/org.apache.ace.connectionfactory/test/org/apache/ace/connectionfactory/impl/ConnectionFactoryImplTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.connectionfactory/test/org/apache/ace/connectionfactory/impl/ConnectionFactoryImplTest.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.connectionfactory/test/org/apache/ace/connectionfactory/impl/ConnectionFactoryImplTest.java (original)
+++ ace/trunk/org.apache.ace.connectionfactory/test/org/apache/ace/connectionfactory/impl/ConnectionFactoryImplTest.java Thu Oct 10 14:11:13 2013
@@ -26,6 +26,7 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.util.Properties;
 
+import org.apache.ace.test.constants.TestConstants;
 import org.testng.annotations.Test;
 
 /**
@@ -37,7 +38,7 @@ public class ConnectionFactoryImplTest {
     
     static {
         try {
-            TEST_URL = new URL("http://localhost:8080/");
+            TEST_URL = new URL("http://localhost:" + TestConstants.PORT + "/");
         }
         catch (MalformedURLException e) {
             throw new RuntimeException(e);

Modified: ace/trunk/org.apache.ace.connectionfactory/test/org/apache/ace/connectionfactory/impl/UrlCredentialsFactoryTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.connectionfactory/test/org/apache/ace/connectionfactory/impl/UrlCredentialsFactoryTest.java?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.connectionfactory/test/org/apache/ace/connectionfactory/impl/UrlCredentialsFactoryTest.java (original)
+++ ace/trunk/org.apache.ace.connectionfactory/test/org/apache/ace/connectionfactory/impl/UrlCredentialsFactoryTest.java Thu Oct 10 14:11:13 2013
@@ -30,6 +30,8 @@ import org.testng.annotations.Test;
  * Test cases for {@link UrlCredentialsFactory}.
  */
 public class UrlCredentialsFactoryTest {
+    /** any valid URL will do, no actual connections will be opened to this URL. */
+    private static final String AUTH_BASE_URL = "http://localhost/";
 
     /**
      * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}.
@@ -37,7 +39,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT }, expectedExceptions = MissingValueException.class)
     public void testGetCredentialsWithDictionaryBasicTypeMissingPasswordFail() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "basic");
         props.put(UrlCredentialsFactory.KEY_AUTH_USER_NAME, "bar");
 
@@ -50,7 +52,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT }, expectedExceptions = MissingValueException.class)
     public void testGetCredentialsWithDictionaryClientCertTypeMissingKeystorePasswordFail() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert");
         props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_FILE, "bar");
         props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_PASS, "qux");
@@ -65,7 +67,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT }, expectedExceptions = MissingValueException.class)
     public void testGetCredentialsWithDictionaryClientCertTypeMissingKeystoreFileFail() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert");
         props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_FILE, "bar");
         props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_PASS, "qux");
@@ -80,7 +82,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT })
     public void testGetCredentialsWithDictionaryClientCertTypeOk() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert");
         props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_FILE, "foo");
         props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_PASS, "bar");
@@ -101,7 +103,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT }, expectedExceptions = MissingValueException.class)
     public void testGetCredentialsWithDictionaryClientCertTypeMissingTruststorePasswordFail() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert");
         props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_FILE, "bar");
         props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_PASS, "qux");
@@ -116,7 +118,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT }, expectedExceptions = MissingValueException.class)
     public void testGetCredentialsWithDictionaryClientCertTypeMissingTruststoreFileFail() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert");
         props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_FILE, "bar");
         props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_PASS, "qux");
@@ -131,7 +133,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT }, expectedExceptions = MissingValueException.class)
     public void testGetCredentialsWithDictionaryBasicTypeMissingUserNameFail() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "basic");
         props.put(UrlCredentialsFactory.KEY_AUTH_USER_PASSWORD, "bar");
 
@@ -144,7 +146,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT })
     public void testGetCredentialsWithDictionaryBasicTypeOk() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "basic");
         props.put(UrlCredentialsFactory.KEY_AUTH_USER_NAME, "foo");
         props.put(UrlCredentialsFactory.KEY_AUTH_USER_PASSWORD, "bar");
@@ -158,7 +160,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT }, expectedExceptions = IllegalArgumentException.class)
     public void testGetCredentialsWithDictionaryInvalidAuthTypeFail() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "nonsense");
 
         UrlCredentialsFactory.getCredentials(props);
@@ -197,7 +199,7 @@ public class UrlCredentialsFactoryTest {
     @Test(groups = { UNIT })
     public void testGetCredentialsWithValidDictionaryOk() {
         Properties props = new Properties();
-        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, "http://localhost:8080/");
+        props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL);
         props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "none");
 
         UrlCredentialsFactory.getCredentials(props);

Modified: ace/trunk/org.apache.ace.deployment.rp.autoconf.itest/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.rp.autoconf.itest/bnd.bnd?rev=1530984&r1=1530983&r2=1530984&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment.rp.autoconf.itest/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.deployment.rp.autoconf.itest/bnd.bnd Thu Oct 10 14:11:13 2013
@@ -1,16 +1,15 @@
 Test-Cases: ${classes;CONCRETE;EXTENDS;junit.framework.TestCase}
--runbundles: org.mockito.mockito-all,\
-	org.apache.ace.deployment.rp.autoconf;version=latest,\
-	org.apache.ace.log.api;version=latest,\
-	org.apache.ace.managementagent;version=latest,\
-	org.apache.ace.test;version=latest,\
+-runbundles: \
+	org.mockito.mockito-all,\
 	org.apache.felix.metatype,\
 	org.apache.felix.dependencymanager,\
-	org.apache.felix.gogo.command,\
-	org.apache.felix.gogo.runtime,\
-	org.apache.felix.gogo.shell,\
+	org.apache.felix.log,\
 	org.apache.felix.configadmin,\
-	org.apache.felix.eventadmin
+	org.apache.felix.eventadmin,\
+	org.apache.ace.test;version=latest,\
+	org.apache.ace.deployment.rp.autoconf;version=latest,\
+	org.apache.ace.log.api;version=latest,\
+	org.apache.ace.managementagent;version=latest
 -runee: JavaSE-1.6
 -runvm: -ea
 -runfw: org.apache.felix.framework