1 29 package com.eaio.nativecall; 30 31 import java.util.HashSet ; 32 33 import junit.framework.TestCase; 34 35 41 public class VoidCallTest extends TestCase { 42 43 static { 44 try { 45 NativeCall.init(); 46 } 47 catch (Throwable thrw) { 48 thrw.printStackTrace(); 49 fail(thrw.getLocalizedMessage()); 50 } 51 } 52 53 57 public VoidCallTest(String arg0) { 58 super(arg0); 59 } 60 61 public static void main(String [] args) { 62 junit.awtui.TestRunner.run(VoidCallTest.class); 63 } 64 65 68 public void testExecuteCall() {} 69 70 73 public void testExecuteCallObject() { 74 75 VoidCall cT = new VoidCall("GetCurrentThread"); 76 try { 77 78 cT.executeCall(new StringBuffer ()); 79 fail("Did not throw ClassCastException"); 80 } 81 catch (ClassCastException ex) {} 82 } 83 84 87 public void testExecuteCallObjectArray() { 88 89 VoidCall cT = new VoidCall("GetCurrentThread"); 90 try { 91 92 cT.executeCall(new Object [] { new StringBuffer () }); 93 fail("Did not throw ClassCastException"); 94 } 95 catch (ClassCastException ex) {} 96 97 VoidCall cT2 = new VoidCall("GetCurrentThread"); 98 assertEquals(cT, cT2); 99 assertEquals(cT, cT); 100 assertFalse(cT.equals(null)); 101 assertTrue(cT.hashCode() == cT2.hashCode()); 102 103 HashSet set = new HashSet (); 104 set.add(cT); 105 set.add(cT2); 106 assertEquals(1, set.size()); 107 108 } 109 110 } 111 | Popular Tags |