View Javadoc

1   package serp.bytecode;
2   
3   import junit.framework.*;
4   import junit.textui.*;
5   
6   /**
7    * Tests the handling of primitive {@link BCClass}es.
8    *
9    * @author Abe White
10   */
11  public class TestPrimitive extends AbstractStateTest {
12      public TestPrimitive(String test) {
13          super(test);
14      }
15  
16      public void setUp() {
17          _bc = _project.loadClass(int.class);
18      }
19  
20      public void testType() {
21          assertEquals("int", _bc.getName());
22          assertNull(_bc.getPackageName());
23          assertEquals("int", _bc.getClassName());
24          assertEquals(int.class, _bc.getType());
25  
26          try {
27              _bc.setName("long");
28              fail("Allowed set name");
29          } catch (UnsupportedOperationException uoe) {
30          }
31  
32          assertTrue(_bc.isPrimitive());
33          assertTrue(!_bc.isArray());
34      }
35  
36      public void testSuperclass() {
37          assertNull(_bc.getSuperclassName());
38          try {
39              _bc.setSuperclass("long");
40              fail("Allowed set superclass");
41          } catch (UnsupportedOperationException uoe) {
42          }
43      }
44  
45      public void testComponent() {
46          assertNull(_bc.getComponentName());
47      }
48  
49      public static Test suite() {
50          return new TestSuite(TestPrimitive.class);
51      }
52  
53      public static void main(String[] args) {
54          TestRunner.run(suite());
55      }
56  }