• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *     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  */
22 
23 /**
24  * Created on 10.02.2005
25  */
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 
38 /**
39  * JDWP Unit test for VirtualMachine.ClassPaths command.
40  */
41 public class ClassPathsTest extends JDWPSyncTestCase {
42 
43     @Override
getDebuggeeClassName()44     protected String getDebuggeeClassName() {
45         return "org.apache.harmony.jpda.tests.jdwp.share.debuggee.HelloWorld";
46     }
47 
48     /**
49      * This testcase exercises VirtualMachine.ClassPaths command.
50      * <BR>At first the test starts HelloWorld debuggee.
51      * <BR> Then the test performs VirtualMachine.ClassPaths command and checks that:
52      * <BR>&nbsp;&nbsp; - the 'baseDir' directory exists;
53      * <BR>&nbsp;&nbsp; - amount of bootclasspaths is greater than 0;
54      * <BR>&nbsp;&nbsp; - length of strings representing classpaths, bootclasspaths is not zero;
55      * <BR>&nbsp;&nbsp; - there are no extra data in the reply packet;
56      */
testClassPaths001()57     public void testClassPaths001() {
58         synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
59 
60         CommandPacket packet = new CommandPacket(
61                 JDWPCommands.VirtualMachineCommandSet.CommandSetID,
62                 JDWPCommands.VirtualMachineCommandSet.ClassPathsCommand);
63         logWriter.println("\trequest class paths");
64 
65         ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
66         checkReplyPacket(reply, "VirtualMachine::ClassPaths command");
67 
68         String baseDir = reply.getNextValueAsString();
69         logWriter.println("baseDir = " + baseDir);
70         assertTrue("baseDir = " + baseDir + " doesn't exists",
71                 new File(baseDir).exists());
72 
73         int classpaths = reply.getNextValueAsInt();
74         logWriter.println("classpaths = " + classpaths);
75         for (int i = 0; i < classpaths; i++) {
76             String path = reply.getNextValueAsString();
77             logWriter.println("\t" + path);
78             if(!(path.length() > 0)){
79                 logWriter.println("Path length = "+path.length());
80             }
81         }
82 
83         int bootclasspaths = reply.getNextValueAsInt();
84         logWriter.println("bootclasspaths = " + bootclasspaths);
85         assertTrue(bootclasspaths > 0);
86         for (int i = 0; i < bootclasspaths; i++) {
87             String path = reply.getNextValueAsString();
88             logWriter.println("\t" + path);
89             assertTrue("Invalid path", path.length() > 0);
90         }
91 
92         assertAllDataRead(reply);
93         synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
94     }
95 }
96