Fix problems with tests
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 20 Sep 2013 12:48:19 +0000 (13:48 +0100)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 20 Sep 2013 12:48:19 +0000 (13:48 +0100)
testsrc/compbio/engine/conf/RunnerConfigMarshallerTester.java
testsrc/compbio/metadata/OptionMarshallerTester.java
testsrc/compbio/metadata/RunnerConfigTester.java

index 9dc53c2..2263857 100644 (file)
@@ -78,9 +78,7 @@ public class RunnerConfigMarshallerTester {
                    "Type of the sequence (PROTEIN or DNA)");\r
            // TODO publish help on a compbio web site\r
 \r
-           p1.setFurtherDetails(new URL("http",\r
-                   "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                   "Index.html"));\r
+           p1.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
            p1.addPossibleValues("PROTEIN", "DNA");\r
            p1.setOptionName("-TYPE");\r
            p1.setRequired(false);\r
@@ -93,9 +91,7 @@ public class RunnerConfigMarshallerTester {
                    "Protein weight matrix");\r
            // TODO publish help on a compbio web site\r
 \r
-           p2.setFurtherDetails(new URL("http",\r
-                   "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                   "Index.html"));\r
+           p2.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
            p2.addOptionNames("-jtree"); // "-retree"\r
            p2.setRequired(false);\r
@@ -103,9 +99,7 @@ public class RunnerConfigMarshallerTester {
            Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1",\r
                    "Protein weight matrix");\r
            // TODO publish help on a compbio web site\r
-           p3.setFurtherDetails(new URL("http",\r
-                   "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                   "Index.html"));\r
+           p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
            p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID");\r
            // This attribute is required by strict schema\r
index 900d6d7..a98a171 100644 (file)
@@ -71,9 +71,7 @@ public class OptionMarshallerTester {
                    "Type of the sequence (PROTEIN or DNA)");\r
            // TODO publish help on a compbio web site\r
 \r
-           p1.setFurtherDetails(new URL("http",\r
-                   "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                   "Index.html"));\r
+           p1.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
            p1.addPossibleValues("PROTEIN", "DNA");\r
            p1.setOptionName("-TYPE");\r
            p1.setRequired(false);\r
@@ -86,9 +84,7 @@ public class OptionMarshallerTester {
                    "Protein weight matrix");\r
            // TODO publish help on a compbio web site\r
 \r
-           p2.setFurtherDetails(new URL("http",\r
-                   "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                   "Index.html"));\r
+           p2.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
            p2.addOptionNames("-jtree");\r
            p2.addOptionNames("-jfasta");\r
@@ -97,9 +93,7 @@ public class OptionMarshallerTester {
            Parameter<Mafft> p3 = new Parameter<Mafft>("MATRIX2",\r
                    "Protein weight matrix");\r
            // TODO publish help on a compbio web site\r
-           p3.setFurtherDetails(new URL("http",\r
-                   "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                   "Index.html"));\r
+           p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
            p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID");\r
            // This attribute is required by strict schema\r
@@ -159,56 +153,49 @@ public class OptionMarshallerTester {
     @Test()\r
     public void testUnMarshalling() {\r
        try {\r
-           File input = new File(this.test_input);\r
-           assertTrue(input.exists());\r
-           JAXBContext ctx = JAXBContext.newInstance(RunnerConfig.class);\r
-           Unmarshaller um = ctx.createUnmarshaller();\r
-           JAXBElement<RunnerConfig> rconfig = um.unmarshal(new StreamSource(\r
-                   input), RunnerConfig.class);\r
-           RunnerConfig<Mafft> runner = rconfig.getValue();\r
-           assertNotNull(runner);\r
-           System.out.println(runner);\r
-           assertFalse(runner.options.isEmpty());\r
-           assertFalse(runner.parameters.isEmpty());\r
-           assertEquals(7, runner.options.size());\r
-           assertEquals(8, runner.parameters.size());\r
-           Option<Mafft> stypeOption = runner.getArgument("Sequence type");\r
-           System.out.println(stypeOption);\r
-           assertNotNull(stypeOption);\r
-           assertFalse(stypeOption.isRequired);\r
-           assertEquals("--auto", stypeOption.defaultValue);\r
-           assertEquals(2, stypeOption.optionNames.size());\r
-\r
-           assertEquals(" ", runner.getPrmSeparator());\r
-           Option<Mafft> guidetrOption = runner\r
-                   .getArgument("Guide tree rebuild");\r
-           Parameter<Mafft> guidetr = (Parameter<Mafft>) guidetrOption;\r
-           ValueConstrain constraint = guidetr.getValidValue();\r
-           assertEquals("Integer", constraint.type.toString());\r
-           assertEquals(1, constraint.getMin());\r
-           assertEquals(100, constraint.getMax());\r
-\r
-           RunnerConfigMarshaller<Mafft> rmarsh = new RunnerConfigMarshaller<Mafft>(\r
-                   RunnerConfig.class);\r
-           // Now see if we can write a valid document back discard the actual\r
-           // output only validation is important here\r
-           rmarsh.write(rconfig,\r
-                   new FileOutputStream(new File(reWrittenInput)));\r
-\r
-           RunnerConfig<Mafft> rc = rmarsh.readAndValidate(\r
-                   new FileInputStream(new File(reWrittenInput)),\r
-                   RunnerConfig.class);\r
-           assertEquals(runner, rc);\r
+               File input = new File(this.test_input);\r
+               assertTrue(input.exists());\r
+               JAXBContext ctx = JAXBContext.newInstance(RunnerConfig.class);\r
+               Unmarshaller um = ctx.createUnmarshaller();\r
+               JAXBElement<RunnerConfig> rconfig = um.unmarshal(new StreamSource(input), RunnerConfig.class);\r
+               RunnerConfig<Mafft> runner = rconfig.getValue();\r
+               assertNotNull(runner);\r
+               System.out.println(runner);\r
+               assertFalse(runner.options.isEmpty());\r
+               assertFalse(runner.parameters.isEmpty());\r
+               assertEquals(7, runner.options.size());\r
+               assertEquals(8, runner.parameters.size());\r
+               Option<Mafft> stypeOption = runner.getArgument("Sequence type");\r
+               System.out.println(stypeOption);\r
+               assertNotNull(stypeOption);\r
+               assertFalse(stypeOption.isRequired);\r
+               assertEquals("--auto", stypeOption.defaultValue);\r
+               assertEquals(2, stypeOption.optionNames.size());\r
+\r
+               assertEquals(" ", runner.getPrmSeparator());\r
+               Option<Mafft> guidetrOption = runner.getArgument("Guide tree rebuild");\r
+               Parameter<Mafft> guidetr = (Parameter<Mafft>) guidetrOption;\r
+               ValueConstrain constraint = guidetr.getValidValue();\r
+               assertEquals("Integer", constraint.type.toString());\r
+               assertEquals(1, constraint.getMin());\r
+               assertEquals(100, constraint.getMax());\r
+\r
+               RunnerConfigMarshaller<Mafft> rmarsh = new RunnerConfigMarshaller<Mafft>(RunnerConfig.class);\r
+               // Now see if we can write a valid document back discard the actual\r
+               // output only validation is important here\r
+               rmarsh.write(rconfig, new FileOutputStream(new File(reWrittenInput)));\r
+               RunnerConfig<Mafft> rc = rmarsh.readAndValidate(new FileInputStream(new File(reWrittenInput)), RunnerConfig.class);\r
+               assertEquals(runner, rc);\r
 \r
        } catch (JAXBException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
+               e.printStackTrace();\r
+               fail(e.getLocalizedMessage());\r
        } catch (IOException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
+               e.printStackTrace();\r
+               fail(e.getLocalizedMessage());\r
        } catch (SAXException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
+               e.printStackTrace();\r
+               fail(e.getLocalizedMessage());\r
        }\r
     }\r
 }\r
index 087ead6..3bf2368 100644 (file)
@@ -77,12 +77,9 @@ public class RunnerConfigTester {
        @Test(expectedExceptions = WrongParameterException.class)\r
        public void testCreateParameter() throws WrongParameterException {\r
                try {\r
-                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1",\r
-                                       "Protein weight matrix");\r
+                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
                        // TODO publish help on a compbio web site\r
-                       p3.setFurtherDetails(new URL("http",\r
-                                       "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                                       "Index.html"));\r
+                       p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
                        p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID");\r
                        // This attribute is required by strict schema\r
@@ -102,12 +99,9 @@ public class RunnerConfigTester {
        @Test()\r
        public void testParameterToCommand() throws WrongParameterException {\r
                try {\r
-                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1",\r
-                                       "Protein weight matrix");\r
+                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
                        // TODO publish help on a compbio web site\r
-                       p3.setFurtherDetails(new URL("http",\r
-                                       "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                                       "Index.html"));\r
+                       p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
                        p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID");\r
                        // This attribute is required by strict schema\r
@@ -124,7 +118,6 @@ public class RunnerConfigTester {
                        com = p3.toCommand("=");\r
                        assertFalse(com.endsWith("PAM"));\r
                        assertFalse(com.contains("PAM"));\r
-\r
                } catch (MalformedURLException e) {\r
                        e.printStackTrace();\r
                        fail(e.getMessage());\r
@@ -134,20 +127,15 @@ public class RunnerConfigTester {
        @Test(expectedExceptions = ValidationException.class)\r
        public void testOptionNoDefaultValidate() throws ValidationException {\r
                try {\r
-                       Option<Mafft> p3 = new Option<Mafft>("Matrix1",\r
-                                       "Protein weight matrix");\r
+                       Option<Mafft> p3 = new Option<Mafft>("Matrix1", "Protein weight matrix");\r
                        // TODO publish help on a compbio web site\r
-                       p3.setFurtherDetails(new URL("http",\r
-                                       "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                                       "Index.html"));\r
+                       p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
-                       p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX",\r
-                                       "--ABMAT", "--BBBB")));\r
+                       p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX", "--ABMAT", "--BBBB")));\r
                        p3.setRequired(true);\r
                        // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED\r
                        // IN WITHIN POSSIBLE VALUES\r
                        p3.validate();\r
-\r
                } catch (MalformedURLException e) {\r
                        e.printStackTrace();\r
                        fail(e.getMessage());\r
@@ -157,20 +145,15 @@ public class RunnerConfigTester {
        @Test(expectedExceptions = WrongParameterException.class)\r
        public void testOptionSetInvalidValue() throws WrongParameterException {\r
                try {\r
-                       Option<Mafft> p3 = new Option<Mafft>("Matrix1",\r
-                                       "Protein weight matrix");\r
+                       Option<Mafft> p3 = new Option<Mafft>("Matrix1", "Protein weight matrix");\r
                        // TODO publish help on a compbio web site\r
-                       p3.setFurtherDetails(new URL("http",\r
-                                       "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                                       "Index.html"));\r
+                       p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
-                       p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX",\r
-                                       "--ABMAT", "--BBBB")));\r
+                       p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX", "--ABMAT", "--BBBB")));\r
                        p3.setRequired(true);\r
                        // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED\r
                        // IN WITHIN POSSIBLE VALUES\r
                        p3.setDefaultValue("AAA");\r
-\r
                } catch (MalformedURLException e) {\r
                        e.printStackTrace();\r
                        fail(e.getMessage());\r
@@ -180,15 +163,11 @@ public class RunnerConfigTester {
        @Test()\r
        public void testOptionToCommand() {\r
                try {\r
-                       Option<Mafft> p3 = new Option<Mafft>("Matrix1",\r
-                                       "Protein weight matrix");\r
+                       Option<Mafft> p3 = new Option<Mafft>("Matrix1", "Protein weight matrix");\r
                        // TODO publish help on a compbio web site\r
-                       p3.setFurtherDetails(new URL("http",\r
-                                       "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                                       "Index.html"));\r
+                       p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
 \r
-                       p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX",\r
-                                       "--ABMAT", "--BBBB")));\r
+                       p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX", "--ABMAT", "--BBBB")));\r
                        p3.setRequired(true);\r
                        // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED\r
                        // IN WITHIN POSSIBLE VALUES\r
@@ -212,10 +191,9 @@ public class RunnerConfigTester {
        }\r
 \r
        @Test(expectedExceptions = IllegalStateException.class)\r
-       public void testCreateNumParameterWithoutValidValue() {\r
+       public void testCreateNumParameterWithoutValidValue() throws MalformedURLException {\r
                try {\r
-                       Parameter<Mafft> p4 = new Parameter<Mafft>("Matrix",\r
-                                       "DNA weight matrix");\r
+                       Parameter<Mafft> p4 = new Parameter<Mafft>("Matrix", "DNA weight matrix");\r
                        // This is causing exception is ValidValue constrain is not defined\r
                        // for\r
                        // numeric value\r
@@ -228,10 +206,8 @@ public class RunnerConfigTester {
        }\r
 \r
        @Test()\r
-       public void testCreateParameterWithValidValueConstrain() {\r
-\r
-               Parameter<Mafft> p4 = new Parameter<Mafft>("Matrix",\r
-                               "DNA weight matrix");\r
+       public void testCreateParameterWithValidValueConstrain() throws MalformedURLException {\r
+               Parameter<Mafft> p4 = new Parameter<Mafft>("Matrix", "DNA weight matrix");\r
                ValueConstrain vc = new ValueConstrain();\r
                vc.setType(ValueConstrain.Type.Float);\r
                vc.setMin("0");\r
@@ -249,12 +225,9 @@ public class RunnerConfigTester {
        public void testValidateLowerBoundaryConstrainCheck()\r
                        throws WrongParameterException {\r
                try {\r
-                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1",\r
-                                       "Protein weight matrix");\r
+                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
                        // TODO publish help on a compbio web site\r
-                       p3.setFurtherDetails(new URL("http",\r
-                                       "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                                       "Index.html"));\r
+                       p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
                        // This attribute is required by strict schema\r
                        p3.setOptionName("--AAMATRIX");\r
                        p3.setRequired(true);\r
@@ -266,7 +239,6 @@ public class RunnerConfigTester {
                        p3.setValidValue(vc);\r
                        // THIS IS CAUSING EXCEPTION\r
                        p3.setDefaultValue("-11.0");\r
-\r
                } catch (MalformedURLException e) {\r
                        e.printStackTrace();\r
                        fail(e.getMessage());\r
@@ -277,12 +249,9 @@ public class RunnerConfigTester {
        public void testValidateUpperBoundaryConstrainCheck()\r
                        throws WrongParameterException {\r
                try {\r
-                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1",\r
-                                       "Protein weight matrix");\r
+                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
                        // TODO publish help on a compbio web site\r
-                       p3.setFurtherDetails(new URL("http",\r
-                                       "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                                       "Index.html"));\r
+                       p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
                        // This attribute is required by strict schema\r
                        p3.setOptionName("--AAMATRIX");\r
                        p3.setRequired(true);\r
@@ -294,7 +263,6 @@ public class RunnerConfigTester {
                        p3.setValidValue(vc);\r
                        // THIS IS CAUSING EXCEPTION\r
                        p3.setDefaultValue("1");\r
-\r
                } catch (MalformedURLException e) {\r
                        e.printStackTrace();\r
                        fail(e.getMessage());\r
@@ -304,12 +272,9 @@ public class RunnerConfigTester {
        @Test()\r
        public void testValidateBoundaryConstrainCheck() {\r
                try {\r
-                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1",\r
-                                       "Protein weight matrix");\r
+                       Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
                        // TODO publish help on a compbio web site\r
-                       p3.setFurtherDetails(new URL("http",\r
-                                       "www.compbio.dundee.ac.uk/users/pvtroshin/ws/",\r
-                                       "Index.html"));\r
+                       p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
                        // This attribute is required by strict schema\r
                        p3.setOptionName("--AAMATRIX");\r
                        p3.setRequired(true);\r