Public feed
#727520
package clustering;import junit.framework.TestCase;import java.util.Enumeration;import java.util.Iterator;import swt.mosi2.xml.elements.Element;import swt.mosi2.xml.elements.Process;import swt.mosi2.xml.elements.SeqEvent;import swt.mosi2.xml.trace.StateActionContainer;import swt.mosi2.xml.trace.Trace;import java.io.File;import java.io.IOException;import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;/** * @author Dan * */public class ClusteringTest extends TestCase{ /* ATTENTION: * *** YOU MUST SET ALL OF THE VARIABLE FOR THIS TEST CLASS TO WORK PROPERLY *** *** THE UNDERLYING CLASSES PROVIDE DEFAULT WHEN NECESSARY *** * Please set the path variable so that it points to the directory where the test XML files reside * * Ex: * path = "/home/f85/Dan/eclipse/CS301-P2/examples/test/"; */ // SET THE PATH VARIABLE -- THE TRAILING SHALSH IS IMPORTANT String basePath = "/home/f85/Dan/eclipse/Traviando/examples/test/"; // SET THE NUMBER OF KMEANS YOU WOULD LIKE (DEFAULT: 4) final int kMeans = 4; // SET THE MAXIMUM NUMBER OF TIMES TO RECALCULTE CLUSTERING (AT THE END -- DEFAULT: 10) // ** NOTE: THIS VALUE SHOULD BE A REASONABLE NUMBER > 0 ** final int maxIterations = 10; // SET THE RANGE OF SIZES TO ACCEPT FOR THE FINAL CLUSTERINGS (DIFFERENCE BETWEEN PASS2 and PASS1) (DEFAULT: 2) final int range = 2; /* *** NO USER MODIFIABLE CODE BELOW THIS LINE *** * *** DO NOT EDIT LINES BELOW HERE *** * *** !!DANGER WILL ROBINSON!! *** * */ // SET THE SIZE VARIABLE FROM MORE THINGS final int SIZE = 10; // Global Variables String[] files; Trace[] traces; DataPoint[] DPList; LoadDataPoint DPLoader; // The cluster system ClusterSystem myClusters; /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); files = new String[SIZE]; traces = new Trace[SIZE]; DPList = new DataPoint[SIZE]; files[0] = "test1.xml"; files[1] = "test2.xml"; files[2] = "test3.xml"; files[3] = "test4.xml"; files[4] = "test5.xml"; files[5] = "test6.xml"; files[6] = "test7.xml"; files[7] = "test8.xml"; files[8] = "test9.xml"; files[9] = "test10.xml"; myClusters = new ClusterSystem(kMeans); } protected void tearDown() throws Exception { super.tearDown(); } /* (non-Javadoc) * @see junit.framework.dpTestCase#tearDown() */ /** Tests the creation of new traces from the given file names **/ public void testCreation() throws IOException, Exception{ for(int i=0; i < files.length; i++){ traces[i] = new Trace(new File(basePath + files[i])); DPLoader = new LoadDataPoint(files[i], traces[i]); DPList[i] = new DataPoint(DPLoader.getName(), DPLoader.getData()); // These things better not be null assertTrue(traces[i] != null); assertTrue(DPList[i] != null); } // end for } // end testCreation /** Makes the cluster system **/ public void testMakeSystem(){ // Did we setup right? assertTrue(myClusters.getKMeans() == kMeans); } // end makeClusterSystem public void testAddPoints(){ for(int i= 0; i < DPList.length; i++){ System.out.println(DPList[i]); //assertTrue(myClusters.countDataPoints() == (i+1)); } // end for } // end addPoints} // end JUnit Test