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 mo...@apache.org on 2009/11/23 15:54:15 UTC
svn commit: r883384 [36/47] - in /incubator/kato/trunk/org.apache.kato: ./
kato.anttasks/src/main/java/org/apache/kato/anttasks/
kato.anttasks/src/main/java/org/apache/kato/anttasks/sitebuilder/
kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/...
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaFieldTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaFieldTest.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaFieldTest.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaFieldTest.java Mon Nov 23 15:53:48 2009
@@ -1,286 +1,286 @@
-/*******************************************************************************
- * 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.tests.junit;
-
-import java.util.Iterator;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.MemoryAccessException;
-import javax.tools.diagnostics.runtime.java.JavaClass;
-import javax.tools.diagnostics.runtime.java.JavaClassLoader;
-import javax.tools.diagnostics.runtime.java.JavaField;
-import javax.tools.diagnostics.runtime.java.JavaObject;
-
-
-public class JavaFieldTest extends AbstractImageTestcase
-{
- private JavaObject _testInstance;
- private JavaField _field;
- private JavaField _anotherField;
-
- public static JavaField defaultJavaField(JavaClass clazz)
- {
- return (JavaField) clazz.getDeclaredFields().get(0);
- }
-
- protected void setUp() throws Exception
- {
- try {
- _testInstance = defaultJavaObject(false);
- Iterator declaredFields=_testInstance.getJavaClass().getDeclaredFields().iterator();
- _field = (JavaField)declaredFields.next(); //guaranteed to exist - see JavaObjectTest#defaultJavaObject()
- _anotherField=(JavaField)declaredFields.next(); //guaranteed to exist - see JavaObjectTest#defaultJavaObject()
- super.setUp();
- } catch (TestNotImplementedException e) {
- throw e;
- } catch (Throwable t) {
- //we weren't expecting any exceptions during startup so that is a test failure
- t.printStackTrace();
- fail();
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.get(JavaObject)'
- *
- * This test will fail if a runtime exception is thrown (i.e. if _field does not represent a proper field of _testInstance)
- */
- public void testGet()
- {
- try {
- Object field = _field.get(_testInstance);
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getBoolean(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetBoolean()
- {
- try {
- _field.getBoolean(_testInstance);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getByte(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetByte()
- {
- try {
- _field.getByte(_testInstance);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getChar(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetChar()
- {
- try {
- _field.getChar(_testInstance);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getDouble(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetDouble()
- {
- try {
- _field.getDouble(_testInstance);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getFloat(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetFloat()
- {
- try {
- _field.getFloat(_testInstance);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getInt(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetInt()
- {
- try {
- _field.getInt(_testInstance);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getLong(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetLong()
- {
- try {
- _field.getLong(_testInstance);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getShort(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetShort()
- {
- try {
- _field.getShort(_testInstance);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getString(JavaObject)'
- *
- * Ensures that we succeed or get expected exceptions
- */
- public void testGetString()
- {
- try {
- String string = _field.getString(_testInstance);
- assertNotNull(string);
- } catch (IllegalArgumentException e) {
- } catch (CorruptDataException e) {
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- }
- }
-
- /**
- * Verify that the equals call doesn't throw
- */
- public void testEquals()
- {
- try{
- assertFalse(_field.equals(_anotherField));
- assertTrue(_field.equals(_field));
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- /**
- * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
- * flagged here to ensure that we aren't doing anything bad to create the hashcode)
- */
- public void testHashCode()
- {
- try {
- assertTrue(0 != _testInstance.hashCode());
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- /**
- * This test is to cover an issue where a static field is not parsed correctly. It is very specialized
- * because of this interest in very special information.
- * It looks up the PI constant on java.lang.Math and compares it to the running VM's notion of that constant
- */
- public void testJavaStaticFieldDouble()
- {
- JavaClass math = null;
- Iterator loaders = defaultJavaRuntime().getJavaClassLoaders().iterator();
-
- while (loaders.hasNext()) {
- JavaClassLoader loader = (JavaClassLoader) loaders.next();
- try {
- for (Iterator iter = loader.getDefinedClasses().iterator(); iter.hasNext();) {
- JavaClass clazz = (JavaClass) iter.next();
- if (clazz.getName().equals("java/lang/Math")) {
- math = clazz;
- break;
- }
- }
- } catch (CorruptDataException e) {
- // Ignore.
- }
- }
-
- if (null != math) {
- Iterator fields = math.getDeclaredFields().iterator();
- while (fields.hasNext()) {
- JavaField field = (JavaField) fields.next();
- try {
- if (field.getName().equals("PI")) {
- double pi = field.getDouble(null);
- assertTrue(Math.PI == pi);
- }
- } catch (CorruptDataException e) {
- //ignore
- } catch (MemoryAccessException e) {
- assertNotNull(e.getPointer());
- //fail
- assertTrue(false);
- }
- }
- } else {
- throw new TestNotImplementedException();
- }
- }
-}
+/*******************************************************************************
+ * 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.tests.junit;
+
+import java.util.Iterator;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaClassLoader;
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+
+public class JavaFieldTest extends AbstractImageTestcase
+{
+ private JavaObject _testInstance;
+ private JavaField _field;
+ private JavaField _anotherField;
+
+ public static JavaField defaultJavaField(JavaClass clazz)
+ {
+ return (JavaField) clazz.getDeclaredFields().get(0);
+ }
+
+ protected void setUp() throws Exception
+ {
+ try {
+ _testInstance = defaultJavaObject(false);
+ Iterator declaredFields=_testInstance.getJavaClass().getDeclaredFields().iterator();
+ _field = (JavaField)declaredFields.next(); //guaranteed to exist - see JavaObjectTest#defaultJavaObject()
+ _anotherField=(JavaField)declaredFields.next(); //guaranteed to exist - see JavaObjectTest#defaultJavaObject()
+ super.setUp();
+ } catch (TestNotImplementedException e) {
+ throw e;
+ } catch (Throwable t) {
+ //we weren't expecting any exceptions during startup so that is a test failure
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.get(JavaObject)'
+ *
+ * This test will fail if a runtime exception is thrown (i.e. if _field does not represent a proper field of _testInstance)
+ */
+ public void testGet()
+ {
+ try {
+ Object field = _field.get(_testInstance);
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getBoolean(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetBoolean()
+ {
+ try {
+ _field.getBoolean(_testInstance);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getByte(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetByte()
+ {
+ try {
+ _field.getByte(_testInstance);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getChar(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetChar()
+ {
+ try {
+ _field.getChar(_testInstance);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getDouble(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetDouble()
+ {
+ try {
+ _field.getDouble(_testInstance);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getFloat(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetFloat()
+ {
+ try {
+ _field.getFloat(_testInstance);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getInt(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetInt()
+ {
+ try {
+ _field.getInt(_testInstance);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getLong(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetLong()
+ {
+ try {
+ _field.getLong(_testInstance);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getShort(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetShort()
+ {
+ try {
+ _field.getShort(_testInstance);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaField.getString(JavaObject)'
+ *
+ * Ensures that we succeed or get expected exceptions
+ */
+ public void testGetString()
+ {
+ try {
+ String string = _field.getString(_testInstance);
+ assertNotNull(string);
+ } catch (IllegalArgumentException e) {
+ } catch (CorruptDataException e) {
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ }
+ }
+
+ /**
+ * Verify that the equals call doesn't throw
+ */
+ public void testEquals()
+ {
+ try{
+ assertFalse(_field.equals(_anotherField));
+ assertTrue(_field.equals(_field));
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
+ * flagged here to ensure that we aren't doing anything bad to create the hashcode)
+ */
+ public void testHashCode()
+ {
+ try {
+ assertTrue(0 != _testInstance.hashCode());
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * This test is to cover an issue where a static field is not parsed correctly. It is very specialized
+ * because of this interest in very special information.
+ * It looks up the PI constant on java.lang.Math and compares it to the running VM's notion of that constant
+ */
+ public void testJavaStaticFieldDouble()
+ {
+ JavaClass math = null;
+ Iterator loaders = defaultJavaRuntime().getJavaClassLoaders().iterator();
+
+ while (loaders.hasNext()) {
+ JavaClassLoader loader = (JavaClassLoader) loaders.next();
+ try {
+ for (Iterator iter = loader.getDefinedClasses().iterator(); iter.hasNext();) {
+ JavaClass clazz = (JavaClass) iter.next();
+ if (clazz.getName().equals("java/lang/Math")) {
+ math = clazz;
+ break;
+ }
+ }
+ } catch (CorruptDataException e) {
+ // Ignore.
+ }
+ }
+
+ if (null != math) {
+ Iterator fields = math.getDeclaredFields().iterator();
+ while (fields.hasNext()) {
+ JavaField field = (JavaField) fields.next();
+ try {
+ if (field.getName().equals("PI")) {
+ double pi = field.getDouble(null);
+ assertTrue(Math.PI == pi);
+ }
+ } catch (CorruptDataException e) {
+ //ignore
+ } catch (MemoryAccessException e) {
+ assertNotNull(e.getPointer());
+ //fail
+ assertTrue(false);
+ }
+ }
+ } else {
+ throw new TestNotImplementedException();
+ }
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaFieldTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaHeapTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaHeapTest.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaHeapTest.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaHeapTest.java Mon Nov 23 15:53:48 2009
@@ -1,92 +1,92 @@
-/*******************************************************************************
- * 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.tests.junit;
-
-import java.util.Iterator;
-import java.util.List;
-
-import javax.tools.diagnostics.runtime.java.JavaHeap;
-
-
-public class JavaHeapTest extends AbstractImageTestcase
-{
- private JavaHeap _heap = null;
-
- protected void setUp() throws Exception
- {
- _heap = defaultJavaHeap();
- super.setUp();
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaHeap.getSections()'
- *
- * Ensure that the heap has at least one section
- */
- public void testGetSections()
- {
- List iter = _heap.getSections();
- assertNotNull(iter);
- assertFalse(iter.isEmpty());
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaHeap.getName()'
- *
- * Ensure that the heap has a non-empty name
- */
- public void testGetName()
- {
- String name = _heap.getName();
- assertNotNull(name);
- assertTrue(name.length() > 0);
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaHeap.getObjects()'
- *
- * Ensure that we return a non-empty iterator
- */
- public void testGetObjects()
- {
- Iterator it = _heap.getObjects().iterator();
- assertNotNull(it);
- assertTrue(it.hasNext());
- }
-
- /**
- * Verify that the equals call doesn't throw
- */
- public void testEquals()
- {
- try{
- assertTrue(_heap.equals(_heap));
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- /**
- * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
- * flagged here to ensure that we aren't doing anything bad to create the hashcode)
- */
- public void testHashCode()
- {
- try {
- assertTrue(0 != _heap.hashCode());
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-}
+/*******************************************************************************
+ * 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.tests.junit;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.tools.diagnostics.runtime.java.JavaHeap;
+
+
+public class JavaHeapTest extends AbstractImageTestcase
+{
+ private JavaHeap _heap = null;
+
+ protected void setUp() throws Exception
+ {
+ _heap = defaultJavaHeap();
+ super.setUp();
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaHeap.getSections()'
+ *
+ * Ensure that the heap has at least one section
+ */
+ public void testGetSections()
+ {
+ List iter = _heap.getSections();
+ assertNotNull(iter);
+ assertFalse(iter.isEmpty());
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaHeap.getName()'
+ *
+ * Ensure that the heap has a non-empty name
+ */
+ public void testGetName()
+ {
+ String name = _heap.getName();
+ assertNotNull(name);
+ assertTrue(name.length() > 0);
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaHeap.getObjects()'
+ *
+ * Ensure that we return a non-empty iterator
+ */
+ public void testGetObjects()
+ {
+ Iterator it = _heap.getObjects().iterator();
+ assertNotNull(it);
+ assertTrue(it.hasNext());
+ }
+
+ /**
+ * Verify that the equals call doesn't throw
+ */
+ public void testEquals()
+ {
+ try{
+ assertTrue(_heap.equals(_heap));
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
+ * flagged here to ensure that we aren't doing anything bad to create the hashcode)
+ */
+ public void testHashCode()
+ {
+ try {
+ assertTrue(0 != _heap.hashCode());
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaHeapTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaLocationTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaLocationTest.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaLocationTest.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaLocationTest.java Mon Nov 23 15:53:48 2009
@@ -1,150 +1,150 @@
-/*******************************************************************************
- * 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.tests.junit;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.ImagePointer;
-import javax.tools.diagnostics.runtime.java.JavaLocation;
-import javax.tools.diagnostics.runtime.java.JavaStackFrame;
-
-public class JavaLocationTest extends AbstractImageTestcase
-{
- private JavaLocation _location;
-
- public JavaLocation defaultLocation()
- {
- try {
- return ((JavaStackFrame)defaultJavaThread().getStackFrames().get(0)).getLocation();
- } catch (CorruptDataException e) {
- //XXX: how should this be handled?
- throw new TestNotImplementedException();
- }
- }
-
- protected void setUp() throws Exception
- {
- _location = defaultLocation();
- super.setUp();
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getAddress()'
- *
- * Ensures that the address is non-null
- */
- public void testGetAddress()
- {
- try {
- ImagePointer address = _location.getAddress();
- assertNotNull(address);
- } catch (CorruptDataException e) {
- //acceptable
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getLineNumber()'
- *
- * Ensures that the line number is >0
- */
- public void testGetLineNumber()
- {
- try {
- assertTrue(_location.getLineNumber() > 0);
- } catch (DataUnavailable e) {
- //acceptable
- } catch (CorruptDataException e) {
- //acceptable
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getFilename()'
- *
- * Ensures that the filename is non-null and non-empty
- */
- public void testGetFilename()
- {
- try {
- String filename = _location.getFilename();
- assertNotNull(filename);
- assertTrue(filename.length() > 0);
- } catch (DataUnavailable e) {
- //acceptable
- } catch (CorruptDataException e) {
- //acceptable
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getCompilationLevel()'
- *
- * Ensures that the call succeeds
- */
- public void testGetCompilationLevel()
- {
- try {
- _location.getCompilationLevel();
- } catch (CorruptDataException e) {
- //acceptable
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getMethod()'
- *
- * Ensures that a non-null method is returned
- */
- public void testGetMethod()
- {
- try {
- assertNotNull(_location.getMethod());
- } catch (CorruptDataException e) {
- //acceptable
- }
- }
-
- /**
- * Verify that the equals call doesn't throw
- */
- public void testEquals()
- {
- try{
- assertTrue(_location.equals(_location));
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- /**
- * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
- * flagged here to ensure that we aren't doing anything bad to create the hashcode)
- */
- public void testHashCode()
- {
- try {
- assertTrue(0 != _location.hashCode());
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- public void testToString()
- {
- String theString = _location.toString();
- assertNotNull(theString);
- assertTrue(theString.length() >= 0 );
- }
-}
+/*******************************************************************************
+ * 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.tests.junit;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.runtime.java.JavaLocation;
+import javax.tools.diagnostics.runtime.java.JavaStackFrame;
+
+public class JavaLocationTest extends AbstractImageTestcase
+{
+ private JavaLocation _location;
+
+ public JavaLocation defaultLocation()
+ {
+ try {
+ return ((JavaStackFrame)defaultJavaThread().getStackFrames().get(0)).getLocation();
+ } catch (CorruptDataException e) {
+ //XXX: how should this be handled?
+ throw new TestNotImplementedException();
+ }
+ }
+
+ protected void setUp() throws Exception
+ {
+ _location = defaultLocation();
+ super.setUp();
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getAddress()'
+ *
+ * Ensures that the address is non-null
+ */
+ public void testGetAddress()
+ {
+ try {
+ ImagePointer address = _location.getAddress();
+ assertNotNull(address);
+ } catch (CorruptDataException e) {
+ //acceptable
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getLineNumber()'
+ *
+ * Ensures that the line number is >0
+ */
+ public void testGetLineNumber()
+ {
+ try {
+ assertTrue(_location.getLineNumber() > 0);
+ } catch (DataUnavailable e) {
+ //acceptable
+ } catch (CorruptDataException e) {
+ //acceptable
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getFilename()'
+ *
+ * Ensures that the filename is non-null and non-empty
+ */
+ public void testGetFilename()
+ {
+ try {
+ String filename = _location.getFilename();
+ assertNotNull(filename);
+ assertTrue(filename.length() > 0);
+ } catch (DataUnavailable e) {
+ //acceptable
+ } catch (CorruptDataException e) {
+ //acceptable
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getCompilationLevel()'
+ *
+ * Ensures that the call succeeds
+ */
+ public void testGetCompilationLevel()
+ {
+ try {
+ _location.getCompilationLevel();
+ } catch (CorruptDataException e) {
+ //acceptable
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaLocation.getMethod()'
+ *
+ * Ensures that a non-null method is returned
+ */
+ public void testGetMethod()
+ {
+ try {
+ assertNotNull(_location.getMethod());
+ } catch (CorruptDataException e) {
+ //acceptable
+ }
+ }
+
+ /**
+ * Verify that the equals call doesn't throw
+ */
+ public void testEquals()
+ {
+ try{
+ assertTrue(_location.equals(_location));
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
+ * flagged here to ensure that we aren't doing anything bad to create the hashcode)
+ */
+ public void testHashCode()
+ {
+ try {
+ assertTrue(0 != _location.hashCode());
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ public void testToString()
+ {
+ String theString = _location.toString();
+ assertNotNull(theString);
+ assertTrue(theString.length() >= 0 );
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaLocationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMethodTest.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMethodTest.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMethodTest.java Mon Nov 23 15:53:48 2009
@@ -1,147 +1,147 @@
-/*******************************************************************************
- * 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.tests.junit;
-
-import java.util.Iterator;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.ImageSection;
-import javax.tools.diagnostics.runtime.java.JavaField;
-import javax.tools.diagnostics.runtime.java.JavaMethod;
-
-
-public class JavaMethodTest extends AbstractImageTestcase
-{
- private JavaMethod _method = null;
-
- protected void setUp() throws Exception
- {
- _method = defaultJavaMethod();
- super.setUp();
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMethod.getBytecodeSections()'
- *
- * Ensures that a non-null iterator is returned and every element of the iterator is ImageSection.
- * (note that the iterator can be empty in the case of natives)
- */
- public void testGetBytecodeSections()
- {
- Iterator it = _method.getBytecodeSections().iterator();
- assertNotNull(it);
- while (it.hasNext()) {
- assertTrue(it.next() instanceof ImageSection);
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMethod.getCompiledSections()'
- *
- * Ensures that a non-null, non-empty iterator is returned
- */
- public void testGetCompiledSections()
- {
- Iterator it = _method.getCompiledSections().iterator();
- assertNotNull(it);
- assertTrue(it.hasNext());
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMember.getModifiers()'
- *
- * Ensures that the call succeeds
- */
- public void testGetModifiers()
- {
- try {
- _method.getModifiers();
- } catch (CorruptDataException e) {
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMember.getDeclaringClass()'
- *
- * Ensures that the class has a non-null address
- */
- public void testGetDeclaringClass()
- {
- try {
- assertTrue(0 != _method.getDeclaringClass().getID().getAddress());
- } catch (CorruptDataException e) {
- } catch (DataUnavailable e) {
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMember.getName()'
- *
- * Ensure that the method has a non-empty name
- */
- public void testGetName()
- {
- try {
- assertTrue(_method.getName().length() > 0);
- } catch (CorruptDataException e) {
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMember.getSignature()'
- *
- * Ensure that the signature is non-empty
- */
- public void testGetSignature()
- {
- try {
- assertTrue(_method.getSignature().length() > 0);
- } catch (CorruptDataException e) {
- }
- }
-
- /**
- * Verify that the equals call doesn't throw
- */
- public void testEquals()
- {
- try{
- assertTrue(_method.equals(_method));
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- /**
- * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
- * flagged here to ensure that we aren't doing anything bad to create the hashcode)
- */
- public void testHashCode()
- {
- try {
- assertTrue(0 != _method.hashCode());
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- public void testToString()
- {
- String theString=_method.toString();
- assertNotNull(theString);
- assertTrue(theString.length() >= 0 );
- }
-
-}
+/*******************************************************************************
+ * 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.tests.junit;
+
+import java.util.Iterator;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImageSection;
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaMethod;
+
+
+public class JavaMethodTest extends AbstractImageTestcase
+{
+ private JavaMethod _method = null;
+
+ protected void setUp() throws Exception
+ {
+ _method = defaultJavaMethod();
+ super.setUp();
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMethod.getBytecodeSections()'
+ *
+ * Ensures that a non-null iterator is returned and every element of the iterator is ImageSection.
+ * (note that the iterator can be empty in the case of natives)
+ */
+ public void testGetBytecodeSections()
+ {
+ Iterator it = _method.getBytecodeSections().iterator();
+ assertNotNull(it);
+ while (it.hasNext()) {
+ assertTrue(it.next() instanceof ImageSection);
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMethod.getCompiledSections()'
+ *
+ * Ensures that a non-null, non-empty iterator is returned
+ */
+ public void testGetCompiledSections()
+ {
+ Iterator it = _method.getCompiledSections().iterator();
+ assertNotNull(it);
+ assertTrue(it.hasNext());
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMember.getModifiers()'
+ *
+ * Ensures that the call succeeds
+ */
+ public void testGetModifiers()
+ {
+ try {
+ _method.getModifiers();
+ } catch (CorruptDataException e) {
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMember.getDeclaringClass()'
+ *
+ * Ensures that the class has a non-null address
+ */
+ public void testGetDeclaringClass()
+ {
+ try {
+ assertTrue(0 != _method.getDeclaringClass().getID().getAddress());
+ } catch (CorruptDataException e) {
+ } catch (DataUnavailable e) {
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMember.getName()'
+ *
+ * Ensure that the method has a non-empty name
+ */
+ public void testGetName()
+ {
+ try {
+ assertTrue(_method.getName().length() > 0);
+ } catch (CorruptDataException e) {
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMember.getSignature()'
+ *
+ * Ensure that the signature is non-empty
+ */
+ public void testGetSignature()
+ {
+ try {
+ assertTrue(_method.getSignature().length() > 0);
+ } catch (CorruptDataException e) {
+ }
+ }
+
+ /**
+ * Verify that the equals call doesn't throw
+ */
+ public void testEquals()
+ {
+ try{
+ assertTrue(_method.equals(_method));
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
+ * flagged here to ensure that we aren't doing anything bad to create the hashcode)
+ */
+ public void testHashCode()
+ {
+ try {
+ assertTrue(0 != _method.hashCode());
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ public void testToString()
+ {
+ String theString=_method.toString();
+ assertNotNull(theString);
+ assertTrue(theString.length() >= 0 );
+ }
+
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMethodTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMonitorTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMonitorTest.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMonitorTest.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMonitorTest.java Mon Nov 23 15:53:48 2009
@@ -1,172 +1,172 @@
-/*******************************************************************************
- * 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.tests.junit;
-
-import java.util.Iterator;
-
-import javax.tools.diagnostics.image.CorruptData;
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.runtime.java.JavaMonitor;
-import javax.tools.diagnostics.runtime.java.JavaThread;
-
-
-public class JavaMonitorTest extends AbstractImageTestcase
-{
- private JavaMonitor _monitor = null;
-
- public JavaMonitor defaultJavaMonitor()
- {
- Iterator it = defaultJavaRuntime().getMonitors().iterator();
- assertNotNull(it);
- assertTrue(it.hasNext());
- return (JavaMonitor) it.next();
- }
-
- protected void setUp() throws Exception
- {
- _monitor = defaultJavaMonitor();
- super.setUp();
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getObject()'
- *
- * Ensures that no unexpected exceptions are thrown
- */
- public void testGetObject()
- {
- _monitor.getObject();
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getName()'
- *
- * Ensures that a non-null name is returned
- */
- public void testGetName()
- {
- try {
- String name = _monitor.getName();
- assertNotNull(name);
- } catch (CorruptDataException e) {
- //this is technically allowed
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getOwner()'
- *
- * Ensures that no unexpected exceptions are thrown
- */
- public void testGetOwner()
- {
- try {
- _monitor.getOwner();
- } catch (CorruptDataException e) {
- //this is technically allowed
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getEnterWaiters()'
- *
- * Ensures that either an empty iterator is returned, or a non-empty iterator where all the
- * elements are JavaThread of CorruptData is returned.
- */
- public void testGetEnterWaiters()
- {
- Iterator iter = _monitor.getEnterWaiters().iterator();
- assertNotNull(iter);
- while (iter.hasNext()) {
- Object element = iter.next();
- assertTrue((element instanceof JavaThread) || (element instanceof CorruptData));
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getNotifyWaiters()'
- *
- * Ensures that either an empty iterator is returned, or a non-empty iterator where all the
- * elements are JavaThread of CorruptData is returned.
- */
- public void testGetNotifyWaiters()
- {
- Iterator iter = _monitor.getNotifyWaiters().iterator();
- assertNotNull(iter);
- while (iter.hasNext()) {
- Object element = iter.next();
- assertTrue((element instanceof JavaThread) || (element instanceof CorruptData));
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getID()'
- *
- * Ensures that the pointer we receive is non-null.
- */
- public void testGetID()
- {
- assertNotNull(_monitor.getID());
- }
-
- /**
- * Verify that the equals call doesn't throw
- */
- public void testEquals()
- {
- try{
- assertTrue(_monitor.equals(_monitor));
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- /**
- * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
- * flagged here to ensure that we aren't doing anything bad to create the hashcode)
- */
- public void testHashCode()
- {
- try {
- assertTrue(0 != _monitor.hashCode());
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- /**
- * Ensure that all the monitors we find which have owners have valid owners.
- *
- * Note: This test may have to be removed or further qualified in the future if we want to restrict this test suite to only deal
- * with spec behaviour (which would allow getOwner() to throw CorruptDataException) or to test corner cases and past bugs in the
- * (since this test suite currently addresses both needs).
- */
- public void testAllMonitorOwners()
- {
- try {
- Iterator it = defaultJavaRuntime().getMonitors().iterator();
-
- while (it.hasNext()) {
- JavaMonitor monitor = (JavaMonitor) it.next();
- JavaThread owner = monitor.getOwner();
-
- if (null != owner) {
- assertNotNull(owner.getName());
- }
- }
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-}
+/*******************************************************************************
+ * 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.tests.junit;
+
+import java.util.Iterator;
+
+import javax.tools.diagnostics.image.CorruptData;
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.runtime.java.JavaMonitor;
+import javax.tools.diagnostics.runtime.java.JavaThread;
+
+
+public class JavaMonitorTest extends AbstractImageTestcase
+{
+ private JavaMonitor _monitor = null;
+
+ public JavaMonitor defaultJavaMonitor()
+ {
+ Iterator it = defaultJavaRuntime().getMonitors().iterator();
+ assertNotNull(it);
+ assertTrue(it.hasNext());
+ return (JavaMonitor) it.next();
+ }
+
+ protected void setUp() throws Exception
+ {
+ _monitor = defaultJavaMonitor();
+ super.setUp();
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getObject()'
+ *
+ * Ensures that no unexpected exceptions are thrown
+ */
+ public void testGetObject()
+ {
+ _monitor.getObject();
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getName()'
+ *
+ * Ensures that a non-null name is returned
+ */
+ public void testGetName()
+ {
+ try {
+ String name = _monitor.getName();
+ assertNotNull(name);
+ } catch (CorruptDataException e) {
+ //this is technically allowed
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getOwner()'
+ *
+ * Ensures that no unexpected exceptions are thrown
+ */
+ public void testGetOwner()
+ {
+ try {
+ _monitor.getOwner();
+ } catch (CorruptDataException e) {
+ //this is technically allowed
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getEnterWaiters()'
+ *
+ * Ensures that either an empty iterator is returned, or a non-empty iterator where all the
+ * elements are JavaThread of CorruptData is returned.
+ */
+ public void testGetEnterWaiters()
+ {
+ Iterator iter = _monitor.getEnterWaiters().iterator();
+ assertNotNull(iter);
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ assertTrue((element instanceof JavaThread) || (element instanceof CorruptData));
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getNotifyWaiters()'
+ *
+ * Ensures that either an empty iterator is returned, or a non-empty iterator where all the
+ * elements are JavaThread of CorruptData is returned.
+ */
+ public void testGetNotifyWaiters()
+ {
+ Iterator iter = _monitor.getNotifyWaiters().iterator();
+ assertNotNull(iter);
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ assertTrue((element instanceof JavaThread) || (element instanceof CorruptData));
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaMonitor.getID()'
+ *
+ * Ensures that the pointer we receive is non-null.
+ */
+ public void testGetID()
+ {
+ assertNotNull(_monitor.getID());
+ }
+
+ /**
+ * Verify that the equals call doesn't throw
+ */
+ public void testEquals()
+ {
+ try{
+ assertTrue(_monitor.equals(_monitor));
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * Verify that hashCode() doesn't throw and returns non-zero (technically zero is ok but it will be
+ * flagged here to ensure that we aren't doing anything bad to create the hashcode)
+ */
+ public void testHashCode()
+ {
+ try {
+ assertTrue(0 != _monitor.hashCode());
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * Ensure that all the monitors we find which have owners have valid owners.
+ *
+ * Note: This test may have to be removed or further qualified in the future if we want to restrict this test suite to only deal
+ * with spec behaviour (which would allow getOwner() to throw CorruptDataException) or to test corner cases and past bugs in the
+ * (since this test suite currently addresses both needs).
+ */
+ public void testAllMonitorOwners()
+ {
+ try {
+ Iterator it = defaultJavaRuntime().getMonitors().iterator();
+
+ while (it.hasNext()) {
+ JavaMonitor monitor = (JavaMonitor) it.next();
+ JavaThread owner = monitor.getOwner();
+
+ if (null != owner) {
+ assertNotNull(owner.getName());
+ }
+ }
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaMonitorTest.java
------------------------------------------------------------------------------
svn:eol-style = native