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 8.7.2005
026: */package org.apache.harmony.jpda.tests.jdwp.MultiSession;
027:
028: import org.apache.harmony.jpda.tests.framework.TestOptions;
029: import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
030: import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
031: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
032:
033: /**
034: * JDWP Unit test for verifying invalidating of referenceTypeID after re-connection.
035: */
036: public class RefTypeIDTest extends JDWPSyncTestCase {
037:
038: private final String DEBUGGEE_SIGNATURE = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee;";
039:
040: private final String METHOD_NAME = "printWord";
041:
042: protected String getDebuggeeClassName() {
043: return "org.apache.harmony.jpda.tests.jdwp.MultiSession.MultiSessionDebuggee";
044: }
045:
046: /**
047: * This testcase verifies invalidating of referenceTypeID after re-connection.
048: * <BR>It runs multiSessionDebuggee, gets classID, re-connects
049: * and tries to set request for BREAKPOINT event using classID, received before
050: * re-connection.
051: * <BR>It is expected that INVALID_OBJECT or INVALID_CLASS error is returned.
052: */
053: public void testRefTypeID001() {
054:
055: synchronizer
056: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
057:
058: long classID = debuggeeWrapper.vmMirror
059: .getClassID(DEBUGGEE_SIGNATURE);
060:
061: logWriter.println("");
062: logWriter.println("=> CLOSE CONNECTION..");
063: closeConnection();
064: logWriter.println("=> CONNECTION CLOSED");
065:
066: logWriter.println("");
067: logWriter.println("=> OPEN NEW CONNECTION..");
068: openConnection();
069: logWriter.println("=> CONNECTION OPENED");
070:
071: boolean success = false;
072: logWriter
073: .println("=> Trying to set a breakpoint using old classID");
074: try {
075: //long requestID =
076: debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
077: classID, METHOD_NAME);
078:
079: } catch (Exception e) {
080: logWriter
081: .println("==> TEST PASSED, because INVALID_OBJECT exception was occurred");
082: success = true;
083: }
084:
085: if (!success) {
086: logWriter
087: .println("==> TEST FAILED, because INVALID_OBJECT exception was not occurred");
088: fail("INVALID_OBJECT exception was not occurred");
089: }
090:
091: // resuming debuggee
092: synchronizer
093: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
094: synchronizer
095: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
096: synchronizer
097: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
098: }
099:
100: protected void beforeDebuggeeStart(
101: JDWPUnitDebuggeeWrapper debuggeeWrapper) {
102: settings.setAttachConnectorKind();
103: if (settings.getTransportAddress() == null) {
104: settings
105: .setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS);
106: }
107: logWriter.println("ATTACH connector kind");
108: super .beforeDebuggeeStart(debuggeeWrapper);
109: }
110:
111: public static void main(String[] args) {
112: junit.textui.TestRunner.run(RefTypeIDTest.class);
113: }
114: }
|