1 19 20 package org.netbeans.test.stub.api; 21 22 import java.sql.Connection ; 23 import org.netbeans.junit.NbTestCase; 24 25 29 public class StubTest extends NbTestCase { 30 31 public StubTest(String name) { 32 super(name); 33 } 34 35 public void testDefault() { 36 Primitives p = (Primitives)Stub.create(new Class [] { Primitives.class }); 37 38 assertEquals(System.identityHashCode(p), p.hashCode()); 39 40 assertTrue(p.equals(p)); 41 assertFalse(p.equals(new Object ())); 42 43 assertEquals((byte)0, p.getByte()); 44 assertEquals((short)0, p.getShort()); 45 assertEquals(0, p.getInteger()); 46 assertEquals(0L, p.getLong()); 47 assertEquals(Float.floatToRawIntBits(0), Float.floatToRawIntBits(p.getFloat())); 48 assertEquals(Double.doubleToRawLongBits(0.0), Double.doubleToRawLongBits(p.getDouble())); 49 assertEquals('\0', p.getCharacter()); 50 assertEquals(false, p.getBoolean()); 51 } 52 53 private static interface Primitives { 54 55 public byte getByte(); 56 57 public short getShort(); 58 59 public int getInteger(); 60 61 public long getLong(); 62 63 public float getFloat(); 64 65 public double getDouble(); 66 67 public char getCharacter(); 68 69 public boolean getBoolean(); 70 } 71 } 72 | Popular Tags |