Update of /cvsroot/bprocessor/model/test/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24155/test/net/sourceforge/bprocessor/model
Added Files:
EdgeTest.java package.html
Log Message:
added JUnit testsuite in test directory, remember to copy junit.jar to your Ant/lib directory
--- NEW FILE: package.html ---
<body>
The test of model classes
</body>
--- NEW FILE: EdgeTest.java ---
//---------------------------------------------------------------------------------
// $Id: EdgeTest.java,v 1.1 2005/09/28 12:28:46 rimestad Exp $
//
// Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net)
// Released under the Lesser GNU Public License v2.1
//---------------------------------------------------------------------------------
package net.sourceforge.bprocessor.model;
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.log4j.Logger;
/**
* The tests for the <code>net.sourceforge.bprocessor.model.Edge</code> class
*/
public class EdgeTest extends TestCase {
/** The logger */
private static Logger log = Logger.getLogger(Edge.class);
/**
* All the pre handling
*/
protected void setUp() {
}
/**
* All the post handling
*/
protected void tearDown() {
}
/**
* Test Edge initialization
*/
public void testInit() {
Edge edge = new Edge("edge");
assertEquals("[init]:1", edge.getName(), "edge");
assertNull("[init]:2", edge.getTo());
assertNull("[init]:3", edge.getFrom());
assertNull("[init]:4", edge.getId());
Vertex v1 = new Vertex("", 1.8, 0.0, 6.5);
Vertex v2 = new Vertex("", -3.2, 2.0, -0.5);
edge = new Edge("edge2", v1, v2);
assertEquals("[init]:5", edge.getName(), "edge2");
assertTrue("[init]:6", edge.getFrom() == v1);
assertTrue("[init]:7", edge.getTo() == v2);
assertNull("[init]:8", edge.getId());
}
/**
* Tests the length method for the Edge
*/
public void testLength() {
Edge edge = new Edge("Edge");
Vertex v1 = new Vertex("v1", 0, 0, 0);
Vertex v2 = new Vertex("v2", 5, 5, 5);
edge.setTo(v1);
edge.setFrom(v2);
assertEquals("[length]:1", edge.getLength(), Math.sqrt(75), 0.0);
assertFalse("[length]:2", edge.getLength() == 0.0);
edge.setFrom(v1);
assertEquals("[length]:3", edge.getLength(), 0.0, 0.0);
assertFalse("[length]:4", edge.getLength() == 5.0);
}
/**
* For single invocation use
* @param args The arguments
*/
public static void main(String[] args) {
junit.textui.TestRunner.run (suite());
}
/**
* Generates the TestSuite for this class
* @return The TestSuite
*/
public static Test suite() {
return new TestSuite(EdgeTest.class);
}
}
|