01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: *
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * @author Vitaly A. Provodin
21: * @version $Revision: 1.5 $
22: */
23:
24: /**
25: * Created on 10.02.2005
26: */package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
27:
28: import java.io.File;
29:
30: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
31: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
32: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
33: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
34: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
35:
36: /**
37: * JDWP Unit test for VirtualMachine.ClassPaths command.
38: */
39: public class ClassPathsTest extends JDWPSyncTestCase {
40:
41: protected String getDebuggeeClassName() {
42: return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
43: }
44:
45: /**
46: * This testcase exercises VirtualMachine.ClassPaths command.
47: * <BR>At first the test starts HelloWorld debuggee.
48: * <BR> Then the test performs VirtualMachine.ClassPaths command and checks that:
49: * <BR> - the 'baseDir' directory exists;
50: * <BR> - amount of bootclasspaths is greater than 0;
51: * <BR> - length of strings representing classpaths, bootclasspaths is not zero;
52: * <BR> - there are no extra data in the reply packet;
53: */
54: public void testClassPaths001() {
55: synchronizer
56: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
57:
58: CommandPacket packet = new CommandPacket(
59: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
60: JDWPCommands.VirtualMachineCommandSet.ClassPathsCommand);
61: logWriter.println("\trequest class paths");
62:
63: ReplyPacket reply = debuggeeWrapper.vmMirror
64: .performCommand(packet);
65: checkReplyPacket(reply, "VirtualMachine::ClassPaths command");
66:
67: String baseDir = reply.getNextValueAsString();
68: logWriter.println("baseDir = " + baseDir);
69: assertTrue("baseDir = " + baseDir + " doesn't exists",
70: new File(baseDir).exists());
71:
72: int classpaths = reply.getNextValueAsInt();
73: logWriter.println("classpaths = " + classpaths);
74: for (int i = 0; i < classpaths; i++) {
75: String path = reply.getNextValueAsString();
76: logWriter.println("\t" + path);
77: if (!(path.length() > 0)) {
78: logWriter.println("Path length = " + path.length());
79: }
80: }
81:
82: int bootclasspaths = reply.getNextValueAsInt();
83: logWriter.println("bootclasspaths = " + bootclasspaths);
84: assertTrue(bootclasspaths > 0);
85: for (int i = 0; i < bootclasspaths; i++) {
86: String path = reply.getNextValueAsString();
87: logWriter.println("\t" + path);
88: assertTrue("Invalid path", path.length() > 0);
89: }
90:
91: assertAllDataRead(reply);
92: synchronizer
93: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
94: }
95:
96: public static void main(String[] args) {
97: junit.textui.TestRunner.run(ClassPathsTest.class);
98: }
99: }
|