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 [38/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/JavaThreadTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaThreadTest.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/JavaThreadTest.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaThreadTest.java Mon Nov 23 15:53:48 2009
@@ -1,187 +1,187 @@
-/*******************************************************************************
- * 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.runtime.java.JavaThread;
-
-
-public class JavaThreadTest extends AbstractImageTestcase
-{
- private JavaThread _thread = null;
- private JavaThread _sameThread = null;
-
- protected void setUp() throws Exception
- {
- _thread = defaultJavaThread();
- _sameThread= defaultJavaThread();
- assertNotNull(_thread);
- super.setUp();
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getJNIEnv()'
- *
- * Ensures that the JNIEnv is non-null
- */
- public void testGetJNIEnv()
- {
- try {
- assertNotNull(_thread.getJNIEnv());
- } catch (CorruptDataException e) {
- //this is acceptable by the spec
- }
- }
-
- /*
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getPriority()'
- */
- public void testGetPriority()
- {
- try {
- int priority = _thread.getPriority();
- assertTrue((priority >= 1) && (priority <= 10));
- } catch (CorruptDataException e) {
- //this is acceptable by the spec
- }
- }
-
- /*
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getObject()'
- */
- public void testGetObject()
- {
- //anything returned here is legal. In fact, even null is ok
- try {
- _thread.getObject();
- } catch (CorruptDataException e) {
- //this is acceptable by the spec
- }
- }
-
- /*
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getState()'
- */
- public void testGetState()
- {
- try {
- assertTrue(_thread.getState() > 0);
- } catch (CorruptDataException e) {
- //this is acceptable by the spec
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getImageThread()'
- *
- * Ensures that a non-null image thread can be pulled from this thread
- */
- public void testGetImageThread()
- {
- try {
- assertNotNull(_thread.getImageThread());
- } catch (CorruptDataException e) {
- //this is acceptable by the spec
- } catch (DataUnavailable e) {
- //this is acceptable by the spec
- }
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getStackSections()'
- *
- * Ensures that a non-null, non-empty iterator is returned
- */
- public void testGetStackSections()
- {
- Iterator it = _thread.getStackSections().iterator();
- assertNotNull(it);
- assertTrue(it.hasNext());
- }
-
- /**
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getStackFrames()'
- *
- * Ensures that the frame iterator is non-null even though it may be empty
- */
- public void testGetStackFrames()
- {
- Iterator frames = _thread.getStackFrames().iterator();
- assertNotNull(frames);
- //it is legal for there to be no frames
- }
-
- /*
- * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getName()'
- */
- public void testGetName()
- {
- try {
- assertNotNull(_thread.getName());
- } catch (CorruptDataException e) {
- //this is acceptable by the spec
- }
- }
-
- /**
- * Verify that the equals call doesn't throw
- */
- public void testEquals()
- {
- try{
- assertTrue(_thread.equals(_thread));
- assertTrue(_thread.equals(_sameThread));
- } 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 != _thread.hashCode());
- assertTrue(_thread.hashCode() == _sameThread.hashCode());
- } catch (Throwable t) {
- assertTrue(false);
- }
- }
-
- /**
- * A test to make sure that all the threads in the runtime have a name and priority.
- *
- * This exists to prove that we can get the name and priority even in cases where the threads are subclasses of java/lang/Thread
- */
- public void testAllThreadsNamed()
- {
- Iterator threads = defaultJavaRuntime().getThreads().iterator();
-
- while (threads.hasNext()) {
- JavaThread thread = (JavaThread) threads.next();
-
- try {
- assertNotNull(thread.getName());
- thread.getPriority();
- } catch (CorruptDataException e) {
- 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.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.runtime.java.JavaThread;
+
+
+public class JavaThreadTest extends AbstractImageTestcase
+{
+ private JavaThread _thread = null;
+ private JavaThread _sameThread = null;
+
+ protected void setUp() throws Exception
+ {
+ _thread = defaultJavaThread();
+ _sameThread= defaultJavaThread();
+ assertNotNull(_thread);
+ super.setUp();
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getJNIEnv()'
+ *
+ * Ensures that the JNIEnv is non-null
+ */
+ public void testGetJNIEnv()
+ {
+ try {
+ assertNotNull(_thread.getJNIEnv());
+ } catch (CorruptDataException e) {
+ //this is acceptable by the spec
+ }
+ }
+
+ /*
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getPriority()'
+ */
+ public void testGetPriority()
+ {
+ try {
+ int priority = _thread.getPriority();
+ assertTrue((priority >= 1) && (priority <= 10));
+ } catch (CorruptDataException e) {
+ //this is acceptable by the spec
+ }
+ }
+
+ /*
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getObject()'
+ */
+ public void testGetObject()
+ {
+ //anything returned here is legal. In fact, even null is ok
+ try {
+ _thread.getObject();
+ } catch (CorruptDataException e) {
+ //this is acceptable by the spec
+ }
+ }
+
+ /*
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getState()'
+ */
+ public void testGetState()
+ {
+ try {
+ assertTrue(_thread.getState() > 0);
+ } catch (CorruptDataException e) {
+ //this is acceptable by the spec
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getImageThread()'
+ *
+ * Ensures that a non-null image thread can be pulled from this thread
+ */
+ public void testGetImageThread()
+ {
+ try {
+ assertNotNull(_thread.getImageThread());
+ } catch (CorruptDataException e) {
+ //this is acceptable by the spec
+ } catch (DataUnavailable e) {
+ //this is acceptable by the spec
+ }
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getStackSections()'
+ *
+ * Ensures that a non-null, non-empty iterator is returned
+ */
+ public void testGetStackSections()
+ {
+ Iterator it = _thread.getStackSections().iterator();
+ assertNotNull(it);
+ assertTrue(it.hasNext());
+ }
+
+ /**
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getStackFrames()'
+ *
+ * Ensures that the frame iterator is non-null even though it may be empty
+ */
+ public void testGetStackFrames()
+ {
+ Iterator frames = _thread.getStackFrames().iterator();
+ assertNotNull(frames);
+ //it is legal for there to be no frames
+ }
+
+ /*
+ * Test method for 'javax.tools.diagnostics.runtime.java.JavaThread.getName()'
+ */
+ public void testGetName()
+ {
+ try {
+ assertNotNull(_thread.getName());
+ } catch (CorruptDataException e) {
+ //this is acceptable by the spec
+ }
+ }
+
+ /**
+ * Verify that the equals call doesn't throw
+ */
+ public void testEquals()
+ {
+ try{
+ assertTrue(_thread.equals(_thread));
+ assertTrue(_thread.equals(_sameThread));
+ } 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 != _thread.hashCode());
+ assertTrue(_thread.hashCode() == _sameThread.hashCode());
+ } catch (Throwable t) {
+ assertTrue(false);
+ }
+ }
+
+ /**
+ * A test to make sure that all the threads in the runtime have a name and priority.
+ *
+ * This exists to prove that we can get the name and priority even in cases where the threads are subclasses of java/lang/Thread
+ */
+ public void testAllThreadsNamed()
+ {
+ Iterator threads = defaultJavaRuntime().getThreads().iterator();
+
+ while (threads.hasNext()) {
+ JavaThread thread = (JavaThread) threads.next();
+
+ try {
+ assertNotNull(thread.getName());
+ thread.getPriority();
+ } catch (CorruptDataException e) {
+ assertTrue(false);
+ }
+ }
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/JavaThreadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestManifestProperties.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestManifestProperties.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/TestManifestProperties.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestManifestProperties.java Mon Nov 23 15:53:48 2009
@@ -1,216 +1,216 @@
-/*******************************************************************************
- * 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.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import javax.tools.diagnostics.image.ImageFactory;
-
-import junit.framework.TestCase;
-
-
-public class TestManifestProperties extends TestCase {
-
-
- private static final String ORG_APACHE_KATO_IMAGE = "org/apache/kato/image/";
- private static final String MANIFEST_ROUTE = "/META-INF/MANIFEST.MF";
- private static String resource="/"+ImageFactory.class.getName().replace('.', '/')+".class";
- private URL getKnownResourceURL() {
- URL knownResourceURL=ImageFactory.class.getResource(resource);
- return knownResourceURL;
- }
-
-
- private Manifest getManifest() throws IOException {
- InputStream in=openManifestStream();
- Manifest m=new Manifest(in);
- in.close();
- return m;
- }
-
- /**
- * Locates the manifest for . This manifest may either
- * be local to the source code (in on the filesystem) on within
- * the jar
- *
- * @return manifest inputstream or null
- * @throws IOException
- */
-
- private InputStream openManifestStream() throws IOException {
-
-
- URL knownResourceURL = getKnownResourceURL();
- String u=knownResourceURL.toExternalForm();
-
- String protocol=knownResourceURL.getProtocol();
- String manifestLocation=null;
-
- if(protocol.equals("file")) {
- manifestLocation=u.substring(0,u.length()-resource.length())+"/.."+MANIFEST_ROUTE;
- }
- else {
- manifestLocation=u.substring(0,u.length()-resource.length())+MANIFEST_ROUTE;
- }
- // create expected manifest location...
-
-
- URL u2=new URL(manifestLocation);
- InputStream manifestStream=u2.openStream();
- return manifestStream;
- }
-
- public void testHasAValidManifestStructure() throws IOException {
-
- InputStream in=openManifestStream();
- Manifest m=new Manifest(in);
- in.close();
-
- }
- public void testHasAManifest() throws IOException {
-
- InputStream manifestStream = openManifestStream();
- assertNotNull(manifestStream);
- manifestStream.close();
-
-
-}
- public void testHasBundleVendor() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs=m.getMainAttributes();
- Object value=attrs.getValue("Bundle-Vendor");
- assertEquals("Bundle Vendor is incorrect","Apache",value.toString());
-
-
- }
- public void testHasBundleVersion() throws IOException {
-
- InputStream in=openManifestStream();
- Manifest m=new Manifest(in);
- Attributes attrs=m.getMainAttributes();
- in.close();
- Object value=attrs.getValue("Bundle-Version");
- assertEquals("Bundle Version is incorrect","1.3.0.qualifier",value.toString());
-
-
- }
- public void testHasAPINameSection() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
-
- assertNotNull("missing API Name section ["+ORG_APACHE_KATO_IMAGE+"] in manifest",attrs);
-
- }
-public void testHasImplementationTitle() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Implementation-Title");
- assertNotNull("Implementation-Title is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
-
-}
-
-
-public void testHasImplementationVendor() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Implementation-Vendor");
- assertNotNull("Implementation-Vendor is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
-
-}
-
-public void testHasImplementationVersion() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Implementation-Version");
- assertNotNull("Implementation-Version is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
-
-}
-
-public void testHasSpecificationTitle() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Specification-Title");
- assertNotNull("Specification-Title is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
-
-}
-public void testHasSpecificationVendor() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Specification-Vendor");
- assertNotNull("Specification-Vendor is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
-
-}
-public void testHasSpecificationVersion() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Specification-Version");
- assertNotNull("Specification-Version is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
-
- }
-public void testHasValidSpecificationVendor() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Specification-Vendor");
- assertEquals("Specification-Vendor is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest","Apache",value.toString());
-
-}
-public void testHasValidSpecificationVersion() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Specification-Version");
- assertEquals("Specification-Version is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest","1.3",value.toString());
-
-}
-public void testHasValidSpecificationTitle() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Specification-Title");
- assertEquals("Specification-Title is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest","Diagnostic Tool Framework for Java",value.toString());
-
-}
-public void testHasValidImplementationVendor() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Implementation-Vendor");
- assertEquals("Implementation-Vendor is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest","Apache",value.toString());
-
-}
-
-public void testHasValidImplementationVersion() throws IOException {
-
- Manifest m = getManifest();
- Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
- Object value=attrs.getValue("Implementation-Version");
- int buildNo=Integer.parseInt(value.toString());
- assertTrue("Implementation Version is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",buildNo>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.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import javax.tools.diagnostics.image.ImageFactory;
+
+import junit.framework.TestCase;
+
+
+public class TestManifestProperties extends TestCase {
+
+
+ private static final String ORG_APACHE_KATO_IMAGE = "org/apache/kato/image/";
+ private static final String MANIFEST_ROUTE = "/META-INF/MANIFEST.MF";
+ private static String resource="/"+ImageFactory.class.getName().replace('.', '/')+".class";
+ private URL getKnownResourceURL() {
+ URL knownResourceURL=ImageFactory.class.getResource(resource);
+ return knownResourceURL;
+ }
+
+
+ private Manifest getManifest() throws IOException {
+ InputStream in=openManifestStream();
+ Manifest m=new Manifest(in);
+ in.close();
+ return m;
+ }
+
+ /**
+ * Locates the manifest for . This manifest may either
+ * be local to the source code (in on the filesystem) on within
+ * the jar
+ *
+ * @return manifest inputstream or null
+ * @throws IOException
+ */
+
+ private InputStream openManifestStream() throws IOException {
+
+
+ URL knownResourceURL = getKnownResourceURL();
+ String u=knownResourceURL.toExternalForm();
+
+ String protocol=knownResourceURL.getProtocol();
+ String manifestLocation=null;
+
+ if(protocol.equals("file")) {
+ manifestLocation=u.substring(0,u.length()-resource.length())+"/.."+MANIFEST_ROUTE;
+ }
+ else {
+ manifestLocation=u.substring(0,u.length()-resource.length())+MANIFEST_ROUTE;
+ }
+ // create expected manifest location...
+
+
+ URL u2=new URL(manifestLocation);
+ InputStream manifestStream=u2.openStream();
+ return manifestStream;
+ }
+
+ public void testHasAValidManifestStructure() throws IOException {
+
+ InputStream in=openManifestStream();
+ Manifest m=new Manifest(in);
+ in.close();
+
+ }
+ public void testHasAManifest() throws IOException {
+
+ InputStream manifestStream = openManifestStream();
+ assertNotNull(manifestStream);
+ manifestStream.close();
+
+
+}
+ public void testHasBundleVendor() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs=m.getMainAttributes();
+ Object value=attrs.getValue("Bundle-Vendor");
+ assertEquals("Bundle Vendor is incorrect","Apache",value.toString());
+
+
+ }
+ public void testHasBundleVersion() throws IOException {
+
+ InputStream in=openManifestStream();
+ Manifest m=new Manifest(in);
+ Attributes attrs=m.getMainAttributes();
+ in.close();
+ Object value=attrs.getValue("Bundle-Version");
+ assertEquals("Bundle Version is incorrect","1.3.0.qualifier",value.toString());
+
+
+ }
+ public void testHasAPINameSection() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+
+ assertNotNull("missing API Name section ["+ORG_APACHE_KATO_IMAGE+"] in manifest",attrs);
+
+ }
+public void testHasImplementationTitle() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Implementation-Title");
+ assertNotNull("Implementation-Title is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
+
+}
+
+
+public void testHasImplementationVendor() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Implementation-Vendor");
+ assertNotNull("Implementation-Vendor is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
+
+}
+
+public void testHasImplementationVersion() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Implementation-Version");
+ assertNotNull("Implementation-Version is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
+
+}
+
+public void testHasSpecificationTitle() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Specification-Title");
+ assertNotNull("Specification-Title is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
+
+}
+public void testHasSpecificationVendor() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Specification-Vendor");
+ assertNotNull("Specification-Vendor is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
+
+}
+public void testHasSpecificationVersion() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Specification-Version");
+ assertNotNull("Specification-Version is missing in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",value);
+
+ }
+public void testHasValidSpecificationVendor() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Specification-Vendor");
+ assertEquals("Specification-Vendor is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest","Apache",value.toString());
+
+}
+public void testHasValidSpecificationVersion() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Specification-Version");
+ assertEquals("Specification-Version is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest","1.3",value.toString());
+
+}
+public void testHasValidSpecificationTitle() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Specification-Title");
+ assertEquals("Specification-Title is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest","Diagnostic Tool Framework for Java",value.toString());
+
+}
+public void testHasValidImplementationVendor() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Implementation-Vendor");
+ assertEquals("Implementation-Vendor is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest","Apache",value.toString());
+
+}
+
+public void testHasValidImplementationVersion() throws IOException {
+
+ Manifest m = getManifest();
+ Attributes attrs =m.getAttributes(ORG_APACHE_KATO_IMAGE);
+ Object value=attrs.getValue("Implementation-Version");
+ int buildNo=Integer.parseInt(value.toString());
+ assertTrue("Implementation Version is incorrect in ["+ORG_APACHE_KATO_IMAGE+"] section of manifest",buildNo>0);
+
+}
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestManifestProperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestNotImplementedException.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestNotImplementedException.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/TestNotImplementedException.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestNotImplementedException.java Mon Nov 23 15:53:48 2009
@@ -1,30 +1,30 @@
-/*******************************************************************************
- * 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;
-
-/**
- * This class exists solely so that JUnit tests which are incomplete because of a lack of underlying
- * implementation do not pass by inaction.
- * It will be safe to remove this once there are no more creation points
- */
-public class TestNotImplementedException extends RuntimeException
-{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-}
+/*******************************************************************************
+ * 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;
+
+/**
+ * This class exists solely so that JUnit tests which are incomplete because of a lack of underlying
+ * implementation do not pass by inaction.
+ * It will be safe to remove this once there are no more creation points
+ */
+public class TestNotImplementedException extends RuntimeException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestNotImplementedException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestPackageInformation.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestPackageInformation.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/TestPackageInformation.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestPackageInformation.java Mon Nov 23 15:53:48 2009
@@ -1,71 +1,71 @@
-/*******************************************************************************
- * 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.ImageFactory;
-
-import junit.framework.TestCase;
-
-
-/**
- * Simple tests to show that the manifest entries that describe the
- * implementation and specification for DTFJ have made their way
- * into the relevant Package instance.
- *
- *
- */
-public class TestPackageInformation extends TestCase {
-
- /**
- * Test that the specification title is what is expected
- */
-
- public void testSpecificationTitle() {
-
- Package p = ImageFactory.class.getPackage();
- assertEquals("Diagnostic Tool Framework for Java", p
- .getSpecificationTitle());
- }
-
- /**
- * Test that the specification version matches
- */
- public void testSpecificationVersion() {
-
- String versionString=ImageFactory.MAJOR_VERSION+"."+ImageFactory.MINOR_VERSION;
- Package p = ImageFactory.class.getPackage();
- assertEquals(versionString, p.getSpecificationVersion());
- }
-
-
- /**
- * Test Implementation version is present
- */
-
- public void testImplementationVersion() {
-
- Package p = ImageFactory.class.getPackage();
- assertNotNull(p.getImplementationVersion());
- }
-
- /**
- * Test implementation title is present
- */
- public void testImplementationTitle() {
- Package p = ImageFactory.class.getPackage();
- assertNotNull(p.getImplementationTitle());
-
- }
-
-}
+/*******************************************************************************
+ * 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.ImageFactory;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Simple tests to show that the manifest entries that describe the
+ * implementation and specification for DTFJ have made their way
+ * into the relevant Package instance.
+ *
+ *
+ */
+public class TestPackageInformation extends TestCase {
+
+ /**
+ * Test that the specification title is what is expected
+ */
+
+ public void testSpecificationTitle() {
+
+ Package p = ImageFactory.class.getPackage();
+ assertEquals("Diagnostic Tool Framework for Java", p
+ .getSpecificationTitle());
+ }
+
+ /**
+ * Test that the specification version matches
+ */
+ public void testSpecificationVersion() {
+
+ String versionString=ImageFactory.MAJOR_VERSION+"."+ImageFactory.MINOR_VERSION;
+ Package p = ImageFactory.class.getPackage();
+ assertEquals(versionString, p.getSpecificationVersion());
+ }
+
+
+ /**
+ * Test Implementation version is present
+ */
+
+ public void testImplementationVersion() {
+
+ Package p = ImageFactory.class.getPackage();
+ assertNotNull(p.getImplementationVersion());
+ }
+
+ /**
+ * Test implementation title is present
+ */
+ public void testImplementationTitle() {
+ Package p = ImageFactory.class.getPackage();
+ assertNotNull(p.getImplementationTitle());
+
+ }
+
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/junit/TestPackageInformation.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/scenarios/ArrayletTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/scenarios/ArrayletTest.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/scenarios/ArrayletTest.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/scenarios/ArrayletTest.java Mon Nov 23 15:53:48 2009
@@ -1,68 +1,68 @@
-/*******************************************************************************
- * 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.scenarios;
-
-public class ArrayletTest {
- public static volatile Thread a, b;
- private static final int DTFJ_ARRAYLET_LENGTH = 7000;
- private static ArrayletTestInstance DTFJ_ARRAYLET_TEST_INSTANCE = new ArrayletTestInstance(DTFJ_ARRAYLET_LENGTH);;
-
-// public static void main(String[] args) throws InterruptedException {
-// //create the arraylet test instance so that the DTFJ test can read it to verify that RT VMs work
-// if (null != DTFJ_ARRAYLET_TEST_INSTANCE) {
-// System.err.println("This null check is only here to make a compiler warning go away. "
-// + "If we actually print out this message, it means that the class's main ran twice (which can't happen)");
-// }
-// DTFJ_ARRAYLET_TEST_INSTANCE = new ArrayletTestInstance(DTFJ_ARRAYLET_LENGTH);
-// //now, on with the actual test
-// a = new Thread() {
-// public void run() {
-// synchronized (a) {
-// try {
-// Thread.sleep(1000);
-// } catch (InterruptedException e) {
-// }
-// synchronized(b) {
-// System.out.println("Deadlock avoided?");
-// }
-// }
-// }
-// };
-//
-// b = new Thread() {
-// public void run() {
-// synchronized (b) {
-// try {
-// Thread.sleep(1000);
-// } catch (InterruptedException e) {
-// }
-// synchronized(a) {
-// System.out.println("Deadlock avoided?");
-// }
-// }
-// }
-// };
-//
-// a.start();
-// b.start();
-//
-// Thread.sleep(2000);
-//
-// new GPTest().gpWrite();
-//
-// // should be unreachable
-// System.err.println("gpWrite failed to stop program. Exiting.");
-// System.exit(-1);
-// }
-}
+/*******************************************************************************
+ * 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.scenarios;
+
+public class ArrayletTest {
+ public static volatile Thread a, b;
+ private static final int DTFJ_ARRAYLET_LENGTH = 7000;
+ private static ArrayletTestInstance DTFJ_ARRAYLET_TEST_INSTANCE = new ArrayletTestInstance(DTFJ_ARRAYLET_LENGTH);;
+
+// public static void main(String[] args) throws InterruptedException {
+// //create the arraylet test instance so that the DTFJ test can read it to verify that RT VMs work
+// if (null != DTFJ_ARRAYLET_TEST_INSTANCE) {
+// System.err.println("This null check is only here to make a compiler warning go away. "
+// + "If we actually print out this message, it means that the class's main ran twice (which can't happen)");
+// }
+// DTFJ_ARRAYLET_TEST_INSTANCE = new ArrayletTestInstance(DTFJ_ARRAYLET_LENGTH);
+// //now, on with the actual test
+// a = new Thread() {
+// public void run() {
+// synchronized (a) {
+// try {
+// Thread.sleep(1000);
+// } catch (InterruptedException e) {
+// }
+// synchronized(b) {
+// System.out.println("Deadlock avoided?");
+// }
+// }
+// }
+// };
+//
+// b = new Thread() {
+// public void run() {
+// synchronized (b) {
+// try {
+// Thread.sleep(1000);
+// } catch (InterruptedException e) {
+// }
+// synchronized(a) {
+// System.out.println("Deadlock avoided?");
+// }
+// }
+// }
+// };
+//
+// a.start();
+// b.start();
+//
+// Thread.sleep(2000);
+//
+// new GPTest().gpWrite();
+//
+// // should be unreachable
+// System.err.println("gpWrite failed to stop program. Exiting.");
+// System.exit(-1);
+// }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/scenarios/ArrayletTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/scenarios/ArrayletTestInstance.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/scenarios/ArrayletTestInstance.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/scenarios/ArrayletTestInstance.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/scenarios/ArrayletTestInstance.java Mon Nov 23 15:53:48 2009
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * 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.scenarios;
-
-public class ArrayletTestInstance
-{
- private int[] DTFJ_ARRAYLET_INTS;
- private byte[] DTFJ_ARRAYLET_BYTES;
- private StringContainer[] DTFJ_ARRAYLET_STRINGCONTAINER;
-
- public ArrayletTestInstance(int length)
- {
- DTFJ_ARRAYLET_INTS = new int[length];
- DTFJ_ARRAYLET_BYTES = new byte[length];
- DTFJ_ARRAYLET_STRINGCONTAINER = new StringContainer[length];
-
- for (int i = 0; i < length; i++)
- {
- int value = length - i;
- DTFJ_ARRAYLET_INTS[i] = value;
- DTFJ_ARRAYLET_BYTES[i] = (byte)value;
- DTFJ_ARRAYLET_STRINGCONTAINER[i] = new StringContainer(value);
- }
- }
-
- private class StringContainer
- {
- private String _stringField;
-
- public StringContainer(int value)
- {
- _stringField = Integer.toString(value);
- }
-
- public String toString()
- {
- return _stringField;
- }
- }
-}
+/*******************************************************************************
+ * 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.scenarios;
+
+public class ArrayletTestInstance
+{
+ private int[] DTFJ_ARRAYLET_INTS;
+ private byte[] DTFJ_ARRAYLET_BYTES;
+ private StringContainer[] DTFJ_ARRAYLET_STRINGCONTAINER;
+
+ public ArrayletTestInstance(int length)
+ {
+ DTFJ_ARRAYLET_INTS = new int[length];
+ DTFJ_ARRAYLET_BYTES = new byte[length];
+ DTFJ_ARRAYLET_STRINGCONTAINER = new StringContainer[length];
+
+ for (int i = 0; i < length; i++)
+ {
+ int value = length - i;
+ DTFJ_ARRAYLET_INTS[i] = value;
+ DTFJ_ARRAYLET_BYTES[i] = (byte)value;
+ DTFJ_ARRAYLET_STRINGCONTAINER[i] = new StringContainer(value);
+ }
+ }
+
+ private class StringContainer
+ {
+ private String _stringField;
+
+ public StringContainer(int value)
+ {
+ _stringField = Integer.toString(value);
+ }
+
+ public String toString()
+ {
+ return _stringField;
+ }
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tck.testsuite/src/main/java/org/apache/kato/tests/scenarios/ArrayletTestInstance.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/ConsoleOutputChannel.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/ConsoleOutputChannel.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/ConsoleOutputChannel.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/ConsoleOutputChannel.java Mon Nov 23 15:53:48 2009
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * 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.katoview;
-
-public class ConsoleOutputChannel implements OutputChannel {
-
- private boolean noPrint = false;
-
- public void print(String outputString) {
- if (!noPrint)
- System.out.print(outputString);
- }
-
- public void printPrompt(String prompt) {
- System.out.print(prompt);
- }
-
- public void println(String outputString) {
- if (!noPrint)
- System.out.println(outputString);
- }
-
- public void error(String outputString) {
- System.err.print("\n");
- System.err.print("\tERROR: " + outputString + "\n");
- }
-
- public void printInput(long timestamp, String prompt, String outputString) {
- // we don't need to output anything, but we could output the time the command was started
- //System.out.println("<started at: " + (new Date(timestamp)).toString() + ">");
- }
-
- public void close() {
- // do nothing, because we don't need to close System.out or System.err
- }
-
- public void setNoPrint(boolean b) {
- noPrint = b;
- }
-}
+/*******************************************************************************
+ * 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.katoview;
+
+public class ConsoleOutputChannel implements OutputChannel {
+
+ private boolean noPrint = false;
+
+ public void print(String outputString) {
+ if (!noPrint)
+ System.out.print(outputString);
+ }
+
+ public void printPrompt(String prompt) {
+ System.out.print(prompt);
+ }
+
+ public void println(String outputString) {
+ if (!noPrint)
+ System.out.println(outputString);
+ }
+
+ public void error(String outputString) {
+ System.err.print("\n");
+ System.err.print("\tERROR: " + outputString + "\n");
+ }
+
+ public void printInput(long timestamp, String prompt, String outputString) {
+ // we don't need to output anything, but we could output the time the command was started
+ //System.out.println("<started at: " + (new Date(timestamp)).toString() + ">");
+ }
+
+ public void close() {
+ // do nothing, because we don't need to close System.out or System.err
+ }
+
+ public void setNoPrint(boolean b) {
+ noPrint = b;
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/ConsoleOutputChannel.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/FileOutputChannel.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/FileOutputChannel.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/FileOutputChannel.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/FileOutputChannel.java Mon Nov 23 15:53:48 2009
@@ -1,79 +1,79 @@
-/*******************************************************************************
- * 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.katoview;
-
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Date;
-
-import org.apache.kato.katoview.commands.helpers.Utils;
-
-
-public class FileOutputChannel implements OutputChannel {
-
- private FileWriter fw;
-
- // f must not be null
- public FileOutputChannel(FileWriter f)
- {
- fw = f;
- }
-
- public void print(String outputString) {
- try {
- fw.write(Utils.toString(outputString));
- } catch (IOException e) {
-
- }
- }
-
- public void printPrompt(String prompt) {
- // do nothing; we'll output the prompt when we get a printInput() call
- }
-
- public void println(String outputString) {
- try {
- fw.write(Utils.toString(outputString) + "\n");
- } catch (IOException e) {
-
- }
- }
-
- public void error(String outputString) {
- try {
- fw.write("\n");
- fw.write("\tERROR: " + Utils.toString(outputString) + "\n");
- fw.write("\n");
- } catch (IOException e) {
-
- }
- }
-
- public void printInput(long timestamp, String prompt, String outputString) {
- try {
- fw.write((new Date(timestamp)).toString() + " " +
- prompt + Utils.toString(outputString) + "\n");
- } catch (IOException e) {
-
- }
- }
-
- public void close() {
- try {
- fw.close();
- } catch (IOException e) {
-
- }
- }
-}
+/*******************************************************************************
+ * 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.katoview;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Date;
+
+import org.apache.kato.katoview.commands.helpers.Utils;
+
+
+public class FileOutputChannel implements OutputChannel {
+
+ private FileWriter fw;
+
+ // f must not be null
+ public FileOutputChannel(FileWriter f)
+ {
+ fw = f;
+ }
+
+ public void print(String outputString) {
+ try {
+ fw.write(Utils.toString(outputString));
+ } catch (IOException e) {
+
+ }
+ }
+
+ public void printPrompt(String prompt) {
+ // do nothing; we'll output the prompt when we get a printInput() call
+ }
+
+ public void println(String outputString) {
+ try {
+ fw.write(Utils.toString(outputString) + "\n");
+ } catch (IOException e) {
+
+ }
+ }
+
+ public void error(String outputString) {
+ try {
+ fw.write("\n");
+ fw.write("\tERROR: " + Utils.toString(outputString) + "\n");
+ fw.write("\n");
+ } catch (IOException e) {
+
+ }
+ }
+
+ public void printInput(long timestamp, String prompt, String outputString) {
+ try {
+ fw.write((new Date(timestamp)).toString() + " " +
+ prompt + Utils.toString(outputString) + "\n");
+ } catch (IOException e) {
+
+ }
+ }
+
+ public void close() {
+ try {
+ fw.close();
+ } catch (IOException e) {
+
+ }
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/FileOutputChannel.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/KatoView.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/KatoView.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/KatoView.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/KatoView.java Mon Nov 23 15:53:48 2009
@@ -1,36 +1,36 @@
-/*******************************************************************************
- * 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.katoview;
-
-import javax.tools.diagnostics.FactoryRegistry;
-
-
-public class KatoView {
-
- private Session session;
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- FactoryRegistry.getDefaultRegistry().addFactory(new org.apache.kato.hprof.image.ImageFactoryImpl());
- FactoryRegistry.getDefaultRegistry().addFactory(new org.apache.kato.jvmti.process.ImageFactoryImpl());
- KatoView katoView = new KatoView();
- katoView.session = new Session(args);
-
- katoView.session.run();
-
-
- }
-}
+/*******************************************************************************
+ * 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.katoview;
+
+import javax.tools.diagnostics.FactoryRegistry;
+
+
+public class KatoView {
+
+ private Session session;
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ FactoryRegistry.getDefaultRegistry().addFactory(new org.apache.kato.hprof.image.ImageFactoryImpl());
+ FactoryRegistry.getDefaultRegistry().addFactory(new org.apache.kato.jvmti.process.ImageFactoryImpl());
+ KatoView katoView = new KatoView();
+ katoView.session = new Session(args);
+
+ katoView.session.run();
+
+
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/KatoView.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Output.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Output.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Output.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Output.java Mon Nov 23 15:53:48 2009
@@ -1,97 +1,97 @@
-/*******************************************************************************
- * 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.katoview;
-
-import java.util.Vector;
-
-public class Output {
-
- Vector outputChannels;
- long lastTimestamp = 0;
- String lastPrompt = "";
- String lastInput = "";
-
- public Output(){
- outputChannels = new Vector();
- }
-
- public void print(String outputString){
- for (int i = 0; i < outputChannels.size(); i++){
- ((OutputChannel)outputChannels.elementAt(i)).print(outputString);
- }
- }
-
- public void printPrompt(String prompt){
- for (int i = 0; i < outputChannels.size(); i++){
- ((OutputChannel)outputChannels.elementAt(i)).printPrompt(prompt);
- }
- }
-
- public void println(String outputString){
- for (int i = 0; i < outputChannels.size(); i++){
- ((OutputChannel)outputChannels.elementAt(i)).println(outputString);
- }
- }
-
- public void error(String outputString){
- for (int i = 0; i < outputChannels.size(); i++){
- ((OutputChannel)outputChannels.elementAt(i)).error(outputString);
- }
- }
-
- public void printInput(long timestamp, String prompt, String outputString){
- for (int i = 0; i < outputChannels.size(); i++){
- ((OutputChannel)outputChannels.elementAt(i)).
- printInput(timestamp, prompt, outputString);
- }
- lastTimestamp = timestamp;
- lastPrompt = prompt;
- lastInput = outputString;
- }
-
- public void addChannel(OutputChannel channel){
- addChannel(channel, false);
- }
-
- public void addChannel(OutputChannel channel, boolean printLastInput){
- outputChannels.add(channel);
- if (printLastInput)
- channel.printInput(lastTimestamp, lastPrompt, lastInput);
- }
-
- public void removeFileChannel(){
- for (int i = 0; i < outputChannels.size(); i++){
- if ((OutputChannel)outputChannels.elementAt(i) instanceof FileOutputChannel)
- {
- ((OutputChannel)outputChannels.elementAt(i)).close();
- outputChannels.removeElementAt(i);
- }
- }
- }
-
- public void setConsoleNoPrint(boolean noPrint){
- for (int i = 0; i < outputChannels.size(); i++){
- if ((OutputChannel)outputChannels.elementAt(i) instanceof ConsoleOutputChannel)
- {
- ((ConsoleOutputChannel)outputChannels.elementAt(i)).setNoPrint(noPrint);
- }
- }
- }
-
- public void close() {
- for (int i = 0; i < outputChannels.size(); i++){
- ((OutputChannel)outputChannels.elementAt(i)).close();
- }
- }
-}
+/*******************************************************************************
+ * 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.katoview;
+
+import java.util.Vector;
+
+public class Output {
+
+ Vector outputChannels;
+ long lastTimestamp = 0;
+ String lastPrompt = "";
+ String lastInput = "";
+
+ public Output(){
+ outputChannels = new Vector();
+ }
+
+ public void print(String outputString){
+ for (int i = 0; i < outputChannels.size(); i++){
+ ((OutputChannel)outputChannels.elementAt(i)).print(outputString);
+ }
+ }
+
+ public void printPrompt(String prompt){
+ for (int i = 0; i < outputChannels.size(); i++){
+ ((OutputChannel)outputChannels.elementAt(i)).printPrompt(prompt);
+ }
+ }
+
+ public void println(String outputString){
+ for (int i = 0; i < outputChannels.size(); i++){
+ ((OutputChannel)outputChannels.elementAt(i)).println(outputString);
+ }
+ }
+
+ public void error(String outputString){
+ for (int i = 0; i < outputChannels.size(); i++){
+ ((OutputChannel)outputChannels.elementAt(i)).error(outputString);
+ }
+ }
+
+ public void printInput(long timestamp, String prompt, String outputString){
+ for (int i = 0; i < outputChannels.size(); i++){
+ ((OutputChannel)outputChannels.elementAt(i)).
+ printInput(timestamp, prompt, outputString);
+ }
+ lastTimestamp = timestamp;
+ lastPrompt = prompt;
+ lastInput = outputString;
+ }
+
+ public void addChannel(OutputChannel channel){
+ addChannel(channel, false);
+ }
+
+ public void addChannel(OutputChannel channel, boolean printLastInput){
+ outputChannels.add(channel);
+ if (printLastInput)
+ channel.printInput(lastTimestamp, lastPrompt, lastInput);
+ }
+
+ public void removeFileChannel(){
+ for (int i = 0; i < outputChannels.size(); i++){
+ if ((OutputChannel)outputChannels.elementAt(i) instanceof FileOutputChannel)
+ {
+ ((OutputChannel)outputChannels.elementAt(i)).close();
+ outputChannels.removeElementAt(i);
+ }
+ }
+ }
+
+ public void setConsoleNoPrint(boolean noPrint){
+ for (int i = 0; i < outputChannels.size(); i++){
+ if ((OutputChannel)outputChannels.elementAt(i) instanceof ConsoleOutputChannel)
+ {
+ ((ConsoleOutputChannel)outputChannels.elementAt(i)).setNoPrint(noPrint);
+ }
+ }
+ }
+
+ public void close() {
+ for (int i = 0; i < outputChannels.size(); i++){
+ ((OutputChannel)outputChannels.elementAt(i)).close();
+ }
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Output.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/OutputChannel.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/OutputChannel.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/OutputChannel.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/OutputChannel.java Mon Nov 23 15:53:48 2009
@@ -1,24 +1,24 @@
-/*******************************************************************************
- * 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.katoview;
-
-public interface OutputChannel {
-
- public void print(String outputString);
- public void printPrompt(String prompt);
- public void println(String outputString);
- public void error(String outputString);
- public void printInput(long timestamp, String prompt, String outputString);
- public void close();
-}
+/*******************************************************************************
+ * 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.katoview;
+
+public interface OutputChannel {
+
+ public void print(String outputString);
+ public void printPrompt(String prompt);
+ public void println(String outputString);
+ public void error(String outputString);
+ public void printInput(long timestamp, String prompt, String outputString);
+ public void close();
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/OutputChannel.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Session.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Session.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Session.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Session.java Mon Nov 23 15:53:48 2009
@@ -1,191 +1,191 @@
-/*******************************************************************************
- * 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.katoview;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.Stack;
-
-import javax.tools.diagnostics.FactoryRegistry;
-import javax.tools.diagnostics.image.Image;
-import javax.tools.diagnostics.image.ImageAddressSpace;
-import javax.tools.diagnostics.image.ImageFactory;
-
-import org.apache.kato.katoview.commands.RootCommand;
-import org.apache.kato.katoview.commands.helpers.Utils;
-
-
-public class Session {
-
- public static final String DUMP_FILE_PATH_PROPERTY = "dump_file_path";
- private Image loadedImage;
- private RootCommand rootCommand;
- private HashMap variables;
- private Output out;
-
- private static final String defaultFactoryName = ""; //TODO: assign proper factory class name
- private static final String factoryProperty = "javax.tools.diagnostics.image.factoryclass";
- private static final String launcherProperty = "javax.tools.diagnostics.tools.katoview.launcher";
-
- public Session(String[] args) {
- sessionInit(args);
- }
-
- private void sessionInit(String[] args){
- variables = new HashMap();
- out = new Output();
-
- out.addChannel(new ConsoleOutputChannel());
-
- rootCommand = new RootCommand(out);
- /*add the root_command object to HashMap so that
- commands such as + and - can access it to invoke hexdump command*/
- variables.put(Utils.RootCommand_OBJECT, rootCommand);
- variables.put("pwd", new File(System.getProperty("user.dir")));
-
- loadedImage = imageFromCommandLine(args);
- }
-
- /**
- * @param args
- */
- private Image imageFromCommandLine(String args[]) {
- Image loadedImage = null;
- int dumpFilePathIndex = indexOf("-dump", args)+1;
- int verboseIndex = indexOf("-verbose", args)+1;
-
- if (0 != verboseIndex) {
- variables.put("verbose.mode", "on");
- }
-
- String launcher = System.getProperty(launcherProperty, "katoview");
-
- // User must specify -core as parameter, and a dump filename following
- if (((0 == dumpFilePathIndex) && (args.length <= dumpFilePathIndex))) {
- out.println(
- "\n\tUsage: \"" + launcher + " [ -verbose ] -dump <dump_file>");
- return null;
- }
-
-// out.println(Version.getAllVersionInfo(factory));
- out.println("Loading dump from Kato...\n");
-
- try {
- String coreFilePath = args[dumpFilePathIndex];
- loadedImage = FactoryRegistry.getDefaultRegistry().getImage(new File(coreFilePath));
-
- if (loadedImage == null) {
- throw new IOException("No ImageFactory could load "+coreFilePath);
- }
-
- //Store the core file file path in the variables. We need it for creating default filenames for heapdumps
- variables.put(DUMP_FILE_PATH_PROPERTY, coreFilePath);
- } catch (IOException e) {
- out.error("Could not load dump file: " + e.getMessage());
-
- if (null != variables.get("verbose.mode")) {
- e.printStackTrace();
- }
- }
-
- return loadedImage;
- }
-
- /**
- * @param string, args
- */
- private int indexOf(String string, String[] args) {
- int index = -1;
-
- for (int x = 0; x < args.length; x++) {
- if (string.equals(args[x])) {
- index = x;
- break;
- }
- }
- return index;
- }
-
- public void run(){
- BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
- String input = "";
- String quit = "";
- String prompt = "> ";
- Stack inputWordsStack = new Stack();
-
- if (null == loadedImage)
- return;
-
- // FIXME: In the current code, this is the _only_ place where the current
- // address space is set. Also, the only commands that use this value (at the
- // time of this writing, anyway) are the "x/k" command (XKCommand class) and
- // the "info thread" command. What we would ideally like is some
- // sort of command that sets the current address space based on some sort of
- // identifier (there is currently no identifier; that would have to be built
- // into the Kato API). Also, we would need all commands (at least those that
- // are dependent on accessing memory in an address space) to use this value;
- // currently only "x/k" and "info thread" use this, as stated above. We don't
- // really know if multiple address spaces can actually exist in a given core
- // file, but this capability is put in here just in case they can.
-
- variables.put(
- "current_address_space",
- (ImageAddressSpace)loadedImage.getAddressSpaces().get(0)
- );
-
- out.println("For a list of commands, type \"help\"; " +
- "for how to use \"help\", type \"help help\"");
-
- while (quit == null || !quit.equals("on"))
- {
- out.printPrompt(prompt);
-
- try {
- input = stdin.readLine();
- } catch (IOException e) {
- out.error("IOException encountered while reading input; exiting program...");
- break;
- }
-
- if (null == input)
- {
- out.error("End of input stream has been reached; exiting program...");
- break;
- }
-
- String trimmedInput = input.trim();
- out.printInput(System.currentTimeMillis(), prompt, input);
-
- if (!trimmedInput.equals(""))
- {
- inputWordsStack = Utils.constructStackFromString(trimmedInput);
- try {
- rootCommand.doCommand(inputWordsStack, loadedImage, variables);
- } catch (RuntimeException e) {
- out.error("An error occurred while processing the command: " + e);
- e.printStackTrace();
- }
- quit = (String)variables.get("quit");
- }
- }
-
- // "out" MUST be closed here, otherwise the file deletions in the below
- // code block will not work
- out.close();
-
- }
-}
+/*******************************************************************************
+ * 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.katoview;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Stack;
+
+import javax.tools.diagnostics.FactoryRegistry;
+import javax.tools.diagnostics.image.Image;
+import javax.tools.diagnostics.image.ImageAddressSpace;
+import javax.tools.diagnostics.image.ImageFactory;
+
+import org.apache.kato.katoview.commands.RootCommand;
+import org.apache.kato.katoview.commands.helpers.Utils;
+
+
+public class Session {
+
+ public static final String DUMP_FILE_PATH_PROPERTY = "dump_file_path";
+ private Image loadedImage;
+ private RootCommand rootCommand;
+ private HashMap variables;
+ private Output out;
+
+ private static final String defaultFactoryName = ""; //TODO: assign proper factory class name
+ private static final String factoryProperty = "javax.tools.diagnostics.image.factoryclass";
+ private static final String launcherProperty = "javax.tools.diagnostics.tools.katoview.launcher";
+
+ public Session(String[] args) {
+ sessionInit(args);
+ }
+
+ private void sessionInit(String[] args){
+ variables = new HashMap();
+ out = new Output();
+
+ out.addChannel(new ConsoleOutputChannel());
+
+ rootCommand = new RootCommand(out);
+ /*add the root_command object to HashMap so that
+ commands such as + and - can access it to invoke hexdump command*/
+ variables.put(Utils.RootCommand_OBJECT, rootCommand);
+ variables.put("pwd", new File(System.getProperty("user.dir")));
+
+ loadedImage = imageFromCommandLine(args);
+ }
+
+ /**
+ * @param args
+ */
+ private Image imageFromCommandLine(String args[]) {
+ Image loadedImage = null;
+ int dumpFilePathIndex = indexOf("-dump", args)+1;
+ int verboseIndex = indexOf("-verbose", args)+1;
+
+ if (0 != verboseIndex) {
+ variables.put("verbose.mode", "on");
+ }
+
+ String launcher = System.getProperty(launcherProperty, "katoview");
+
+ // User must specify -core as parameter, and a dump filename following
+ if (((0 == dumpFilePathIndex) && (args.length <= dumpFilePathIndex))) {
+ out.println(
+ "\n\tUsage: \"" + launcher + " [ -verbose ] -dump <dump_file>");
+ return null;
+ }
+
+// out.println(Version.getAllVersionInfo(factory));
+ out.println("Loading dump from Kato...\n");
+
+ try {
+ String coreFilePath = args[dumpFilePathIndex];
+ loadedImage = FactoryRegistry.getDefaultRegistry().getImage(new File(coreFilePath));
+
+ if (loadedImage == null) {
+ throw new IOException("No ImageFactory could load "+coreFilePath);
+ }
+
+ //Store the core file file path in the variables. We need it for creating default filenames for heapdumps
+ variables.put(DUMP_FILE_PATH_PROPERTY, coreFilePath);
+ } catch (IOException e) {
+ out.error("Could not load dump file: " + e.getMessage());
+
+ if (null != variables.get("verbose.mode")) {
+ e.printStackTrace();
+ }
+ }
+
+ return loadedImage;
+ }
+
+ /**
+ * @param string, args
+ */
+ private int indexOf(String string, String[] args) {
+ int index = -1;
+
+ for (int x = 0; x < args.length; x++) {
+ if (string.equals(args[x])) {
+ index = x;
+ break;
+ }
+ }
+ return index;
+ }
+
+ public void run(){
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ String input = "";
+ String quit = "";
+ String prompt = "> ";
+ Stack inputWordsStack = new Stack();
+
+ if (null == loadedImage)
+ return;
+
+ // FIXME: In the current code, this is the _only_ place where the current
+ // address space is set. Also, the only commands that use this value (at the
+ // time of this writing, anyway) are the "x/k" command (XKCommand class) and
+ // the "info thread" command. What we would ideally like is some
+ // sort of command that sets the current address space based on some sort of
+ // identifier (there is currently no identifier; that would have to be built
+ // into the Kato API). Also, we would need all commands (at least those that
+ // are dependent on accessing memory in an address space) to use this value;
+ // currently only "x/k" and "info thread" use this, as stated above. We don't
+ // really know if multiple address spaces can actually exist in a given core
+ // file, but this capability is put in here just in case they can.
+
+ variables.put(
+ "current_address_space",
+ (ImageAddressSpace)loadedImage.getAddressSpaces().get(0)
+ );
+
+ out.println("For a list of commands, type \"help\"; " +
+ "for how to use \"help\", type \"help help\"");
+
+ while (quit == null || !quit.equals("on"))
+ {
+ out.printPrompt(prompt);
+
+ try {
+ input = stdin.readLine();
+ } catch (IOException e) {
+ out.error("IOException encountered while reading input; exiting program...");
+ break;
+ }
+
+ if (null == input)
+ {
+ out.error("End of input stream has been reached; exiting program...");
+ break;
+ }
+
+ String trimmedInput = input.trim();
+ out.printInput(System.currentTimeMillis(), prompt, input);
+
+ if (!trimmedInput.equals(""))
+ {
+ inputWordsStack = Utils.constructStackFromString(trimmedInput);
+ try {
+ rootCommand.doCommand(inputWordsStack, loadedImage, variables);
+ } catch (RuntimeException e) {
+ out.error("An error occurred while processing the command: " + e);
+ e.printStackTrace();
+ }
+ quit = (String)variables.get("quit");
+ }
+ }
+
+ // "out" MUST be closed here, otherwise the file deletions in the below
+ // code block will not work
+ out.close();
+
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Session.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Version.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Version.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Version.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Version.java Mon Nov 23 15:53:48 2009
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * 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.katoview;
-
-import javax.tools.diagnostics.image.ImageFactory;
-
-public class Version {
-
- private static int majorVersion = 1;
- private static int minorVersion = 0;
- private static int buildVersion = 24;
-
- private static String name = "KatoView";
-
- public static String getVersion()
- {
- return Integer.toString(majorVersion) + "." +
- Integer.toString(minorVersion) + "." +
- Integer.toString(buildVersion);
- }
-
- public static String getName()
- {
- return name;
- }
-
- public static String getAllVersionInfo(ImageFactory factory)
- {
- String katoViewVersion = getName() + " version " + getVersion();
- String katoAPIVersion = factory.getMajorVersion() + "." + factory.getMinorVersion();
-
- return katoViewVersion + ", using Kato API version " + katoAPIVersion;
- }
-}
+/*******************************************************************************
+ * 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.katoview;
+
+import javax.tools.diagnostics.image.ImageFactory;
+
+public class Version {
+
+ private static int majorVersion = 1;
+ private static int minorVersion = 0;
+ private static int buildVersion = 24;
+
+ private static String name = "KatoView";
+
+ public static String getVersion()
+ {
+ return Integer.toString(majorVersion) + "." +
+ Integer.toString(minorVersion) + "." +
+ Integer.toString(buildVersion);
+ }
+
+ public static String getName()
+ {
+ return name;
+ }
+
+ public static String getAllVersionInfo(ImageFactory factory)
+ {
+ String katoViewVersion = getName() + " version " + getVersion();
+ String katoAPIVersion = factory.getMajorVersion() + "." + factory.getMinorVersion();
+
+ return katoViewVersion + ", using Kato API version " + katoAPIVersion;
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.tools.katoview/src/main/java/org/apache/kato/katoview/Version.java
------------------------------------------------------------------------------
svn:eol-style = native