/*
 * The baseCode project
 * 
 * Copyright (c) 2008 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.basecode.io.reader;

import java.io.IOException;
import java.io.InputStream;

import junit.framework.TestCase;
import ubic.basecode.dataStructure.matrix.StringMatrix;

/**
 * @author pavlidis
 * @version $Id$
 */
public class TestStringMatrixReader extends TestCase {

    InputStream is = null;
    StringMatrix<String, String> matrix = null;
    StringMatrixReader reader = null;

    public void testReadInputStreamColumnCount() {
        try {
            matrix = reader.read( is );
            int actualReturn = matrix.columns();
            int expectedReturn = 12;
            assertEquals( "return value", expectedReturn, actualReturn );
        } catch ( IOException e ) {
            e.printStackTrace();
        }
    }

    public void testReadInputStreamGotColName() {
        try {
            matrix = reader.read( is );
            boolean actualReturn = matrix.containsColumnName( "sample1" ) && matrix.containsColumnName( "sample12" );
            boolean expectedReturn = true;
            assertEquals( "return value (for sample1 and sample12)", expectedReturn, actualReturn );
        } catch ( IOException e ) {
            e.printStackTrace();
        }
    }

    public void testReadInputStreamGotRowName() {
        try {
            matrix = reader.read( is );
            boolean actualReturn = matrix.containsRowName( "gene1_at" ) && matrix.containsRowName( "AFFXgene30_at" );
            boolean expectedReturn = true;
            assertEquals( "return value", expectedReturn, actualReturn );
        } catch ( IOException e ) {
            e.printStackTrace();
        }
    }

    /*
     * Class under test for NamedMatrix read(InputStream)
     */
    public void testReadInputStreamRowCount() {
        try {
            matrix = reader.read( is );
            int actualReturn = matrix.rows();
            int expectedReturn = 30;
            assertEquals( "return value", expectedReturn, actualReturn );
        } catch ( IOException e ) {
            e.printStackTrace();
        }
    }

    /*
     * @see TestCase#setUp()
     */
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        reader = new StringMatrixReader();
        is = TestStringMatrixReader.class.getResourceAsStream( "/data/testdata.txt" );
    }

    /*
     * @see TestCase#tearDown()
     */
    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

}
@@ -679,16 +679,62 @@
 eader;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 import j
@@ -793,33 +793,49 @@
 ort 
+org.
 junit.
-framework.TestCase;
+Before;%0Aimport org.junit.Test;%0A
 %0Aimp
@@ -973,25 +973,8 @@
 der 
-extends TestCase 
 %7B%0A%0A 
@@ -1086,16 +1086,26 @@
  null;%0A%0A
+    @Test%0A
     publ
@@ -1439,32 +1439,42 @@
        %7D%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -1905,24 +1905,34 @@
    %7D%0A    %7D%0A%0A
+    @Test%0A
     public v
@@ -2413,24 +2413,34 @@
 am)%0A     */%0A
+    @Test%0A
     public v
@@ -2813,39 +2813,37 @@
 ()%0A     */%0A    @
-Overrid
+Befor
 e%0A    protected 
@@ -2878,31 +2878,8 @@
 n %7B%0A
-        super.setUp();%0A
     
@@ -3015,148 +3015,5 @@
  %7D%0A%0A
-    /*%0A     * @see TestCase#tearDown()%0A     */%0A    @Override%0A    protected void tearDown() throws Exception %7B%0A        super.tearDown();%0A    %7D%0A%0A
 %7D

forgotten test convert to new framework