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/05/07 14:50:35 UTC
svn commit: r772669 [7/7] - in /incubator/kato/trunk: HprofBinaryReaderPOC/
HprofBinaryReaderPOC/.settings/ HprofBinaryReaderPOC/META-INF/
HprofBinaryReaderPOC/bin/ HprofBinaryReaderPOC/bin/org/
HprofBinaryReaderPOC/bin/org/apache/ HprofBinaryReaderPOC...
Added: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImage.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImage.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImage.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImage.java Thu May 7 14:50:21 2009
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * 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 test.apache.kato.hprof.image;
+
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.kato.hprof.image.ImageImpl;
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.Image;
+import org.apache.kato.image.ImageAddressSpace;
+
+
+public class TestImage extends AbstractHProfTestCase {
+
+
+ public void testNullConstructor() {
+
+ try {
+ new ImageImpl(null);
+ fail("expected illegal argument exception");
+ } catch(IllegalArgumentException iae) {
+ ;
+ }
+
+ }
+
+
+ public void testGetCreationTime() throws IOException, DataUnavailable {
+
+ Image minimal=getMinimalImage();
+ long creationTime=minimal.getCreationTime();
+ assertEquals("creation time is incorrect",0xF0F0,creationTime);
+
+
+ }
+
+ public void testGetHostName() throws IOException, CorruptDataException {
+ try {
+ Image minimal=getMinimalImage();
+ minimal.getHostName();
+ fail("expected DataUnavailableException");
+ } catch(DataUnavailable du) {
+
+ }
+ }
+
+ public void testGetIPAddresses() throws IOException, CorruptDataException {
+ try {
+ Image minimal=getMinimalImage();
+ minimal.getIPAddresses();
+ fail("expected DataUnavailableException");
+ } catch(DataUnavailable du) {
+
+ }
+ }
+ public void testGetInstalledMemory() throws IOException, CorruptDataException {
+ try {
+ Image minimal=getMinimalImage();
+ minimal.getInstalledMemory();
+ fail("expected DataUnavailableException");
+ } catch(DataUnavailable du) {
+
+ }
+ }
+ public void testGetProcessorCount() throws IOException, CorruptDataException {
+ try {
+ Image minimal=getMinimalImage();
+ minimal.getProcessorCount();
+ fail("expected DataUnavailableException");
+ } catch(DataUnavailable du) {
+
+ }
+ }
+ public void testGetProcessorSubType() throws IOException, CorruptDataException {
+ try {
+ Image minimal=getMinimalImage();
+ minimal.getProcessorSubType();
+ fail("expected DataUnavailableException");
+ } catch(DataUnavailable du) {
+
+ }
+ }
+ public void testGetProcessorType() throws IOException, CorruptDataException {
+ try {
+ Image minimal=getMinimalImage();
+ minimal.getProcessorType();
+ fail("expected DataUnavailableException");
+ } catch(DataUnavailable du) {
+
+ }
+ }
+ public void testGetSystemType() throws IOException, CorruptDataException {
+ try {
+ Image minimal=getMinimalImage();
+ minimal.getSystemType();
+ fail("expected DataUnavailableException");
+ } catch(DataUnavailable du) {
+
+ }
+ }
+ public void testGetSystemSubType() throws IOException, CorruptDataException {
+ try {
+ Image minimal=getMinimalImage();
+ minimal.getSystemSubType();
+ fail("expected DataUnavailableException");
+ } catch(DataUnavailable du) {
+
+ }
+ }
+
+
+ public void testGetAddressSpaceIterator() throws IOException {
+
+ Image minimal=getMinimalImage();
+ Iterator i=minimal.getAddressSpaces();
+ assertNotNull(i);
+ }
+
+ public void testGetNonEmptyAddressSpaceIterator() throws IOException {
+
+ Image minimal=getMinimalImage();
+ Iterator i=minimal.getAddressSpaces();
+ assertTrue(i.hasNext());
+ }
+
+ public void testGetRealAddressSpace() throws IOException {
+
+ Image minimal=getMinimalImage();
+ Iterator i=minimal.getAddressSpaces();
+ Object o=i.next();
+ assertTrue("object is not an image address space",o instanceof ImageAddressSpace);
+
+ }
+
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java Thu May 7 14:50:21 2009
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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 test.apache.kato.hprof.image;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.kato.image.ImageAddressSpace;
+import org.apache.kato.image.ImageProcess;
+
+public class TestImageAddressSpace extends AbstractHProfTestCase {
+
+
+ public void testGetImageSectionIterator() throws IOException {
+
+ ImageAddressSpace space=getFirstAddressSpace();
+ Iterator i=space.getImageSections();
+ assertNotNull(i);
+
+ }
+
+ public void testGetEmptyImageSectionIterator() throws IOException {
+
+ ImageAddressSpace space=getFirstAddressSpace();
+ Iterator i=space.getImageSections();
+ assertFalse(i.hasNext());
+
+ }
+
+ public void testGetCurrentProcess() throws IOException {
+ ImageAddressSpace space=getFirstAddressSpace();
+ ImageProcess process=space.getCurrentProcess();
+ assertNotNull(process);
+
+ }
+ public void testGetProcessIterator() throws IOException {
+ ImageAddressSpace space=getFirstAddressSpace();
+ Iterator i=space.getProcesses();
+ assertNotNull(i);
+
+ }
+
+ public void testGetNonEmptyProcessIterator() throws IOException {
+ ImageAddressSpace space=getFirstAddressSpace();
+ Iterator i=space.getProcesses();
+ assertTrue(i.hasNext());
+
+ }
+ public void testProcessIteratorReturnsProcess() throws IOException {
+ ImageAddressSpace space=getFirstAddressSpace();
+ Iterator i=space.getProcesses();
+ ImageProcess p=(ImageProcess) i.next();
+
+ }
+ public void testProcessIteratorReturnsCurrentProcess() throws IOException {
+ ImageAddressSpace space=getFirstAddressSpace();
+ Iterator i=space.getProcesses();
+ ImageProcess p=(ImageProcess) i.next();
+ ImageProcess current=space.getCurrentProcess();
+ assertEquals("first image process is not current",current,p);
+ }
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageFactory.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageFactory.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageFactory.java Thu May 7 14:50:21 2009
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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 test.apache.kato.hprof.image;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.kato.common.InvalidFileFormat;
+import org.apache.kato.hprof.image.ImageFactoryImpl;
+import org.apache.kato.image.Image;
+import org.apache.kato.image.ImageFactory;
+
+public class TestImageFactory extends AbstractHProfTestCase {
+
+
+ public void testConstructor() {
+
+ new ImageFactoryImpl();
+
+ }
+ public void testMajorVersion() {
+
+ ImageFactory factory=new ImageFactoryImpl();
+ assertEquals("major version mismatch",1,factory.getDTFJMajorVersion());
+ }
+ public void testMinorVersion() {
+
+ ImageFactory factory=new ImageFactoryImpl();
+ assertEquals("minor version mismatch",3,factory.getDTFJMinorVersion());
+ }
+
+ public void testModVersion() {
+
+ ImageFactory factory=new ImageFactoryImpl();
+ assertEquals("modification version mismatch",0,factory.getDTFJModificationLevel());
+ }
+
+ public void testGetImageFromNull1() throws IOException {
+
+ ImageFactory factory=new ImageFactoryImpl();
+ try {
+ factory.getImage(null);
+ fail("Expected illegal argument exception");
+ }
+ catch(IllegalArgumentException iae) {
+
+ }
+ }
+
+ public void testGetImageFromNull2() throws IOException {
+
+ ImageFactory factory=new ImageFactoryImpl();
+ try {
+ factory.getImage(null,null);
+ fail("Expected illegal argument exception");
+ }
+ catch(IllegalArgumentException iae) {
+
+ }
+ }
+
+ public void testGetImageFromEmptyFile() throws IOException {
+
+ ImageFactory factory=new ImageFactoryImpl();
+ File realFile = getEmptyHProfFile();
+ try {
+ factory.getImage(realFile);
+ fail("Expecting InvalidFileFormat exception");
+ } catch(InvalidFileFormat iff) {
+
+ }
+
+ }
+ public void testGetImageFromheaderOnlyFile() throws IOException {
+
+ ImageFactory factory=new ImageFactoryImpl();
+ File realFile = getHeaderOnlyHProfFile();
+ try {
+ factory.getImage(realFile);
+ fail("Expecting InvalidFileFormat exception");
+ } catch(InvalidFileFormat iff) {
+
+ }
+
+ }
+public void testGetImageFromMinimalFile() throws IOException {
+
+ ImageFactory factory=new ImageFactoryImpl();
+ File realFile = getMinimalHProfFile();
+ Image image=factory.getImage(realFile);
+
+
+}
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java Thu May 7 14:50:21 2009
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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 test.apache.kato.hprof.image;
+
+import java.io.IOException;
+
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.ImageProcess;
+
+
+public class TestImageProcess extends AbstractHProfTestCase {
+
+
+ public void testGetCommandLine() throws IOException, CorruptDataException {
+
+ ImageProcess process=getCurrentProcess();
+ try {
+ process.getCommandLine();
+ fail("expected DataUnavailable exception");
+ } catch(DataUnavailable du) {
+
+ }
+
+
+ }
+
+public void testGetEnvironment() throws IOException, CorruptDataException {
+
+ ImageProcess process=getCurrentProcess();
+ try {
+ process.getEnvironment();
+ fail("expected DataUnavailable exception");
+ } catch(DataUnavailable du) {
+
+ }
+
+
+ }
+
+public void testGetExecutable() throws IOException, CorruptDataException {
+
+ ImageProcess process=getCurrentProcess();
+ try {
+ process.getExecutable();
+ fail("expected DataUnavailable exception");
+ } catch(DataUnavailable du) {
+
+ }
+
+
+}
+public void testGetLibraries() throws IOException, CorruptDataException {
+
+ ImageProcess process=getCurrentProcess();
+ try {
+ process.getLibraries();
+ fail("expected DataUnavailable exception");
+ } catch(DataUnavailable du) {
+
+ }
+
+
+}
+public void testGetSignalNumber() throws IOException, CorruptDataException {
+
+ ImageProcess process=getCurrentProcess();
+ try {
+ process.getSignalNumber();
+ fail("expected DataUnavailable exception");
+ } catch(DataUnavailable du) {
+
+ }
+
+
+}
+public void testGetSignalName() throws IOException, CorruptDataException {
+
+ ImageProcess process=getCurrentProcess();
+ try {
+ process.getSignalName();
+ fail("expected DataUnavailable exception");
+ } catch(DataUnavailable du) {
+
+ }
+
+
+}
+
+public void testGetID() throws IOException, CorruptDataException {
+
+ ImageProcess process=getCurrentProcess();
+ try {
+ process.getID();
+ fail("expected DataUnavailable exception");
+ } catch(DataUnavailable du) {
+
+ }
+
+
+}
+public void testGetPointerSize() throws IOException, CorruptDataException {
+
+ ImageProcess process=getCurrentProcess();
+
+ int size=process.getPointerSize();
+ assertTrue("pointer size ("+size+") is less than 1",size>0);
+
+}
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/java/TestJavaHeap.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/java/TestJavaHeap.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/java/TestJavaHeap.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/java/TestJavaHeap.java Thu May 7 14:50:21 2009
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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 test.apache.kato.hprof.java;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.kato.java.JavaHeap;
+
+import test.apache.kato.hprof.image.AbstractHProfTestCase;
+
+public class TestJavaHeap extends AbstractHProfTestCase {
+
+
+ public void testGetName() throws IOException {
+
+ JavaHeap heap=getPopulatedJavaHeap();
+ String name=heap.getName();
+ assertNotNull(name);
+
+ }
+
+ public void testGetSectionsReturns() throws IOException {
+
+ JavaHeap heap=getPopulatedJavaHeap();
+ Iterator i=heap.getSections();
+ assertNotNull(i);
+
+ }
+ public void testGetSectionsIsEmpty() throws IOException {
+
+ JavaHeap heap=getPopulatedJavaHeap();
+ Iterator i=heap.getSections();
+ assertFalse("expected empty iterator",i.hasNext());
+
+ }
+
+ public void testGetObjectsReturns() throws IOException {
+
+ JavaHeap heap=getPopulatedJavaHeap();
+ Iterator i=heap.getObjects();
+ assertNull(i);
+
+ }
+
+
+
+
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/java/TestJavaRuntime.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/java/TestJavaRuntime.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/java/TestJavaRuntime.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/java/TestJavaRuntime.java Thu May 7 14:50:21 2009
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * 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 test.apache.kato.hprof.java;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.ImagePointer;
+import org.apache.kato.image.MemoryAccessException;
+import org.apache.kato.java.JavaObject;
+import org.apache.kato.java.JavaRuntime;
+import org.apache.kato.java.JavaVMInitArgs;
+
+import test.apache.kato.hprof.image.AbstractHProfTestCase;
+
+public class TestJavaRuntime extends AbstractHProfTestCase{
+
+ public void testGetFullVersion() throws IOException, CorruptDataException {
+
+ JavaRuntime runtime=getJavaRuntime();
+ assertNull(runtime.getFullVersion());
+
+ }
+public void testGetVersion() throws IOException, CorruptDataException {
+
+ JavaRuntime runtime=getJavaRuntime();
+ assertNull(runtime.getVersion());
+
+ }
+
+
+public void testEqualsPasses() throws IOException {
+ JavaRuntime runtime=getJavaRuntime();
+ assertTrue(runtime.equals(runtime));
+
+}
+public void testEqualsFails() throws IOException {
+ JavaRuntime runtime=getJavaRuntime();
+ assertFalse(runtime.equals(new MockJavaRuntime()));
+
+}
+
+public void testGetMonitors() throws IOException {
+
+ JavaRuntime runtime=getJavaRuntime();
+ Iterator i=runtime.getMonitors();
+ assertNull(i);
+
+}
+
+public void testGetJVM() throws IOException, DataUnavailable, CorruptDataException {
+ JavaRuntime runtime=getJavaRuntime();
+
+ ImagePointer pointer=(ImagePointer) runtime.getJavaVM();
+ assertNull(pointer);
+
+}
+
+public void testGetVMArguments() throws CorruptDataException, IOException {
+ JavaRuntime runtime=getJavaRuntime();
+ try {
+ runtime.getJavaVMInitArgs();
+ fail("expected DataUnavailable exception");
+ } catch(DataUnavailable du) {
+
+ }
+
+}
+
+public void testGetCompiledMethodsReturns() throws IOException {
+ JavaRuntime runtime=getJavaRuntime();
+ Iterator i=runtime.getCompiledMethods();
+ assertNotNull(i);
+
+}
+public void testGetCompiledMethodsIteratorIsEmpty() throws IOException {
+ JavaRuntime runtime=getJavaRuntime();
+ Iterator i=runtime.getCompiledMethods();
+ assertFalse("compiled methods iterator is not empty",i.hasNext());
+
+}
+
+public void testGetHeapIteratorReturns() throws IOException {
+ JavaRuntime runtime=getPopulatedJavaRuntime();
+ Iterator i=runtime.getHeaps();
+ assertNotNull(i);
+
+}
+private final class MockJavaRuntime implements JavaRuntime {
+ @Override
+ public Iterator getCompiledMethods() {
+
+ return null;
+ }
+
+ @Override
+ public Iterator getHeapRoots() {
+
+ return null;
+ }
+
+ @Override
+ public Iterator getHeaps() {
+
+ return null;
+ }
+
+ @Override
+ public Iterator getJavaClassLoaders() {
+
+ return null;
+ }
+
+ @Override
+ public ImagePointer getJavaVM() throws CorruptDataException {
+
+ return null;
+ }
+
+ @Override
+ public JavaVMInitArgs getJavaVMInitArgs() throws DataUnavailable,
+ CorruptDataException {
+
+ return null;
+ }
+
+ @Override
+ public Iterator getMonitors() {
+
+ return null;
+ }
+
+ @Override
+ public JavaObject getObjectAtAddress(ImagePointer address)
+ throws CorruptDataException, IllegalArgumentException,
+ MemoryAccessException, DataUnavailable {
+
+ return null;
+ }
+
+ @Override
+ public Iterator getThreads() {
+
+ return null;
+ }
+
+ @Override
+ public Object getTraceBuffer(String bufferName, boolean formatted)
+ throws CorruptDataException {
+
+ return null;
+ }
+
+ @Override
+ public String getFullVersion() throws CorruptDataException {
+
+ return null;
+ }
+
+ @Override
+ public String getVersion() throws CorruptDataException {
+
+ return null;
+ }
+}
+}