[jboss-cvs] JBossAS SVN: r90940 - in projects/mc-tools/grapher/trunk/src/test: java/org/jboss/test/mctools/grapher/graph and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 8 11:09:04 EDT 2009


Author: alesj
Date: 2009-07-08 11:09:03 -0400 (Wed, 08 Jul 2009)
New Revision: 90940

Added:
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/
   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/
   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/render/
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/RenderTestSuite.java
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/AbstractRendererTest.java
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/ManualGraphWrite2FileTestCase.java
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/RendererTestCase.java
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.java
   projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/
   projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/
   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/render/
   projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/
   projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/RendererTestCase.xml
   projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.xml
Removed:
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/test/
   projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/test/
Modified:
   projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/GrapherTestSuite.java
Log:
Refactoring pckgs

Modified: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/GrapherTestSuite.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/GrapherTestSuite.java	2009-07-08 14:52:01 UTC (rev 90939)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/GrapherTestSuite.java	2009-07-08 15:09:03 UTC (rev 90940)
@@ -24,10 +24,8 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
-import org.jboss.test.mctools.grapher.test.GraphCreatorTestCase;
-import org.jboss.test.mctools.grapher.test.RendererTestCase;
-import org.jboss.test.mctools.grapher.test.Write2FileTestCase;
-import org.jboss.test.mctools.grapher.test.ManualGraphWrite2FileTestCase;
+import org.jboss.test.mctools.grapher.graph.GraphTestSuite;
+import org.jboss.test.mctools.grapher.render.RenderTestSuite;
 
 /**
  * Grapher test suite.
@@ -46,13 +44,10 @@
       TestSuite suite = new TestSuite("Grapher Tests");
 
       // graph creator tests
-      suite.addTest(GraphCreatorTestCase.suite());
+      suite.addTest(GraphTestSuite.suite());
       // renderers tests
-      suite.addTest(RendererTestCase.suite());
-      suite.addTest(Write2FileTestCase.suite());
-      suite.addTest(ManualGraphWrite2FileTestCase.suite());
+      suite.addTest(RenderTestSuite.suite());
 
       return suite;
    }
-
 }

Added: 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	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/GraphTestSuite.java	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.mctools.grapher.graph.test.GraphCreatorTestCase;
+
+/**
+ * Graph creation test suite.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class GraphTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Graph Tests");
+
+      suite.addTest(GraphCreatorTestCase.suite());
+
+      return suite;
+   }
+}

Copied: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java (from rev 90933, projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/test/GraphCreatorTestCase.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,82 @@
+/*
+ * 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 junit.framework.Test;
+import org.jboss.mctools.grapher.graph.AllGraphCreator;
+import org.jboss.mctools.grapher.graph.BeanGraphCreator;
+import org.jboss.mctools.grapher.graph.GraphCreator;
+import org.jboss.test.mctools.grapher.GrapherTest;
+import org.jgraph.JGraph;
+import org.jgraph.graph.DefaultGraphCell;
+import org.jgraph.graph.Edge;
+
+/**
+ * Graph creator impl tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class GraphCreatorTestCase extends GrapherTest
+{
+   public GraphCreatorTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(GraphCreatorTestCase.class);
+   }
+
+   protected String getDefaultBean()
+   {
+      return "Owner";
+   }
+
+   protected void assertGraphCreator(GraphCreator creator, int vertices, int edges)
+   {
+      JGraph graph = creator.createGraph(getKernelController());
+      Object[] roots = graph.getRoots();
+      assertNotNull(roots);
+      for (Object cell : roots)
+      {
+         if (cell instanceof Edge)
+            edges--;
+         else if (cell instanceof DefaultGraphCell)
+            vertices--;
+      }
+      assertEquals("Vertices: " + Arrays.asList(roots).toString(), 0, vertices);
+      assertEquals("Edges: " + Arrays.asList(roots).toString(), 0, edges);
+   }
+
+   public void testAll()
+   {
+      assertGraphCreator(new AllGraphCreator(), 3, 3);
+   }
+
+   public void testBean()
+   {
+      assertGraphCreator(new BeanGraphCreator("Dep2"), 2, 2);
+   }
+}

Added: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/RenderTestSuite.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/RenderTestSuite.java	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/RenderTestSuite.java	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,53 @@
+/*
+ * 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.render;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.mctools.grapher.render.test.ManualGraphWrite2FileTestCase;
+import org.jboss.test.mctools.grapher.render.test.RendererTestCase;
+import org.jboss.test.mctools.grapher.render.test.Write2FileTestCase;
+
+/**
+ * Renderers test suite.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class RenderTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Render Tests");
+
+      suite.addTest(RendererTestCase.suite());
+      suite.addTest(Write2FileTestCase.suite());
+      suite.addTest(ManualGraphWrite2FileTestCase.suite());
+
+      return suite;
+   }
+}

Copied: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/AbstractRendererTest.java (from rev 90938, projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/test/AbstractRendererTest.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/AbstractRendererTest.java	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/AbstractRendererTest.java	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,106 @@
+/*
+ * 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.render.test;
+
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.jboss.mctools.grapher.render.GIFRenderer;
+import org.jboss.mctools.grapher.render.JPGRenderer;
+import org.jboss.mctools.grapher.render.Renderer;
+import org.jboss.mctools.grapher.render.SVGRenderer;
+import org.jboss.test.mctools.grapher.GrapherTest;
+import org.jgraph.JGraph;
+
+/**
+ * Renderer impl tests.
+ *
+ * @param <T> exact output stream type
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class AbstractRendererTest<T extends OutputStream> extends GrapherTest
+{
+   protected AbstractRendererTest(String name)
+   {
+      super(name);
+   }
+
+   private static Map<Class<? extends Renderer>, String> suffixes;
+
+   static
+   {
+      suffixes = new HashMap<Class<? extends Renderer>, String>();
+      suffixes.put(SVGRenderer.class, ".svg");
+      suffixes.put(GIFRenderer.class, ".gif");
+      suffixes.put(JPGRenderer.class, ".jpg");
+   }
+
+   protected abstract T createOutputStream(String suffix) throws Throwable;
+
+   protected abstract void testOutputStream(T out, String suffix);
+
+   protected abstract JGraph createGraph();
+
+   protected void cleanupOutputStream(T out)
+   {
+      getLog().info(out);
+   }
+
+   protected void testRenderer(Renderer renderer) throws Throwable
+   {
+      JGraph graph = createGraph();
+      String suffix = suffixes.get(renderer.getClass());
+      T out = createOutputStream(suffix);
+      try
+      {
+         renderer.render(graph, out, 0);
+         testOutputStream(out, suffix);
+      }
+      finally
+      {
+         try
+         {
+            out.close();
+         }
+         finally
+         {
+            cleanupOutputStream(out);
+         }
+      }
+   }
+
+   public void testSVG() throws Throwable
+   {
+      testRenderer(new SVGRenderer());
+   }
+
+   public void testGIF() throws Throwable
+   {
+      testRenderer(new GIFRenderer());
+   }
+
+   public void testJPG() throws Throwable
+   {
+      testRenderer(new JPGRenderer());
+   }
+}
\ No newline at end of file

Copied: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/ManualGraphWrite2FileTestCase.java (from rev 90938, projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/test/ManualGraphWrite2FileTestCase.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/ManualGraphWrite2FileTestCase.java	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/ManualGraphWrite2FileTestCase.java	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,80 @@
+/*
+ * 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.render.test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+import org.jgraph.JGraph;
+import org.jgraph.graph.ConnectionSet;
+import org.jgraph.graph.DefaultEdge;
+import org.jgraph.graph.DefaultGraphCell;
+import org.jgraph.graph.DefaultGraphModel;
+import org.jgraph.graph.Edge;
+import org.jgraph.graph.GraphModel;
+
+/**
+ * Write to file tests, manual graph creation.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ManualGraphWrite2FileTestCase extends Write2FileTestCase
+{
+   public ManualGraphWrite2FileTestCase(String name)
+   {
+      super(name);
+      //setDeleteFile(false);
+   }
+
+   public static Test suite()
+   {
+      return suite(ManualGraphWrite2FileTestCase.class);
+   }
+
+   @SuppressWarnings("unchecked")
+   protected JGraph createGraph()
+   {
+      List cells = new ArrayList();
+      ConnectionSet cs = new ConnectionSet();
+      Map attributes = new HashMap();
+
+      DefaultGraphCell v1 = new DefaultGraphCell("v1");
+      v1.addPort();
+      cells.add(v1);
+
+      DefaultGraphCell v2 = new DefaultGraphCell("v2");
+      v2.addPort();
+      cells.add(v2);
+
+      Edge e1 = new DefaultEdge("e1");
+      cs.connect(e1, v1.getChildAt(0), v2.getChildAt(0));
+      cells.add(e1);
+
+      // create simple graph
+      GraphModel model = new DefaultGraphModel();
+      model.insert(cells.toArray(), attributes, cs, null, null);
+      return new JGraph(model);
+   }
+}
\ No newline at end of file

Copied: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/RendererTestCase.java (from rev 90938, projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/test/RendererTestCase.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/RendererTestCase.java	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/RendererTestCase.java	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,69 @@
+/*
+ * 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.render.test;
+
+import java.io.ByteArrayOutputStream;
+
+import junit.framework.Test;
+import org.jboss.mctools.grapher.graph.GraphCreator;
+import org.jboss.mctools.grapher.map.GraphCreatorMapper;
+import org.jgraph.JGraph;
+
+/**
+ * Renderer impl tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class RendererTestCase extends AbstractRendererTest<ByteArrayOutputStream>
+{
+   public RendererTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(RendererTestCase.class);
+   }
+
+   protected String getDefaultBean()
+   {
+      return "Owner";
+   }
+
+   protected ByteArrayOutputStream createOutputStream(String suffix)
+   {
+      return new ByteArrayOutputStream();
+   }
+
+   protected void testOutputStream(ByteArrayOutputStream out, String suffix)
+   {
+      byte[] bytes = out.toByteArray();
+      assertTrue(bytes.length > 0);
+   }
+
+   protected JGraph createGraph()
+   {
+      GraphCreator creator = GraphCreatorMapper.ALL;
+      return creator.createGraph(getKernelController());
+   }
+}
\ No newline at end of file

Copied: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.java (from rev 90938, projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/test/Write2FileTestCase.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.java	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.java	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,92 @@
+/*
+ * 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.render.test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.security.ProtectionDomain;
+import java.security.CodeSource;
+import java.net.URL;
+
+import junit.framework.Test;
+import org.jboss.mctools.grapher.graph.GraphCreator;
+import org.jboss.mctools.grapher.map.GraphCreatorMapper;
+import org.jgraph.JGraph;
+
+/**
+ * Write to file tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class Write2FileTestCase extends AbstractRendererTest<FileOutputStream>
+{
+   private boolean deleteFile = true; // change this if you wanna inspect the pics
+
+   private File tempFile;
+
+   public Write2FileTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(Write2FileTestCase.class);
+   }
+
+   protected String getDefaultBean()
+   {
+      return "Owner";
+   }
+
+   protected FileOutputStream createOutputStream(String suffix) throws Throwable
+   {
+      ProtectionDomain pd = getClass().getProtectionDomain();
+      CodeSource cs = pd.getCodeSource();
+      URL location = cs.getLocation();
+      File root = new File(location.toURI());
+      tempFile = File.createTempFile("grapher-", suffix, root);
+      return new FileOutputStream(tempFile);
+   }
+
+   protected void testOutputStream(FileOutputStream out, String suffix)
+   {
+   }
+
+   @Override
+   protected void cleanupOutputStream(FileOutputStream out)
+   {
+      if (deleteFile)
+         assertTrue(tempFile.delete());
+   }
+
+   protected JGraph createGraph()
+   {
+      GraphCreator creator = GraphCreatorMapper.ALL;
+      return creator.createGraph(getKernelController());
+   }
+
+   public void setDeleteFile(boolean deleteFile)
+   {
+      this.deleteFile = deleteFile;
+   }
+}
\ No newline at end of file

Copied: projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.xml (from rev 90933, projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/test/GraphCreatorTestCase.xml)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.xml	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.xml	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="Owner" class="java.lang.Object">
+    <alias>OwAlias</alias>
+  </bean>
+
+  <bean name="Dep1" class="java.lang.Object">
+    <alias>Dep1Alias</alias>
+    <demand>OwAlias</demand>
+  </bean>
+
+  <bean name="Dep2" class="java.lang.Object">
+    <alias>Dep2Alias</alias>
+    <depends>Dep1</depends>
+  </bean>
+
+</deployment>

Copied: projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/RendererTestCase.xml (from rev 90938, projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/test/RendererTestCase.xml)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/RendererTestCase.xml	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/RendererTestCase.xml	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="Owner" class="java.lang.Object">
+    <alias>OwAlias</alias>
+  </bean>
+
+  <bean name="Dep1" class="java.lang.Object">
+    <alias>Dep1Alias</alias>
+    <demand>OwAlias</demand>
+  </bean>
+
+  <bean name="Dep2" class="java.lang.Object">
+    <alias>Dep2Alias</alias>
+    <depends>Dep1</depends>
+  </bean>
+
+</deployment>

Copied: projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.xml (from rev 90938, projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/test/Write2FileTestCase.xml)
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.xml	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/test/resources/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.xml	2009-07-08 15:09:03 UTC (rev 90940)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="Owner" class="java.lang.Object">
+    <alias>OwAlias</alias>
+  </bean>
+
+  <bean name="Dep1" class="java.lang.Object">
+    <alias>Dep1Alias</alias>
+    <demand>OwAlias</demand>
+  </bean>
+
+  <bean name="Dep2" class="java.lang.Object">
+    <alias>Dep2Alias</alias>
+    <depends>Dep1</depends>
+  </bean>
+
+</deployment>




More information about the jboss-cvs-commits mailing list