001    package serp.bytecode;
002    
003    import junit.framework.*;
004    import junit.textui.*;
005    
006    /**
007     * Tests the handling of primitive {@link BCClass}es.
008     *
009     * @author Abe White
010     */
011    public class TestPrimitive extends AbstractStateTest {
012        public TestPrimitive(String test) {
013            super(test);
014        }
015    
016        public void setUp() {
017            _bc = _project.loadClass(int.class);
018        }
019    
020        public void testType() {
021            assertEquals("int", _bc.getName());
022            assertNull(_bc.getPackageName());
023            assertEquals("int", _bc.getClassName());
024            assertEquals(int.class, _bc.getType());
025    
026            try {
027                _bc.setName("long");
028                fail("Allowed set name");
029            } catch (UnsupportedOperationException uoe) {
030            }
031    
032            assertTrue(_bc.isPrimitive());
033            assertTrue(!_bc.isArray());
034        }
035    
036        public void testSuperclass() {
037            assertNull(_bc.getSuperclassName());
038            try {
039                _bc.setSuperclass("long");
040                fail("Allowed set superclass");
041            } catch (UnsupportedOperationException uoe) {
042            }
043        }
044    
045        public void testComponent() {
046            assertNull(_bc.getComponentName());
047        }
048    
049        public static Test suite() {
050            return new TestSuite(TestPrimitive.class);
051        }
052    
053        public static void main(String[] args) {
054            TestRunner.run(suite());
055        }
056    }