Examples of ArtifactObject


Examples of org.apache.ace.client.repository.object.ArtifactObject

        File simpleTemplateFile = createFileWithContents("template", ".xml", xmlHeader + simpleTemplate + xmlFooter);

        // create some tree from artifacts to a target
        FeatureObject go = runAndWaitForEvent(new Callable<FeatureObject>() {
            public FeatureObject call() throws Exception {
                ArtifactObject b1 = createBasicBundleObject("myBundle");
                createBasicBundleObject("myProcessor", "1.0.0", "org.osgi.deployment.rp.autoconf");
                FeatureObject go = createBasicFeatureObject("myfeature");
                DistributionObject lo = createBasicDistributionObject("mydistribution");
                TargetObject gwo = createBasicTargetObject("templatetarget2");
                m_artifact2featureRepository.create(b1, go);
                // note that we do not associate b2: this is a resource processor, so it will be packed
                // implicitly. It should not be available to a preprocessor either.
                m_feature2distributionRepository.create(go, lo);
                m_distribution2targetRepository.create(lo, gwo);
                return go;
            }
        }, false, TOPIC_ADDED);

        ArtifactObject a1 = m_artifactRepository.importArtifact(noTemplateFile.toURI().toURL(), true);
        Artifact2FeatureAssociation a2g = m_artifact2featureRepository.create(a1, go);

        final StatefulTargetObject sgo = findStatefulTarget("templatetarget2");

        // create a deploymentversion
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

        m_dependencyManager.add(helperService);
       
        String targetId = "templatetarget";

        createBasicBundleObject("myProcessor", "1.0.0", "myProcessor.pid");
        final ArtifactObject b1 = createBasicBundleObject("myBundle");
        final ArtifactObject a1 = createBasicArtifactObject("myArtifact", "mymime", "myProcessor.pid");
        final FeatureObject go = createBasicFeatureObject("myfeature");
        final DistributionObject lo = createBasicDistributionObject("mydistribution");
    final TargetObject gwo = createBasicTargetObject(targetId);

        // create some tree from artifacts to a target
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

            }
            catch (IOException ex) {
                throw ex;
            }
        }
        ArtifactObject result = create(attributes, tags);
        return result;
    }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

     * @throws InvalidSyntaxException
     */
    @Test( groups = { TestUtils.UNIT } )
    public void testArtifactObjectAndRepository() throws InvalidSyntaxException {
        // Create a very simple artifact.
        ArtifactObject a = createBasicArtifactObject("myartifact", "1.0.0");

        // Try to create an illegal one
        try {
            createBasicArtifactObject("");
            assert false : "Creating an artifact with an empty name is not allowed.";
        }
        catch (IllegalArgumentException iae) {
            // expected
        }

        // Even though the artifact is not yet associated to a feature, try to get its features.
        List<FeatureObject> features = a.getFeatures();

        assert features.size() == 0 : "The artifact is not associated, so it should not return any features.";

        assert a.getAttribute(BundleHelper.KEY_SYMBOLICNAME).equals("myartifact") : "We should be able to read an attribute we just put in ourselves.";

        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(BundleHelper.KEY_SYMBOLICNAME) == null : "We should not find an attribute value when asking for a tag.";

        a.addTag(BundleHelper.KEY_SYMBOLICNAME, "mytagname");

        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 = 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("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 artifact.";
        assert m_artifactRepository.get().get(0).equals(a) : "The repository should contain exactly our artifact.";

        ArtifactObject b2 = createBasicArtifactObject("myotherartifact", "1");

        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 {
            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
        }

        try {
            b2.addAttribute("thenewattribute", "withsomevalue");
        }
        catch (UnsupportedOperationException uoe) {
            assert false : "Adding arbitrary attributes to a artifact object should be allowed.";
        }

        try {
            b2.addAttribute(BundleHelper.KEY_SYMBOLICNAME, "artifact.42");
            assert false : "Changing key attributes in a artifact should not be allowed.";
        }
        catch (UnsupportedOperationException uoe) {
            //expected
        }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

        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.";
    }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

     */
    @Test( groups = { TestUtils.UNIT } )
    public void testAssociations() {
        initializeRepositoryAdmin();
        // 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_artifact2FeatureRepository.create(b1, g2);
        assert b2g1 != null;
        Artifact2FeatureAssociation b2g2 = m_artifact2FeatureRepository.create(b2, g1);
        assert b2g2 != null;
        Artifact2FeatureAssociation b2g3 = m_artifact2FeatureRepository.create(b1, g3);
        assert b2g3 != null;
        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 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 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> b1features = b1.getFeatures();
        List<FeatureObject> b2features = b2.getFeatures();

        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);
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

    }

    @Test( groups = { TestUtils.UNIT } )
    public void testGetAssociationsWith() {
        initializeRepositoryAdmin();
        ArtifactObject a1 = createBasicArtifactObject("artifact1");
        FeatureObject f1 = createBasicFeatureObject("feature1");
        Artifact2FeatureAssociation a2f1 = m_artifact2FeatureRepository.create(a1, f1);

        List<Artifact2FeatureAssociation> b1Associations = a1.getAssociationsWith(f1);
        List<Artifact2FeatureAssociation> g1Associations = f1.getAssociationsWith(a1);

        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.";
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

        assert for1.get(0) == version1 : "The only version for" + gwId +  "should be version1";
    }

    @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<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_artifact2FeatureRepository.create(artifacts, features);

        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.";
        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<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";
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

        assert !foundArtifacts.contains(b3) : "g1 should not be associated with b3";
    }

    @Test( groups = { TestUtils.UNIT } )
    public void testAssociationsWithCardinality() {
        ArtifactObject a1 = createBasicArtifactObject("a1");
        FeatureObject f1 = createBasicFeatureObject("f1");
        FeatureObject f2 = createBasicFeatureObject("f2");
        FeatureObject f3 = createBasicFeatureObject("f3");

        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>();

        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
        }

        props.put(Association.RIGHT_CARDINALITY, "3");

        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.";
    }
View Full Code Here

Examples of org.apache.ace.client.repository.object.ArtifactObject

            // expected
        }

        m_artifactRepository.addHelper("myMime", helper);

        ArtifactObject obj = createArtifact("myMime", "myUrl", null, null);

        assert obj.getURL().equals("yourURL");

        try {
            m_artifactRepository.getHelper("yourMime");
            assert false : "We have not registered this helper.";
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.