KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > eaio > nativecall > VoidCallTest


1 /*
2  * VoidCallTest.java
3  *
4  * Created on 05.01.2006.
5  *
6  * eaio: NativeCall - calling operating system methods from Java
7  * Copyright (c) 2004-2006 Johann Burkard (<mailto:jb@eaio.com>)
8  * <http://eaio.com>
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
23  * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
24  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26  * USE OR OTHER DEALINGS IN THE SOFTWARE.
27  *
28  */

29 package com.eaio.nativecall;
30
31 import java.util.HashSet JavaDoc;
32
33 import junit.framework.TestCase;
34
35 /**
36  * Test case for the {@link com.eaio.nativecall.VoidCall} class.
37  *
38  * @author <a HREF="mailto:jb@eaio.com">Johann Burkard</a>
39  * @version $Id: VoidCallTest.java,v 1.2 2006/04/12 22:11:41 grnull Exp $
40  */

41 public class VoidCallTest extends TestCase {
42
43     static {
44         try {
45             NativeCall.init();
46         }
47         catch (Throwable JavaDoc thrw) {
48             thrw.printStackTrace();
49             fail(thrw.getLocalizedMessage());
50         }
51     }
52
53     /**
54      * Constructor for VoidCallTest.
55      * @param arg0
56      */

57     public VoidCallTest(String JavaDoc arg0) {
58         super(arg0);
59     }
60
61     public static void main(String JavaDoc[] args) {
62         junit.awtui.TestRunner.run(VoidCallTest.class);
63     }
64
65     /*
66      * Test for void executeCall()
67      */

68     public void testExecuteCall() {}
69
70     /*
71      * Test for void executeCall(Object)
72      */

73     public void testExecuteCallObject() {
74         /* This is of course not really a void call. */
75         VoidCall cT = new VoidCall("GetCurrentThread");
76         try {
77             /* to trigger an Exception */
78             cT.executeCall(new StringBuffer JavaDoc());
79             fail("Did not throw ClassCastException");
80         }
81         catch (ClassCastException JavaDoc ex) {}
82     }
83
84     /*
85      * Test for void executeCall(Object[])
86      */

87     public void testExecuteCallObjectArray() {
88         /* This is of course not really a void call. */
89         VoidCall cT = new VoidCall("GetCurrentThread");
90         try {
91             /* to trigger an Exception */
92             cT.executeCall(new Object JavaDoc[] { new StringBuffer JavaDoc() });
93             fail("Did not throw ClassCastException");
94         }
95         catch (ClassCastException JavaDoc 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 JavaDoc set = new HashSet JavaDoc();
104         set.add(cT);
105         set.add(cT2);
106         assertEquals(1, set.size());
107
108     }
109
110 }
111
Popular Tags