1f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz/* 2f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * Licensed to the Apache Software Foundation (ASF) under one or more 3f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * contributor license agreements. See the NOTICE file distributed with 4f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * this work for additional information regarding copyright ownership. 5f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * The ASF licenses this file to You under the Apache License, Version 2.0 6f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * (the "License"); you may not use this file except in compliance with 7f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * the License. You may obtain a copy of the License at 8f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * 9f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * http://www.apache.org/licenses/LICENSE-2.0 10f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * 11f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * Unless required by applicable law or agreed to in writing, software 12f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * distributed under the License is distributed on an "AS IS" BASIS, 13f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * 15f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * See the License for the specific language governing permissions and 16f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * limitations under the License. 17f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz */ 18f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 19f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertzpackage org.apache.harmony.jpda.tests.jdwp.ClassType; 20f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 21f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertzimport org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; 22f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertzimport org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands; 23f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertzimport org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants; 24f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertzimport org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; 25f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertzimport org.apache.harmony.jpda.tests.framework.jdwp.TaggedObject; 26f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertzimport org.apache.harmony.jpda.tests.jdwp.share.JDWPInvokeMethodWithSuspensionTestCase; 27f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 28f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz/** 29f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz * JDWP unit test for ClassType.NewInstance command with a thread suspension. 30f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz */ 31f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertzpublic class NewInstanceWithSuspensionTest extends JDWPInvokeMethodWithSuspensionTestCase { 32f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz public void testInvokeWithMultipleEvents001() { 33f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz runInvokeMethodTest("<init>"); 34f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz } 35f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 36f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz @Override 37f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz protected CommandPacket buildInvokeCommand(long threadId, long classID, 38f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz long methodId, int invoke_options) { 39f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz CommandPacket command = new CommandPacket( 40f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz JDWPCommands.ClassTypeCommandSet.CommandSetID, 41f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz JDWPCommands.ClassTypeCommandSet.NewInstanceCommand); 42f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz command.setNextValueAsClassID(classID); 43f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz command.setNextValueAsThreadID(threadId); 44f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz command.setNextValueAsMethodID(methodId); 45f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz command.setNextValueAsInt(0); 46f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz command.setNextValueAsInt(invoke_options); 47f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz return command; 48f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz } 49f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 50f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz @Override 51f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz protected String getInvokeCommandName() { 52f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz return "ClassType.NewInstance"; 53f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz } 54f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 55f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz @Override 56f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz protected void checkInvokeReply(ReplyPacket reply) { 57f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz // Check result is 'void' 58f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz TaggedObject invokeNewObject = reply.getNextValueAsTaggedObject(); 59f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz assertEquals(JDWPConstants.Tag.OBJECT_TAG, invokeNewObject.tag); 60f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz assertFalse("Invalid exception object id", invokeNewObject.objectID == 0); 61f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 62f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz // Check exception is null. 63f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz TaggedObject invokeException = reply.getNextValueAsTaggedObject(); 64f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz assertEquals(JDWPConstants.Tag.OBJECT_TAG, invokeException.tag); 65f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz assertEquals("Invalid exception object id", 0, invokeException.objectID); 66f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 67f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz assertAllDataRead(reply); 68f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 69f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz } 70f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz 71f8670f3c29626892e32d30aa00ce8e4b94bd9609Sebastien Hertz} 72