[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Sun Mar 2 12:45:27 UTC 2008


senger
Sun Mar  2 07:45:27 EST 2008
Update of /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser
In directory dev.open-bio.org:/tmp/cvs-serv32345/src/test/java/org/biomoby/shared/parser

Modified Files:
	MobyParserTest.java 
Log Message:
Too Many Changes - see docs/ChangeLog

moby-live/Java/src/test/java/org/biomoby/shared/parser MobyParserTest.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java	2008/02/28 05:21:48	1.1
+++ /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java	2008/03/02 12:45:27	1.2
@@ -1,4 +1,4 @@
-// MobyParserTestCase.java
+// MobyParserTest.java
 //
 // Created: February 2008
 //
@@ -20,17 +20,21 @@
 package org.biomoby.shared.parser;
 
 import org.biomoby.shared.MobyException;
+import org.biomoby.shared.datatypes.*;
 
 import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.*;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
 
 import java.io.InputStream;
 import java.io.IOException;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Arrays;
 
 
 public class MobyParserTest {
@@ -39,12 +43,6 @@
     private static final String INPUT_2 = "parser-test-input-2.xml";
     private static final String INPUT_3 = "parser-test-input-3.xml";
     private static final String INPUT_4 = "parser-test-input-4.xml";
-
-    private static final String OUTPUT_1 = "parser-test-output-1.xml";
-    private static final String OUTPUT_2 = "parser-test-output-2.xml";
-    private static final String OUTPUT_3 = "parser-test-output-3.xml";
-    private static final String OUTPUT_4 = "parser-test-output-4.xml";
-
  
     /**************************************************************************
      *
@@ -55,38 +53,55 @@
     @Test
     public void testNormal()
 	throws IOException, MobyException {
-	parse (INPUT_1, OUTPUT_1, null, null);
-    }
-
-    @Test
-    public void testUnknownTopLevel()
-	throws IOException, MobyException {
-	parse (INPUT_2, OUTPUT_2, "DNASequence", null);
-    }
-
-    @Test
-    public void testUnknownTopLevelAndMember()
-	throws IOException, MobyException {
-	parse (INPUT_3, OUTPUT_3, "BasicGFF3MultiFeature", null);
-    }
-
-    @Test
-    public void testMoreUnknownTopLevels()
-	throws IOException, MobyException {
-	Map<String,String> backups = new HashMap<String,String>();
-	backups.put ("mySeq",   "DNASequence");
-	backups.put ("myPairs", "BasicGFF3MultiFeature");
-	parse (INPUT_4, OUTPUT_4, null, backups);
-    }
+	MobyPackage moby = parse (INPUT_1, null, null);
+	assertEquals (moby.getServiceNotes(), "freetext notes here");
+	assertEquals (moby.getAuthority(), "http://\"me\".<org>&");
+	MobyJob[] jobs = moby.getJobs();
+	assertEquals (jobs.length, 4);
+	assertEquals (jobs[0].getId(), "a1");
+	MobyObject data = jobs[0].getData();
+	assertEquals (data.getMobyTypeName(), "NucleotideSequence");
+	assertEquals (data.getName(), "");
+	assertEquals (data.getNamespace(), "DragonDB_Allele");
+	assertEquals (data.getId(), "chlorae");
+	assertFalse (data.isPrimitiveType());
+	assertEquals (data.getClass().getName(), "org.biomoby.shared.datatypes.NucleotideSequence");
+	NucleotideSequence typedData = (NucleotideSequence)jobs[0].getData();
+	assertEquals (typedData.get_SequenceString(), ">tata\ntatata");
+	assertEquals (typedData.getMoby_SequenceString().getValue(), ">tata\ntatata");
+	assertEquals (typedData.getMoby_Length().getIntValue(), 10);
+    }
+
+//     @Test
+//     public void testUnknownTopLevel()
+// 	throws IOException, MobyException {
+// 	parse (INPUT_2, "DNASequence", null);
+//     }
+
+//     @Test
+//     public void testUnknownTopLevelAndMember()
+// 	throws IOException, MobyException {
+// 	parse (INPUT_3, "BasicGFF3MultiFeature", null);
+//     }
+
+//     @Test
+//     public void testMoreUnknownTopLevels()
+// 	throws IOException, MobyException {
+// 	Map<String,String> backups = new HashMap<String,String>();
+// 	backups.put ("mySeq",   "DNASequence");
+// 	backups.put ("myPairs", "BasicGFF3MultiFeature");
+// 	parse (INPUT_4, null, backups);
+//     }
 
 
     /**************************************************************************
-     * Read XML from 'infile', turn it back to XML and compare it with
-     * 'outfile'. Use 'backup' (or 'backups') as the 'latest known
-     * data top-level(s)' data type (any of them may be null).
+     * Create and return a MobyPackage form the XML 'infile'. Use
+     * 'backup' (or 'backups') as the 'latest known data top-level(s)'
+     * data type (any of them may be null).
      **************************************************************************/
-    protected void parse (String infile, String outfile,
-			  String backup, Map<String,String> backups)
+    protected MobyPackage parse (String infile,
+				 String backup,
+				 Map<String,String> backups)
 	throws IOException, MobyException {
 
 	InputStream ins = null;
@@ -95,7 +110,7 @@
 	    ins = this.getClass().getClassLoader().getResourceAsStream (infile);
 	    if (ins == null) {
 		fail ("Could not find test data resource '" + infile + "'.");
-		return;
+		throw new MobyException ("Test parsing failed.");
 	    }
 	    MobyPackage moby = null;
 	    if (backups != null) {
@@ -104,18 +119,7 @@
 		moby = MobyPackage.createFromXML (IOUtils.toByteArray (ins), backup);
 	    }
 	    assertFalse (moby == null);
-	    IOUtils.closeQuietly (ins);
-
-	    // reading expected result
-	    ins = this.getClass().getClassLoader().getResourceAsStream (outfile);
-	    if (ins == null) {
-		fail ("Could not find test data resource '" + outfile + "'.");
-		return;
-	    }
-	    String expected = IOUtils.toString (ins);
-
-	    // comparing
-	    assertEquals (moby.toXML(), expected);
+	    return moby;
 
 	} finally {
 	    IOUtils.closeQuietly (ins);




More information about the MOBY-guts mailing list