Code example for ObjectStreamField

Methods: getName, getType, isUnshared

0
        assertFalse("Test 3: Unshared member not set correctly.",
                    osf.isUnshared());
 
        // Repeat the tests with a different object to make sure 
        // that we have not tested against default values. 
        osf = new ObjectStreamField("anotherField", String.class, true);
        assertTrue("Test 4: Name member not set correctly.",
                   osf.getName().equals("anotherField"));
        assertTrue("Test 5: Type member not set correctly.",
                   osf.getType().equals(String.class));
        assertTrue("Test 6: Unshared member not set correctly.",
                   osf.isUnshared());
 
        // Invalid argument tests. 
        try { 
            osf = new ObjectStreamField(null, boolean.class);
            fail("Test 7: NullPointerException expected.");
        } catch (NullPointerException e) {
            // Expected. 
        } 
        try {