Revision: 1681
          http://svn.sourceforge.net/vexi/?rev=1681&view=rev
Author:   mkpg2
Date:     2007-02-16 21:54:50 -0800 (Fri, 16 Feb 2007)

Log Message:
-----------
Refactoring test code a little. Principally to enable passing arguments into 
testcases

Modified Paths:
--------------
    core/trunk/org.vexi.core/src_junit/test/core/CoreTestCase.java
    
core/trunk/org.vexi.core/src_junit/test/core/linenumbering/TestLineNumbering.java

Added Paths:
-----------
    core/trunk/org.vexi.core/src_junit/test/core/Util.java

Modified: core/trunk/org.vexi.core/src_junit/test/core/CoreTestCase.java
===================================================================
--- core/trunk/org.vexi.core/src_junit/test/core/CoreTestCase.java      
2007-02-17 04:29:36 UTC (rev 1680)
+++ core/trunk/org.vexi.core/src_junit/test/core/CoreTestCase.java      
2007-02-17 05:54:50 UTC (rev 1681)
@@ -30,20 +30,21 @@
                super(resourceDir, templateFileName.replace(".t", ""));
        }
        
+       protected String getSharedDir(){
+               return CoreTestCase.class.getResource("shared").getPath();
+       }
+       
        protected void runTest() throws Throwable {
         Platform.forceLoad();
-        String sharedDir = getClass().getResource("shared").getPath();
+        String sharedDir = getSharedDir();
                final Vexi v = DevUtil.createVexi(new String[]{sharedDir, 
resourceDir});
 
-
-               Scheduler.add(new Callable(){
-                       public Object run(Object o) throws Exception {
-                               Log.uInfo(CoreTestCase.class, "invoking initial 
template: "+ main);
-                               Vexi.resolveString(v, main, false).call(null, 
new JS[]{new Box()});
-                               return null;
-                       }
-               });
-
+               
+               
+               schedule(v);
+       
+               
+               
                // Start scheduler
         Exception e = (Exception)Scheduler.init(new Scheduler(true));
         if(e != null){
@@ -52,4 +53,14 @@
         }
                
        }
+       
+       protected void schedule(final Vexi v) throws Exception{
+               Scheduler.add(new Callable(){
+                       public Object run(Object o) throws Exception {
+                               Log.uInfo(CoreTestCase.class, "invoking initial 
template: "+ main);
+                               Vexi.resolveString(v, main, false).call(null, 
new JS[]{new Box()});
+                               return null;
+                       }
+               });
+       }
 }

Added: core/trunk/org.vexi.core/src_junit/test/core/Util.java
===================================================================
--- core/trunk/org.vexi.core/src_junit/test/core/Util.java                      
        (rev 0)
+++ core/trunk/org.vexi.core/src_junit/test/core/Util.java      2007-02-17 
05:54:50 UTC (rev 1681)
@@ -0,0 +1,44 @@
+package test.core;
+
+import java.io.File;
+import java.util.StringTokenizer;
+
+import org.ibex.js.JS;
+import org.ibex.js.JSExn;
+import org.ibex.js.JSU;
+import org.vexi.core.Vexi;
+
+public class Util {
+
+       static private JS getStaticForTemplate(Vexi v, String template) throws 
JSExn{
+               JS blessing = v.getAndTriggerTraps(JSU.S(""));
+               StringTokenizer st = new StringTokenizer(template,".");
+               while(st.hasMoreTokens()){
+                       blessing=blessing.get(JSU.S(st.nextToken()));
+               }
+               JS r =blessing.get(JSU.S("")); 
+               return r;
+               
+       }
+       
+       static public JS getStatic(Vexi v, String template, String attribute) 
throws JSExn{
+               return getStaticForTemplate(v,template).get(JSU.S(attribute));
+       }
+       static public void putStatic(Vexi v, String template, String attribute, 
JS value) throws JSExn{
+               getStaticForTemplate(v,template).put(JSU.S(attribute),value);
+       }
+       
+       static public File createTmpDir(){
+               File tempDir = new File("_temp_");
+               tempDir.mkdir();
+               return tempDir;
+       }
+       /*
+       public static JS callStatic(Vexi v, String template, String attribute, 
JS[] args) throws JSExn {
+               JS function = getStatic(v,template,attribute);
+               // Call in a pausable thread.
+               return Thread.runInCurrent(function, args);
+       }*/
+
+
+}

Modified: 
core/trunk/org.vexi.core/src_junit/test/core/linenumbering/TestLineNumbering.java
===================================================================
--- 
core/trunk/org.vexi.core/src_junit/test/core/linenumbering/TestLineNumbering.java
   2007-02-17 04:29:36 UTC (rev 1680)
+++ 
core/trunk/org.vexi.core/src_junit/test/core/linenumbering/TestLineNumbering.java
   2007-02-17 05:54:50 UTC (rev 1681)
@@ -12,6 +12,7 @@
 import junit.framework.TestCase;
 import junit.framework.TestResult;
 import test.core.CoreTestSuite;
+import test.core.Util;
 
 /**
  * @author mike
@@ -24,8 +25,7 @@
                super(TestLineNumbering.class);
                
                File resourceDir = new 
File(TestLineNumbering.class.getResource(".").getPath());
-               tempDir = new File("_temp_");
-               tempDir.mkdir();
+               tempDir = Util.createTmpDir();
                
                File[] toPreprocess = resourceDir.listFiles();
                for(int i=0; i<toPreprocess.length; i++)


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