[jboss-cvs] JBossAS SVN: r91953 - in projects/mc-tools/grapher/trunk/src: test/java/org/jboss/test/mctools/grapher/graph and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 4 06:25:18 EDT 2009
Author: alesj
Date: 2009-08-04 06:25:18 -0400 (Tue, 04 Aug 2009)
New Revision: 91953
Added:
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/support/MockDeploymentGC.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/support/MockMDStructure.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/DependencyTypeTestCase.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/DeploymentGraphCreatorTestCase.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTest.java
projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/DependencyTypeTestCase.xml
projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/DeploymentGraphCreatorTestCase.xml
Modified:
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/GraphTestSuite.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java
Log:
Add deployment tests.
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java 2009-08-04 08:34:57 UTC (rev 91952)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java 2009-08-04 10:25:18 UTC (rev 91953)
@@ -39,7 +39,6 @@
/**
* Render deployment's beans.
- * TODO - test this
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
Modified: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/GraphTestSuite.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/GraphTestSuite.java 2009-08-04 08:34:57 UTC (rev 91952)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/GraphTestSuite.java 2009-08-04 10:25:18 UTC (rev 91953)
@@ -24,7 +24,9 @@
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.jboss.test.mctools.grapher.graph.test.DeploymentGraphCreatorTestCase;
import org.jboss.test.mctools.grapher.graph.test.GraphCreatorTestCase;
+import org.jboss.test.mctools.grapher.graph.test.DependencyTypeTestCase;
/**
* Graph creation test suite.
@@ -43,6 +45,8 @@
TestSuite suite = new TestSuite("Graph Tests");
suite.addTest(GraphCreatorTestCase.suite());
+ suite.addTest(DeploymentGraphCreatorTestCase.suite());
+ suite.addTest(DependencyTypeTestCase.suite());
return suite;
}
Added: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/support/MockDeploymentGC.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/support/MockDeploymentGC.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/support/MockDeploymentGC.java 2009-08-04 10:25:18 UTC (rev 91953)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.mctools.grapher.graph.support;
+
+import org.jboss.mctools.grapher.graph.DeploymentGraphCreator;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockDeploymentGC extends DeploymentGraphCreator
+{
+ public MockDeploymentGC(String folder, String deploymentName, boolean recurse)
+ {
+ super(folder, deploymentName, recurse);
+ }
+
+ @Override
+ protected String generateName() throws Exception
+ {
+ return "<default>"; // not important
+ }
+}
\ No newline at end of file
Added: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/support/MockMDStructure.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/support/MockMDStructure.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/support/MockMDStructure.java 2009-08-04 10:25:18 UTC (rev 91953)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.mctools.grapher.graph.support;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockMDStructure implements MainDeployerStructure
+{
+ public DeploymentUnit getDeploymentUnit(String name)
+ {
+ return new AbstractDeploymentUnit()
+ {
+ @Override
+ public Set<Object> getControllerContextNames()
+ {
+ return Collections.<Object>singleton("Owner");
+ }
+
+ @Override
+ public List<DeploymentUnit> getChildren()
+ {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List<DeploymentUnit> getComponents()
+ {
+ return Collections.emptyList();
+ }
+ };
+ }
+
+ public DeploymentUnit getDeploymentUnit(String name, boolean errorNotFound) throws DeploymentException
+ {
+ return getDeploymentUnit(name);
+ }
+
+ public DeploymentContext getDeploymentContext(String name)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public DeploymentContext getDeploymentContext(String name, boolean errorNotFound) throws DeploymentException
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/DependencyTypeTestCase.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/DependencyTypeTestCase.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/DependencyTypeTestCase.java 2009-08-04 10:25:18 UTC (rev 91953)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.mctools.grapher.graph.test;
+
+import junit.framework.Test;
+import org.jboss.mctools.grapher.graph.TreeGraphCreator;
+import org.jboss.mctools.grapher.graph.DependencyTypes;
+
+/**
+ * Dependency type tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DependencyTypeTestCase extends GraphCreatorTest
+{
+ public DependencyTypeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(DependencyTypeTestCase.class);
+ }
+
+ protected String getDefaultBean()
+ {
+ return "Owner";
+ }
+
+ public void testIDependOn() throws Exception
+ {
+ assertGraphCreator(new TreeGraphCreator("Owner"), DependencyTypes.IDependOn, 3, 2);
+ }
+
+ public void testDependsOnMe() throws Exception
+ {
+ assertGraphCreator(new TreeGraphCreator("Owner"), DependencyTypes.DependsOnMe, 2, 1);
+ }
+
+ public void testUnresolved() throws Exception
+ {
+ assertGraphCreator(new TreeGraphCreator("Owner"), DependencyTypes.Unresolved, 1, 0);
+ }
+}
\ No newline at end of file
Copied: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/DeploymentGraphCreatorTestCase.java (from rev 91924, projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/DeploymentGraphCreatorTestCase.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/DeploymentGraphCreatorTestCase.java 2009-08-04 10:25:18 UTC (rev 91953)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.mctools.grapher.graph.test;
+
+import junit.framework.Test;
+import org.jboss.mctools.grapher.graph.DependencyTypes;
+import org.jboss.test.mctools.grapher.graph.support.MockDeploymentGC;
+
+/**
+ * Deployment graph creator impl tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DeploymentGraphCreatorTestCase extends GraphCreatorTest
+{
+ public DeploymentGraphCreatorTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(DeploymentGraphCreatorTestCase.class);
+ }
+
+ protected String getDefaultBean()
+ {
+ return "Owner";
+ }
+
+ public void testDeployment() throws Exception
+ {
+ assertGraphCreator(new MockDeploymentGC("test", "test", false), DependencyTypes.IDependOn, 2, 1, "core");
+ assertGraphCreator(new MockDeploymentGC("test", "test", true), DependencyTypes.IDependOn, 3, 2, "core");
+ }
+}
\ No newline at end of file
Copied: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTest.java (from rev 91924, projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTest.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTest.java 2009-08-04 10:25:18 UTC (rev 91953)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.mctools.grapher.graph.test;
+
+import java.util.Arrays;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.mctools.grapher.graph.DependencyType;
+import org.jboss.mctools.grapher.graph.GEdge;
+import org.jboss.mctools.grapher.graph.GVertex;
+import org.jboss.mctools.grapher.graph.GraphCreator;
+import org.jboss.mctools.grapher.map.ComponentTypes;
+import org.jboss.test.mctools.grapher.GrapherTest;
+import org.jgraph.JGraph;
+
+/**
+ * Graph creator test.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class GraphCreatorTest extends GrapherTest
+{
+ protected GraphCreatorTest(String name)
+ {
+ super(name);
+ }
+
+ protected void assertGraphCreator(GraphCreator creator, DependencyType dtype, int vertices, int edges, String... excludes)
+ {
+ Class<? extends ControllerContext>[] excluded = ComponentTypes.createExcludedTypes(false, excludes);
+ JGraph graph = creator.createGraph(getKernelController(), dtype, excluded);
+ Object[] roots = graph.getRoots();
+ assertNotNull(roots);
+ // make sure we just have vertices and edges
+ assertEquals(vertices + edges, roots.length);
+ for (Object cell : roots)
+ {
+ if (cell instanceof GEdge)
+ edges--;
+ else if (cell instanceof GVertex)
+ vertices--;
+ }
+ assertEquals("Vertices: " + Arrays.asList(roots).toString(), 0, vertices);
+ assertEquals("Edges: " + Arrays.asList(roots).toString(), 0, edges);
+ }
+}
\ No newline at end of file
Modified: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java 2009-08-04 08:34:57 UTC (rev 91952)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java 2009-08-04 10:25:18 UTC (rev 91953)
@@ -21,29 +21,19 @@
*/
package org.jboss.test.mctools.grapher.graph.test;
-import java.util.Arrays;
-
import junit.framework.Test;
import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContext;
import org.jboss.mctools.grapher.graph.AllGraphCreator;
import org.jboss.mctools.grapher.graph.BeanGraphCreator;
-import org.jboss.mctools.grapher.graph.DependencyType;
import org.jboss.mctools.grapher.graph.DependencyTypes;
-import org.jboss.mctools.grapher.graph.GEdge;
-import org.jboss.mctools.grapher.graph.GVertex;
-import org.jboss.mctools.grapher.graph.GraphCreator;
import org.jboss.mctools.grapher.graph.TreeGraphCreator;
-import org.jboss.mctools.grapher.map.ComponentTypes;
-import org.jboss.test.mctools.grapher.GrapherTest;
-import org.jgraph.JGraph;
/**
- * Graph creator impl tests.
+ * Basic graph creator impl tests.
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public class GraphCreatorTestCase extends GrapherTest
+public class GraphCreatorTestCase extends GraphCreatorTest
{
public GraphCreatorTestCase(String name)
{
@@ -60,25 +50,6 @@
return "Owner";
}
- protected void assertGraphCreator(GraphCreator creator, DependencyType dtype, int vertices, int edges, String... excludes)
- {
- Class<? extends ControllerContext>[] excluded = ComponentTypes.createExcludedTypes(false, excludes);
- JGraph graph = creator.createGraph(getKernelController(), dtype, excluded);
- Object[] roots = graph.getRoots();
- assertNotNull(roots);
- // make sure we just have vertices and edges
- assertEquals(vertices + edges, roots.length);
- for (Object cell : roots)
- {
- if (cell instanceof GEdge)
- edges--;
- else if (cell instanceof GVertex)
- vertices--;
- }
- assertEquals("Vertices: " + Arrays.asList(roots).toString(), 0, vertices);
- assertEquals("Edges: " + Arrays.asList(roots).toString(), 0, edges);
- }
-
public void testAll()
{
assertGraphCreator(new AllGraphCreator(), DependencyTypes.IDependOn, 8, 6);
@@ -142,7 +113,7 @@
public void testExcludeExtAndCore() throws Throwable
{
- //assertGraphCreator(new BeanGraphCreator("CA"), DependencyTypes.IDependOn, 2, 1, "ext");
+ assertGraphCreator(new BeanGraphCreator("CA"), DependencyTypes.IDependOn, 2, 1, "ext");
assertGraphCreator(new TreeGraphCreator("CA"), DependencyTypes.IDependOn, 2, 1, "ext");
}
}
Added: projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/DependencyTypeTestCase.xml
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/DependencyTypeTestCase.xml (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/DependencyTypeTestCase.xml 2009-08-04 10:25:18 UTC (rev 91953)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Owner" class="java.lang.Object">
+ <demand>Dep1</demand>
+ <demand>Dep2</demand>
+ </bean>
+
+ <bean name="Dep1" class="java.lang.Object"/>
+
+ <bean name="Dep2" class="java.lang.Object"/>
+
+ <bean name="Dep3" class="java.lang.Object">
+ <demand>Owner</demand>
+ </bean>
+
+</deployment>
Copied: projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/DeploymentGraphCreatorTestCase.xml (from rev 91924, projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.xml)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/DeploymentGraphCreatorTestCase.xml (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/DeploymentGraphCreatorTestCase.xml 2009-08-04 10:25:18 UTC (rev 91953)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="MainDeployer" class="org.jboss.test.mctools.grapher.graph.support.MockMDStructure"/>
+
+ <bean name="Owner" class="java.lang.Object">
+ <demand>Dep1</demand>
+ </bean>
+
+ <bean name="Dep1" class="java.lang.Object">
+ <demand>Dep2</demand>
+ </bean>
+
+ <bean name="Dep2" class="java.lang.Object">
+ <demand>jboss.kernel:service=Kernel</demand>
+ </bean>
+
+</deployment>
More information about the jboss-cvs-commits
mailing list