Revision: 1739
          http://svn.sourceforge.net/vexi/?rev=1739&view=rev
Author:   mkpg2
Date:     2007-03-16 13:41:32 -0700 (Fri, 16 Mar 2007)

Log Message:
-----------
Development - refactoring debug tests

Modified Paths:
--------------
    core/trunk/org.vexi.devl/src_junit/test/debug/Debugee.java
    core/trunk/org.vexi.devl/src_junit/test/debug/TestDebugger.java
    core/trunk/org.vexi.devl/src_junit/test/debug/simple/TestSimple.java
    core/trunk/org.vexi.devl/src_junit/test/debug/thread/TestThread.java
    core/trunk/org.vexi.devl/src_junit/test/debug/vars/TestVars.java

Added Paths:
-----------
    core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTestCase.java
    core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTestSuite.java
    core/trunk/org.vexi.devl/src_junit/test/debug/simple/testBreakpoint.t
    core/trunk/org.vexi.devl/src_junit/test/debug/simple/testRestart.t
    core/trunk/org.vexi.devl/src_junit/test/debug/simple/testResume.t
    core/trunk/org.vexi.devl/src_junit/test/debug/simple/testStepOver.t
    core/trunk/org.vexi.devl/src_junit/test/debug/testclient.t
    core/trunk/org.vexi.devl/src_junit/test/debug/thread/testSwitchingThreads.t
    core/trunk/org.vexi.devl/src_junit/test/debug/vars/shared.t
    core/trunk/org.vexi.devl/src_junit/test/debug/vars/testVars.t

Removed Paths:
-------------
    core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTest.java

Modified: core/trunk/org.vexi.devl/src_junit/test/debug/Debugee.java
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/Debugee.java  2007-03-16 
18:25:34 UTC (rev 1738)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/Debugee.java  2007-03-16 
20:41:32 UTC (rev 1739)
@@ -2,27 +2,93 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Vector;
 
