X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FTCoffeeScoreFileTest.java;h=85c0bff282a40cedc3014f3acb7b02c14dafd449;hb=1c66dc9053356a709e9cd9d3282517b5221f1ba2;hp=7257e144fd762488ed14ec25706c28721afc5af1;hpb=ef23315db576f5451de0fcb850f645c5db222b20;p=jalview.git diff --git a/test/jalview/io/TCoffeeScoreFileTest.java b/test/jalview/io/TCoffeeScoreFileTest.java index 7257e14..85c0bff 100644 --- a/test/jalview/io/TCoffeeScoreFileTest.java +++ b/test/jalview/io/TCoffeeScoreFileTest.java @@ -16,12 +16,15 @@ import org.junit.Test; public class TCoffeeScoreFileTest { - final static File SCORE_FILE = new File("./test/jalview/io/tcoffee.score_ascii"); + final static File SCORE_FILE = new File("test/jalview/io/tcoffee.score_ascii"); + final static File ALIGN_FILE = new File("test/jalview/io/tcoffee.fasta_aln"); @Test - public void testReadHeader() throws FileNotFoundException { + public void testReadHeader() throws IOException, FileNotFoundException { - Header header = TCoffeeScoreFile.readHeader( new BufferedReader(new FileReader(SCORE_FILE)) ); + TCoffeeScoreFile scoreFile = new TCoffeeScoreFile(SCORE_FILE.getPath(),AppletFormatAdapter.FILE); + assertTrue(scoreFile.getWarningMessage(),scoreFile.isValid()); + Header header = scoreFile.header; assertNotNull(header); assertEquals( "T-COFFEE, Version_9.02.r1228 (2012-02-16 18:15:12 - Revision 1228 - Build 336)", header.head ); assertEquals( 90, header.score ); @@ -39,14 +42,19 @@ public class TCoffeeScoreFileTest { @Test public void testWrongFile() { - TCoffeeScoreFile result = TCoffeeScoreFile.load(new File("./test/jalview/io/tcoffee.fasta_aln")); - assertNull(result); + try { + TCoffeeScoreFile result = new TCoffeeScoreFile(ALIGN_FILE.getPath(), FormatAdapter.FILE); + assertFalse(result.isValid()); + } catch (IOException x) + { + assertTrue("File not found exception thrown",x instanceof FileNotFoundException); + } } @Test - public void testHeightAndWidth() { - TCoffeeScoreFile result = TCoffeeScoreFile.load(new File("./test/jalview/io/tcoffee.score_ascii")); - assertNotNull(result); + public void testHeightAndWidth() throws IOException { + TCoffeeScoreFile result = new TCoffeeScoreFile(SCORE_FILE.getPath(), FormatAdapter.FILE); + assertTrue(result.isValid()); assertEquals( 8, result.getHeight() ); assertEquals( 83, result.getWidth() ); } @@ -68,9 +76,10 @@ public class TCoffeeScoreFileTest { "cons 999999999999999999999999999851000110321100001134\n" + "\n" + "\n"; - - Block block = TCoffeeScoreFile.readBlock(new BufferedReader(new StringReader(BLOCK)), 0); - assertNotNull(block); + FileParse source=new FileParse(BLOCK, FormatAdapter.PASTE); + Block block = TCoffeeScoreFile.readBlock(source, 0); + + assertNotNull(block); assertEquals( "999999999999999999999999998762112222543211112134", block.getScoresFor("1PHT") ); assertEquals( "99999999999999999999999999987-------4322----2234", block.getScoresFor("1BB9") ); assertEquals( "99999999999999999999999999987-------5321----2246", block.getScoresFor("1UHC") ); @@ -83,9 +92,9 @@ public class TCoffeeScoreFileTest { } @Test - public void testParse() throws FileNotFoundException { + public void testParse() throws IOException { - TCoffeeScoreFile parser = TCoffeeScoreFile.load(new BufferedReader(new FileReader(SCORE_FILE)) ); + TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(), FormatAdapter.FILE); assertEquals( "999999999999999999999999998762112222543211112134----------5666642367889999999999889", parser.getScoresFor("1PHT") ); assertEquals( "99999999999999999999999999987-------4322----22341111111111676653-355679999999999889", parser.getScoresFor("1BB9") ); @@ -100,10 +109,10 @@ public class TCoffeeScoreFileTest { @Test - public void testGetAsList() throws FileNotFoundException { + public void testGetAsList() throws IOException { - TCoffeeScoreFile parser = TCoffeeScoreFile.load(new BufferedReader(new FileReader(SCORE_FILE)) ); - + TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(),FormatAdapter.FILE); + assertTrue(parser.getWarningMessage(),parser.isValid()); List scores = parser.getScoresList(); assertEquals( "999999999999999999999999998762112222543211112134----------5666642367889999999999889", scores.get(0) ); assertEquals( "99999999999999999999999999987-------4322----22341111111111676653-355679999999999889", scores.get(1) ); @@ -119,10 +128,10 @@ public class TCoffeeScoreFileTest { @Test - public void testGetAsArray() throws FileNotFoundException { + public void testGetAsArray() throws IOException { - TCoffeeScoreFile parser = TCoffeeScoreFile.load(new BufferedReader(new FileReader(SCORE_FILE)) ); - + TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(),FormatAdapter.FILE); + assertTrue(parser.getWarningMessage(),parser.isValid()); byte[][] scores = parser.getScoresArray(); assertEquals( 9, scores[0][0] );