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 8.7.2005 25 */ 26 package org.apache.harmony.jpda.tests.jdwp.MultiSession; 27 28 import org.apache.harmony.jpda.tests.framework.TestOptions; 29 import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase; 30 import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper; 31 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer; 32 33 34 /** 35 * JDWP Unit test for verifying invalidating of referenceTypeID after re-connection. 36 */ 37 public class RefTypeIDTest extends JDWPSyncTestCase { 38 39 private final String DEBUGGEE_SIGNATURE = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee;"; 40 41 private final String METHOD_NAME = "printWord"; 42 getDebuggeeClassName()43 protected String getDebuggeeClassName() { 44 return "org.apache.harmony.jpda.tests.jdwp.MultiSession.MultiSessionDebuggee"; 45 } 46 47 /** 48 * This testcase verifies invalidating of referenceTypeID after re-connection. 49 * <BR>It runs multiSessionDebuggee, gets classID, re-connects 50 * and tries to set request for BREAKPOINT event using classID, received before 51 * re-connection. 52 * <BR>It is expected that INVALID_OBJECT or INVALID_CLASS error is returned. 53 */ testRefTypeID001()54 public void testRefTypeID001() { 55 56 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 57 58 long classID = debuggeeWrapper.vmMirror.getClassID(DEBUGGEE_SIGNATURE); 59 60 logWriter.println(""); 61 logWriter.println("=> CLOSE CONNECTION.."); 62 closeConnection(); 63 logWriter.println("=> CONNECTION CLOSED"); 64 65 logWriter.println(""); 66 logWriter.println("=> OPEN NEW CONNECTION.."); 67 openConnection(); 68 logWriter.println("=> CONNECTION OPENED"); 69 70 boolean success = false; 71 logWriter.println("=> Trying to set a breakpoint using old classID"); 72 try{ 73 //long requestID = 74 debuggeeWrapper.vmMirror 75 .setBreakpointAtMethodBegin(classID, METHOD_NAME); 76 77 }catch(Exception e){ 78 logWriter.println("==> TEST PASSED, because INVALID_OBJECT exception was occurred"); 79 success = true; 80 } 81 82 if (!success) { 83 logWriter.println("==> TEST FAILED, because INVALID_OBJECT exception was not occurred"); 84 fail("INVALID_OBJECT exception was not occurred"); 85 } 86 87 // resuming debuggee 88 synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); 89 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 90 synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); 91 } 92 beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper)93 protected void beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper) { 94 settings.setAttachConnectorKind(); 95 if (settings.getTransportAddress() == null) { 96 settings.setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS); 97 } 98 logWriter.println("ATTACH connector kind"); 99 super.beforeDebuggeeStart(debuggeeWrapper); 100 } 101 } 102