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 classObjectID after re-connection.
035: */
036: public class ClassObjectIDTest extends JDWPSyncTestCase {
037:
038: private String DEBUGGEE_SIGNATURE = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee;";
039:
040: //private 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 classObjectID after re-connection.
048: * <BR>It runs multiSessionDebuggee, gets classID and classObjectID, re-connects
049: * and tries to get refTypeID with ObjectReference.ReferenceType command
050: * using old classObjectID.
051: * <BR>It is expected that INVALID_OBJECT error is returned by command.
052: */
053: public void testClassObjectID001() {
054:
055: synchronizer
056: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
057:
058: long classID = debuggeeWrapper.vmMirror
059: .getClassID(DEBUGGEE_SIGNATURE);
060: long classObjectID = debuggeeWrapper.vmMirror
061: .getClassObjectId(classID);
062:
063: logWriter.println("");
064: logWriter.println("=> CLOSE CONNECTION..");
065: closeConnection();
066: logWriter.println("=> CONNECTION CLOSED");
067:
068: logWriter.println("");
069: logWriter.println("=> OPEN NEW CONNECTION..");
070: openConnection();
071: logWriter.println("=> CONNECTION OPENED");
072:
073: logWriter
074: .println("=> Trying to get classID using old classObjectID");
075: boolean success = false;
076: try {
077: //long requestID =
078: debuggeeWrapper.vmMirror.getReferenceType(classObjectID);
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(ClassObjectIDTest.class);
113: }
114: }
|