EMMA Coverage Report (generated Wed Apr 19 22:57:21 CEST 2006)
[all classes][com.eaio.nativecall]

COVERAGE SUMMARY FOR SOURCE FILE [Win32VerifierTest.java]

nameclass, %method, %block, %line, %
Win32VerifierTest.java100% (1/1)83%  (5/6)76%  (123/161)84%  (38,8/46)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Win32VerifierTest100% (1/1)83%  (5/6)76%  (123/161)84%  (38,8/46)
main (String []): void 0%   (0/1)0%   (0/17)0%   (0/2)
testVerifyFunctionName (): void 100% (1/1)41%  (13/32)49%  (4,9/10)
testVerifyModuleName (): void 100% (1/1)95%  (42/44)99%  (11,9/12)
Win32VerifierTest (String): void 100% (1/1)100% (4/4)100% (2/2)
testGetDefaultModule (): void 100% (1/1)100% (9/9)100% (3/3)
testHandleString (): void 100% (1/1)100% (55/55)100% (17/17)

1/*
2 * Win32VerifierTest.java
3 * 
4 * Created on 16.09.2004
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 */
29package com.eaio.nativecall;
30import junit.framework.TestCase;
31 
32import com.eaio.nativecall.Win32Verifier;
33 
34/**
35 * Test case for the {@link com.eaio.nativecall.Win32Verifier} class.
36 * 
37 * @author <a href="mailto:jb@eaio.com">Johann Burkard</a>
38 * @version $Id: Win32VerifierTest.java,v 1.2 2006/01/05 19:57:07 grnull Exp $
39 */
40public class Win32VerifierTest extends TestCase {
41 
42    /**
43     * Constructor for Win32VerifierTest.
44     * @param arg0
45     */
46    public Win32VerifierTest(String arg0) {
47        super(arg0);
48    }
49 
50    public static void main(String[] args) {
51        junit.awtui.TestRunner.run(Win32VerifierTest.class);
52    }
53 
54    public void testVerifyModuleName() {
55        Win32Verifier ver = new Win32Verifier();
56        
57        assertEquals("kernel32", ver.verifyModuleName(null));
58        assertEquals("kernel32", ver.verifyModuleName(""));
59 
60        String module = "blabla.dll";
61        assertTrue(module == ver.verifyModuleName(module));
62 
63        module = "bla\\blorb.dll";
64        assertTrue(module == ver.verifyModuleName(module));
65 
66        module = "c:/bla/blorb/blub\\bla.dll";
67        assertEquals(
68            "c:\\bla\\blorb\\blub\\bla.dll",
69            ver.verifyModuleName(module));
70    }
71 
72    public void testVerifyFunctionName() {
73        Win32Verifier ver = new Win32Verifier();
74 
75        try {
76            ver.verifyFunctionName(null);
77            fail("Did not throw NPE.");
78        }
79        catch (NullPointerException ex) {}
80 
81        try {
82            ver.verifyFunctionName("");
83            fail("Did not throw NPE.");
84        }
85        catch (NullPointerException ex) {}
86 
87        String function = "GetProcessId";
88        assertTrue(function == ver.verifyFunctionName(function));
89    }
90 
91    public void testGetDefaultModule() {
92        Win32Verifier ver = new Win32Verifier();
93        assertEquals("kernel32", ver.getDefaultModule());
94    }
95 
96    public void testHandleString() {
97        Win32Verifier ver = new Win32Verifier();
98 
99        String bla = "blorb";
100 
101        assertTrue(ver.handleString(bla, "kernel32", "Blub") instanceof byte[]);
102        assertEquals(
103            6,
104            ((byte[]) ver.handleString(bla, "kernel32", "Blub")).length);
105        assertTrue(
106            ver.handleString(bla, "kernel32", "BlubA") instanceof byte[]);
107        assertEquals(
108            6,
109            ((byte[]) ver.handleString(bla, "kernel32", "BlubA")).length);
110 
111        assertTrue(
112            ver.handleString(bla, "kernel32", "BlubW") instanceof char[]);
113        assertEquals(
114            6,
115            ((char[]) ver.handleString(bla, "kernel32", "BlubW")).length);
116    }
117 
118}

[all classes][com.eaio.nativecall]
EMMA 2.0.4217 (C) Vladimir Roubtsov