You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by mc...@apache.org on 2008/05/15 01:16:26 UTC
svn commit: r656462 - in /geronimo/devtools/eclipse-plugin/trunk/plugins:
org.apache.geronimo.runtime.common/
org.apache.geronimo.runtime.common/META-INF/ org.apache.geronimo.st.core/
org.apache.geronimo.st.core/META-INF/ org.apache.geronimo.st.core/sr...
Author: mcconne
Date: Wed May 14 16:16:25 2008
New Revision: 656462
URL: http://svn.apache.org/viewvc?rev=656462&view=rev
Log:
GERONIMODEVTOOLS-347 Create new dependency manager to be used to register dependencies between published modules
Added:
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyManager.java (with props)
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/DependencyManagerTest.java (with props)
Modified:
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/META-INF/MANIFEST.MF
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/pom.xml
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/.classpath
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/META-INF/MANIFEST.MF?rev=656462&r1=656461&r2=656462&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/META-INF/MANIFEST.MF (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/META-INF/MANIFEST.MF Wed May 14 16:16:25 2008
@@ -7,12 +7,12 @@
lib/geronimo-j2ee-deployment_1.1_spec-1.0.jar,
lib/commons-logging-1.0.4.jar,
lib/cglib-nodep-2.1_3.jar,
- lib/xstream-1.2.2.jar,
- lib/xpp3-1.1.3.3.jar,
lib/jaxb-api-2.0.jar,
lib/jaxb-impl-2.0.5.jar,
lib/geronimo-stax-api_1.0_spec-1.0.1.jar,
- lib/geronimo-activation_1.1_spec-1.0.2.jar
+ lib/geronimo-activation_1.1_spec-1.0.2.jar,
+ lib/xstream-1.2.2.jar,
+ lib/xpp3_min-1.1.3.4.O.jar
Export-Package:
com.sun.istack,
com.sun.xml.bind,
@@ -92,13 +92,5 @@
org.apache.commons.logging,
org.apache.commons.logging.impl,
org.xmlpull.mxp1,
- org.xmlpull.mxp1_serializer,
- org.xmlpull.v1,
- org.xmlpull.v1.builder,
- org.xmlpull.v1.builder.adapter,
- org.xmlpull.v1.builder.impl,
- org.xmlpull.v1.sax2,
- org.xmlpull.v1.util,
- org.xmlpull.v1.wrapper,
- org.xmlpull.v1.wrapper.classic
+ org.xmlpull.v1
Bundle-Vendor: Apache.org
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/pom.xml?rev=656462&r1=656461&r2=656462&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/pom.xml (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.common/pom.xml Wed May 14 16:16:25 2008
@@ -89,7 +89,7 @@
</artifactItem>
<artifactItem>
<groupId>xpp3</groupId>
- <artifactId>xpp3</artifactId>
+ <artifactId>xpp3_min</artifactId>
</artifactItem>
<artifactItem>
<groupId>javax.xml.bind</groupId>
@@ -166,7 +166,7 @@
</dependency>
<dependency>
<groupId>xpp3</groupId>
- <artifactId>xpp3</artifactId>
+ <artifactId>xpp3_min</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/.classpath
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/.classpath?rev=656462&r1=656461&r2=656462&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/.classpath (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/.classpath Wed May 14 16:16:25 2008
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/classes"/>
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF?rev=656462&r1=656461&r2=656462&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/META-INF/MANIFEST.MF Wed May 14 16:16:25 2008
@@ -35,3 +35,4 @@
org.apache.geronimo.st.core.internal,
org.apache.geronimo.st.core.jaxb,
org.apache.geronimo.st.core.operations
+Import-Package: junit.framework;version="3.8.2"
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyManager.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyManager.java?rev=656462&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyManager.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyManager.java Wed May 14 16:16:25 2008
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.st.core.internal;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.geronimo.jee.deployment.Artifact;
+
+/**
+ * <b>DependencyManager</b> is very closely-based on the similar class in the Geronimo server.
+ * DependencyManager is the record keeper of the dependencies in the Geronimo Eclipse Plugin. The
+ * DependencyManager does not enforce any dependencies, it is simply a place where components can
+ * register their intent to be dependent on another component, and where other components can query
+ * those dependencies.
+ *
+ * <p>Like the DependencyManager in the Geronimo server, it uses the nomenclature of parent-child
+ * where a child is dependent on a parent. The names parent and child have no other meaning are just
+ * a convience to make the code readable.
+ *
+ * <p>The initial usage of this DependencyManager in the GEP is somewhat limited but other usages
+ * are possible<p>
+ *
+ * @version $Rev$ $Date$
+ */
+public class DependencyManager {
+
+ //
+ // Map from child to a list of parents
+ //
+ private final Map childToParentMap = new HashMap();
+
+ //
+ // Map from parent back to a list of its children
+ //
+ private final Map parentToChildMap = new HashMap();
+
+
+ /**
+ *
+ */
+ public void close() {
+ childToParentMap.clear();
+ parentToChildMap.clear();
+ }
+
+
+ /**
+ * Declares a dependency from a child to a parent.
+ *
+ * @param child the dependent component
+ * @param parent the component the child is depending on
+ */
+ public void addDependency(Artifact child, Artifact parent) {
+
+ Set parents = (Set) childToParentMap.get(child);
+ if (parents == null) {
+ parents = new HashSet();
+ childToParentMap.put(child, parents);
+ }
+ parents.add(parent);
+
+ Set children = (Set) parentToChildMap.get(parent);
+ if (children == null) {
+ children = new HashSet();
+ parentToChildMap.put(parent, children);
+ }
+ children.add(child);
+ }
+
+
+ /**
+ * Removes a dependency from a child to a parent
+ *
+ * @param child the dependnet component
+ * @param parent the component that the child wil no longer depend on
+ */
+ public void removeDependency(Artifact child, Artifact parent) {
+
+ Set parents = (Set) childToParentMap.get(child);
+ if (parents != null) {
+ parents.remove(parent);
+ }
+
+ Set children = (Set) parentToChildMap.get(parent);
+ if (children != null) {
+ children.remove(child);
+ }
+ }
+
+
+ /**
+ * Removes all dependencies for a child
+ *
+ * @param child the component that will no longer depend on anything
+ */
+ public void removeAllDependencies(Artifact child) {
+
+ Set parents = (Set) childToParentMap.remove(child);
+ if (parents == null) {
+ return;
+ }
+
+ for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+ Artifact parent = (Artifact) iterator.next();
+ Set children = (Set) parentToChildMap.get(parent);
+ if (children != null) {
+ children.remove(child);
+ }
+ }
+ }
+
+
+ /**
+ * Adds dependencies from the child to every parent in the parents set
+ *
+ * @param child the dependent component
+ * @param parents the set of components the child is depending on
+ */
+ public void addDependencies(Artifact child, Set parents) {
+
+ Set existingParents = (Set) childToParentMap.get(child);
+ if (existingParents == null) {
+ existingParents = new HashSet(parents);
+ childToParentMap.put(child, existingParents);
+ }
+ else {
+ existingParents.addAll(parents);
+ }
+
+ for (Iterator i = parents.iterator(); i.hasNext();) {
+ Object startParent = i.next();
+ Set children = (Set) parentToChildMap.get(startParent);
+ if (children == null) {
+ children = new HashSet();
+ parentToChildMap.put(startParent, children);
+ }
+ children.add(child);
+ }
+ }
+
+
+ /**
+ * Gets the set of parents that the child is depending on
+ *
+ * @param child the dependent component
+ * @return a collection containing all of the components the child depends on; will never be null
+ */
+ public Set getParents(Artifact child) {
+
+ Set parents = (Set) childToParentMap.get(child);
+ if (parents == null) {
+ return Collections.EMPTY_SET;
+ }
+
+ return new HashSet(parents);
+ }
+
+
+ /**
+ * Gets all of the children that have a dependency on the specified parent.
+ *
+ * @param parent the component the returned childen set depend on
+ * @return a collection containing all of the components that depend on the parent; will never be null
+ */
+ public Set getChildren(Artifact parent) {
+
+ Set children = (Set) parentToChildMap.get(parent);
+ if (children == null) {
+ return Collections.EMPTY_SET;
+ }
+
+ return new HashSet(children);
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyManager.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/DependencyManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/DependencyManagerTest.java?rev=656462&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/DependencyManagerTest.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/DependencyManagerTest.java Wed May 14 16:16:25 2008
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.st.core.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.geronimo.jee.deployment.Artifact;
+import org.apache.geronimo.jee.deployment.ObjectFactory;
+
+/**
+ * <b>DependencyManagerTest</b> is used to test various inter-dependencies between artifacts that
+ * are used to represent Geronimo-specific deployment plans<p>
+ *
+ * @version $Rev$ $Date$
+ */
+public class DependencyManagerTest extends TestCase {
+
+ private DependencyManager dm = new DependencyManager();
+ private ObjectFactory deploymentFactory = new ObjectFactory();
+
+ //
+ // Instantiate some artifacts
+ //
+ private Artifact artifact1 = deploymentFactory.createArtifact();
+ private Artifact artifact2 = deploymentFactory.createArtifact();
+ private Artifact artifact3 = deploymentFactory.createArtifact();
+ private Artifact artifact4 = deploymentFactory.createArtifact();
+ private Artifact artifact5 = deploymentFactory.createArtifact();
+ private Artifact artifact6 = deploymentFactory.createArtifact();
+ private Artifact artifact7 = deploymentFactory.createArtifact();
+ private Artifact artifact8 = deploymentFactory.createArtifact();
+ private Artifact artifact9 = deploymentFactory.createArtifact();
+
+
+ protected void setUp() {
+
+ //
+ // Set the artifacts to a known state before each testcase
+ //
+ artifact1.setGroupId("org.apache.geronimo.groupid1");
+ artifact1.setArtifactId("artifactid1");
+ artifact1.setVersion("version1");
+ artifact1.setType("war");
+
+ artifact2.setGroupId("org.apache.geronimo.groupid2");
+ artifact2.setArtifactId("artifactid2");
+ artifact2.setVersion("version2");
+ artifact2.setType("ear");
+
+ artifact3.setGroupId("org.apache.geronimo.groupid3");
+ artifact3.setArtifactId("artifactid3");
+ artifact3.setVersion("version3");
+ artifact3.setType("rar");
+
+ artifact4.setGroupId("org.apache.geronimo.groupid4");
+ artifact4.setArtifactId("artifactid4");
+ artifact4.setVersion("version4");
+ artifact4.setType("jar");
+
+ artifact5.setGroupId("org.apache.geronimo.groupid5");
+ artifact5.setArtifactId("artifactid5");
+ artifact5.setVersion("version5");
+ artifact5.setType("war");
+
+ artifact6.setGroupId(null);
+ artifact6.setArtifactId("artifactid6");
+ artifact6.setVersion("version6");
+ artifact6.setType("ear");
+
+ artifact7.setGroupId("org.apache.geronimo.groupid7");
+ artifact7.setArtifactId(null);
+ artifact7.setVersion("version7");
+ artifact7.setType("rar");
+
+ artifact8.setGroupId("org.apache.geronimo.groupid8");
+ artifact8.setArtifactId("artifactid8");
+ artifact8.setVersion(null);
+ artifact8.setType("war");
+
+ artifact9.setGroupId("org.apache.geronimo.groupid9");
+ artifact9.setArtifactId("artifactid9");
+ artifact9.setVersion("version9");
+ artifact9.setType(null);
+
+ //
+ // Set the dependency manager to a known state between each testcase
+ //
+ dm.close();
+ }
+
+
+ /*------------------------------------------------------------------------*\
+ | |
+ | Testcase(s) |
+ | |
+ \*------------------------------------------------------------------------*/
+ public void testSingleParent() {
+
+ dm.addDependency(artifact2,artifact1);
+ dm.addDependency(artifact3,artifact1);
+ dm.addDependency(artifact4,artifact1);
+ dm.addDependency(artifact5,artifact1);
+ dm.addDependency(artifact6,artifact1);
+ dm.addDependency(artifact7,artifact1);
+ dm.addDependency(artifact8,artifact1);
+ dm.addDependency(artifact9,artifact1);
+ dm.addDependency(artifact9,artifact1); // Must not change the number of children
+
+ Set children = dm.getChildren(artifact1);
+ assertEquals(children.size(),8);
+ assertTrue(children.contains(artifact2));
+ assertTrue(children.contains(artifact3));
+ assertTrue(children.contains(artifact4));
+ assertTrue(children.contains(artifact5));
+ assertTrue(children.contains(artifact6));
+ assertTrue(children.contains(artifact7));
+ assertTrue(children.contains(artifact8));
+ assertTrue(children.contains(artifact9));
+
+ Set parents = dm.getParents(artifact9);
+ assertEquals(parents.size(),1);
+ assertTrue(parents.contains(artifact1));
+
+ dm.removeDependency(artifact9,artifact1);
+ children = dm.getChildren(artifact1);
+ assertEquals(children.size(),7);
+ assertTrue(children.contains(artifact2));
+ assertTrue(children.contains(artifact3));
+ assertTrue(children.contains(artifact4));
+ assertTrue(children.contains(artifact5));
+ assertTrue(children.contains(artifact6));
+ assertTrue(children.contains(artifact7));
+ assertTrue(children.contains(artifact8));
+
+ parents = dm.getParents(artifact9);
+ assertEquals(parents.size(),0);
+
+ dm.removeAllDependencies(artifact7);
+ children = dm.getChildren(artifact1);
+ assertEquals(children.size(),6);
+ assertTrue(children.contains(artifact2));
+ assertTrue(children.contains(artifact3));
+ assertTrue(children.contains(artifact4));
+ assertTrue(children.contains(artifact5));
+ assertTrue(children.contains(artifact6));
+ assertTrue(children.contains(artifact8));
+
+ dm.removeDependency(artifact7,artifact1);
+ children = dm.getChildren(artifact1);
+ assertEquals(children.size(),6);
+
+ children = dm.getChildren(artifact2);
+ assertEquals(children.size(),0);
+
+ dm.removeAllDependencies(artifact5);
+ children = dm.getChildren(artifact1);
+ assertEquals(children.size(),5);
+ assertTrue(children.contains(artifact2));
+ assertTrue(children.contains(artifact3));
+ assertTrue(children.contains(artifact4));
+ assertTrue(children.contains(artifact6));
+ assertTrue(children.contains(artifact8));
+
+ dm.removeAllDependencies(artifact1);
+ dm.removeAllDependencies(artifact2);
+ dm.removeAllDependencies(artifact3);
+ dm.removeAllDependencies(artifact4);
+ dm.removeAllDependencies(artifact5);
+ dm.removeAllDependencies(artifact6);
+ dm.removeAllDependencies(artifact7);
+ dm.removeAllDependencies(artifact8);
+ dm.removeAllDependencies(artifact9);
+ dm.removeDependency(artifact1,artifact1);
+ dm.removeDependency(artifact2,artifact1);
+ dm.removeDependency(artifact3,artifact1);
+ dm.removeDependency(artifact4,artifact1);
+ dm.removeDependency(artifact5,artifact1);
+ dm.removeDependency(artifact6,artifact1);
+ dm.removeDependency(artifact7,artifact1);
+ dm.removeDependency(artifact8,artifact1);
+ dm.removeDependency(artifact7,artifact1);
+
+ children = dm.getChildren(artifact1);
+ assertEquals(children.size(),0);
+ children = dm.getChildren(artifact2);
+ assertEquals(children.size(),0);
+ children = dm.getChildren(artifact3);
+ assertEquals(children.size(),0);
+ children = dm.getChildren(artifact4);
+ assertEquals(children.size(),0);
+ children = dm.getChildren(artifact5);
+ assertEquals(children.size(),0);
+ children = dm.getChildren(artifact6);
+ assertEquals(children.size(),0);
+ children = dm.getChildren(artifact7);
+ assertEquals(children.size(),0);
+ children = dm.getChildren(artifact8);
+ assertEquals(children.size(),0);
+ children = dm.getChildren(artifact9);
+ assertEquals(children.size(),0);
+ }
+
+ public void testMultipleParents() throws Exception {
+
+ dm.addDependency(artifact1,artifact2);
+ dm.addDependency(artifact1,artifact3);
+ dm.addDependency(artifact1,artifact4);
+ dm.addDependency(artifact1,artifact5);
+ dm.addDependency(artifact1,artifact6);
+ dm.addDependency(artifact1,artifact7);
+ dm.addDependency(artifact1,artifact8);
+ dm.addDependency(artifact1,artifact9);
+ dm.addDependency(artifact1,artifact9); // Must not change the number of parents
+
+ Set parents = dm.getParents(artifact1);
+ assertEquals(parents.size(),8);
+ assertTrue(parents.contains(artifact2));
+ assertTrue(parents.contains(artifact3));
+ assertTrue(parents.contains(artifact4));
+ assertTrue(parents.contains(artifact5));
+ assertTrue(parents.contains(artifact6));
+ assertTrue(parents.contains(artifact7));
+ assertTrue(parents.contains(artifact8));
+ assertTrue(parents.contains(artifact9));
+
+ dm.removeAllDependencies(artifact1);
+ parents = dm.getParents(artifact1);
+ assertEquals(parents.size(),0);
+ Set children = dm.getChildren(artifact1);
+ assertEquals(children.size(),0);
+
+ dm.addDependency(artifact1,artifact2);
+ dm.addDependency(artifact1,artifact3);
+ dm.addDependency(artifact1,artifact4);
+ dm.addDependency(artifact1,artifact5);
+ dm.addDependency(artifact6,artifact7);
+ dm.addDependency(artifact6,artifact8);
+ dm.addDependency(artifact6,artifact9);
+ parents = dm.getParents(artifact1);
+ assertEquals(parents.size(),4);
+ assertTrue(parents.contains(artifact2));
+ assertTrue(parents.contains(artifact3));
+ assertTrue(parents.contains(artifact4));
+ assertTrue(parents.contains(artifact5));
+ parents = dm.getParents(artifact6);
+ assertEquals(parents.size(),3);
+ assertTrue(parents.contains(artifact7));
+ assertTrue(parents.contains(artifact8));
+ assertTrue(parents.contains(artifact9));
+
+ Set parentSet = new HashSet();
+ parentSet.add(artifact2);
+ parentSet.add(artifact3);
+ parentSet.add(artifact4);
+ parentSet.add(artifact5);
+ parentSet.add(artifact6);
+ parentSet.add(artifact7);
+ parentSet.add(artifact8);
+ parentSet.add(artifact9);
+ dm.addDependencies(artifact1,parentSet);
+ parents = dm.getParents(artifact1);
+ assertEquals(parents.size(),8);
+ assertTrue(parents.contains(artifact2));
+ assertTrue(parents.contains(artifact3));
+ assertTrue(parents.contains(artifact4));
+ assertTrue(parents.contains(artifact5));
+ assertTrue(parents.contains(artifact6));
+ assertTrue(parents.contains(artifact7));
+ assertTrue(parents.contains(artifact8));
+ assertTrue(parents.contains(artifact9));
+ }
+
+ public void testMultipleChildrenAndParents() throws Exception {
+
+ dm.addDependency(artifact1,artifact2);
+ dm.addDependency(artifact1,artifact3);
+ dm.addDependency(artifact1,artifact4);
+ dm.addDependency(artifact1,artifact5);
+ dm.addDependency(artifact6,artifact9);
+ dm.addDependency(artifact7,artifact9);
+ dm.addDependency(artifact8,artifact9);
+
+ Set parents = dm.getParents(artifact1);
+ assertEquals(parents.size(),4);
+ assertTrue(parents.contains(artifact2));
+ assertTrue(parents.contains(artifact3));
+ assertTrue(parents.contains(artifact4));
+ assertTrue(parents.contains(artifact5));
+
+ Set children = dm.getChildren(artifact9);
+ assertEquals(children.size(),3);
+ assertTrue(children.contains(artifact6));
+ assertTrue(children.contains(artifact7));
+ assertTrue(children.contains(artifact8));
+ }
+
+ public void testCircularDependency() throws Exception {
+
+ dm.addDependency(artifact1,artifact1);
+ Set children = dm.getChildren(artifact1);
+ Set parents = dm.getParents(artifact1);
+ assertEquals(children.size(),1);
+ assertTrue(children.contains(artifact1));
+ assertEquals(parents.size(),1);
+ assertTrue(parents.contains(artifact1));
+
+ dm.addDependency(artifact2,artifact2);
+ children = dm.getChildren(artifact2);
+ parents = dm.getParents(artifact2);
+ assertEquals(children.size(),1);
+ assertTrue(children.contains(artifact2));
+ assertEquals(parents.size(),1);
+ assertTrue(parents.contains(artifact2));
+
+ dm.close();
+
+ dm.addDependency(artifact2,artifact1);
+ dm.addDependency(artifact3,artifact2);
+ dm.addDependency(artifact4,artifact3);
+ dm.addDependency(artifact5,artifact4);
+ dm.addDependency(artifact6,artifact5);
+ dm.addDependency(artifact7,artifact6);
+ dm.addDependency(artifact8,artifact7);
+ dm.addDependency(artifact9,artifact8);
+ dm.addDependency(artifact1,artifact9);
+ children = dm.getChildren(artifact1);
+ parents = dm.getParents(artifact1);
+ assertEquals(children.size(),1);
+ assertTrue(children.contains(artifact2));
+ assertEquals(parents.size(),1);
+ assertTrue(parents.contains(artifact9));
+ children = dm.getChildren(artifact2);
+ parents = dm.getParents(artifact3);
+ assertEquals(children.size(),1);
+ assertTrue(children.contains(artifact3));
+ assertEquals(parents.size(),1);
+ assertTrue(parents.contains(artifact2));
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/DependencyManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/DependencyManagerTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/test/java/org/apache/geronimo/st/core/internal/DependencyManagerTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain