View Javadoc

1   /*
2   Copyright (c) 2005 The European Bioinformatics Institute, and others.
3   All rights reserved. Please see the file LICENSE
4   in the root directory of this distribution.
5   */
6   package uk.ac.ebi.intenz.tools.sib.translator;
7   
8   import junit.framework.TestCase;
9   import uk.ac.ebi.xchars.SpecialCharacters;
10  import uk.ac.ebi.xchars.domain.EncodingType;
11  
12  import java.util.List;
13  import java.util.ArrayList;
14  import java.util.Iterator;
15  
16  import uk.ac.ebi.intenz.tools.sib.translator.helper.DataHolder;
17  import org.apache.log4j.Logger;
18  
19  
20  /**
21   * BaseLineTest
22   *
23   * @author P. de Matos
24   * @version $id 24-Jun-2005 13:29:18
25   *          <p/>
26   *          History:
27   *          Developer          Date              Description<br>
28   *          P. de Matos        24-Jun-2005           Created class<br>
29   */
30  public abstract class BaseLineTest extends TestCase {
31  
32     Logger LOGGER = Logger.getLogger(BaseLineTest.class);
33     XCharsASCIITranslator translator;
34     SpecialCharacters sc;
35     List<DataHolder> dataHolders = new ArrayList<DataHolder>();
36  
37     public BaseLineTest (String s) {
38        super(s);
39     }
40  
41     public void setUp() throws Exception {
42      super.setUp();
43       populateTests();
44      translator = XCharsASCIITranslator.getInstance();
45       String path = CALineTest.class.getClassLoader().getResource("specialCharacters.xml").getPath();
46       sc = SpecialCharacters.getInstance(path.replaceFirst("specialCharacters.xml", ""), "specialCharacters.xml");
47  
48    }
49  
50    public void tearDown() throws Exception {
51      super.tearDown();
52    }
53  
54     public void testData(){
55        Iterator<DataHolder> iter = dataHolders.iterator();
56        while ( iter.hasNext() ) {
57           DataHolder reactionData = iter.next();
58           boolean ca = this instanceof CALineTest;
59           boolean de = this instanceof DELineTest;
60           String translatedString = sc.xml2Display( translator.toASCII(reactionData.getIntenzData(), ca, de), EncodingType.SWISSPROT_CODE);
61           if( !translatedString.equals(reactionData.getEnzymeData()) ){
62              LOGGER.error("ASSERT FALSE - EC "+reactionData.getEC()+"  ORIGINAL IntEnz XML \n"+reactionData.getIntenzData()+"\n"+translatedString+" SHOULD BE \n"+reactionData.getEnzymeData());
63              assertFalse(true);
64           }
65        }
66  
67     }
68  
69     public abstract void populateTests();
70  }