* Better exceptions used in the tests 30/1930/3
Sylvestre Ledru [Tue, 14 Sep 2010 16:34:23 +0000 (18:34 +0200)]
* Provide exception AlreadyRunningException (was missing from a previous commit)

Change-Id: I818265237c8252a70db0e130c126c2a1c1501996

scilab/modules/javasci/src/java/org/scilab/modules/javasci/JavasciException.java
scilab/modules/javasci/tests/java/org/scilab/tests/modules/javasci/testErrorManagement.java
scilab/modules/javasci/tests/java/org/scilab/tests/modules/javasci/testExec.java
scilab/modules/javasci/tests/java/org/scilab/tests/modules/javasci/testExistingVariable.java
scilab/modules/javasci/tests/java/org/scilab/tests/modules/javasci/testOpenClose.java
scilab/modules/javasci/tests/java/org/scilab/tests/modules/javasci/testReadWrite.java
scilab/modules/javasci/tests/java/org/scilab/tests/modules/javasci/testReadWriteInteger.java
scilab/modules/types/tests/java/org/scilab/tests/modules/types/testEquals.java

index 48592ac..d78bf7b 100644 (file)
@@ -33,7 +33,13 @@ public abstract class JavasciException extends Exception {
                public UnsupportedTypeException(String message) {
                        super(message);
                }
+       }
+
+       public static class AlreadyRunningException extends JavasciException {
 
+               public AlreadyRunningException(String message) {
+                       super(message);
+               }
        }
 
        public static class ScilabInternalException extends JavasciException {
index d51b39e..1dc4165 100644 (file)
@@ -30,7 +30,7 @@ public class testErrorManagement {
         * would fail.
         */ 
        @BeforeMethod
-       public void open() throws NullPointerException, InitializationException {
+       public void open() throws NullPointerException, JavasciException {
                sci = new Scilab();
         assert sci.open() == true;
 
@@ -38,7 +38,7 @@ public class testErrorManagement {
 
 
        @Test(sequential = true)
-    public void getLastErrorCodeTest() throws NullPointerException, InitializationException {
+    public void getLastErrorCodeTest() throws NullPointerException, JavasciException {
         assert sci.getLastErrorCode() == 0; // No error
                sci.close();
 
@@ -51,7 +51,7 @@ public class testErrorManagement {
     }
 
        @Test(sequential = true)
-    public void getLastErrorMessageTest() throws NullPointerException, InitializationException {
+    public void getLastErrorMessageTest() throws NullPointerException, JavasciException {
         sci.exec("errclear();"); // No error by default
         assert sci.getLastErrorMessage().equals("");
         assert sci.getLastErrorMessage().length() == 0;
index 64bd6d5..2782b42 100644 (file)
@@ -35,7 +35,7 @@ public class testExec {
         * would fail.
         */ 
        @BeforeMethod
-       public void open() throws NullPointerException, InitializationException {
+       public void open() throws NullPointerException, JavasciException {
                sci = new Scilab();
         assert sci.open() == true;
        }
@@ -79,7 +79,12 @@ public class testExec {
         ScilabType sumMatrix = sci.get("sumMatrix");
         /* Compare if they match */
         assert ((ScilabDouble)sumMatrix).getRealPart()[0][0] == sum;
-
+sci.exec("b = matrix(1:100,10,10)") ;
+ScilabType b2 = sci.get("b");
+b2.getHeight(); // 10 
+b2.getWidth(); // 10
+ScilabDouble b3 = (ScilabDouble)sci.get("b");
+assert b3.equals(b2);
     }
 
 
@@ -109,7 +114,7 @@ public class testExec {
     }
 
     @Test(sequential = true, expectedExceptions = FileNotFoundException.class)
-    public void execFromNonExistingFileTest() throws NullPointerException, InitializationException, FileNotFoundException {
+    public void execFromNonExistingFileTest() throws NullPointerException, InitializationException, FileNotFoundException, JavasciException {
                sci.close();
 
         File nonExistingFile = new File("/wrong/path/file");
index c28b8cb..5187a2f 100644 (file)
@@ -31,7 +31,7 @@ public class testExistingVariable {
         * would fail.
         */ 
        @BeforeMethod
-       public void open() throws NullPointerException, InitializationException {
+       public void open() throws NullPointerException, JavasciException {
                sci = new Scilab();
         assert sci.open() == true;
        }
index 4595d3c..87bcee0 100644 (file)
@@ -34,33 +34,33 @@ public class testOpenClose {
         * would fail.
         */ 
        @BeforeMethod
-       public void openTest() throws NullPointerException, InitializationException {
+       public void openTest() throws NullPointerException, JavasciException {
                sci = new Scilab();
                assert sci.open() == true;
        }
 
        @Test(sequential = true)
-       public void multipleOpenCloseTest() throws NullPointerException, InitializationException {
+       public void multipleOpenCloseTest() throws NullPointerException, JavasciException {
                assert sci.close() == true;
                assert sci.open() == true;
                assert sci.close() == true;
        }
 
-       @Test(sequential = true, expectedExceptions = InitializationException.class)
-       public void specificWrongSCIPathTest() throws NullPointerException, InitializationException {
+       @Test(sequential = true, expectedExceptions = JavasciException.class)
+       public void specificWrongSCIPathTest() throws NullPointerException, JavasciException {
                assert sci.close() == true;
                sci = new Scilab(System.getProperty("java.io.tmpdir")+"/non-existing-directory-scilab/");
        }
 
 
        @Test(sequential = true)
-       public void specificPropertySCIPathTest() throws NullPointerException, InitializationException {
+       public void specificPropertySCIPathTest() throws NullPointerException, JavasciException {
                assert sci.close() == true;
                sci = new Scilab(System.getProperty("SCI"));
        }
 
        @Test(sequential = true)
-       public void specificEnvSCIPathTest() throws NullPointerException, InitializationException {
+       public void specificEnvSCIPathTest() throws NullPointerException, JavasciException {
                assert sci.close() == true;
                String SCIPath = System.getProperty("SCI"); // Temp backup to set it again
                System.clearProperty("SCI"); // Remove the property to check it is using the variable
@@ -93,8 +93,8 @@ public class testOpenClose {
                assert ((ScilabBoolean)c).getData()[0][0] == false;
        }
 
-       @Test(sequential = true, expectedExceptions = InitializationException.class)
-       public void OpenMultipleTimeTest() throws NullPointerException, InitializationException {
+       @Test(sequential = true, expectedExceptions = JavasciException.class)
+       public void OpenMultipleTimeTest() throws NullPointerException, JavasciException {
                assert sci.open("a=42*2;") == true;
 
        }
index 8a3308f..f4fe4e4 100644 (file)
@@ -35,7 +35,7 @@ public class testReadWrite {
         * would fail.
         */ 
        @BeforeMethod
-       public void open() throws NullPointerException, InitializationException {
+       public void open() throws NullPointerException, JavasciException {
                sci = new Scilab();
         assert sci.open() == true;
        }
index 273efeb..05895bc 100644 (file)
@@ -31,7 +31,7 @@ public class testReadWriteInteger {
         * would fail.
         */ 
        @BeforeMethod
-       public void open() throws NullPointerException, InitializationException {
+       public void open() throws NullPointerException, JavasciException {
                sci = new Scilab();
         assert sci.open() == true;
        }
index f5cf928..d1fb267 100644 (file)
@@ -439,7 +439,7 @@ public class testEquals {
                data3.add(new ScilabBoolean(true));
                assert data.equals(data2) == true;
                assert data.equals(data3) == false;
-               System.out.println("mlist " + data);
+
                assert data.toString().equals("mlist([\"hello\"], [2.0], [51.0])") == true;
                assert data3.toString().equals("mlist([\"hello\"], [2.0], [42.0], [%t])") == true;
                String []b={"a","b","c"};