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.4 $
22: */
23:
24: /**
25: * Created on 29.01.2005
26: */package org.apache.harmony.jpda.tests.jdwp.VirtualMachine;
27:
28: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
29: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
30: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
31: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
32: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
33:
34: /**
35: * JDWP Unit test for VirtualMachine.Version command.
36: */
37: public class VersionTest extends JDWPSyncTestCase {
38:
39: protected String getDebuggeeClassName() {
40: return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
41: }
42:
43: /**
44: * This testcase exercises VirtualMachine.Version command.
45: * <BR>At first the test starts HelloWorld debuggee.
46: * <BR> Then the test performs VirtualMachine.Version command
47: * and checks that:
48: * <BR> - length of returned description is greater than 0;
49: * <BR> - length of returned vmVersion is greater than 0;
50: * <BR> - length of returned vmName is greater than 0;
51: */
52: public void testVersion001() {
53:
54: synchronizer
55: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
56:
57: CommandPacket packet = new CommandPacket(
58: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
59: JDWPCommands.VirtualMachineCommandSet.VersionCommand);
60:
61: ReplyPacket reply = debuggeeWrapper.vmMirror
62: .performCommand(packet);
63:
64: String description = reply.getNextValueAsString();
65: int jdwpMajor = reply.getNextValueAsInt();
66: int jdwpMinor = reply.getNextValueAsInt();
67: String vmVersion = reply.getNextValueAsString();
68: String vmName = reply.getNextValueAsString();
69:
70: logWriter.println("description\t= " + description);
71: logWriter.println("jdwpMajor\t= " + jdwpMajor);
72: logWriter.println("jdwpMinor\t= " + jdwpMinor);
73: logWriter.println("vmVersion\t= " + vmVersion);
74: logWriter.println("vmName\t\t= " + vmName);
75:
76: if (!(description.length() > 0)) {
77: printErrorAndFail("description.length = 0");
78: }
79:
80: if (!(vmVersion.length() > 0)) {
81: printErrorAndFail("vmVersion.length = 0");
82: }
83:
84: if (!(vmName.length() > 0)) {
85: printErrorAndFail("vmName.length = 0");
86: }
87:
88: logWriter.println("CHECK PASSED");
89:
90: synchronizer
91: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
92: }
93:
94: public static void main(String[] args) {
95: junit.textui.TestRunner.run(VersionTest.class);
96: }
97: }
|