X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FFileIOTester.java;h=f6480a63dfed295ebfd33bcb43dd5931b28e9e5e;hb=049cfa5fc078e6daac6158f25cea7d9a60b48969;hp=926b908fcf205eeef4723b8c918c1e0c15b1f5a5;hpb=ab43013b7e357b84b4abade0dba949668dfb2a0e;p=jalview.git diff --git a/test/jalview/io/FileIOTester.java b/test/jalview/io/FileIOTester.java index 926b908..f6480a6 100644 --- a/test/jalview/io/FileIOTester.java +++ b/test/jalview/io/FileIOTester.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,14 +20,15 @@ */ package jalview.io; -import static org.junit.Assert.*; +import jalview.gui.JvOptionPane; import java.io.File; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; /** * @author jimp @@ -36,10 +37,17 @@ import org.junit.Test; public class FileIOTester { + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + /** * @throws java.lang.Exception */ - @BeforeClass + @BeforeClass(alwaysRun = true) public static void setUpBeforeClass() throws Exception { } @@ -47,7 +55,7 @@ public class FileIOTester /** * @throws java.lang.Exception */ - @AfterClass + @AfterClass(alwaysRun = true) public static void tearDownAfterClass() throws Exception { } @@ -66,65 +74,67 @@ public class FileIOTester final static File STARS_FA_FILE2 = new File( "test/jalview/io/test_fasta_stars2.fa"); - private void assertValidFormat(String fmt, String src, FileParse fp) + private void assertValidFormat(FileFormatI fmt, String src, FileParse fp) + throws FileFormatException { - assertTrue("Couldn't resolve " + src + " as a valid file", fp.isValid()); - String type = new IdentifyFile().Identify(fp); - assertTrue("Data from '" + src + "' Expected to be '" + fmt - + "' identified as '" + type + "'", type.equalsIgnoreCase(fmt)); + AssertJUnit.assertTrue("Couldn't resolve " + src + " as a valid file", + fp.isValid()); + FileFormatI type = new IdentifyFile().identify(fp); + AssertJUnit.assertSame("Data from '" + src + "' Expected to be '" + fmt + + "' identified as '" + type + "'", type, fmt); } - @Test + @Test(groups = { "Functional" }) public void testStarsInFasta1() throws IOException { String uri; FileParse fp = new FileParse(uri = STARS_FA_FILE1.getAbsoluteFile() - .toString(), AppletFormatAdapter.FILE); - assertValidFormat("FASTA", uri, fp); + .toString(), DataSourceType.FILE); + assertValidFormat(FileFormat.Fasta, uri, fp); } - @Test + @Test(groups = { "Functional" }) public void testStarsInFasta2() throws IOException { String uri; FileParse fp = new FileParse(uri = STARS_FA_FILE2.getAbsoluteFile() - .toString(), AppletFormatAdapter.FILE); - assertValidFormat("FASTA", uri, fp); + .toString(), DataSourceType.FILE); + assertValidFormat(FileFormat.Fasta, uri, fp); } - @Test + @Test(groups = { "Functional" }) public void testGzipIo() throws IOException { String uri; FileParse fp = new FileParse(uri = ALIGN_FILE.getAbsoluteFile().toURI() - .toString(), AppletFormatAdapter.URL); - assertValidFormat("FASTA", uri, fp); + .toString(), DataSourceType.URL); + assertValidFormat(FileFormat.Fasta, uri, fp); } - @Test + @Test(groups = { "Functional" }) public void testGziplocalFileIO() throws IOException { String filepath; FileParse fp = new FileParse(filepath = ALIGN_FILE.getAbsoluteFile() - .toString(), AppletFormatAdapter.FILE); - assertValidFormat("FASTA", filepath, fp); + .toString(), DataSourceType.FILE); + assertValidFormat(FileFormat.Fasta, filepath, fp); } - @Test + @Test(groups = { "Functional" }) public void testNonGzipURLIO() throws IOException { String uri; FileParse fp = new FileParse(uri = NOTGZALIGN_FILE.getAbsoluteFile() - .toURI().toString(), AppletFormatAdapter.URL); - assertValidFormat("FASTA", uri, fp); + .toURI().toString(), DataSourceType.URL); + assertValidFormat(FileFormat.Fasta, uri, fp); } - @Test + @Test(groups = { "Functional" }) public void testNonGziplocalFileIO() throws IOException { String filepath; FileParse fp = new FileParse(filepath = NOTGZALIGN_FILE - .getAbsoluteFile().toString(), AppletFormatAdapter.FILE); - assertValidFormat("FASTA", filepath, fp); + .getAbsoluteFile().toString(), DataSourceType.FILE); + assertValidFormat(FileFormat.Fasta, filepath, fp); } }