001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Aleksander V. Budniy
021: * @version $Revision: 1.5 $
022: */
023:
024: /**
025: * Created on 12.08.2005
026: */package org.apache.harmony.jpda.tests.jdwp.MultiSession;
027:
028: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
029: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
030: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
031: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
032: import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
033: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
034:
035: /**
036: * JDWP Unit test to check capacity for work of listening connector.
037: */
038: public class ListenConnectorTest extends JDWPSyncTestCase {
039:
040: protected String getDebuggeeClassName() {
041: return "org.apache.harmony.jpda.tests.jdwp.MultiSession.ConnectorKindDebuggee";
042: }
043:
044: /**
045: * Sets kind of connection: listen kind.
046: */
047: protected void beforeDebuggeeStart(
048: JDWPUnitDebuggeeWrapper debuggeeWrapper) {
049: settings.setListenConnectorKind();
050: logWriter.println("LISTEN connector kind");
051: super .beforeDebuggeeStart(debuggeeWrapper);
052: }
053:
054: /**
055: * This testcase checks capacity for work of listening connector.
056: * <BR>Before debuggee start it sets up connector kind to listening and starts
057: * ConnectorKindDebuggee. Then testcase performs VirtualMachine.Version
058: * command and checks it's correctness.
059: * It is expected that command returns not empty strings describing VM version.
060: */
061: public void testListenConnector() {
062:
063: synchronizer
064: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
065:
066: CommandPacket packet = new CommandPacket(
067: JDWPCommands.VirtualMachineCommandSet.CommandSetID,
068: JDWPCommands.VirtualMachineCommandSet.VersionCommand);
069:
070: ReplyPacket reply = debuggeeWrapper.vmMirror
071: .performCommand(packet);
072: checkReplyPacket(reply, "VirtualMachine::Version command");
073:
074: String description = reply.getNextValueAsString();
075: int jdwpMajor = reply.getNextValueAsInt();
076: int jdwpMinor = reply.getNextValueAsInt();
077: String vmVersion = reply.getNextValueAsString();
078: String vmName = reply.getNextValueAsString();
079:
080: logWriter.println("description\t= " + description);
081: logWriter.println("jdwpMajor\t= " + jdwpMajor);
082: logWriter.println("jdwpMinor\t= " + jdwpMinor);
083: logWriter.println("vmVersion\t= " + vmVersion);
084: logWriter.println("vmName\t\t= " + vmName);
085:
086: if (!(description.length() > 0)) {
087: logWriter.println("\n## FAILURE: description.length = 0");
088: fail("description.length = 0");
089: }
090:
091: if (!(vmVersion.length() > 0)) {
092: logWriter.println("\n## FAILURE: vmVersion.length = 0");
093: fail("vmVersion.length = 0");
094: }
095:
096: if (!(vmName.length() > 0)) {
097: logWriter.println("\n## FAILURE: vmName.length = 0");
098: fail("vmName.length = 0");
099: }
100:
101: logWriter.println("CHECK PASSED");
102: logWriter.println("System property: "
103: + System.getProperty("isDebuggeeRunning"));
104:
105: synchronizer.sendMessage("stop");
106: synchronizer.receiveMessage("END");
107: logWriter.println("==> testListenConnector001 PASSED!");
108: }
109:
110: public static void main(String[] args) {
111: junit.textui.TestRunner.run(ListenConnectorTest.class);
112: }
113: }
|