\r
public class RunnerConfigMarshallerTester {\r
\r
- public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE\r
- + "MafftParameters.xml";\r
- public static String test_schema_output = "RunnerConfigSchema.xml";\r
- public static String test_output = AllTestSuit.OUTPUT_DIR_ABSOLUTE\r
- + "MafftParameters.out.xml";\r
-\r
- public static String invalidDoc = AllTestSuit.TEST_DATA_PATH_ABSOLUTE\r
- + "InvalidMafftParameters.xml";\r
-\r
- RunnerConfig<Mafft> rconfig = null;\r
- Parameter<Mafft> matrixParam = null;\r
- RunnerConfigMarshaller<Mafft> pmarshaller = null;\r
-\r
- @BeforeMethod\r
- public void setup() {\r
- // write some parameters programmatically\r
- try {\r
- rconfig = new RunnerConfig<Mafft>();\r
- rconfig.setRunnerClassName(Mafft.class.getName());\r
- List<Option<Mafft>> prms = new ArrayList<Option<Mafft>>();\r
-\r
- Parameter<Mafft> p1 = new Parameter<Mafft>("Type",\r
- "Type of the sequence (PROTEIN or DNA)");\r
- // TODO publish help on a compbio web site\r
-\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
-\r
- /*\r
- * -MATRIX= :Protein weight matrix=BLOSUM, PAM, GONNET, ID or\r
- * filename\r
- */\r
- Option<Mafft> p2 = new Option<Mafft>("MATRIX",\r
- "Protein weight matrix");\r
- // TODO publish help on a compbio web site\r
-\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
-\r
- Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1",\r
- "Protein weight matrix");\r
- // TODO publish help on a compbio web site\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
- p3.setOptionName("--AAMATRIX");\r
- p3.setRequired(true);\r
- p3.setDefaultValue("pam");\r
- ValueConstrain vc = new ValueConstrain();\r
- vc.setType(ValueConstrain.Type.Float);\r
- vc.setMin("-10.12");\r
- vc.setMax("0");\r
- p3.setValidValue(vc);\r
-\r
- prms.add(p1);\r
- prms.add(p2);\r
- prms.add(p3);\r
- matrixParam = p3;\r
- rconfig.setOptions(prms);\r
-\r
- pmarshaller = new RunnerConfigMarshaller<Mafft>(RunnerConfig.class,\r
- Parameter.class, Option.class, ValueConstrain.class);\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (JAXBException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (WrongParameterException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
+ public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "MafftParameters.xml";\r
+ public static String test_schema_output = "RunnerConfigSchema.xml";\r
+ public static String test_output = AllTestSuit.OUTPUT_DIR_ABSOLUTE + "MafftParameters.out.xml";\r
+\r
+ public static String invalidDoc = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "InvalidMafftParameters.xml";\r
+\r
+ RunnerConfig<Mafft> rconfig = null;\r
+ Parameter<Mafft> matrixParam = null;\r
+ RunnerConfigMarshaller<Mafft> pmarshaller = null;\r
+\r
+ @BeforeMethod\r
+ public void setup() {\r
+ // write some parameters programmatically\r
+ try {\r
+ rconfig = new RunnerConfig<Mafft>();\r
+ rconfig.setRunnerClassName(Mafft.class.getName());\r
+ List<Option<Mafft>> prms = new ArrayList<Option<Mafft>>();\r
+\r
+ Parameter<Mafft> p1 = new Parameter<Mafft>("Type", "Type of the sequence (PROTEIN or DNA)");\r
+ // TODO publish help on a compbio web site\r
+\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
+\r
+ /*\r
+ * -MATRIX= :Protein weight matrix=BLOSUM, PAM, GONNET, ID or\r
+ * filename\r
+ */\r
+ Option<Mafft> p2 = new Option<Mafft>("MATRIX", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\r
+\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
+\r
+ Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\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
+ p3.setOptionName("--AAMATRIX");\r
+ p3.setRequired(true);\r
+ p3.setDefaultValue("pam");\r
+ ValueConstrain vc = new ValueConstrain();\r
+ vc.setType(ValueConstrain.Type.Float);\r
+ vc.setMin("-10.12");\r
+ vc.setMax("0");\r
+ p3.setValidValue(vc);\r
+\r
+ prms.add(p1);\r
+ prms.add(p2);\r
+ prms.add(p3);\r
+ matrixParam = p3;\r
+ rconfig.setOptions(prms);\r
+\r
+ pmarshaller = new RunnerConfigMarshaller<Mafft>(RunnerConfig.class, Parameter.class, Option.class, ValueConstrain.class);\r
+ } catch (JAXBException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (WrongParameterException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
+\r
}\r
\r
- }\r
-\r
- @Test()\r
- public void testMarshalling() {\r
-\r
- File outfile = new File(this.test_output);\r
- try {\r
- pmarshaller.write(rconfig, new FileOutputStream(outfile));\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (JAXBException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
+ @Test()\r
+ public void testMarshalling() {\r
+\r
+ File outfile = new File(this.test_output);\r
+ try {\r
+ pmarshaller.write(rconfig, new FileOutputStream(outfile));\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (JAXBException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
+ assertTrue("Output file expected, but nothing found!", outfile.exists());\r
+ outfile.delete();\r
}\r
- assertTrue("Output file expected, but nothing found!", outfile.exists());\r
- outfile.delete();\r
- }\r
-\r
- @Test()\r
- public void testUnMarshalling() {\r
-\r
- File outfile = new File(this.test_output);\r
- try {\r
- pmarshaller.write(rconfig, new FileOutputStream(outfile));\r
-\r
- RunnerConfig<?> rconfig = pmarshaller.read(new FileInputStream(\r
- outfile), RunnerConfig.class, Parameter.class,\r
- Option.class, ValueConstrain.class);\r
- assertNotNull(rconfig);\r
- assertEquals(rconfig.getParameters().size(), this.rconfig\r
- .getParameters().size());\r
- assertEquals(rconfig.getRunnerClassName(), this.rconfig\r
- .getRunnerClassName());\r
- assertTrue(matrixParam.equals(rconfig.getArgument("MATRIX1")));\r
- assertFalse(matrixParam.equals(rconfig.getArgument("Type")));\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (JAXBException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
+\r
+ @Test()\r
+ public void testUnMarshalling() {\r
+\r
+ File outfile = new File(this.test_output);\r
+ try {\r
+ pmarshaller.write(rconfig, new FileOutputStream(outfile));\r
+\r
+ RunnerConfig<?> rconfig = pmarshaller.read(new FileInputStream(outfile), RunnerConfig.class, Parameter.class, Option.class,\r
+ ValueConstrain.class);\r
+ assertNotNull(rconfig);\r
+ assertEquals(rconfig.getParameters().size(), this.rconfig.getParameters().size());\r
+ assertEquals(rconfig.getRunnerClassName(), this.rconfig.getRunnerClassName());\r
+ assertTrue(matrixParam.equals(rconfig.getArgument("MATRIX1")));\r
+ assertFalse(matrixParam.equals(rconfig.getArgument("Type")));\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (JAXBException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
+ // outfile.delete();\r
}\r
- // outfile.delete();\r
- }\r
-\r
- @Test()\r
- public void testValidation() {\r
- try {\r
- System.out.println("CCCC " + rconfig);\r
- // write schema\r
- pmarshaller.generateSchema(AllTestSuit.OUTPUT_DIR_ABSOLUTE,\r
- test_schema_output);\r
-\r
- File schemafile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE,\r
- test_schema_output);\r
- assertTrue(schemafile.exists());\r
- // document is NOT valid even against a loose schema as elements in\r
- // java are annotated as required\r
- Validator looseValidator = RunnerConfigMarshaller\r
- .getValidator(schemafile.getAbsolutePath());\r
-\r
- // write output xml file\r
- File outfile = new File(this.test_output);\r
- pmarshaller.write(rconfig, new FileOutputStream(outfile));\r
-\r
- assertTrue("Invalid output is NOT expected", RunnerConfigMarshaller\r
- .validate(looseValidator, test_output));\r
-\r
- Schema strictSchema = RunnerConfigMarshaller\r
- .getSchema(AllTestSuit.TEST_DATA_PATH_ABSOLUTE\r
- + File.separator + "RunnerConfigSchema.xsd");\r
-\r
- Validator strictVal = RunnerConfigMarshaller\r
- .getValidator(strictSchema);\r
-\r
- // document is invalid against strict schema\r
- assertFalse("Invalid output is expected", RunnerConfigMarshaller\r
- .validate(strictVal, invalidDoc));\r
-\r
- // schemafile.delete();\r
- // outfile.delete();\r
-\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (JAXBException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (SAXException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
+\r
+ @Test()\r
+ public void testValidation() {\r
+ try {\r
+ System.out.println("CCCC " + rconfig);\r
+ // write schema\r
+ pmarshaller.generateSchema(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_schema_output);\r
+\r
+ File schemafile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_schema_output);\r
+ assertTrue(schemafile.exists());\r
+ // document is NOT valid even against a loose schema as elements in\r
+ // java are annotated as required\r
+ Validator looseValidator = RunnerConfigMarshaller.getValidator(schemafile.getAbsolutePath());\r
+\r
+ // write output xml file\r
+ File outfile = new File(this.test_output);\r
+ pmarshaller.write(rconfig, new FileOutputStream(outfile));\r
+\r
+ assertTrue("Invalid output is NOT expected", RunnerConfigMarshaller.validate(looseValidator, test_output));\r
+\r
+ Schema strictSchema = RunnerConfigMarshaller.getSchema(AllTestSuit.TEST_DATA_PATH_ABSOLUTE + File.separator\r
+ + "RunnerConfigSchema.xsd");\r
+\r
+ Validator strictVal = RunnerConfigMarshaller.getValidator(strictSchema);\r
+\r
+ // document is invalid against strict schema\r
+ assertFalse("Invalid output is expected", RunnerConfigMarshaller.validate(strictVal, invalidDoc));\r
+\r
+ // schemafile.delete();\r
+ // outfile.delete();\r
+\r
+ } catch (MalformedURLException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (JAXBException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (SAXException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ }\r
+\r
}\r
\r
- }\r
-\r
- @Test(expectedExceptions = JAXBException.class)\r
- public void testValidationOnMarshalling() throws SAXException,\r
- JAXBException, MalformedURLException {\r
- // This is not valid parameter\r
- Parameter<Mafft> p = new Parameter<Mafft>("MATRIXXX", "Protein weight matrix");\r
- // This attribute is required by strict schema\r
- // p.setOptionName("-M");\r
- p.setRequired(true);\r
- rconfig.addParameter(p);\r
- try {\r
-\r
- // strict schema invalidate this document and throw an exception\r
- // just discard the output\r
- pmarshaller.writeAndValidate(rconfig,\r
- AllTestSuit.TEST_DATA_PATH_ABSOLUTE + File.separator\r
- + "RunnerConfigSchema.xsd",\r
- new ByteArrayOutputStream());\r
-\r
- fail("Exception has been thrown before this place in unreachable");\r
-\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
+ @Test(expectedExceptions = JAXBException.class)\r
+ public void testValidationOnMarshalling() throws SAXException, JAXBException, MalformedURLException {\r
+ // This is not valid parameter\r
+ Parameter<Mafft> p = new Parameter<Mafft>("MATRIXXX", "Protein weight matrix");\r
+ // This attribute is required by strict schema\r
+ // p.setOptionName("-M");\r
+ p.setRequired(true);\r
+ rconfig.addParameter(p);\r
+ try {\r
+\r
+ // strict schema invalidate this document and throw an exception\r
+ // just discard the output\r
+ pmarshaller.writeAndValidate(rconfig, AllTestSuit.TEST_DATA_PATH_ABSOLUTE + File.separator + "RunnerConfigSchema.xsd",\r
+ new ByteArrayOutputStream());\r
+\r
+ fail("Exception has been thrown before this place in unreachable");\r
+\r
+ } catch (MalformedURLException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
}\r
- }\r
-\r
- @Test()\r
- public void testSchemaFromCodeGeneration() {\r
- try {\r
-\r
- pmarshaller.generateSchema(AllTestSuit.OUTPUT_DIR_ABSOLUTE,\r
- test_schema_output);\r
- } catch (JAXBException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
+\r
+ @Test()\r
+ public void testSchemaFromCodeGeneration() {\r
+ try {\r
+\r
+ pmarshaller.generateSchema(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_schema_output);\r
+ } catch (JAXBException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
+ File schemafile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_schema_output);\r
+ assertTrue("Schema file expected but not found", schemafile.exists());\r
+ assertTrue("Schema file seems to be empty", schemafile.length() > 50);\r
+ // schemafile.delete();\r
}\r
- File schemafile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE,\r
- test_schema_output);\r
- assertTrue("Schema file expected but not found", schemafile.exists());\r
- assertTrue("Schema file seems to be empty", schemafile.length() > 50);\r
- // schemafile.delete();\r
- }\r
\r
}\r
\r
public class OptionMarshallerTester {\r
\r
- public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE\r
- + "MafftParameters.xml";\r
- public static String test_schema_output = "NextGenMafftOptionsSchema.xml";\r
- public static String test_output = "MafftOptions.xml.out";\r
- public static String reWrittenInput = AllTestSuit.OUTPUT_DIR_ABSOLUTE\r
- + "rewrittenMafftParams.xml";\r
-\r
- RunnerConfig<Mafft> rconfig = null;\r
- Option<Mafft> matrixParam = null;\r
-\r
- @BeforeMethod()\r
- public void setup() {\r
- // write some parameters programmatically\r
- try {\r
- rconfig = new RunnerConfig<Mafft>();\r
- rconfig.setRunnerClassName(Mafft.class.getName());\r
- List<Option<Mafft>> prms = new ArrayList<Option<Mafft>>();\r
-\r
- Parameter<Mafft> p1 = new Parameter<Mafft>("Type",\r
- "Type of the sequence (PROTEIN or DNA)");\r
- // TODO publish help on a compbio web site\r
-\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
-\r
- /*\r
- * -MATRIX= :Protein weight matrix=BLOSUM, PAM, GONNET, ID or\r
- * filename\r
- */\r
- Option<Mafft> p2 = new Option<Mafft>("MATRIX",\r
- "Protein weight matrix");\r
- // TODO publish help on a compbio web site\r
-\r
- p2.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
-\r
- p2.addOptionNames("-jtree");\r
- p2.addOptionNames("-jfasta");\r
- p2.setRequired(false);\r
-\r
- Parameter<Mafft> p3 = new Parameter<Mafft>("MATRIX2",\r
- "Protein weight matrix");\r
- // TODO publish help on a compbio web site\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
- p3.setOptionName("-MATRIX");\r
- p3.setRequired(true);\r
- p3.setDefaultValue("id");\r
- ValueConstrain vc = new ValueConstrain();\r
- vc.setType(ValueConstrain.Type.Float);\r
- vc.setMin("-10.12");\r
- vc.setMax("0");\r
- p3.setValidValue(vc);\r
-\r
- prms.add(p1);\r
- prms.add(p2);\r
- prms.add(p3);\r
- matrixParam = p2;\r
- rconfig.setOptions(prms);\r
-\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (WrongParameterException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
+ public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "MafftParameters.xml";\r
+ public static String test_schema_output = "NextGenMafftOptionsSchema.xml";\r
+ public static String test_output = "MafftOptions.xml.out";\r
+ public static String reWrittenInput = AllTestSuit.OUTPUT_DIR_ABSOLUTE + "rewrittenMafftParams.xml";\r
+\r
+ RunnerConfig<Mafft> rconfig = null;\r
+ Option<Mafft> matrixParam = null;\r
+\r
+ @BeforeMethod()\r
+ public void setup() {\r
+ // write some parameters programmatically\r
+ try {\r
+ rconfig = new RunnerConfig<Mafft>();\r
+ rconfig.setRunnerClassName(Mafft.class.getName());\r
+ List<Option<Mafft>> prms = new ArrayList<Option<Mafft>>();\r
+\r
+ Parameter<Mafft> p1 = new Parameter<Mafft>("Type", "Type of the sequence (PROTEIN or DNA)");\r
+ // TODO publish help on a compbio web site\r
+\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
+\r
+ /*\r
+ * -MATRIX= :Protein weight matrix=BLOSUM, PAM, GONNET, ID or\r
+ * filename\r
+ */\r
+ Option<Mafft> p2 = new Option<Mafft>("MATRIX", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\r
+\r
+ p2.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
+\r
+ p2.addOptionNames("-jtree");\r
+ p2.addOptionNames("-jfasta");\r
+ p2.setRequired(false);\r
+\r
+ Parameter<Mafft> p3 = new Parameter<Mafft>("MATRIX2", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\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
+ p3.setOptionName("-MATRIX");\r
+ p3.setRequired(true);\r
+ p3.setDefaultValue("id");\r
+ ValueConstrain vc = new ValueConstrain();\r
+ vc.setType(ValueConstrain.Type.Float);\r
+ vc.setMin("-10.12");\r
+ vc.setMax("0");\r
+ p3.setValidValue(vc);\r
+\r
+ prms.add(p1);\r
+ prms.add(p2);\r
+ prms.add(p3);\r
+ matrixParam = p2;\r
+ rconfig.setOptions(prms);\r
+\r
+ } catch (WrongParameterException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
}\r
- }\r
-\r
- @Test(expectedExceptions = { javax.xml.bind.MarshalException.class })\r
- public void testMarshalling() throws JAXBException {\r
-\r
- File outfile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_output);\r
- try {\r
- RunnerConfigMarshaller<Mafft> rmarsh = new RunnerConfigMarshaller<Mafft>(\r
- RunnerConfig.class);\r
-\r
- // This throws an exception\r
- // I am not sure why\r
- rmarsh.writeAndValidate(rconfig,\r
- AllTestSuit.TEST_DATA_PATH_ABSOLUTE + File.separator\r
- + "RunnerConfigSchema.xsd", new FileOutputStream(\r
- outfile));\r
-\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (SAXException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
+\r
+ @Test(expectedExceptions = { javax.xml.bind.MarshalException.class })\r
+ public void testMarshalling() throws JAXBException {\r
+\r
+ File outfile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_output);\r
+ try {\r
+ RunnerConfigMarshaller<Mafft> rmarsh = new RunnerConfigMarshaller<Mafft>(RunnerConfig.class);\r
+\r
+ // This throws an exception\r
+ // I am not sure why\r
+ rmarsh.writeAndValidate(rconfig, AllTestSuit.TEST_DATA_PATH_ABSOLUTE + File.separator + "RunnerConfigSchema.xsd",\r
+ new FileOutputStream(outfile));\r
+\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (SAXException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
+ assertTrue("Output file expected, but nothing found!", outfile.exists());\r
+ // outfile.delete();\r
}\r
- assertTrue("Output file expected, but nothing found!", outfile.exists());\r
- // outfile.delete();\r
- }\r
-\r
- @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(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
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (SAXException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
+\r
+ @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(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
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (SAXException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
}\r
- }\r
}\r
\r
public class RunnerConfigTester {\r
\r
- public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE\r
- + "MafftParameters.xml";\r
+ public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "MafftParameters.xml";\r
\r
RunnerConfig<Mafft> rconfig = null;\r
\r
rconfig.setRunnerClassName(Mafft.class.getName());\r
List<Option<Mafft>> prms = new ArrayList<Option<Mafft>>();\r
\r
- RunnerConfigMarshaller<Mafft> pmarshaller = new RunnerConfigMarshaller<Mafft>(\r
- RunnerConfig.class, Parameter.class, Option.class,\r
- ValueConstrain.class);\r
+ RunnerConfigMarshaller<Mafft> pmarshaller = new RunnerConfigMarshaller<Mafft>(RunnerConfig.class, Parameter.class,\r
+ Option.class, ValueConstrain.class);\r
} catch (JAXBException e) {\r
e.printStackTrace();\r
fail(e.getLocalizedMessage());\r
\r
@Test(expectedExceptions = WrongParameterException.class)\r
public void testCreateParameter() throws WrongParameterException {\r
- try {\r
- Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
- // TODO publish help on a compbio web site\r
- p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
+ Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\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
- p3.setOptionName("--AAMATRIX");\r
- p3.setRequired(true);\r
- // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED\r
- // IN WITHIN POSSIBLE VALUES\r
- p3.setDefaultValue("pam22");\r
- String com = p3.toCommand(" ");\r
- System.out.println("AAAAAAAAAAAAAA!" + com);\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
+ p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID");\r
+ // This attribute is required by strict schema\r
+ p3.setOptionName("--AAMATRIX");\r
+ p3.setRequired(true);\r
+ // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED\r
+ // IN WITHIN POSSIBLE VALUES\r
+ p3.setDefaultValue("pam22");\r
+ String com = p3.toCommand(" ");\r
+ System.out.println("AAAAAAAAAAAAAA!" + com);\r
}\r
\r
@Test()\r
public void testParameterToCommand() throws WrongParameterException {\r
- try {\r
- Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
- // TODO publish help on a compbio web site\r
- p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
+ Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\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
- p3.setOptionName("--AAMATRIX");\r
- p3.setRequired(true);\r
- // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED\r
- // IN WITHIN POSSIBLE VALUES\r
- p3.setDefaultValue("PAM");\r
- String com = p3.toCommand("=");\r
- assertTrue(com.startsWith("--AAMATRIX"));\r
- assertTrue(com.endsWith("PAM"));\r
- assertTrue(com.contains("="));\r
- p3.setDefaultValue("ID");\r
- com = p3.toCommand("=");\r
- assertFalse(com.endsWith("PAM"));\r
- assertFalse(com.contains("PAM"));\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
+ p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID");\r
+ // This attribute is required by strict schema\r
+ p3.setOptionName("--AAMATRIX");\r
+ p3.setRequired(true);\r
+ // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED\r
+ // IN WITHIN POSSIBLE VALUES\r
+ p3.setDefaultValue("PAM");\r
+ String com = p3.toCommand("=");\r
+ assertTrue(com.startsWith("--AAMATRIX"));\r
+ assertTrue(com.endsWith("PAM"));\r
+ assertTrue(com.contains("="));\r
+ p3.setDefaultValue("ID");\r
+ com = p3.toCommand("=");\r
+ assertFalse(com.endsWith("PAM"));\r
+ assertFalse(com.contains("PAM"));\r
}\r
\r
@Test(expectedExceptions = ValidationException.class)\r
public void testOptionNoDefaultValidate() throws ValidationException {\r
- try {\r
- Option<Mafft> p3 = new Option<Mafft>("Matrix1", "Protein weight matrix");\r
- // TODO publish help on a compbio web site\r
- p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
+ Option<Mafft> p3 = new Option<Mafft>("Matrix1", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\r
+ p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
\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
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\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
\r
@Test(expectedExceptions = WrongParameterException.class)\r
public void testOptionSetInvalidValue() throws WrongParameterException {\r
- try {\r
- Option<Mafft> p3 = new Option<Mafft>("Matrix1", "Protein weight matrix");\r
- // TODO publish help on a compbio web site\r
- p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
\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
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
+ Option<Mafft> p3 = new Option<Mafft>("Matrix1", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\r
+ p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html");\r
+\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
\r
@Test()\r
p3.setDefaultValue("--ABMAT");\r
com = p3.toCommand("=");\r
assertEquals("--ABMAT", com);\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
} catch (ValidationException e) {\r
e.printStackTrace();\r
fail(e.getMessage());\r
}\r
\r
@Test(expectedExceptions = WrongParameterException.class)\r
- public void testValidateLowerBoundaryConstrainCheck()\r
- throws WrongParameterException {\r
- try {\r
- Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
- // TODO publish help on a compbio web site\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
+ public void testValidateLowerBoundaryConstrainCheck() throws WrongParameterException {\r
+ Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\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
\r
- ValueConstrain vc = new ValueConstrain();\r
- vc.setType(ValueConstrain.Type.Float);\r
- vc.setMin("-10.12");\r
- vc.setMax("0");\r
- p3.setValidValue(vc);\r
- // THIS IS CAUSING EXCEPTION\r
- p3.setDefaultValue("-11.0");\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
+ ValueConstrain vc = new ValueConstrain();\r
+ vc.setType(ValueConstrain.Type.Float);\r
+ vc.setMin("-10.12");\r
+ vc.setMax("0");\r
+ p3.setValidValue(vc);\r
+ // THIS IS CAUSING EXCEPTION\r
+ p3.setDefaultValue("-11.0");\r
}\r
\r
@Test(expectedExceptions = WrongParameterException.class)\r
- public void testValidateUpperBoundaryConstrainCheck()\r
- throws WrongParameterException {\r
- try {\r
- Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
- // TODO publish help on a compbio web site\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
+ public void testValidateUpperBoundaryConstrainCheck() throws WrongParameterException {\r
+ Parameter<Mafft> p3 = new Parameter<Mafft>("Matrix1", "Protein weight matrix");\r
+ // TODO publish help on a compbio web site\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
\r
- ValueConstrain vc = new ValueConstrain();\r
- vc.setType(ValueConstrain.Type.Float);\r
- vc.setMin("-10.12");\r
- vc.setMax("0");\r
- p3.setValidValue(vc);\r
- // THIS IS CAUSING EXCEPTION\r
- p3.setDefaultValue("1");\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
+ ValueConstrain vc = new ValueConstrain();\r
+ vc.setType(ValueConstrain.Type.Float);\r
+ vc.setMin("-10.12");\r
+ vc.setMax("0");\r
+ p3.setValidValue(vc);\r
+ // THIS IS CAUSING EXCEPTION\r
+ p3.setDefaultValue("1");\r
}\r
\r
@Test()\r
// Max value boundary is not defined so 1 is valid\r
p3.setDefaultValue("1");\r
p3.validate();\r
- } catch (MalformedURLException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
} catch (WrongParameterException e) {\r
e.printStackTrace();\r
fail(e.getMessage());\r