\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