/*
 * The Gemma project
 * 
 * Copyright (c) 2005 Columbia University
 * 
 * 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 edu.columbia.gemma.loader.entrez.pubmed;

import java.io.IOException;
import java.text.SimpleDateFormat;

import org.xml.sax.SAXParseException;

import junit.framework.TestCase;
import edu.columbia.gemma.common.description.BibliographicReference;

/**
 * <hr>
 * <p>
 * Copyright (c) 2004-2005 Columbia University
 * 
 * @author pavlidis
 * @version $Id$
 */
public class PubMedXMLFetcherTest extends TestCase {

    PubMedXMLFetcher pmf;

    protected void setUp() throws Exception {
        super.setUp();
        pmf = new PubMedXMLFetcher();
    }

    protected void tearDown() throws Exception {
        super.tearDown();
        pmf = null;
    }

    public final void testRetrieveByHTTP() throws Exception {
        BibliographicReference br = pmf.retrieveByHTTP( 15173114 );
        assertEquals( "Lee, Homin K; Hsu, Amy K; Sajdak, Jon; Qin, Jie; Pavlidis, Paul", br.getAuthorList() );
        assertEquals( "Genome Res", br.getPublication() );
        assertEquals( "Coexpression analysis of human genes across many microarray data sets.", br.getTitle() );

        SimpleDateFormat f = new SimpleDateFormat( "mm/HH/MM/dd/yyyy" );
        assertEquals( "00/05/06/03/2004", f.format( br.getPublicationDate() ) );
    }

    public final void testRetrieveByHTTPNotFound() throws Exception {
        try {
            pmf.retrieveByHTTP( 1517311444 );
            fail( "Should have gotten a 'Not found' exception" );
        } catch ( SAXParseException e ) {
        } catch ( IOException e ) {
        }
    }

}

@@ -697,96 +697,29 @@
 ava.
-io.IOException;%0Aimport java.text.SimpleDateFormat;%0A%0Aimport org.xml.sax.SAXParseException
+text.SimpleDateFormat
 ;%0A%0Ai
@@ -1885,25 +1885,35 @@
     
-try %7B%0A           
+BibliographicReference br =
  pmf
@@ -1955,153 +1955,33 @@
     
-    fail( %22Should have gotten a 'Not found' exception%22 );%0A        %7D catch ( SAXParseException e ) %7B%0A        %7D catch ( IOException e ) %7B%0A        %7D
+assertEquals( null, br );
 %0A   

fix test broken by code change in fetcher