Coverage Report - net.sourceforge.combean.test.adapters.jgraph.TestJGraphClique
 
Classes in this File Line Coverage Branch Coverage Complexity
TestJGraphClique
94%
29/31
50%
6/12
1,286
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean is distributed in the hope that it will be useful,
 10  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Combean; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 /*
 19  
  * Created on 19.03.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.test.adapters.jgraph;
 23  
 
 24  
 import org.jgraph.JGraph;
 25  
 import org.jgraph.graph.DefaultCellViewFactory;
 26  
 import org.jgraph.graph.DefaultGraphCell;
 27  
 import org.jgraph.graph.DefaultGraphModel;
 28  
 import org.jgraph.graph.GraphCell;
 29  
 import org.jgraph.graph.GraphLayoutCache;
 30  
 
 31  
 import net.sourceforge.combean.adapters.jgraph.JGraphModelAsGraph;
 32  
 import net.sourceforge.combean.adapters.jgraph.JGraphUtils;
 33  
 import net.sourceforge.combean.interfaces.graph.Graph;
 34  
 import net.sourceforge.combean.test.graph.generic.AbstractTestClique;
 35  
 
 36  
 /**
 37  
  * @author schickin
 38  
  *
 39  
  */
 40  3
 public class TestJGraphClique extends AbstractTestClique {
 41  
     
 42  
     private static final int CLIQUESIZE = 4;
 43  
     
 44  6
     private DefaultGraphModel jgModel = null;
 45  6
     private GraphLayoutCache jgLayout = null;
 46  6
     private JGraph jg = null;
 47  
     
 48  6
     private JGraphModelAsGraph g = null;
 49  
 
 50  
     public static void main(String[] args) {
 51  0
         junit.textui.TestRunner.run(TestJGraphClique.class);
 52  0
     }
 53  
 
 54  
     /*
 55  
      * @see AbstractTestClique#setUp()
 56  
      */
 57  
     protected void setUp() throws Exception {
 58  
         
 59  6
         this.jgModel = new DefaultGraphModel();
 60  6
         this.jgLayout = new GraphLayoutCache(this.jgModel, new DefaultCellViewFactory());
 61  6
         this.jg = new JGraph(this.jgModel, this.jgLayout);
 62  
         
 63  6
         DefaultGraphCell[] cells = JGraphUtils.createGraphCells(CLIQUESIZE);
 64  6
         this.jgLayout.insert(cells);
 65  
         
 66  6
         GraphCell[] edges = new GraphCell[CLIQUESIZE * (CLIQUESIZE-1) / 2];
 67  6
         int pos = 0;
 68  30
         for (int from = 0; from < cells.length; from ++) {
 69  60
             for (int to = from+1; to < cells.length; to++) {
 70  36
                 edges[pos++] = JGraphUtils.createEdge(cells, from, to);
 71  
             }
 72  
         }
 73  6
         this.jgLayout.insert(edges);
 74  
         
 75  6
         this.g = new JGraphModelAsGraph(this.jgModel);
 76  
 
 77  
         // access variables in order to satisfy the compiler
 78  6
         assert this.g != null;
 79  6
         assert this.jg != null;
 80  
 
 81  6
         super.setUp();
 82  6
     }
 83  
 
 84  
     /*
 85  
      * @see AbstractTestClique#tearDown()
 86  
      */
 87  
     protected void tearDown() throws Exception {
 88  6
         super.tearDown();
 89  6
     }
 90  
 
 91  
     /**
 92  
      * Constructor for TestJGraphClique.
 93  
      * @param name
 94  
      */
 95  
     public TestJGraphClique(String name)
 96  
     throws Exception {
 97  6
         super(name);
 98  6
     }
 99  
 
 100  
     /* (non-Javadoc)
 101  
      * @see net.sourceforge.combean.test.graph.AbstractTestClique#getClique()
 102  
      */
 103  
     protected Graph getGraph() {
 104  18
          return this.g;
 105  
     }
 106  
     
 107  
     /* (non-Javadoc)
 108  
      * @see net.sourceforge.combean.test.graph.generic.AbstractTestClique#getNumNodes()
 109  
      */
 110  
     protected int getNumNodes() {
 111  3
          return CLIQUESIZE;
 112  
     }
 113  
 
 114  
     /* (non-Javadoc)
 115  
      * it is necessary to override the method from AbstractTestClique because
 116  
      * otherwise Eclipse does not find and run this test case automatically
 117  
      * 
 118  
      * @see net.sourceforge.combean.test.graph.AbstractTestClique#testGetNeighborsOfAllNodes()
 119  
      */
 120  
     public final void testGetNeighborsOfAllNodes() {
 121  3
          super.testGetNeighborsOfAllNodes();
 122  3
     }
 123  
 }