+import org.apache.xmlrpc.XmlRpcClient;
+import org.apache.xmlrpc.XmlRpcException;
+import org.ibex.util.Log;
+import org.vexi.debug.Constants;
 import org.vexi.debug.StreamGobbler;
 
 public class Debugee {
+       ///
+       // STATIC Public Interface
+       //////
+       static boolean DISABLE = false;
+       
+       static public void start(String mainTemplate, String resourceDir) 
throws IOException{
+               if(!DISABLE){
+                       killPrevious();
+                       Debugee d = new Debugee(mainTemplate, resourceDir);
+                       d.launch();
+               }
+       }
+       
+       static public void stop(){
+               if(!DISABLE)killPrevious();
+       }
+       
+       ////
+       // STATIC implementation (management of Debugee)
+       ///
+       
+       static private Object execXmlrpc(String method) throws XmlRpcException, 
IOException{
+               return execXmlrpc(method, new Vector());
+       }
+       
+       static private Object execXmlrpc(String method, Vector args) throws 
XmlRpcException, IOException{
+               Object response = getXmlRpc().execute(Constants.HANDLER  + "." 
+ method, args);
+               if(response instanceof XmlRpcException){
+                       throw (XmlRpcException)response;
+               }
+               return response;
+       }
+       
+       static private XmlRpcClient xmlRpc;
+       static private XmlRpcClient getXmlRpc(){
+               if(xmlRpc==null)
+                       try {
+                               xmlRpc = new XmlRpcClient("http://localhost:"; + 
Constants.DEFAULT_PORT);
+                       } catch (MalformedURLException e) {
+                               throw new RuntimeException(e);
+                       }
+               return xmlRpc;
+       }
+       static void killPrevious(){
+               try{
+                       while(true){
+                               execXmlrpc("getVersion");
+                               Log.uInfo(Debugee.class,"Previous debuggee 
process has not finished, killing it");
+                               execXmlrpc("suicide");
+                       }
+                       
+               }catch(Exception e){
+                       // Expected
+               }
+       }
+       
+       
+       ////
+       // Implementation
+       ///
+       
        static Object lock = new Object();
 
        Process proc;
        String mainTemplate;
-       Class resourceLocator;
+       String resourceDir;
        
-       public Debugee(String mainTemplate, Class resourceLocator) {
+       private Debugee(String mainTemplate, String resourceDir) {
                this.mainTemplate = mainTemplate;
-               this.resourceLocator = resourceLocator;
+               this.resourceDir = resourceDir;
        }       
        
-       public void launch() throws IOException{
+       void launch() throws IOException{
                //URL url = 
AbstractDebuggerTests.this.getClass().getResource(".");
-               URL url = resourceLocator.getResource(".");
                
-               final File workingDir = new File(url.getPath());
+               final File workingDir = new File(resourceDir);
                final String[] command =
                        new String[]{"java","-cp", 
System.getProperty("java.class.path"), 
                                
"org.vexi.devl.Main","-db","-dbclient=NONE",".",mainTemplate};
@@ -76,4 +142,10 @@
                        t.printStackTrace();
                }
        }*/
+       
+
+       
+       
+       
+       
 }

Deleted: core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTest.java
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTest.java     
2007-03-16 18:25:34 UTC (rev 1738)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTest.java     
2007-03-16 20:41:32 UTC (rev 1739)
@@ -1,370 +0,0 @@
-package test.debug;
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import junit.framework.ComparisonFailure;
-import junit.framework.TestCase;
-
-import org.apache.xmlrpc.XmlRpcClient;
-import org.apache.xmlrpc.XmlRpcException;
-import org.ibex.util.Log;
-import org.vexi.debug.Constants;
-import org.vexi.debug.StreamGobbler;
-
-import test.js.JSTestSuite;
-
-
-
-public abstract class DebuggerTest extends TestCase implements Constants {
-
-       XmlRpcClient xmlrpc;
-       Debugee debugee;
-       protected TestClient tc;
-       String mainTemplate;
-       
-       protected DebuggerTest(){
-               this("main");
-       }
-       
-       protected DebuggerTest(String mainTemplate){
-               this.mainTemplate = mainTemplate;
-       }
-       
-       
-       Object execXmlrpc(String method) throws XmlRpcException, IOException{
-               return execXmlrpc(method, new Vector());
-       }
-       
-       Object execXmlrpc(String method, Vector args) throws XmlRpcException, 
IOException{
-               Object response = xmlrpc.execute(HANDLER  + "." + method, args);
-               if(response instanceof XmlRpcException){
-                       throw (XmlRpcException)response;
-               }
-               return response;
-       }
-       
-       protected class TestClient implements Runnable{
-               private int stateCounter = -1;
-               private int lastStateCounter = -1;
-               private String status="";
-               
-               private Hashtable currentThread;
-               private Vector sleepingThreads;
-               private Vector scheduledThreads;
-               private Vector vars;
-               private Thread t;
-               private boolean killed =false;
-
-               public TestClient() {
-                       start();
-               }
-               
-               private void start(){
-                       t=new Thread(this);
-                       t.start();
-               }
-               
-
-               
-               
-               //////////////
-               // Remote methods. 
-               ///////////////
-               public void killDebugee(){
-                       killed = true;
-                       t.interrupt();
-                       try{
-                               execXmlrpc("suicide");
-                       }catch(Exception e){
-                               // ignore, call cannot complete as
-                               // xmlserver was killed before it could respond
-                       }
-               }
-               
-               public void stepOver() throws XmlRpcException, IOException{
-                       Object response = execXmlrpc("stepOver");
-                       assertEquals(Boolean.TRUE,response);
-               }
-               
-               public void resume() throws XmlRpcException, IOException{
-                       Object response = execXmlrpc("resume");
-                       assertEquals(Boolean.TRUE,response);
-               }
-               
-               public void restart() throws XmlRpcException, IOException{
-                       start();
-                       Object response = execXmlrpc("restart");
-                       assertEquals(Boolean.TRUE,response);
-               }
-               
-               public void setBreakPoint(String filename, int ln) throws 
XmlRpcException, IOException {
-                       Vector args = new Vector();
-                       args.add(filename);
-                       args.add(new Integer(ln));
-                       Object response = execXmlrpc("addBreakPoint", args);
-                       assertEquals(Boolean.TRUE,response);
-               }
-               
-               ////////
-               // Wait for 
-               ////
-               public void waitForHalt() throws XmlRpcException, IOException, 
InterruptedException{
-                       waitFor(STATUS_HALTED);
-                       assertEquals(STATUS_HALTED,status);
-               }
-               
-               public void waitForStop() throws XmlRpcException, IOException, 
InterruptedException{
-                       waitFor();
-                       assertEquals(STATUS_STOPPED,status);
-               }
-               
-               private void waitFor(String status) throws XmlRpcException, 
IOException, InterruptedException{
-                       do{
-                               while(!isSynchronized(status)){
-                                       Thread.sleep(100);
-                               }
-                               lastStateCounter = stateCounter;
-                       }while(status!=null && !status.equals(this.status));
-                       //System.out.println("stateCounter: " + stateCounter);
-               }
-               
-               private void waitFor() throws XmlRpcException, IOException, 
InterruptedException{
-                       waitFor(null);
-               }
-               
-               ////////////
-               // State synchronization
-               ///
-               synchronized private void update(Integer stateCounter, String 
status, Hashtable currentThread, Vector scheduledThreads, Vector 
sleepingThreads, Vector vars){
-                       this.stateCounter = stateCounter.intValue();
-                       this.status = status;
-                       if(currentThread!=null) this.currentThread = 
currentThread;
-                       if(sleepingThreads!=null) this.sleepingThreads = 
sleepingThreads;
-                       if(scheduledThreads!=null) this.scheduledThreads = 
scheduledThreads;
-                       
-                       this.vars = vars;
-               }
-
-               private boolean isSynchronized(String syncStatus) throws 
XmlRpcException, IOException{
-                       Hashtable r = (Hashtable) 
execXmlrpc("getStatusAndState");
-                       String status = (String)r.get("status");
-                       Integer stateCounter = (Integer)r.get("stateCounter");
-                       //boolean correctStatus = 
(syncStatus==null&&(STATUS_HALTED.equals(status) || 
STATUS_STOPPED.equals(status)))  
-                       //                      || 
(syncStatus!=null&&syncStatus.equals(status));
-                       return (STATUS_HALTED.equals(status) || 
STATUS_STOPPED.equals(status)) &&
-                              stateCounter.intValue() >= this.stateCounter && 
-                              this.stateCounter!=lastStateCounter; // make 
sure were not in the previous halted state
-               }
-
-               public void run() {
-                       
-                       while(true){
-                               try{
-                               Vector args = new Vector();
-                               args.add(new Integer(stateCounter));
-                               Object response = execXmlrpc("getState",args);
-                               Map message = (Map)response;
-                               //System.out.println(response);
-                               //System.out.println("vars " + 
message.get("vars"));
-                               update((Integer) message.get("stateCounter"),
-                                          (String) message.get("status"),
-                                          (Hashtable) 
message.get("currentThread"),
-                                          (Vector) 
message.get("scheduledThreads"),
-                                          (Vector) 
message.get("sleepingThreads"),
-                                          (Vector) message.get("vars"));
-                               if(STATUS_STOPPED.equals(this.status))
-                                       break;
-                               }catch(Exception e){
-                                       if(killed) break;
-                                       e.printStackTrace();
-                                       try {
-                                               Thread.sleep(300);
-                                       } catch (InterruptedException e1) {
-                                               if(killed) break;
-                                               e1.printStackTrace();
-                                       }
-                               }
-                       }
-               }
-
-
-               ///////////
-               // Assertions
-               //////
-               synchronized public void assertPosition(String srcName, int 
line){
-                       assertEquals(srcName,currentThread.get("srcName"));
-                       assertEquals(new Integer(line),currentThread.get("ln"));
-               }
-               
-               synchronized public void assertCurrentThread(String threadName){
-                       assertEquals(threadName,currentThread.get("name"));
-               }
-               
-               synchronized public void assertCallStack(String[] strings){
-                       Vector v = (Vector)currentThread.get("callStack");
-                       //System.err.println(v);
-                       String a = "", b = "";
-                       for(int i=0; i<strings.length;i++){a += strings[i] + 
",";}
-                       for(int i=0; i<v.size();i++){
-                               Hashtable call = (Hashtable) v.get(i);
-                               b+=call.get("srcName")+":"+call.get("ln")+",";
-                       }
-                       try{
-                               assertEquals(a,b);
-                       }catch(ComparisonFailure e){    
-                               Log.uError(DebuggerTest.class, "exp: <"+a +">");
-                               Log.uError(DebuggerTest.class, "act: <"+b +">");
-                               throw e;
-                       }
-                       /*
-                       assertEquals(strings.length, v.size());
-                       for(int i=0; i<strings.length;i++){
-                               int divider = strings[i].indexOf(':');
-                               String srcName = 
strings[i].substring(0,divider);
-                               int ln = 
Integer.parseInt(strings[i].substring(divider+1));
-                               
-                               Hashtable call = (Hashtable) v.get(i);
-                               
-                               assertEquals(srcName, call.get("srcName"));
-                               assertEquals(ln, 
((Integer)call.get("ln")).intValue());
-                               
-                       }*/
-               
-               }
-               
-               synchronized public void assertScheduledThreads(String[] 
threadNames){
-                       for(int i=0; i<threadNames.length; i++){
-                               assertContains(scheduledThreads, 
threadNames[i]);
-                       }
-               }
-               
-               private boolean assertContains(Vector threads, String 
threadName){
-                       for(int i=0; i<threads.size(); i++){
-                               Hashtable t = (Hashtable) threads.get(i);
-                               if(threadName.equals(t.get("name")))
-                                       return true;
-                       }
-                       return false;
-               }
-
-               public VarInfo getVarInfo() {
-                       return new VarInfo(vars);
-               }
-
-               public VarInfo getVarInfo(int callStackPos) throws 
XmlRpcException, IOException {
-                       Vector args = new Vector();
-                       args.add((Integer)currentThread.get("id"));
-                       args.add(new Integer(callStackPos));
-                       Object r =  execXmlrpc("getVarInfo", args );
-                       return new VarInfo((Vector) r);
-               }
-               
-               
-       }
-
-       public static class VarInfo{
-               
-               Vector vars;
-               public VarInfo(Vector vars){
-                       this.vars = vars;
-               }
-               
-               public void assertVar(String name, Object val) {
-
-                       assertVar(name, val, VARTYPE_PRIMITIVE);
-               }
-               public void assertVar(String name, Object val, String type) {
-                       for(int i=0; i<vars.size(); i++){
-                               Hashtable var = (Hashtable) vars.get(i);
-                               if(var.get("name").equals(name)){
-                                       Object valSent = var.get("value");
-                                       Object typeSent = var.get("type");
-                                       if(VARTYPE_PRIMITIVE.equals(type)){
-                                               if(val == null){
-                                                       assertEquals(typeSent, 
VARTYPE_NULL);
-                                                       return;
-                                               }
-                                               else
-                                                       assertEquals(val, 
valSent);
-                                       }
-                                       assertEquals(type, typeSent);
-                                       return;
-                               }
-                       }
-                       fail();
-               }
-
-               public void assertNoVar(String name) {
-                       for(int i=0; i<vars.size(); i++){
-                               Hashtable var = (Hashtable) vars.get(i);
-                               if(var.get("name").equals(name)){
-                                       fail();
-                               }
-                       }
-               }
-       }
-       
-       
-       protected void setUp() throws Exception {
-               Log.uError("---------------", "---------------- " + 
this.getName() + "-----------------");
-                                  
-               killPrevious();
-               debugee = new Debugee(mainTemplate, this.getClass());
-               debugee.launch();
-               super.setUp();
-               setUpClient();
-       }
-       protected void killPrevious() throws MalformedURLException{
-               try{
-                       xmlrpc = new XmlRpcClient("http://localhost:"; + 
DEFAULT_PORT);
-                       while(true){
-                               execXmlrpc("getVersion");
-                               Log.uInfo(DebuggerTest.class,"Previous debuggee 
process has not finished, killing it");
-                               execXmlrpc("suicide");
-                       }
-                       
-               }catch(Exception e){
-                       // Expected
-               }
-       }
-               
-       protected void setUpClient() throws MalformedURLException{
-               xmlrpc = new XmlRpcClient("http://localhost:"; + DEFAULT_PORT);
-               
-               Log.uInfo(DebuggerTest.class,"Wait for debug server to come 
up");
-               while(true){
-                       try{
-                               Thread.sleep(300);
-                               Object o = execXmlrpc("getVersion");
-                               Log.uInfo(DebuggerTest.class,"Server up. 
Protocol version: " + o);
-                               break;
-                       }catch(Exception e){
-                               continue;
-                       }
-               }
-               
-               tc = new TestClient();
-       }
-
-       protected void tearDown() throws Exception {
-               // Port is blocked otherwise. When running (in eclipse at 
least) the 
-               // child process does not get killed.
-               
-               // REMARK - killing the debugees process does not always seem 
to work
-               //debugee.kill();
-               
-               // So kill with XmlrpcCall
-               tc.killDebugee();
-       }
-       /*
-       public String getName() {
-               return JSTestSuite.nameFromClass(getClass());
-       }*/
-}
-

Added: core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTestCase.java
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTestCase.java         
                (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTestCase.java 
2007-03-16 20:41:32 UTC (rev 1739)
@@ -0,0 +1,41 @@
+package test.debug;
+
+import java.util.List;
+
+import org.ibex.js.JS;
+import org.ibex.js.Thread;
+import org.ibex.util.Log;
+import org.vexi.core.Vexi;
+
+import test.core.CoreTestCase;
+import test.core.Util;
+
+public class DebuggerTestCase extends CoreTestCase{
+
+       public DebuggerTestCase(String resourceDir, String templateFileName) {
+               super(resourceDir, templateFileName);
+       }
+       protected void setUp() throws Exception {
+               Log.uError("---------------", "---------------- " + 
this.getName() + "-----------------");
+               Debugee.start("main", resourceDir);
+
+       }
+       protected void addSharedDirs(List sharedDirs) {
+               super.addSharedDirs(sharedDirs);
+               /*
+               sharedDirs.add(getClass().getClassLoader()
+                       
.getResource("org/vexi/devl/debuggerclient.vexi").getPath());
+               sharedDirs.add(getClass().getClassLoader()
+                       .getResource("org/vexi/devl/widgets.vexi").getPath());*/
+               sharedDirs.add("../org.vexi.widgets/src");
+               sharedDirs.add("../org.vexi.debugclient/src");
+               
sharedDirs.add(DebuggerTestCase.class.getResource(".").getPath());
+       }
+       protected void schedule(Vexi v) throws Exception {
+               JS function = Util.getStatic(v, main, "runtest");
+               Thread.runInNew(function, new JS[]{});
+       }
+       protected void tearDown(){
+               Debugee.stop();
+       }
+}

Copied: core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTestSuite.java 
(from rev 1726, core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTest.java)
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTestSuite.java        
                        (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/DebuggerTestSuite.java        
2007-03-16 20:41:32 UTC (rev 1739)
@@ -0,0 +1,44 @@
+package test.debug;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.apache.xmlrpc.XmlRpcClient;
+import org.apache.xmlrpc.XmlRpcException;
+import org.ibex.util.Log;
+import org.vexi.debug.Constants;
+
+import test.core.CoreTestSuite;
+import test.debug.simple.TestSimple;
+
+
+
+
+public abstract class DebuggerTestSuite extends CoreTestSuite implements 
Constants {
+       
+
+       protected DebuggerTestSuite(Class klass){
+               super(klass);
+       }
+       
+       public TestCase createTestCase(String resourceDir, String fileName) {
+               return new DebuggerTestCase(resourceDir, fileName);
+       }
+       
+       protected boolean filter(String name) {
+               return super.filter(name) && name.startsWith("test");
+       }
+
+       public void run(String testFile){
+               Debugee.DISABLE = true;
+               TestCase t = 
createTestCase(getClass().getResource(".").getPath(), testFile);
+               try{
+                       t.runBare();
+               }catch(Throwable e){
+                       Log.uError(getClass(), e);
+               }
+       }
+}
+

Modified: core/trunk/org.vexi.devl/src_junit/test/debug/TestDebugger.java
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/TestDebugger.java     
2007-03-16 18:25:34 UTC (rev 1738)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/TestDebugger.java     
2007-03-16 20:41:32 UTC (rev 1739)
@@ -4,10 +4,9 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import test.debug.simple.TestSimple;
-import test.debug.thread.TestThread;
-import test.debug.vars.TestVars;
 import test.js.JSTestSuite;
 
+
 public class TestDebugger {
        
        /////////
@@ -17,8 +16,8 @@
        public static Test suite() {
        TestSuite suite = new 
TestSuite(JSTestSuite.nameFromClass(TestDebugger.class));
        suite.addTestSuite(TestSimple.class);
-       suite.addTestSuite(TestThread.class);
-       suite.addTestSuite(TestVars.class);
+       //suite.addTestSuite(TestThread.class);
+       //suite.addTestSuite(TestVars.class);
        return suite;
     }
 }

Modified: core/trunk/org.vexi.devl/src_junit/test/debug/simple/TestSimple.java
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/simple/TestSimple.java        
2007-03-16 18:25:34 UTC (rev 1738)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/simple/TestSimple.java        
2007-03-16 20:41:32 UTC (rev 1739)
@@ -1,72 +1,26 @@
 package test.debug.simple;
 
-import test.debug.DebuggerTest;
+import org.ibex.util.Log;
 
-public class TestSimple extends DebuggerTest {
+import junit.framework.Test;
+import junit.framework.TestCase;
+import test.core.CoreTestSuite;
+import test.core.linenumbering.TestLineNumbering;
+import test.debug.DebuggerTestSuite;
 
+public class TestSimple extends DebuggerTestSuite {
+
        public TestSimple() {
-               super();
+               super(TestSimple.class);
        }
        
        // Main method to just execute client (so server can be manually 
executed
        // as a debugable process.
        public static void main(String[] args) throws Exception {
-               TestSimple t = new TestSimple();
-               //t.setUp();
-               t.killPrevious();
-               t.setUpClient();
-               try{
-                       t.testRestart();
-               }finally{
-                       t.tearDown();
-               }
+               new TestSimple().run("testBreakpoint");
        }
        
-       ///////////
-       // TESTS
-       ////////
-       public void testStepOver() throws Exception{
-               tc.waitForHalt();
-               tc.assertPosition("main", 2);
-               tc.assertCallStack(new String[]{"main:2"});
-               tc.stepOver();
-               tc.waitForHalt();
-               tc.assertPosition("main", 4);
-               tc.stepOver();
-               tc.waitForHalt();
-               tc.assertPosition("main", 5);
-               tc.stepOver();
-               tc.waitForHalt();
-               tc.assertPosition("main", 7);
-               tc.stepOver();
-               tc.waitForHalt();
-               tc.assertPosition("main", 8);
-               tc.stepOver();
-               tc.waitForStop();
-       }
-       
-       public void testResume() throws Exception{
-               tc.waitForHalt();
-               tc.assertPosition("main", 2);
-               tc.resume();
-               tc.waitForStop();
-       }
-       
-       public void testRestart() throws Exception{
-               testResume();
-               tc.restart();
-               testResume();
-       }
-       
-       public void testBreakPoint() throws Exception{
-               tc.waitForHalt();
-               tc.assertPosition("main", 2);
-               tc.setBreakPoint("main", 7);
-               tc.resume();
-               tc.waitForHalt();
-               tc.assertPosition("main", 7);
-               tc.resume();
-               tc.waitForStop();
-       }
-       
+       public static Test suite(){
+       return CoreTestSuite.suite(new TestSimple());
+    }
 }

Added: core/trunk/org.vexi.devl/src_junit/test/debug/simple/testBreakpoint.t
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/simple/testBreakpoint.t       
                        (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/simple/testBreakpoint.t       
2007-03-16 20:41:32 UTC (rev 1739)
@@ -0,0 +1,23 @@
+<vexi xmlns:ui="vexi://ui" xmlns:tc="testclient"
+         xmlns:model="org.vexi.debugclient.core.model"
+         xmlns="">
+       static.runtest = function(){
+               tc..waitForHalt();
+               tc..assertPosition("main:2");
+               var x;
+               model..breakPointAdded ++=function(v){
+                       x = v.toString;
+               };
+               tc..setBreakPoint("main", 7);
+               tc..assertBreakPoint("main:7");
+               .util..assertEquals("main:7",x);
+               tc..resume();
+               tc..waitForHalt();
+               tc..assertPosition("main:7");
+               tc..resume();
+               tc..waitForStop();
+               
+       };
+
+       <ui:box/>
+</vexi>

Added: core/trunk/org.vexi.devl/src_junit/test/debug/simple/testRestart.t
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/simple/testRestart.t          
                (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/simple/testRestart.t  
2007-03-16 20:41:32 UTC (rev 1739)
@@ -0,0 +1,9 @@
+<vexi xmlns:ui="vexi://ui" xmlns:tc="testclient" xmlns="">
+       static.runtest = function(){
+               .testResume..runtest();
+               tc..restart();
+               .testResume..runtest();
+       };
+
+       <ui:box/>
+</vexi>

Added: core/trunk/org.vexi.devl/src_junit/test/debug/simple/testResume.t
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/simple/testResume.t           
                (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/simple/testResume.t   
2007-03-16 20:41:32 UTC (rev 1739)
@@ -0,0 +1,10 @@
+<vexi xmlns:ui="vexi://ui" xmlns:tc="testclient">
+       static.runtest = function(){
+               tc..waitForHalt();
+               tc..assertPosition("main:2");
+               tc..resume();
+               tc..waitForStop();
+       };
+
+       <ui:box/>
+</vexi>

Added: core/trunk/org.vexi.devl/src_junit/test/debug/simple/testStepOver.t
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/simple/testStepOver.t         
                (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/simple/testStepOver.t 
2007-03-16 20:41:32 UTC (rev 1739)
@@ -0,0 +1,25 @@
+<vexi xmlns:ui="vexi://ui" xmlns:tc="testclient">
+       static.runtest = function(){
+               tc..waitForHalt();
+               tc..assertPosition("main:2");
+               tc..assertCallStack(["main:2"]);
+               tc..stepOver();
+               tc..waitForHalt();
+               tc..assertPosition("main:4");
+               tc..stepOver();
+               tc..waitForHalt();
+               tc..assertPosition("main:5");
+               tc..stepOver();
+               tc..waitForHalt();
+               tc..assertPosition("main:7");
+               tc..stepOver();
+               tc..waitForHalt();
+               tc..assertPosition("main:8");
+               tc..stepOver();
+               tc..waitForStop();
+               vexi.log.error("BOO!");
+       };
+               /*tc.waitForHalt();
+               */
+       <ui:box/>
+</vexi>

Added: core/trunk/org.vexi.devl/src_junit/test/debug/testclient.t
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/testclient.t                  
        (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/testclient.t  2007-03-16 
20:41:32 UTC (rev 1739)
@@ -0,0 +1,116 @@
+<vexi xmlns:ui="vexi://ui"
+        xmlns=""
+        xmlns:model="org.vexi.debugclient.core.model"
+        xmlns:server="org.vexi.debugclient.core.server">
+       static.waitFor = function(expected){
+               while(true){
+                       try{
+                               server..syncState();
+                               vexi.log.info(model..status);
+                               if(model..status=="halted" || 
model..status=="stopped"){
+                                       
.util..assertEquals(expected,model..status);
+                                       return;
+                               }
+                       }catch(e){
+                               if(e.type=="xmlrpc"){
+                                       vexi.log.error("debuggee xmlrpc server 
not up yet");
+                                       vexi.thread.sleep(100);
+                                       continue;
+                               }
+                               vexi.log.error("e.type: " + e.type);
+                               vexi.log.error(e);
+                               throw e;
+                       };
+               }
+       };
+       
+       static.waitForHalt = function(){
+               waitFor("halted");
+       };
+       
+       static.waitForStop = function(){
+               waitFor("stopped");
+       };
+       
+       static.stepOver = function(){
+               server..stepOver();
+       };
+       
+       static.resume = function(){
+               server..resume();
+       };
+               
+       static.restart = function(){
+               server..restart();
+       };
+       
+       static.setBreakPoint = function(srcName,ln){
+               assert(server.._setBreakPoint(srcName, ln));
+       };
+       
+       static.assertBreakPoint = function(pos){
+               assert(model.breakPoints[pos]);
+       };
+       
+       static.assertPosition = function(pos){
+               var currentPos = model..breakPosition;
+               assert(currentPos!=null);
+               .util..assertEquals(pos, currentPos.toString);
+       };
+       
+       var callStackToString = function(cs){
+               if(cs.length==0)return "";
+               var r = cs[0].srcName + ":" + cs[0].ln;
+               for(var i=1; cs.length>i; i++){
+                       r += "," + cs[i].srcName + ":" + cs[i].ln;
+               }
+               return r;
+       };
+       
+       var assertCallStack = function(expected, actual){
+               assert(actual!=null);
+               vexi.log.info("expected " + expected);
+               try{
+                       .util..assertEquals(expected.length,actual.length);
+                       for(var i=0; expected.length>i; i++){
+                               .util..assertEquals(expected[i], 
actual[i].srcName + ":" + actual[i].ln);
+                       }
+               }catch(e){
+                       vexi.log.info("expected " + expected.join(","));
+                       vexi.log.info("actual " + callStackToString(actual));
+                       throw e;
+               }
+       };
+       
+       static.assertCurrentStack = function(expected){
+               var actual = model..currentThread.callStack;
+               assertCallStack(expected,actual);
+       };
+       
+       static.assertScheduledStacks = function(expected2){
+               var actual2 = model..scheduledThreads;
+               .util..assertEquals(expected2.length,actual2.length);
+               for(var i=0; expected2.length>i; i++){
+                       var expected = expected2[i];
+                       var actual = actual2[i].callStack;
+                       assertCallStack(expected,actual);
+               }
+       };
+       
+       static.assertCurrentName = function(expected){
+               .util..assertEquals(expected,
+                                       model..currentThread.name);
+       };
+       
+       static.assertScheduledNames = function(expected2){
+               var actual2 = model..scheduledThreads;
+               .util..assertEquals(expected2.length,actual2.length);
+               for(var i=0; expected2.length>i; i++){
+                       var expected = expected2[i];
+                       var actual = actual2[i].name;
+                       .util..assertEquals(expected, actual);
+               }
+       };
+       
+       <ui:box/>
+</vexi>

Modified: core/trunk/org.vexi.devl/src_junit/test/debug/thread/TestThread.java
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/thread/TestThread.java        
2007-03-16 18:25:34 UTC (rev 1738)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/thread/TestThread.java        
2007-03-16 20:41:32 UTC (rev 1739)
@@ -1,28 +1,29 @@
 package test.debug.thread;
 
-import test.debug.DebuggerTest;
+import junit.framework.Test;
+import test.core.CoreTestSuite;
+import test.debug.DebuggerTestSuite;
 
-public class TestThread extends DebuggerTest {
+public class TestThread extends DebuggerTestSuite {
 
-       public TestThread() {
-               super();
+       protected TestThread() {
+               super(TestThread.class);
        }
-       
+
        // Main method to just execute client (so server can be manually 
executed
        // as a debugable process.
        public static void main(String[] args) throws Exception {
-               TestThread t = new TestThread();
-               t.setUpClient();
-               try{
-                       t.testSwitchingThreads();
-               }finally{
-                       t.tearDown();
-               }
+               new TestThread().run("testSwitchingThreads");
        }
        
+       public static Test suite(){
+       return CoreTestSuite.suite(new TestThread());
+    }
+       
        ///////////
        // TESTS
        ////////
+       /*
        public void testSwitchingThreads() throws Exception{
                tc.waitForHalt();
                tc.assertCurrentThread("main:1");
@@ -52,6 +53,6 @@
                tc.resume();
                tc.waitForStop();
                
-       }
+       }*/
        
 }

Added: 
core/trunk/org.vexi.devl/src_junit/test/debug/thread/testSwitchingThreads.t
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/thread/testSwitchingThreads.t 
                        (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/thread/testSwitchingThreads.t 
2007-03-16 20:41:32 UTC (rev 1739)
@@ -0,0 +1,57 @@
+<vexi xmlns:ui="vexi://ui" xmlns:tc="testclient" xmlns="">
+       static.runtest = function(){
+               tc..waitForHalt();
+               tc..assertCurrentStack(["main:3"]);
+               tc..assertPosition("main:3");
+               tc..setBreakPoint("main", 6);
+               tc..setBreakPoint("main", 13);
+               tc..resume();
+               tc..waitForHalt();
+               tc..assertCurrentStack(["main:6"]);
+               tc..assertScheduledStacks([[]]);
+               tc..stepOver();
+               tc..waitForHalt();
+               tc..stepOver();
+               tc..waitForHalt();
+               //tc..assertCurrentThread("main:11");
+               tc..assertPosition("main:13");
+               tc..assertScheduledStacks([["main:7"]]);
+               tc..assertCurrentStack(["main:17","main:13"]);
+               tc..resume();
+               tc..waitForHalt();
+               tc..assertCurrentName("main:5");
+               tc..assertScheduledNames(["main:11"]);
+               tc..assertCurrentStack(["main:8"]);
+               tc..assertPosition("main:8");
+               tc..resume();
+               tc..waitForStop();
+       };
+/*             tc.waitForHalt();
+               tc.assertCurrentThread("main:1");
+               tc.assertPosition("main", 3);
+               tc.setBreakPoint("main", 6);
+               tc.setBreakPoint("main", 13);
+               tc.resume();
+               tc.waitForHalt();
+               tc.assertCurrentThread("main:5");
+               tc.assertScheduledStacks(new String[]{});
+               tc.assertCallStack(new String[]{"main:6"});
+               tc.assertPosition("main", 6);
+               tc.stepOver();
+               tc.waitForHalt();
+               tc.stepOver();
+               tc.waitForHalt();
+               tc.assertCurrentThread("main:11");
+               tc.assertPosition("main", 13);
+               tc.assertScheduledStacks(new String[]{"main:5"});
+               tc.assertCallStack(new String[]{"main:17","main:13"});
+               tc.resume();
+               tc.waitForHalt();
+               tc.assertCurrentThread("main:5");
+               tc.assertScheduledStacks(new String[]{"main:11"});
+               tc.assertCallStack(new String[]{"main:8"});
+               tc.assertPosition("main", 8);
+               tc.resume();
+               tc.waitForStop();*/
+       <ui:box/>
+</vexi>

Modified: core/trunk/org.vexi.devl/src_junit/test/debug/vars/TestVars.java
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/vars/TestVars.java    
2007-03-16 18:25:34 UTC (rev 1738)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/vars/TestVars.java    
2007-03-16 20:41:32 UTC (rev 1739)
@@ -1,31 +1,24 @@
 package test.debug.vars;
 
-import test.debug.DebuggerTest;
+import test.debug.DebuggerTestSuite;
 
-public class TestVars extends DebuggerTest {
+public class TestVars extends DebuggerTestSuite {
 
-       public TestVars() {
-               super();
+       protected TestVars() {
+               super(TestVars.class);
        }
        
        // Main method to just execute client (so server can be manually 
executed
        // as a debugable process.
        public static void main(String[] args) throws Exception {
-               TestVars t = new TestVars();
-               t.killPrevious();
-               t.setUpClient();
-               try{
-                       t.testVarsFromPrevious();
-               }finally{
-                       t.tearDown();
-               }
+               new TestVars().run("testSwitchingThreads");
        }
        
        
        ///////////
        // TESTS
        ////////
-       
+       /*
        private void assertBeforeC(VarInfo vi){
                
                vi.assertVar("a",new Integer(1));
@@ -106,6 +99,6 @@
                assertInsideC(vi);
                
                tc.resume();tc.waitForStop();
-       }
+       }*/
        
 }

Added: core/trunk/org.vexi.devl/src_junit/test/debug/vars/shared.t
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/vars/shared.t                 
        (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/vars/shared.t 2007-03-16 
20:41:32 UTC (rev 1739)
@@ -0,0 +1,25 @@
+<vexi xmlns:ui="vexi://ui" xmlns:tc="testclient"
+         xmlns:model="org.vexi.debugclient.core.model"
+         xmlns="">
+         
+         
+        /* 
+       private void assertBeforeC(VarInfo vi){
+               
+               vi.assertVar("a",new Integer(1));
+               vi.assertVar("b","b");
+               vi.assertVar("c",null, VARTYPE_FUNCTION);
+               // FEATURE - don't display uninitialized/undeclared variables 
somehow
+               vi.assertVar("f", null); //tc.assertNoVar("f");
+               vi.assertNoVar("d");
+               vi.assertNoVar("e");
+       }
+       
+       private void assertInsideC(VarInfo vi){
+               vi.assertVar("a",new Integer(1));
+               vi.assertVar("b","b");
+               vi.assertVar("c",null, VARTYPE_FUNCTION);
+               vi.assertVar("d","d");
+       }*/
+       <ui:box/>
+</vexi>

Added: core/trunk/org.vexi.devl/src_junit/test/debug/vars/testVars.t
===================================================================
--- core/trunk/org.vexi.devl/src_junit/test/debug/vars/testVars.t               
                (rev 0)
+++ core/trunk/org.vexi.devl/src_junit/test/debug/vars/testVars.t       
2007-03-16 20:41:32 UTC (rev 1739)
@@ -0,0 +1,23 @@
+<vexi xmlns:ui="vexi://ui" xmlns:tc="testclient"
+         xmlns:model="org.vexi.debugclient.core.model"
+         xmlns="">
+       static.runtest = function(){
+               tc..waitForHalt();
+               tc..assertPosition("main:2");
+               var x;
+               model..breakPointAdded ++=function(v){
+                       x = v.toString;
+               };
+               tc..setBreakPoint("main", 7);
+               tc..assertBreakPoint("main:7");
+               .util..assertEquals("main:7",x);
+               tc..resume();
+               tc..waitForHalt();
+               tc..assertPosition("main:7");
+               tc..resume();
+               tc..waitForStop();
+               
+       };
+
+       <ui:box/>
+</vexi>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to