From: cmzmasek@gmail.com Date: Wed, 22 Oct 2014 02:43:13 +0000 (+0000) Subject: testing under java 8... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f90a2c91f9e20651e261d7538758cc554b8066ee;p=jalview.git testing under java 8... once again stream closed issues... --- diff --git a/forester/java/src/org/forester/io/parsers/nhx/NHXParser.java b/forester/java/src/org/forester/io/parsers/nhx/NHXParser.java index 4bcfb08..7a30ce9 100644 --- a/forester/java/src/org/forester/io/parsers/nhx/NHXParser.java +++ b/forester/java/src/org/forester/io/parsers/nhx/NHXParser.java @@ -127,10 +127,10 @@ public final class NHXParser implements PhylogenyParser, IteratingPhylogenyParse @Override public final Phylogeny[] parse() throws IOException { final List l = new ArrayList(); - int c = 0; + //int c = 0; while ( hasNext() ) { l.add( next() ); - c++; + // c++; } final Phylogeny[] p = new Phylogeny[ l.size() ]; for( int i = 0; i < l.size(); ++i ) { @@ -158,7 +158,7 @@ public final class NHXParser implements PhylogenyParser, IteratingPhylogenyParse _my_source_sbuff = null; _my_source_sbuil = null; _my_source_charary = null; - determineSourceType( _source ); + determineAndProcessSourceType( _source ); switch ( _input_type ) { case STRING: _my_source_br = null; @@ -211,7 +211,7 @@ public final class NHXParser implements PhylogenyParser, IteratingPhylogenyParse _allow_errors_in_distance_to_parent = allow_errors_in_distance_to_parent; } - private final void determineSourceType( final Object nhx_source ) throws IOException { + private final void determineAndProcessSourceType( final Object nhx_source ) throws IOException { if ( nhx_source == null ) { throw new PhylogenyParserException( getClass() + ": attempt to parse null object." ); } @@ -244,11 +244,12 @@ public final class NHXParser implements PhylogenyParser, IteratingPhylogenyParse _input_type = NHXParser.BUFFERED_READER; _source_length = 0; if ( _my_source_br != null ) { - try { - _my_source_br.close(); - } - catch ( final IOException e ) { - } + // I am REALLY not sure if it a "good" NOT to close the stream... +// try { +// _my_source_br.close(); +// } +// catch ( final IOException e ) { +// } } final File f = ( File ) nhx_source; final String error = ForesterUtil.isReadableFile( f ); @@ -261,11 +262,12 @@ public final class NHXParser implements PhylogenyParser, IteratingPhylogenyParse _input_type = NHXParser.BUFFERED_READER; _source_length = 0; if ( _my_source_br != null ) { - try { - _my_source_br.close(); - } - catch ( final IOException e ) { - } +// I am REALLY not sure if it a "good" NOT to close the stream... +// try { +// _my_source_br.close(); +// } +// catch ( final IOException e ) { +// } } final InputStreamReader isr = new InputStreamReader( ( ( URL ) nhx_source ).openStream() ); _nhx_source = new BufferedReader( isr ); @@ -274,11 +276,12 @@ public final class NHXParser implements PhylogenyParser, IteratingPhylogenyParse _input_type = NHXParser.BUFFERED_READER; _source_length = 0; if ( _my_source_br != null ) { - try { - _my_source_br.close(); - } - catch ( final IOException e ) { - } + // I am REALLY not sure if it a "good" NOT to close the stream... +// try { +// _my_source_br.close(); +// } +// catch ( final IOException e ) { +// } } final InputStreamReader isr = new InputStreamReader( ( InputStream ) nhx_source ); _nhx_source = new BufferedReader( isr ); diff --git a/forester/java/src/org/forester/test/Test.java b/forester/java/src/org/forester/test/Test.java index feddccc..713d018 100644 --- a/forester/java/src/org/forester/test/Test.java +++ b/forester/java/src/org/forester/test/Test.java @@ -139,7 +139,7 @@ public final class Test { private final static String PATH_TO_TEST_DATA = System.getProperty( "user.dir" ) + ForesterUtil.getFileSeparator() + "test_data" + ForesterUtil.getFileSeparator(); - private final static boolean PERFORM_DB_TESTS = true; + private final static boolean PERFORM_DB_TESTS = false; private static final boolean PERFORM_WEB_TREE_ACCESS = true; private static final String PHYLOXML_LOCAL_XSD = PATH_TO_RESOURCES + "phyloxml_schema/" + ForesterConstants.PHYLO_XML_VERSION + "/" @@ -181,6 +181,22 @@ public final class Test { System.exit( -1 ); } final long start_time = new Date().getTime(); + + // + if ( Test.testNHXparsingFromURL() ) { + System.out.println( "OK." ); + succeeded++; + } + else { + System.out.println( "failed." ); + failed++; + } + // System.exit( 1 ); + + // + + + System.out.print( "MSA entropy: " ); if ( Test.testMsaEntropy() ) { System.out.println( "OK." ); @@ -1218,6 +1234,7 @@ public final class Test { } catch ( final Exception e ) { e.printStackTrace(); + return false; } return true; } @@ -1239,7 +1256,10 @@ public final class Test { System.out.println( phys[ 1 ].toNewHampshire() ); return false; } - final Phylogeny[] phys2 = factory.create( u.openStream(), new NHXParser() ); + + final URL u2 = new URL( s ); + + final Phylogeny[] phys2 = factory.create( u2.openStream(), new NHXParser() ); if ( ( phys2 == null ) || ( phys2.length != 5 ) ) { return false; } @@ -1249,8 +1269,8 @@ public final class Test { } final PhylogenyFactory factory2 = ParserBasedPhylogenyFactory.getInstance(); final NHXParser p = new NHXParser(); - final URL u2 = new URL( s ); - p.setSource( u2 ); + final URL u3 = new URL( s ); + p.setSource( u3 ); if ( !p.hasNext() ) { return false; } @@ -1282,7 +1302,9 @@ public final class Test { } } catch ( final Exception e ) { + System.out.println( e.toString()); e.printStackTrace(); + return false; } return true; }