/* * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.io; import static org.junit.Assert.*; import java.io.File; import java.io.IOException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; /** * @author jimp * */ public class FileIOTester { /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { } /** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception { } final static File ALIGN_FILE = new File("test/jalview/io/test_gz_fasta.gz"); final static File NOTGZALIGN_FILE = new File("test/jalview/io/test_gz_fasta_notgz.gz"); private void assertValidFasta(String src, FileParse fp) { assertTrue("Couldn't resolve "+src+" as a valid file",fp.isValid()); String type = new IdentifyFile().Identify(fp); assertTrue("Gzipped data from '"+src+"' identified as '"+type+"'",type.equalsIgnoreCase("FASTA")); } @Test public void testGzipIo() throws IOException { String uri; FileParse fp = new FileParse(uri=ALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL); assertValidFasta(uri, fp); } @Test public void testGziplocalFileIO() throws IOException { String filepath; FileParse fp = new FileParse(filepath=ALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE); assertValidFasta(filepath, fp); } @Test public void testNonGzipURLIO() throws IOException { String uri; FileParse fp = new FileParse(uri=NOTGZALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL); assertValidFasta(uri, fp); } @Test public void testNonGziplocalFileIO() throws IOException { String filepath; FileParse fp = new FileParse(filepath=NOTGZALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE); assertValidFasta(filepath, fp); } }