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 package org.apache.harmony.jpda.tests.jdwp.Events; 20 21 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants; 22 import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent.EventThread; 23 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer; 24 25 /** 26 * JDWP Unit test for BREAKPOINT event in methods possibly inlined. 27 */ 28 public class Breakpoint002Test extends JDWPEventTestCase { getDebuggeeClassName()29 protected String getDebuggeeClassName() { 30 return Breakpoint002Debuggee.class.getName(); 31 } 32 33 /** 34 * This testcase is for BREAKPOINT event. 35 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 36 * breakpointReturnVoid method, then verifies that requested BREAKPOINT 37 * event occurs. 38 */ testInlinedReturnVoid()39 public void testInlinedReturnVoid() { 40 testBreakpointIn("testInlinedReturnVoid", "breakpointReturnVoid"); 41 } 42 43 /** 44 * This testcase is for BREAKPOINT event. 45 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 46 * breakpointReturnIntConst method, then verifies that requested BREAKPOINT 47 * event occurs. 48 */ testInlinedReturnIntConstant()49 public void testInlinedReturnIntConstant() { 50 testBreakpointIn("testInlinedReturnIntConstant", 51 "breakpointReturnIntConst"); 52 } 53 54 /** 55 * This testcase is for BREAKPOINT event. 56 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 57 * breakpointReturnLongConst method, then verifies that requested BREAKPOINT 58 * event occurs. 59 */ testInlinedReturnLongConstant()60 public void testInlinedReturnLongConstant() { 61 testBreakpointIn("testInlinedReturnLongConstant", 62 "breakpointReturnLongConst"); 63 } 64 65 /** 66 * This testcase is for BREAKPOINT event. 67 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 68 * breakpointReturnIntArg method, then verifies that requested BREAKPOINT 69 * event occurs. 70 */ testInlinedReturnIntArgument()71 public void testInlinedReturnIntArgument() { 72 testBreakpointIn("testInlinedReturnIntArgument", 73 "breakpointReturnIntArg"); 74 } 75 76 /** 77 * This testcase is for BREAKPOINT event. 78 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 79 * breakpointReturnLongArg method, then verifies that requested BREAKPOINT 80 * event occurs. 81 */ testInlinedReturnLongArgument()82 public void testInlinedReturnLongArgument() { 83 testBreakpointIn("testInlinedReturnLongArgument", 84 "breakpointReturnLongArg"); 85 } 86 87 /** 88 * This testcase is for BREAKPOINT event. 89 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 90 * breakpointReturnObjectArg method, then verifies that requested BREAKPOINT 91 * event occurs. 92 */ testInlinedReturnObjectArgument()93 public void testInlinedReturnObjectArgument() { 94 testBreakpointIn("testInlinedReturnObjectArgument", 95 "breakpointReturnObjectArg"); 96 } 97 98 /** 99 * This testcase is for BREAKPOINT event. 100 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 101 * breakpointIntGetter method, then verifies that requested BREAKPOINT 102 * event occurs. 103 */ testInlinedIntGetter()104 public void testInlinedIntGetter() { 105 testBreakpointIn("testInlinedIntGetter", "breakpointIntGetter"); 106 } 107 108 /** 109 * This testcase is for BREAKPOINT event. 110 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 111 * breakpointLongGetter method, then verifies that requested BREAKPOINT 112 * event occurs. 113 */ testInlinedLongGetter()114 public void testInlinedLongGetter() { 115 testBreakpointIn("testInlinedLongGetter", "breakpointLongGetter"); 116 } 117 118 /** 119 * This testcase is for BREAKPOINT event. 120 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 121 * breakpointObjectGetter method, then verifies that requested BREAKPOINT 122 * event occurs. 123 */ testInlinedObjectGetter()124 public void testInlinedObjectGetter() { 125 testBreakpointIn("testInlinedObjectGetter", "breakpointObjectGetter"); 126 } 127 128 /** 129 * This testcase is for BREAKPOINT event. 130 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 131 * breakpointIntSetter method, then verifies that requested BREAKPOINT 132 * event occurs. 133 */ testInlinedIntSetter()134 public void testInlinedIntSetter() { 135 testBreakpointIn("testInlinedIntSetter", "breakpointIntSetter"); 136 } 137 138 /** 139 * This testcase is for BREAKPOINT event. 140 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 141 * breakpointLongSetter method, then verifies that requested BREAKPOINT 142 * event occurs. 143 */ testInlinedLongSetter()144 public void testInlinedLongSetter() { 145 testBreakpointIn("testInlinedLongSetter", "breakpointLongSetter"); 146 } 147 148 /** 149 * This testcase is for BREAKPOINT event. 150 * <BR>It runs Breakpoint002Debuggee and sets breakpoint in the 151 * breakpointObjectSetter method, then verifies that requested BREAKPOINT 152 * event occurs. 153 */ testInlinedObjectSetter()154 public void testInlinedObjectSetter() { 155 testBreakpointIn("testInlinedObjectSetter", "breakpointObjectSetter"); 156 } 157 testBreakpointIn(String testName, String methodName)158 private void testBreakpointIn(String testName, String methodName) { 159 logWriter.println(testName + " started"); 160 long classID = debuggeeWrapper.vmMirror.getClassID(getDebuggeeClassSignature()); 161 assertTrue("Failed to find debuggee class", classID != -1); 162 163 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 164 int breakpointReqID = debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(classID, methodName); 165 assertTrue("Failed to install breakpoint in method " + methodName, breakpointReqID != -1); 166 synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); 167 168 long eventThreadID = debuggeeWrapper.vmMirror.waitForBreakpoint(breakpointReqID); 169 checkThreadState(eventThreadID, JDWPConstants.ThreadStatus.RUNNING, 170 JDWPConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED); 171 172 logWriter.println(testName + " done"); 173 } 174 } 175