View Javadoc

1   package org.lcsim.geometry.compact.converter;
2   import java.io.File;
3   import java.io.FileOutputStream;
4   import java.io.InputStream;
5   import java.io.OutputStream;
6   import java.util.List;
7   
8   import junit.framework.Test;
9   import junit.framework.TestCase;
10  import junit.framework.TestSuite;
11  
12  import org.lcsim.util.test.TestUtil.TestOutputFile;
13  
14  
15  /**
16   *
17   * @author tonyj
18   */
19  public class MainTest extends TestCase
20  {
21     private File tempFile;
22     
23     public MainTest(String testName)
24     {
25        super(testName);
26     }
27     
28     protected void setUp() throws Exception
29     {
30        InputStream in = MainTest.class.getResourceAsStream("/org/lcsim/geometry/compact/sid01_compact.xml");
31        tempFile = File.createTempFile("xyz","xml");
32        OutputStream out = new FileOutputStream(tempFile);
33        byte[] buffer = new byte[8096];
34        for (;;)
35        {
36           int l = in.read(buffer);
37           if (l < 0) break;
38           out.write(buffer, 0, l);
39        }
40        out.close();
41        in.close();
42     }
43     
44     protected void tearDown() throws Exception
45     {
46        tempFile.delete();
47     }
48     
49     public static Test suite()
50     {
51        return new TestSuite(MainTest.class);
52     }
53     
54     /**
55      * Test of main method, of class org.lcsim.geometry.compact.converter.Main.
56      */
57     public void testMain() throws Throwable
58     {
59        String[] args = new String[]{tempFile.getAbsolutePath(), new TestOutputFile("temp.heprep").getAbsolutePath()};
60        Main.main(args);
61     }
62     
63     /**
64      * Test of getConverters method, of class org.lcsim.geometry.compact.converter.Main.
65      */
66  /*
67     public void testGetConverters()
68     {
69        List<Converter> converters = Main.getConverters();
70        assertEquals(3,converters.size());
71        for (Converter c : converters)
72        {
73           assertTrue(c instanceof Converter);
74        }
75     }
76  */
77  }