You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by sp...@apache.org on 2009/11/24 12:27:11 UTC
svn commit: r883669 [2/6] - in
/incubator/kato/trunk/org.apache.kato/kato.tck: ./ src/test/ant/
src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/kato/
src/test/java/org/apache/kato/tck/ src/test/java/org/apache/kato/tck/tests/
src/...
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getInt.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getInt.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getInt.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getInt.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaField_getInt;
+
+
+/**
+ * Test JavaField.getInteger() against various fields and values.
+ *
+ */
+public class TestJavaField_getInt extends TCKJavaRuntimeTestcase {
+
+ SetupJavaField_getInt setup=new SetupJavaField_getInt();
+
+ static JavaObject thisObject = null;
+ public JavaObject getScenerioReference() {
+ if (thisObject == null) {
+ thisObject = super.getScenerioReference();
+ }
+ return thisObject;
+ }
+
+ public void testMaxIntegerValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField maxIntegerField = getJavaField(thisJavaObject, "maxInteger");
+
+ int maxIntegerValue = maxIntegerField.getInt(thisJavaObject);
+
+ assertEquals(setup.maxInteger, maxIntegerValue);
+ }
+
+ public void testMinIntegerValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField minIntegerField = getJavaField(thisJavaObject, "minInteger");
+
+ int minIntegerValue = minIntegerField.getInt(thisJavaObject);
+
+ assertEquals(setup.minInteger, minIntegerValue);
+ }
+
+ public void testStaticMinIntegerValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField minIntegerField = getJavaField(thisJavaObject, "staticMinInteger");
+
+ int minIntegerValue = minIntegerField.getInt(null);
+
+ assertEquals(SetupJavaField_getInt.staticMinInteger, minIntegerValue);
+ }
+
+ public void testZeroIntegerValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField zeroIntegerField = getJavaField(thisJavaObject, "zeroInteger");
+
+ int zeroIntegerValue = zeroIntegerField.getInt(thisJavaObject);
+
+ assertEquals(setup.zeroInteger, zeroIntegerValue);
+ }
+
+ public void testNegIntegerValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField negIntegerField = getJavaField(thisJavaObject, "negInteger");
+
+ int negIntegerValue = negIntegerField.getInt(thisJavaObject);
+
+ assertEquals(setup.negInteger, negIntegerValue);
+ }
+
+ public void testPosIntegerValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField posIntegerField = getJavaField(thisJavaObject, "posInteger");
+
+ int posIntegerValue = posIntegerField.getInt(thisJavaObject);
+
+ assertEquals(setup.posInteger, posIntegerValue);
+ }
+
+
+ public void testDoubleValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField doubleValueField = getJavaField(thisJavaObject, "doubleValue");
+
+ try{
+ int aDoubleValue = doubleValueField.getInt(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getInt(doubleValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testFloatValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField floatValueField = getJavaField(thisJavaObject, "floatValue");
+
+ try{
+ int aFloatValue = floatValueField.getInt(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getInt(floatValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testLongValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField longValueField = getJavaField(thisJavaObject, "longValue");
+
+ try{
+ int aLongValue = longValueField.getInt(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getInt(longValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testByteValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField byteValueField = getJavaField(thisJavaObject, "byteValue");
+
+ try{
+ int aByteValue = byteValueField.getInt(thisJavaObject);
+ } catch (IllegalArgumentException e) {
+ fail("Unexpected illegal argument exception from JavaField.getInt(byteValue)");
+ }
+ }
+
+ public void testCharValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField charValueField = getJavaField(thisJavaObject, "charValue");
+
+ try{
+ int aCharValue = charValueField.getInt(thisJavaObject);
+ } catch (IllegalArgumentException e) {
+ fail("Unexpected illegal argument exception from JavaField.getInt(charValue)");
+ }
+ }
+
+ public void testShortValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField shortValueField = getJavaField(thisJavaObject, "shortValue");
+
+ try{
+ int aShortValue = shortValueField.getInt(thisJavaObject);
+ } catch (IllegalArgumentException e) {
+ fail("Unexpected illegal argument exception from JavaField.getInt(shortValue)");
+ }
+ }
+
+ public void testBooleanValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField booleanValueField = getJavaField(thisJavaObject, "booleanValue");
+
+ try{
+ int aBooleanValue = booleanValueField.getInt(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getInteger(booleanValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testObjectReference() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField objectReferenceField = getJavaField(thisJavaObject, "objectReference");
+
+ try{
+ int anObjectReference = objectReferenceField.getInt(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getInteger(objectReference)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getLong.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getLong.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getLong.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getLong.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaField_getLong;
+
+
+/**
+ * Test JavaField.getLong() against various fields and values.
+ *
+ */
+public class TestJavaField_getLong extends TCKJavaRuntimeTestcase {
+
+ SetupJavaField_getLong setup=new SetupJavaField_getLong();
+
+ static JavaObject thisObject = null;
+ public JavaObject getScenerioReference() {
+ if (thisObject == null) {
+ thisObject = super.getScenerioReference();
+ }
+ return thisObject;
+ }
+
+ public void testMaxLongValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField maxLongField = getJavaField(thisJavaObject, "maxLong");
+
+ long maxLongValue = maxLongField.getLong(thisJavaObject);
+
+ assertEquals(setup.maxLong, maxLongValue);
+ }
+
+ public void testMinLongValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField minLongField = getJavaField(thisJavaObject, "minLong");
+
+ long minLongValue = minLongField.getLong(thisJavaObject);
+
+ assertEquals(setup.minLong, minLongValue);
+ }
+
+ public void testStaticMinLongValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField minLongField = getJavaField(thisJavaObject, "staticMinLong");
+
+ long minLongValue = minLongField.getLong(null);
+
+ assertEquals(SetupJavaField_getLong.staticMinLong, minLongValue);
+ }
+
+ public void testZeroLongValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField zeroLongField = getJavaField(thisJavaObject, "zeroLong");
+
+ long zeroLongValue = zeroLongField.getLong(thisJavaObject);
+
+ assertEquals(setup.zeroLong, zeroLongValue);
+ }
+
+ public void testNegLongValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField negLongField = getJavaField(thisJavaObject, "negLong");
+
+ long negLongValue = negLongField.getLong(thisJavaObject);
+
+ assertEquals(setup.negLong, negLongValue);
+ }
+
+ public void testPosLongValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField posLongField = getJavaField(thisJavaObject, "posLong");
+
+ long posLongValue = posLongField.getLong(thisJavaObject);
+
+ assertEquals(setup.posLong, posLongValue);
+ }
+
+ public void testDoubleValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField doubleValueField = getJavaField(thisJavaObject, "doubleValue");
+
+ try{
+ long aDoubleValue = doubleValueField.getLong(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getLong(doubleValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testFloatValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField floatValueField = getJavaField(thisJavaObject, "floatValue");
+
+ try{
+ long aFloatValue = floatValueField.getLong(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getLong(floatValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testIntValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField intValueField = getJavaField(thisJavaObject, "intValue");
+
+ try{
+ long aIntValue = intValueField.getLong(thisJavaObject);
+ } catch (IllegalArgumentException e) {
+ fail("Unexpected illegal argument exception from JavaField.getLong(intValue)");
+ }
+ }
+
+ public void testByteValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField byteValueField = getJavaField(thisJavaObject, "byteValue");
+
+ try{
+ long aByteValue = byteValueField.getLong(thisJavaObject);
+ } catch (IllegalArgumentException e) {
+ fail("Unexpected illegal argument exception from JavaField.getLong(byteValue)");
+ }
+ }
+
+ public void testCharValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField charValueField = getJavaField(thisJavaObject, "charValue");
+
+ try{
+ long aCharValue = charValueField.getLong(thisJavaObject);
+ } catch (IllegalArgumentException e) {
+ fail("Unexpected illegal argument exception from JavaField.getLong(charValue)");
+ }
+ }
+
+ public void testShortValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField shortValueField = getJavaField(thisJavaObject, "shortValue");
+
+ try{
+ long aShortValue = shortValueField.getLong(thisJavaObject);
+ } catch (IllegalArgumentException e) {
+ fail("Unexpected illegal argument exception from JavaField.getLong(shortValue)");
+ }
+ }
+
+ public void testBooleanValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField booleanValueField = getJavaField(thisJavaObject, "booleanValue");
+
+ try{
+ long aBooleanValue = booleanValueField.getLong(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getLong(booleanValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testObjectReference() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField objectReferenceField = getJavaField(thisJavaObject, "objectReference");
+
+ try{
+ long anObjectReference = objectReferenceField.getLong(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getLong(objectReference)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getModifiers.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getModifiers.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getModifiers.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getModifiers.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import java.lang.reflect.Modifier;
+
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+
+
+public class TestJavaField_getModifiers extends TCKJavaRuntimeTestcase {
+
+
+ static JavaObject thisObject = null;
+ public JavaObject getScenerioReference() {
+ if (thisObject == null) {
+ thisObject = super.getScenerioReference();
+ }
+ return thisObject;
+
+ }
+
+ public void testFinalField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "finalField");
+ assertEquals(Modifier.FINAL, field.getModifiers() & 0xFF);
+ }
+
+ public void testPrivateField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "privateField");
+ assertEquals(Modifier.PRIVATE, field.getModifiers() & 0xFF);
+ }
+
+ public void testProtectedField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "protectedField");
+ assertEquals(Modifier.PROTECTED, field.getModifiers() & 0xFF);
+ }
+
+ public void testPublicField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "publicField");
+ assertEquals(Modifier.PUBLIC, field.getModifiers() & 0xFF);
+ }
+
+ public void testStaticField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "staticField");
+ assertEquals(Modifier.STATIC, field.getModifiers() & 0xFF);
+ }
+
+ public void testTransientField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "transientField");
+ assertEquals(Modifier.TRANSIENT, field.getModifiers() & 0xFF);
+ }
+
+ public void testVolatileField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "volatileField");
+ assertEquals(Modifier.VOLATILE, field.getModifiers() & 0xFF);
+ }
+
+ public void testDefaultField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "defaultField");
+ assertEquals(0, field.getModifiers() & 0xFF);
+ }
+
+ public void testStaticPrivateVolatileTransientField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "staticPrivateVolatileTransientField");
+ assertEquals(Modifier.STATIC| Modifier.PRIVATE| Modifier.VOLATILE| Modifier.TRANSIENT
+ , field.getModifiers() & 0xFF);
+ }
+ public void testFinalProtectedField() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "finalProtectedField");
+ assertEquals( Modifier.FINAL | Modifier.PROTECTED, field.getModifiers() & 0xFF);
+ }
+
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getName.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getName.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getName.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getName.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaField_getName;
+
+
+public class TestJavaField_getName extends TCKJavaRuntimeTestcase {
+
+ SetupJavaField_getName setup=new SetupJavaField_getName();
+
+ static JavaObject thisObject = null;
+ public JavaObject getScenerioReference() {
+ if (thisObject == null) {
+ thisObject = super.getScenerioReference();
+ }
+ return thisObject;
+ }
+
+ public void testUnicodeName() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField unicodeField = getJavaField(thisJavaObject, "\u0412\u043e\u0434\u043a\u0430");
+
+ assertNotNull("Unable to find the field \u0412\u043e\u0434\u043a\u0430", unicodeField);
+
+ int intValue = unicodeField.getInt(thisJavaObject);
+
+ assertEquals(setup.\u0412\u043e\u0434\u043a\u0430, intValue);
+ }
+
+ public void testStaticUnicodeName() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField unicodeField = getJavaField(thisJavaObject, "\u0412\u043e\u0434\u043a\u0430_static");
+
+ assertNotNull("Unable to find the field \u0412\u043e\u0434\u043a\u0430_static", unicodeField);
+
+ int intValue = unicodeField.getInt(null);
+
+ assertEquals(SetupJavaField_getName.\u0412\u043e\u0434\u043a\u0430_static, intValue);
+ }
+
+ public void testLongName() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField longField = getJavaField(thisJavaObject, "thisIsAnIncrediblyLongNameBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah");
+
+ assertNotNull("Unable to find the field thisIsAnIncrediblyLongNameBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah", longField);
+
+ byte byteValue = longField.getByte(thisJavaObject);
+
+ assertEquals(setup.thisIsAnIncrediblyLongNameBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah, byteValue);
+ }
+
+ public void testLongStaticName() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField longField = getJavaField(thisJavaObject, "thisIsAnIncrediblyLongNameBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah_static");
+
+ assertNotNull("Unable to find the field thisIsAnIncrediblyLongNameBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah_static", longField);
+
+ byte byteValue = longField.getByte(thisJavaObject);
+
+ assertEquals(SetupJavaField_getName.thisIsAnIncrediblyLongNameBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah_static, byteValue);
+ }
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getShort.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getShort.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getShort.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getShort.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaField_getShort;
+
+
+/**
+ * Test JavaField.getShort() against various fields and values.
+ *
+ */
+public class TestJavaField_getShort extends TCKJavaRuntimeTestcase {
+
+ SetupJavaField_getShort setup=new SetupJavaField_getShort();
+
+ static JavaObject thisObject = null;
+ public JavaObject getScenerioReference() {
+ if (thisObject == null) {
+ thisObject = super.getScenerioReference();
+ }
+ return thisObject;
+ }
+
+ public void testMaxShortValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField maxShortField = getJavaField(thisJavaObject, "maxShort");
+
+ short maxShortValue = maxShortField.getShort(thisJavaObject);
+
+ assertEquals(setup.maxShort, maxShortValue);
+ }
+
+ public void testMinShortValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField minShortField = getJavaField(thisJavaObject, "minShort");
+
+ short minShortValue = minShortField.getShort(thisJavaObject);
+
+ assertEquals(setup.minShort, minShortValue);
+ }
+
+ public void testStaticMinShortValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField minShortField = getJavaField(thisJavaObject, "staticMinShort");
+
+ short minShortValue = minShortField.getShort(null);
+
+ assertEquals(SetupJavaField_getShort.staticMinShort, minShortValue);
+ }
+
+ public void testZeroShortValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField zeroShortField = getJavaField(thisJavaObject, "zeroShort");
+
+ short zeroShortValue = zeroShortField.getShort(thisJavaObject);
+
+ assertEquals(setup.zeroShort, zeroShortValue);
+ }
+
+ public void testNegShortValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField negShortField = getJavaField(thisJavaObject, "negShort");
+
+ short negShortValue = negShortField.getShort(thisJavaObject);
+
+ assertEquals(setup.negShort, negShortValue);
+ }
+
+ public void testPosShortValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField posShortField = getJavaField(thisJavaObject, "posShort");
+
+ short posShortValue = posShortField.getShort(thisJavaObject);
+
+ assertEquals(setup.posShort, posShortValue);
+ }
+
+
+ public void testDoubleValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField doubleValueField = getJavaField(thisJavaObject, "doubleValue");
+
+ try{
+ short aDoubleValue = doubleValueField.getShort(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getShort(doubleValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testFloatValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField floatValueField = getJavaField(thisJavaObject, "floatValue");
+
+ try{
+ short aFloatValue = floatValueField.getShort(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getShort(floatValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testLongValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField longValueField = getJavaField(thisJavaObject, "longValue");
+
+ try{
+ short aLongValue = longValueField.getShort(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getShort(longValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testIntValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField intValueField = getJavaField(thisJavaObject, "intValue");
+
+ try{
+ short aIntValue = intValueField.getShort(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getShort(intValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testByteValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField byteValueField = getJavaField(thisJavaObject, "byteValue");
+
+ try{
+ short aByteValue = byteValueField.getShort(thisJavaObject);
+ } catch (IllegalArgumentException e) {
+ fail("Unexpected illegal argument exception from JavaField.getShort(byteValue)");
+ }
+ }
+
+ public void testCharValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField charValueField = getJavaField(thisJavaObject, "charValue");
+
+ try{
+ short aShortValue = charValueField.getShort(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getShort(charValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testBooleanValue() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField booleanValueField = getJavaField(thisJavaObject, "booleanValue");
+
+ try{
+ short aBooleanValue = booleanValueField.getShort(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getShort(booleanValue)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testObjectReference() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+ JavaField objectReferenceField = getJavaField(thisJavaObject, "objectReference");
+
+ try{
+ short anObjectReference = objectReferenceField.getShort(thisJavaObject);
+ fail("Missing illegal argument exception from JavaField.getShort(objectReference)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getSignature.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getSignature.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getSignature.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getSignature.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaField_getSignature;
+
+
+public class TestJavaField_getSignature extends TCKJavaRuntimeTestcase {
+
+ static JavaObject thisObject = null;
+ public JavaObject getScenerioReference() {
+ if (thisObject == null) {
+ thisObject = super.getScenerioReference();
+ }
+ return thisObject;
+
+ }
+
+
+ public void testByteFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "byteField");
+
+ assertEquals("B", field.getSignature());
+ }
+
+ public void testShortFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "shortField");
+
+ assertEquals("S", field.getSignature());
+ }
+
+ public void testCharFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "charField");
+
+ assertEquals("C", field.getSignature());
+ }
+
+ public void testIntFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "intField");
+
+ assertEquals("I", field.getSignature());
+ }
+
+ public void testLongFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "longField");
+
+ assertEquals("J", field.getSignature());
+ }
+
+ public void testFloatFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "floatField");
+
+ assertEquals("F", field.getSignature());
+ }
+
+ public void testDoubleFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "doubleField");
+
+ assertEquals("D", field.getSignature());
+ }
+
+ public void testObjectFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "objectField");
+
+ assertEquals("Ljava/lang/String;", field.getSignature());
+ }
+
+ public void testByteArrayArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "byteArrayArrayField");
+
+ assertEquals("[[B", field.getSignature());
+ }
+
+ public void testShortArrayArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "shortArrayArrayField");
+
+ assertEquals("[[S", field.getSignature());
+ }
+
+ public void testCharArrayArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "charArrayArrayField");
+
+ assertEquals("[[C", field.getSignature());
+ }
+
+ public void testIntArrayArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "intArrayArrayField");
+
+ assertEquals("[[I", field.getSignature());
+ }
+
+ public void testLongArrayArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "longArrayArrayField");
+
+ assertEquals("[[J", field.getSignature());
+ }
+
+ public void testFloatArrayArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "floatArrayArrayField");
+
+ assertEquals("[[F", field.getSignature());
+ }
+
+ public void testDoubleArrayArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "doubleArrayArrayField");
+
+ assertEquals("[[D", field.getSignature());
+ }
+
+ public void testObjectArrayArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "objectArrayArrayField");
+
+ assertEquals("[[Ljava/lang/String;", field.getSignature());
+ }
+
+ public void testByteArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "byteArrayField");
+
+ assertEquals("[B", field.getSignature());
+ }
+
+ public void testShortArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "shortArrayField");
+
+ assertEquals("[S", field.getSignature());
+ }
+
+ public void testCharArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "charArrayField");
+
+ assertEquals("[C", field.getSignature());
+ }
+
+ public void testIntArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "intArrayField");
+
+ assertEquals("[I", field.getSignature());
+ }
+
+ public void testLongArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "longArrayField");
+
+ assertEquals("[J", field.getSignature());
+ }
+
+ public void testFloatArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "floatArrayField");
+
+ assertEquals("[F", field.getSignature());
+ }
+
+ public void testDoubleArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "doubleArrayField");
+
+ assertEquals("[D", field.getSignature());
+ }
+
+ public void testObjectArrayFieldSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "objectArrayField");
+
+ assertEquals("[Ljava/lang/String;", field.getSignature());
+ }
+
+ public void testUnicodeClassSignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "unicodeClass");
+ assertEquals("L"+SetupJavaField_getSignature.unicodeClassName+";", field.getSignature());
+ }
+
+ public void testUnicodeClassArraySignature() throws Exception {
+ JavaField field = getJavaField(getScenerioReference(), "unicodeClassArray");
+ assertEquals("[L"+SetupJavaField_getSignature.unicodeClassName+";", field.getSignature());
+ }
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getString.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getString.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getString.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaField_getString.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaField_getString;
+
+
+public class TestJavaField_getString extends TCKJavaRuntimeTestcase {
+
+ SetupJavaField_getString setup=new SetupJavaField_getString();
+
+ static JavaObject thisObject = null;
+ public JavaObject getScenerioReference() {
+ if (thisObject == null) {
+ thisObject = super.getScenerioReference();
+ }
+ return thisObject;
+ }
+
+ /**
+ * Tests that a long string can be retrieved correctly.
+ *
+ */
+ public void testLongString() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+
+ assertNotNull(thisJavaObject);
+
+ JavaField longStringField = getJavaField(thisJavaObject, "longString");
+
+ assertNotNull(longStringField);
+
+ String longStringValue = longStringField.getString(thisJavaObject);
+
+ assertEquals(setup.longString, longStringValue);
+ }
+
+ public void testEmptyString() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+
+ assertNotNull(thisJavaObject);
+
+ JavaField emptyStringField = getJavaField(thisJavaObject, "emptyString");
+
+ assertNotNull(emptyStringField);
+
+ String emptyStringValue = emptyStringField.getString(thisJavaObject);
+
+ assertEquals(setup.emptyString, emptyStringValue);
+
+ }
+
+ public void testNullString() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+
+ assertNotNull(thisJavaObject);
+
+ JavaField nullStringField = getJavaField(thisJavaObject, "nullString");
+
+ assertNotNull(nullStringField);
+
+ String nullStringValue = nullStringField.getString(thisJavaObject);
+
+ assertEquals(setup.nullString, nullStringValue);
+
+ }
+
+ public void testForeignString() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+
+ assertNotNull(thisJavaObject);
+
+ JavaField foreignStringField = getJavaField(thisJavaObject, "foreignString");
+
+ assertNotNull(foreignStringField);
+
+ String foreignStringValue = foreignStringField.getString(thisJavaObject);
+
+ assertEquals(setup.foreignString, foreignStringValue);
+
+ }
+
+ public void testNullJavaObjectOnInstanceField() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+
+ assertNotNull(thisJavaObject);
+
+ JavaField longStringField = getJavaField(thisJavaObject, "longString");
+
+ assertNotNull(longStringField);
+
+ try{
+ String string = longStringField.getString(null);
+ fail ("Expected NullPointerException. Got \""+string+"\"");
+ } catch (NullPointerException e) {
+ // passes.
+ }
+ }
+
+ public void testStaticString() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+
+ assertNotNull(thisJavaObject);
+
+ JavaField staticStringField = getJavaField(thisJavaObject, "staticString");
+
+ String staticStringValue = staticStringField.getString(null);
+
+ assertEquals(SetupJavaField_getString.staticString, staticStringValue);
+ }
+
+ public void testNonString() throws Exception {
+ JavaObject thisJavaObject = getScenerioReference();
+
+ assertNotNull(thisJavaObject);
+
+ JavaField nonStringField = getJavaField(thisJavaObject, "nonString");
+
+ try {
+ String nonStringValue = nonStringField.getString(thisJavaObject);
+ fail("Didn't get illegal argument exception when int field read with getString.");
+ } catch(IllegalArgumentException e) {
+ // passed - expect exception.
+ }
+ }
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaHeap_getName.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaHeap_getName.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaHeap_getName.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaHeap_getName.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import java.util.Iterator;
+
+import javax.tools.diagnostics.image.CorruptData;
+import javax.tools.diagnostics.runtime.java.JavaHeap;
+import javax.tools.diagnostics.runtime.java.JavaRuntime;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+
+
+public class TestJavaHeap_getName extends TCKJavaRuntimeTestcase {
+
+ /**
+ *
+ *
+ */
+ public void testJavaHeap_getName()
+ {
+ boolean foundHeaps = false;
+
+ JavaRuntime runtime=getJavaRuntime();
+
+ Iterator heaps = runtime.getHeaps().iterator();
+
+ while (heaps.hasNext()) {
+ Object nextHeap = heaps.next();
+ if (nextHeap instanceof CorruptData) {
+ System.err.println("returned CorruptData `" + nextHeap + "'");
+ break;
+ }
+
+ JavaHeap aJavaHeap = (JavaHeap) nextHeap;
+ assertTrue("One of the java heaps has a null name.", aJavaHeap.getName()!=null);
+ }
+ }
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaMethod_getName.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaMethod_getName.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaMethod_getName.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaMethod_getName.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import java.util.Iterator;
+
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaLocation;
+import javax.tools.diagnostics.runtime.java.JavaMethod;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaStackFrame;
+import javax.tools.diagnostics.runtime.java.JavaThread;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaMethod_getName;
+
+
+public class TestJavaMethod_getName extends TCKJavaRuntimeTestcase {
+
+ static JavaObject thisObject = null;
+ public JavaObject getScenerioReference() {
+ if (thisObject == null) {
+ thisObject = super.getScenerioReference();
+ }
+ return thisObject;
+ }
+
+ /**
+ * Get this class directly, and find the method via getDeclaredMethods().iterator();
+ *
+ * @throws Exception
+ */
+ public void testGetDeclaredMethods() throws Exception {
+ JavaClass thisClass = getScenerioReference().getJavaClass();
+
+ assertNotNull("Unable to find this class", thisClass);
+
+ Iterator methods = thisClass.getDeclaredMethods().iterator();
+ boolean found=false;
+ while(methods.hasNext()) {
+ JavaMethod method = (JavaMethod) methods.next();
+
+ if (method.getName().equals(SetupJavaMethod_getName.methodName)) {
+ found = true;
+ break;
+ }
+ }
+
+ assertTrue("Unable to find method get\u0412\u043e\u0434\u043a\u0430()", found);
+ }
+
+ /**
+ * Pick the method off of the JavaThreads stack. The JavaMethod might be
+ * instantiated differently.
+ *
+ * @throws Exception
+ */
+ public void testGetStackMethods() throws Exception {
+ Iterator threads = getJavaRuntime().getThreads().iterator();
+
+ JavaThread testThread = null;
+ while(threads.hasNext()) {
+ Object next = threads.next();
+
+ if (next instanceof JavaThread) {
+ JavaThread thread = (JavaThread) next;
+ if (thread.getName().equals(SetupJavaMethod_getName.threadName)) {
+ testThread = thread;
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
+ assertNotNull("Unable to find thread "+SetupJavaMethod_getName.threadName, testThread);
+
+ Iterator frames = testThread.getStackFrames().iterator();
+ boolean found = false;
+
+ while(frames.hasNext()) {
+ Object next = frames.next();
+
+ if(next instanceof JavaStackFrame) {
+ JavaStackFrame frame = (JavaStackFrame) next;
+
+ JavaLocation location = frame.getLocation();
+
+ if (location != null) {
+ JavaMethod method = location.getMethod();
+
+ if(method != null) {
+ if (SetupJavaMethod_getName.methodName.equals(method.getName())) {
+ found = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ assertTrue("Unable to find method "+SetupJavaMethod_getName.methodName+" in stack.", found);
+ }
+}
Added: incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaMonitor_ObjectMonitors.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaMonitor_ObjectMonitors.java?rev=883669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaMonitor_ObjectMonitors.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck/src/test/java/org/apache/kato/tck/tests/javaruntime/TestJavaMonitor_ObjectMonitors.java Tue Nov 24 12:27:01 2009
@@ -0,0 +1,1137 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.tck.tests.javaruntime;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.tools.diagnostics.image.CorruptData;
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaMonitor;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaRuntime;
+import javax.tools.diagnostics.runtime.java.JavaThread;
+
+import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaMonitor_ObjectMonitors;
+import org.apache.kato.tck.scenario142.javaruntime.SetupJavaMonitor_ObjectMonitors.MonitorThreadConfig;
+
+
+/**
+ * Tests that monitors work correctly.
+ *
+ * Tests with variations on the number of notify waiters, enter waiters and owners,
+ * up to a maximum of 2 waiters of each type (there can be only one owner, of course).
+ *
+ * TODO Add tests where threads own one monitor and wait on another.
+ *
+ */
+public class TestJavaMonitor_ObjectMonitors extends TCKJavaRuntimeTestcase {
+
+
+ public SetupJavaMonitor_ObjectMonitors setup=new SetupJavaMonitor_ObjectMonitors();
+
+
+ /**
+ * Not executed anywhere - for debugging
+ */
+ private void printMonitors() {
+ System.out.println("JVM "+ System.getProperty("java.vm.name")+ ", "+System.getProperty("java.vm.vendor")+
+ System.getProperty("java.vm.version"));
+
+ for (int i = 0; i < setup.monitorConfigs.length; i++) {
+ System.out.println("Printing out status of "+ setup.monitorConfigs[i].id);
+ System.out.println("==================================");
+ JavaMonitor monitor = (JavaMonitor) setup.monitorConfigs[i].getMonitor();
+
+ if (monitor == null) {
+ System.out.println("monitor = null");
+ continue;
+ }
+
+ try {
+ System.out.println("monitor.getName()"+ monitor.getName());
+ } catch (CorruptDataException e) {
+ assertNotNull(e.getCorruptData());
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ System.out.println("\nmonitor.getEntersWaiters():");
+
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+
+ if (next instanceof CorruptData) {
+ System.out.println("enter waiter corrupt: "+ next);
+ continue;
+ }
+
+ JavaThread thread = (JavaThread) next;
+
+ try {
+ System.out.println("EnterWaiter: "+thread.getName());
+ } catch (CorruptDataException e) {
+ assertNotNull(e.getCorruptData());
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
+ System.out.println("\nmonitor.getNotifyWaiters():");
+
+ Iterator notifiers = monitor.getNotifyWaiters().iterator();
+
+ while (notifiers.hasNext()) {
+ Object next = notifiers.next();
+
+ if (next instanceof CorruptData) {
+ System.out.println("notify waiter corrupt: "+ next);
+ continue;
+ }
+
+ JavaThread thread = (JavaThread) next;
+
+ try {
+ System.out.println("NotifyWaiter: "+thread.getName());
+ } catch (CorruptDataException e) {
+ assertNotNull(e.getCorruptData());
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ JavaThread thread;
+ try {
+ thread = monitor.getOwner();
+ if (thread == null) {
+ System.out.println("Owner thread = null");
+ } else {
+ try {
+ System.out.println("Owner thread = "+thread.getName());
+ } catch (CorruptDataException e) {
+ assertNotNull(e.getCorruptData());
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ } catch (CorruptDataException e1) {
+ assertNotNull(e1.getCorruptData());
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ System.out.println("\n\n");
+ }
+ }
+
+
+
+ private static String generatePrefix(int waiters, int enters, int owners) {
+ return SetupJavaMonitor_ObjectMonitors.namePrefix + waiters + "-" + owners + "-" + enters;
+ }
+
+
+
+ public class MonitorNotifyThread extends Thread {
+ private Object monitor;
+ private volatile boolean almostReady = false;
+
+ public MonitorNotifyThread(String name, Object monitor) {
+ super(name);
+ this.setDaemon(true); // Allow JVM to exit.
+ this.monitor = monitor;
+ }
+
+ public void run() {
+ synchronized (monitor) {
+ synchronized (this) {
+ almostReady = true;
+ this.notify();
+ }
+ while (true) {
+ try {
+ monitor.wait();
+ } catch (InterruptedException e) {
+ // Keep waiting...
+ }
+ }
+ }
+ }
+
+ /**
+ * Start thread, and waits until the thread is about to release the
+ * monitor.
+ */
+ public void start() {
+ super.start();
+ synchronized (this) {
+ try {
+ while (!almostReady) {
+ this.wait();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ }
+
+ /**
+ * A thread that tries to own a monitor.
+ *
+ */
+ public class MonitorOwnerThread extends Thread {
+ private Object monitor;
+ private volatile boolean owned = false;
+
+ public MonitorOwnerThread(String name, Object monitor) {
+ super(name);
+ this.setDaemon(true); // Allow JVM to exit.
+ this.monitor = monitor;
+ }
+
+ public void run() {
+ synchronized (monitor) {
+ synchronized (this) {
+ owned = true;
+ this.notify();
+ }
+ while (true) {
+ // We have either entered, or are entering.
+
+ try {
+ sleep(10000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public void start() {
+ super.start();
+ synchronized (this) {
+ try {
+ while (!owned) {
+ this.wait();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+ }
+
+ /**
+ * A thread that tries to enter a monitor.
+ *
+ */
+ public class MonitorEnterThread extends Thread {
+ private Object monitor;
+ private volatile boolean owned = false;
+
+ public MonitorEnterThread(String name, Object monitor) {
+ super(name);
+ this.setDaemon(true); // Allow JVM to exit.
+ this.monitor = monitor;
+ }
+
+ public void run() {
+ synchronized (this) {
+ owned = true;
+ this.notify();
+ }
+ synchronized (monitor) {
+ // This code should never be reached.
+ }
+ }
+
+ public void start() {
+ super.start();
+
+ synchronized (this) {
+
+ try {
+ while (!owned) {
+ this.wait();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ try {
+ sleep(1000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ static private JavaRuntime runtime;
+
+ public void setUp() throws Exception {
+ JavaRuntime currentRuntime = getJavaRuntime();
+
+ if (runtime != null && currentRuntime.equals(runtime)) {
+ return;
+ }
+
+ runtime = getJavaRuntime();
+
+ findMonitors();
+ }
+
+ public void findMonitors() throws Exception {
+ JavaRuntime runtime = getJavaRuntime();
+
+ Iterator monitorIterator = runtime.getMonitors().iterator();
+
+ // Search through all monitors for this test's monitor.
+ while (monitorIterator.hasNext()) {
+ Object next = monitorIterator.next();
+
+ // Ignore corrupt data
+ if (next instanceof CorruptData) {
+ continue;
+ }
+
+ JavaMonitor monitorCandidate = (JavaMonitor) next;
+
+ //System.out.println("Monitor candidate->"+monitorCandidate.getName());
+ JavaObject monitorObjectCandidate = monitorCandidate.getObject();
+
+ if (monitorObjectCandidate != null) {
+ JavaClass monitorClass = monitorObjectCandidate.getJavaClass();
+ if (!SetupJavaMonitor_ObjectMonitors.monitorClassName.equals(monitorClass.getName())) {
+ continue;
+ }
+
+ Iterator fields = monitorClass.getDeclaredFields().iterator();
+
+ while (fields.hasNext()) {
+ Object next2 = fields.next();
+
+ if (next2 instanceof CorruptData) {
+ continue;
+ }
+
+ JavaField field = (JavaField) next2;
+ String id = null;
+
+ if ("id".equals(field.getName())) {
+ id = field.getString(monitorObjectCandidate);
+ }
+
+ if (id != null) {
+
+ MonitorThreadConfig config = setup.findMonitorThreadConfig(id);
+
+ if (config != null) {
+ config.setMonitor(monitorCandidate);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void testFindMonitor_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+
+ assertNotNull("Couldn't find 0-1-1", monitor);
+ }
+
+ public void testGetID_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+
+ assertNotNull("JavaMonitor.getID() for 0-1-1 is null.", monitor.getID());
+ }
+
+ public void testGetName_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+ assertNotNull("JavaMonitor.getName() for 0-1-1 is null.", monitor
+ .getName());
+ }
+
+ public void testCountWaiters_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 0, count);
+ }
+
+ public void testCountEnters_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+ count++;
+ }
+
+ assertEquals("Enters count incorrect :" + count, 1, count);
+ }
+
+ public void testCountOwners_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertNotNull("Owner count incorrect", owner);
+ }
+
+ public void testNameWaiters_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ JavaThread next = (JavaThread) waiters.next();
+ assertEquals("Waiters name incorrect", generatePrefix(0, 1, 1)
+ + "-" + SetupJavaMonitor_ObjectMonitors.monitorNotifyThreadName + "-" + count, next
+ .getName());
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 0, count);
+ }
+
+ public void testNameEnters_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ JavaThread next = (JavaThread) enters.next();
+ assertEquals("Enters name incorrect", generatePrefix(0, 1, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorEnterThreadName + "-" + count, next.getName());
+ count++;
+ }
+ }
+
+ public void testNameOwners_0_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 1, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertEquals("Owner name incorrect", generatePrefix(0, 1, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorOwnerThreadName + "-0", owner.getName());
+ }
+
+ ///////////////////////////////////////////
+
+ public void testFindMonitor_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor) setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+
+ assertNotNull("Couldn't find 0-1-1", monitor);
+ }
+
+ public void testGetID_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+
+ assertNotNull("JavaMonitor.getID() for 0-1-1 is null.", monitor.getID());
+ }
+
+ public void testGetName_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+ assertNotNull("JavaMonitor.getName() for 0-1-1 is null.", monitor
+ .getName());
+ }
+
+ public void testCountWaiters_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 0, count);
+ }
+
+ public void testCountEnters_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+ count++;
+ }
+
+ assertEquals("Enters count incorrect :" + count, 0, count);
+ }
+
+ public void testCountOwners_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertNotNull("Owner count incorrect", owner);
+ }
+
+ public void testNameWaiters_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ JavaThread next = (JavaThread) waiters.next();
+ assertEquals("Waiters name incorrect", generatePrefix(0, 0, 1)
+ + "-" + SetupJavaMonitor_ObjectMonitors.monitorNotifyThreadName + "-" + count, next
+ .getName());
+ count++;
+ }
+
+ }
+
+ public void testNameEnters_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ JavaThread next = (JavaThread) enters.next();
+ assertEquals("Enters name incorrect", generatePrefix(0, 0, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorEnterThreadName + "-" + count, next.getName());
+ count++;
+ }
+ }
+
+ public void testNameOwners_0_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 0, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertEquals("Owner name incorrect", generatePrefix(0, 0, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorOwnerThreadName + "-0", owner.getName());
+ }
+
+ ///////////////////////////////////////////
+
+ public void testFindMonitor_1_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 0).getMonitor();
+
+ assertNotNull("Couldn't find monitor 1-0-0", monitor);
+ }
+
+ public void testGetID_1_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 0).getMonitor();
+
+ assertNotNull("JavaMonitor.getID() for 1-0-0 is null.", monitor.getID());
+ }
+
+ public void testGetName_1_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 0).getMonitor();
+ assertNotNull("JavaMonitor.getName() for 1-0-0 is null.", monitor
+ .getName());
+ }
+
+ public void testCountWaiters_1_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 0).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 1, count);
+ }
+
+ public void testCountEnters_1_0_0() throws Exception {
+ JavaMonitor monitor =(JavaMonitor)setup.findMonitorThreadConfig(1, 0, 0).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+ count++;
+ }
+
+ assertEquals("Enters count incorrect :" + count, 0, count);
+ }
+
+ public void testCountOwners_1_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 0).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertNull("Owner count incorrect", owner);
+ }
+
+ public void testNameWaiters_1_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 0).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ JavaThread next = (JavaThread) waiters.next();
+ assertEquals("Waiters name incorrect", generatePrefix(1, 0, 0)
+ + "-" + SetupJavaMonitor_ObjectMonitors.monitorNotifyThreadName + "-" + count, next
+ .getName());
+ count++;
+ }
+ }
+
+ public void testNameEnters_1_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 0).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ JavaThread next = (JavaThread) enters.next();
+ assertEquals("Enters name incorrect", generatePrefix(1, 0, 0) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorEnterThreadName + "-" + count, next.getName());
+ count++;
+ }
+ }
+
+ ///////////////////////////////////////////
+
+ public void testFindMonitor_1_1_1() throws Exception {
+ JavaMonitor monitor =(JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+
+ assertNotNull("Couldn't find monitor 1-1-1", monitor);
+ }
+
+ public void testGetID_1_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+
+ assertNotNull("JavaMonitor.getID() for 1-1-1 is null.", monitor.getID());
+ }
+
+ public void testGetName_1_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+ assertNotNull("JavaMonitor.getName() for 1-1-1 is null.", monitor
+ .getName());
+ }
+
+ public void testCountWaiters_1_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 1, count);
+ }
+
+ public void testCountEnters_1_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+ enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+ count++;
+ }
+
+ assertEquals("Enters count incorrect :" + count, 1, count);
+ }
+
+ public void testCountOwners_1_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertNotNull("Owner count incorrect", owner);
+ }
+
+ public void testNameWaiters_1_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ Iterator monitors = getJavaRuntime().getMonitors().iterator();
+ monitors = getJavaRuntime().getMonitors().iterator();
+
+
+ while (waiters.hasNext()) {
+ JavaThread next = (JavaThread) waiters.next();
+ assertEquals("Waiters name incorrect", generatePrefix(1, 1, 1)
+ + "-" + SetupJavaMonitor_ObjectMonitors.monitorNotifyThreadName + "-" + count, next
+ .getName());
+ count++;
+ }
+ }
+
+ public void testNameEnters_1_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ JavaThread next = (JavaThread) enters.next();
+ assertEquals("Enters name incorrect", generatePrefix(1, 1, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorEnterThreadName + "-" + count, next.getName());
+ count++;
+ }
+ }
+
+ public void testNameOwners_1_1_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 1, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertEquals("Owner name incorrect", generatePrefix(1, 1, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorOwnerThreadName + "-0", owner.getName());
+ }
+
+ //////////////////////////////////////////////
+
+ public void testFindMonitor_2_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 0, 0).getMonitor();
+
+ assertNotNull("Couldn't find monitor 2-0-0", monitor);
+ }
+
+ public void testGetID_2_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 0, 0).getMonitor();
+
+ assertNotNull("JavaMonitor.getID() for 2-0-0 is null.", monitor.getID());
+ }
+
+ public void testGetName_2_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 0, 0).getMonitor();
+ assertNotNull("JavaMonitor.getName() for 2-0-0 is null.", monitor
+ .getName());
+ }
+
+ public void testCountWaiters_2_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 0, 0).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 2, count);
+ }
+
+ public void testCountEnters_2_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 0, 0).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+ count++;
+ }
+
+ assertEquals("Enters count incorrect :" + count, 0, count);
+ }
+
+ public void testCountOwners_2_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 0, 0).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertNull("Owner count incorrect", owner);
+ }
+
+ public void testNameWaiters_2_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 0, 0).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ JavaThread next = (JavaThread) waiters.next();
+ assertEquals("Waiters name incorrect", generatePrefix(2, 0, 0)
+ + "-" + SetupJavaMonitor_ObjectMonitors.monitorNotifyThreadName + "-" + count, next
+ .getName());
+ count++;
+ }
+ }
+
+ public void testNameEnters_2_0_0() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 0, 0).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ JavaThread next = (JavaThread) enters.next();
+ assertEquals("Enters name incorrect", generatePrefix(2, 0, 0) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorEnterThreadName + "-" + count, next.getName());
+ count++;
+ }
+ }
+ ///////////////////////////////////////////
+
+ public void testFindMonitor_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+
+ assertNotNull("Couldn't find monitor 1-0-1", monitor);
+ }
+
+ public void testGetID_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+
+ assertNotNull("JavaMonitor.getID() for 1-0-1 is null.", monitor.getID());
+ }
+
+ public void testGetName_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+ assertNotNull("JavaMonitor.getName() for 1-0-1 is null.", monitor
+ .getName());
+ }
+
+ public void testCountWaiters_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 1, count);
+ }
+
+ public void testCountEnters_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+ count++;
+ }
+
+ assertEquals("Enters count incorrect :" + count, 0, count);
+ }
+
+ public void testCountOwners_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertNotNull("Owner count incorrect", owner);
+ }
+
+ public void testNameWaiters_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ JavaThread next = (JavaThread) waiters.next();
+ assertEquals("Waiters name incorrect", generatePrefix(1, 0, 1)
+ + "-" + SetupJavaMonitor_ObjectMonitors.monitorNotifyThreadName + "-" + count, next
+ .getName());
+ count++;
+ }
+ }
+
+ public void testNameEnters_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ JavaThread next = (JavaThread) enters.next();
+ assertEquals("Enters name incorrect", generatePrefix(1, 0, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorEnterThreadName + "-" + count, next.getName());
+ count++;
+ }
+ }
+
+ public void testNameOwners_1_0_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(1, 0, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertEquals("Owner name incorrect", generatePrefix(1, 0, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorOwnerThreadName + "-0", owner.getName());
+ }
+ ///////////////////////////////////////////
+
+ public void testFindMonitor_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+
+ assertNotNull("Couldn't find monitor 0-2-1", monitor);
+ }
+
+ public void testGetID_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+
+ assertNotNull("JavaMonitor.getID() for 0-2-1 is null.", monitor.getID());
+ }
+
+ public void testGetName_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+ assertNotNull("JavaMonitor.getName() for 0-2-1 is null.", monitor
+ .getName());
+ }
+
+ public void testCountWaiters_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 0, count);
+ }
+
+ public void testCountEnters_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+ count++;
+ }
+
+ assertEquals("Enters count incorrect :" + count, 2, count);
+ }
+
+ public void testCountOwners_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertNotNull("Owner count incorrect", owner);
+ }
+
+ public void testNameWaiters_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ JavaThread next = (JavaThread) waiters.next();
+ assertEquals("Waiters name incorrect", generatePrefix(0, 2, 1)
+ + "-" + SetupJavaMonitor_ObjectMonitors.monitorNotifyThreadName + "-" + count, next
+ .getName());
+ count++;
+ }
+ }
+
+ public void testNameEnters_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ String error = checkNames(enters, generatePrefix(0, 2, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorEnterThreadName, 2);
+
+ assertNull(error, error);
+ }
+
+ public void testNameOwners_0_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(0, 2, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertEquals("Owner name incorrect", generatePrefix(0, 2, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorOwnerThreadName + "-0", owner.getName());
+ }
+
+ ///////////////////////////////////////////
+
+ public void testFindMonitor_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+
+ assertNotNull("Couldn't find monitor 2-2-1", monitor);
+ }
+
+ public void testGetID_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+
+ assertNotNull("JavaMonitor.getID() for 2-2-1 is null.", monitor.getID());
+ }
+
+ public void testGetName_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+ assertNotNull("JavaMonitor.getName() for 2-2-1 is null.", monitor
+ .getName());
+ }
+
+ public void testCountWaiters_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+ int count = 0;
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+ count++;
+ }
+
+ assertEquals("Waiters count incorrect :" + count, 2, count);
+ }
+
+ public void testCountEnters_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+ int count = 0;
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ while (enters.hasNext()) {
+ Object next = enters.next();
+ count++;
+ }
+
+ assertEquals("Enters count incorrect :" + count, 2, count);
+ }
+
+ public void testCountOwners_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertNotNull("Owner count incorrect", owner);
+ }
+
+ public void testNameWaiters_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+ Iterator waiters = monitor.getNotifyWaiters().iterator();
+
+ String error = checkNames(waiters, generatePrefix(2, 2, 1)
+ + "-" + SetupJavaMonitor_ObjectMonitors.monitorNotifyThreadName , 2);
+ assertNull(error, error);
+ }
+
+ public void testNameEnters_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+ Iterator enters = monitor.getEnterWaiters().iterator();
+
+ String error = checkNames(enters, generatePrefix(2, 2, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorEnterThreadName, 2);
+
+ assertNull(error, error);
+ }
+
+ public void testNameOwners_2_2_1() throws Exception {
+ JavaMonitor monitor = (JavaMonitor)setup.findMonitorThreadConfig(2, 2, 1).getMonitor();
+ JavaThread owner = monitor.getOwner();
+
+ assertEquals("Owner name incorrect", generatePrefix(2, 2, 1) + "-"
+ + SetupJavaMonitor_ObjectMonitors.monitorOwnerThreadName + "-0", owner.getName());
+ }
+
+ ////////////////////////////////////
+
+ /**
+ * Check uniqueness of all the monitor ID's.
+ *
+ */
+ public void testGetID() throws Exception {
+ Set foundSet = new HashSet(SetupJavaMonitor_ObjectMonitors.NUM_MONITORS);
+
+ for (int i=0; i < SetupJavaMonitor_ObjectMonitors.NUM_MONITORS; i++){
+ JavaMonitor monitor=(JavaMonitor) setup.monitorConfigs[i].monitor;
+ ImagePointer id = monitor.getID();
+
+ assertNotNull("Found null monitor id for " + setup.monitorConfigs[i].id, id);
+
+ assertFalse("Found duplicate monitor id. " + setup.monitorConfigs[i].id, foundSet.contains(id));
+
+ foundSet.add(id);
+ }
+ }
+
+ ////////////////////////////////////
+
+ public void testGetName() throws Exception {
+ for (int i=0; i < SetupJavaMonitor_ObjectMonitors.NUM_MONITORS; i++){
+ JavaMonitor monitor=(JavaMonitor) setup.monitorConfigs[i].monitor;
+ String name = monitor.getName();
+
+ assertNotNull("Found null monitor name for " + setup.monitorConfigs[i].id, name);
+ }
+ }
+
+ public void testGetObject() throws Exception {
+ for (int i=0; i < SetupJavaMonitor_ObjectMonitors.NUM_MONITORS; i++){
+ JavaMonitor monitor=(JavaMonitor) setup.monitorConfigs[i].monitor;
+ JavaObject object = monitor.getObject();
+
+ assertEquals("Monitor object class unexpected name.",setup.monitorClassName, object.getJavaClass().getName());
+
+ JavaField idField = getJavaField(object, "id");
+ String idString = idField.getString(object);
+
+ assertEquals("MonitorClass id strings didn't match.", setup.monitorConfigs[i].id, idString);
+ }
+ }
+
+ public void testEqualsSelf() throws Exception {
+ assertTrue(setup.monitorConfigs[0].monitor.equals(setup.monitorConfigs[0].monitor));
+ }
+
+ public void testEqualsNull() throws Exception {
+ assertFalse(setup.monitorConfigs[0].monitor.equals(null));
+ }
+
+ public void testNotEqualsOther() throws Exception {
+ assertFalse(setup.monitorConfigs[0].monitor.equals(setup.monitorConfigs[1].monitor));
+ }
+
+ /**
+ * Checks that the expected JavaThreads are within the iterator
+ * of waiters passed, in no particular order.
+ * Number of JavaThreads should be checked elsewhere.
+ *
+ * @param waiters a set of a monitor's waiters.
+ * @param prefix start of the thread name
+ * @param count number of threads to look for. Used as suffix of thread name
+ * @return null if ok or an error string if it is not ok
+ * @throws CorruptDataException
+ *
+ */
+ public String checkNames(Iterator waiters, String prefix, int count) throws CorruptDataException {
+ Set foundSet = new HashSet(count);
+
+ while (waiters.hasNext()) {
+ Object next = waiters.next();
+
+ if (next instanceof JavaThread) {
+ JavaThread thread = (JavaThread) next;
+ foundSet.add(thread.getName());
+ }
+ }
+
+ for(int i=0; i < count; i++) {
+ String threadName = prefix+"-"+i;
+
+ if (!foundSet.contains(threadName)) {
+ return "Missing thread "+threadName;
+ }
+ }
+
+ return null;
+ }
+
+
+}