/*
 * The baseCode 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.basecode.xml;

import java.io.InputStream; 
import java.util.zip.ZipInputStream;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import junit.framework.TestCase;
import ubic.basecode.util.RegressionTesting;

/**
 * @author Paul Pavlidis
 * @version $Id$
 */
public class TestGOParser extends TestCase {

    private static Log log = LogFactory.getLog( TestGOParser.class );

    private GOParser gOParser = null;

    /**
     * This sample is of a rather old version of the ontology
     * 
     * @throws Exception
     */
    public void testGOParser() throws Exception {

        InputStream i = GOParser.class.getResourceAsStream( "/data/go-termdb-sample.xml" );

        if ( i == null ) {
            throw new Exception( "Couldn't read the sample file" );
        }
        gOParser = new GOParser( i );

        String actualReturn = gOParser.getGraph().toString();
        String expectedReturn = RegressionTesting.readTestResult( "/data/goparsertestoutput.txt" );
        assertEquals( "return", expectedReturn, actualReturn );
        /*
         * assertEquals( "Diffs: " + RegressionTesting.regress( expectedReturn, actualReturn ), expectedReturn,
         * actualReturn );
         */
    }

    /**
     * @throws Exception
     */
    public void testGOParserNewFormat() throws Exception {

        ZipInputStream i = new ZipInputStream( GOParser.class
                .getResourceAsStream( "/data/go_daily-termdb.rdf-updated.zip" ) );
        if ( i == null ) {
            throw new Exception( "Couldn't read the sample file" );
        }
        i.getNextEntry();

        gOParser = new GOParser( i );

        assertTrue( gOParser.getGraph().getRoot().toString().startsWith( "all" ) );

    }
}
@@ -704,46 +704,8 @@
 eam;
- %0Aimport java.util.zip.ZipInputStream;
 %0A%0Aim
@@ -1534,16 +1534,17 @@
 ring();%0A
+%0A
         
@@ -1690,32 +1690,117 @@
  actualReturn );
+%0A%0A        assertTrue( gOParser.getGraph().getRoot().toString().startsWith( %22all%22 ) );
 %0A        /*%0A    
@@ -2026,17 +2026,9 @@
 rser
-NewFormat
+B
 () t
@@ -2054,19 +2054,16 @@
         
-Zip
 InputStr
@@ -2074,59 +2074,22 @@
 i = 
-new ZipInputStream( GOParser.class%0A                
+GOParser.class
 .get
@@ -2137,25 +2137,24 @@
 rdf-
-updated.zip%22 ) );
+sample2.xml%22 );%0A
 %0A   
@@ -2255,24 +2255,25 @@
       %7D%0A
+%0A
         
 i.getNex
@@ -2268,61 +2268,263 @@
     
-i.getNextEntry();%0A%0A        gOParser = new GOParser( i
+gOParser = new GOParser( i );%0A%0A        String actualReturn = gOParser.getGraph().toString();%0A        String expectedReturn = RegressionTesting.readTestResult( %22/data/goparsertestoutput.2.txt%22 );%0A        assertEquals( %22return%22, expectedReturn, actualReturn
  );%0A

update small sample tests - both work now.