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 Aleksander V. Budniy 21 */ 22 23 /** 24 * Created on 12.08.2005 25 */ 26 package org.apache.harmony.jpda.tests.jdwp.MultiSession; 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.jdwp.share.JDWPUnitDebuggeeWrapper; 33 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer; 34 35 36 /** 37 * JDWP Unit test to check capacity for work of listening connector. 38 */ 39 public class ListenConnectorTest extends JDWPSyncTestCase { 40 getDebuggeeClassName()41 protected String getDebuggeeClassName() { 42 return "org.apache.harmony.jpda.tests.jdwp.MultiSession.ConnectorKindDebuggee"; 43 } 44 45 /** 46 * Sets kind of connection: listen kind. 47 */ beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper)48 protected void beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper) { 49 settings.setListenConnectorKind(); 50 logWriter.println("LISTEN connector kind"); 51 super.beforeDebuggeeStart(debuggeeWrapper); 52 } 53 54 /** 55 * This testcase checks capacity for work of listening connector. 56 * <BR>Before debuggee start it sets up connector kind to listening and starts 57 * ConnectorKindDebuggee. Then testcase performs VirtualMachine.Version 58 * command and checks it's correctness. 59 * It is expected that command returns not empty strings describing VM version. 60 */ testListenConnector()61 public void testListenConnector() { 62 63 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 64 65 CommandPacket packet = new CommandPacket( 66 JDWPCommands.VirtualMachineCommandSet.CommandSetID, 67 JDWPCommands.VirtualMachineCommandSet.VersionCommand); 68 69 ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet); 70 checkReplyPacket(reply, "VirtualMachine::Version command"); 71 72 String description = reply.getNextValueAsString(); 73 int jdwpMajor = reply.getNextValueAsInt(); 74 int jdwpMinor = reply.getNextValueAsInt(); 75 String vmVersion = reply.getNextValueAsString(); 76 String vmName = reply.getNextValueAsString(); 77 78 logWriter.println("description\t= " + description); 79 logWriter.println("jdwpMajor\t= " + jdwpMajor); 80 logWriter.println("jdwpMinor\t= " + jdwpMinor); 81 logWriter.println("vmVersion\t= " + vmVersion); 82 logWriter.println("vmName\t\t= " + vmName); 83 84 if (!(description.length() > 0)) { 85 logWriter.println("\n## FAILURE: description.length = 0"); 86 fail("description.length = 0"); 87 } 88 89 if (!(vmVersion.length() > 0)) { 90 logWriter.println("\n## FAILURE: vmVersion.length = 0"); 91 fail("vmVersion.length = 0"); 92 } 93 94 if (!(vmName.length() > 0)) { 95 logWriter.println("\n## FAILURE: vmName.length = 0"); 96 fail("vmName.length = 0"); 97 } 98 99 logWriter.println("CHECK PASSED"); 100 logWriter.println("System property: " 101 + System.getProperty("isDebuggeeRunning")); 102 103 synchronizer.sendMessage("stop"); 104 synchronizer.receiveMessage("END"); 105 logWriter.println("==> testListenConnector001 PASSED!"); 106 } 107 } 108