/*
 * The Gemma project
 * 
 * Copyright (c) 2006 University of British Columbia
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package ubic.gemma.apps;

import java.io.File;

/**
 * @author pavlidis
 * @version $Id$
 */
public class ProbeMapperTest extends AbstractCLITestCase {

    File tempFile;

    ProbeMapper p;

    /*
     * (non-Javadoc)
     * 
     * @see junit.framework.TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
        tempFile = File.createTempFile( "cli", ".txt" );
        p = new ProbeMapper();
    }

    protected void tearDown() throws Exception {
        // tempFile.delete();
    }

    public final void testMainBadPort() throws Exception {
        Exception result = p.doWork( new String[] { "-P", "c", "-u", "pavlidis", "-p", "toast", "-o",
                tempFile.getAbsolutePath() } );
        // should result in an exception
        assertTrue( result.getMessage(), result != null );
    }

    public void testBlatHandling() throws Exception {

        String basePath = this.getTestFileBasePath();

        String blatFile = basePath + System.getProperty( "file.separator" )
                + "/gemma-core/src/test/resources/data/loader/genome/blatresult.noheader.txt";

        Exception result = p.doWork( new String[] { "-u", "pavlidis", "-p", "toast", "-o", tempFile.getAbsolutePath(),
                "-b", blatFile, "-d", "hg17" } );
        if ( result != null ) {
            fail( result.getMessage() );
        }
    }

    public void testGbHandling() throws Exception {

        String basePath = this.getTestFileBasePath();

        String gbFile = basePath + System.getProperty( "file.separator" )
                + "/gemma-core/src/test/resources/data/loader/genome/ncbiGenes.test.txt";

        Exception result = p.doWork( new String[] { "-u", "pavlidis", "-p", "toast", "-o", tempFile.getAbsolutePath(),
                "-g", gbFile, "-d", "hg17" } );
        if ( result != null ) {
            fail( result.getMessage() );
        }
    }

    public void testSingleGb() throws Exception {
        Exception result = p.doWork( new String[] { "-u", "pavlidis", "-p", "toast", "-o", tempFile.getAbsolutePath(),
                "-d", "hg17", "AF015731", "BX473803" } );
        if ( result != null ) {
            result.printStackTrace();
            fail( result.getMessage() );
        }
    }
}

@@ -1767,24 +1767,92 @@
 eader.txt%22;%0A
+        %0A        assert ( new File( blatFile ) ).canRead();%0A        
 %0A        Exc
@@ -2372,16 +2372,66 @@
 .txt%22;%0A%0A
+        assert ( new File( gbFile ) ).canRead();%0A%0A
         

check for valid test files