harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r438430 - in /incubator/harmony/enhanced/classlib/trunk/modules/instrument: ./ src/main/java/org/apache/harmony/instrument/internal/ src/test/java/org/apache/harmony/tests/java/lang/instrument/ src/test/resources/jars/ src/test/resources/ja...
Date Wed, 30 Aug 2006 09:16:40 GMT
Author: pyang
Date: Wed Aug 30 02:16:39 2006
New Revision: 438430

URL: http://svn.apache.org/viewvc?rev=438430&view=rev
Log:
Patch applied for HARMONY-1276 ([classlib][instrument]Add tests for instruement implementation)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/TestMain.java
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BadFormatJar.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_Class_null.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_addTransformer_null.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_notExists.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_null.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Properity_case_sensitive.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Property_Premain_null.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Property_other_null.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/loading_class.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/new_classloader.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/old_version_class.jar
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/zero_byte_class.jar
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/main/java/org/apache/harmony/instrument/internal/InstrumentationImpl.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/instrument/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/build.xml?rev=438430&r1=438429&r2=438430&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/instrument/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/instrument/build.xml Wed Aug 30 02:16:39
2006
@@ -1,198 +1,199 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    Copyright 2006 The Apache Software Foundation or its
-    licensors, as applicable.
-  
-    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.
--->
-
-<project name="INSTRUMENT Build" default="build" basedir=".">
-    <description>Build for INSTRUMENT component</description>
-
-    <!-- import common properties -->
-    <import file="${basedir}/../../make/properties.xml" />
-
-    <!-- set global properties for this build. -->
-    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
-
-    <fileset id="classes" dir="${hy.build}">
-        <includesfile name="${hy.instrument}/make/patternset.txt" />
-        <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
-        <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
-    </fileset>
-                               
-    <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
-         use the Eclipse Java compiler. -->
-    <property name="build.compiler" value="modern" />
-    
-    <property name="iculib.zip" location="${depends.oss}/icu4c-3.4-harmony.zip" />
-
-    <target name="build" depends="compile.java, copy.resources, build.jar" />
-
-    <target name="test" depends="build, compile.tests, run.tests" />
-    
-    <target name="overlay-oss">
-    <mkdir dir="${hy.instrument.src.main.native}/icu4c/unicode" />
-    <unzip src="${iculib.zip}" dest="${hy.instrument.src.main.native}/icu4c/unicode" />
-    <chmod dir="${hy.instrument.src.main.native}/icu4c/unicode" perm="ugo+r" />
-    </target>
-    
-    <target name="clean-overlay-oss">
-    <delete dir="${hy.instrument.src.main.native}/icu4c" quiet="true" />
-    </target>
-    
-    <!-- Build native code -->
-    <target name="build.native" >
-    <make dir="${hy.instrument.src.main.native}/instrument/${hy.os}" />
-
-    <!-- Copy the built shared libs over to the jre/bin dir -->
-    <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-        <fileset dir="${hy.instrument.src.main.native}/instrument">
-                <patternset includes="*${shlib.suffix}*" />
-            </fileset>
-        </copy>
-    </target>
-    
-    <!-- Clean natives -->
-    <target name="clean.native">
-    <make dir="${hy.instrument.src.main.native}/instrument/${hy.os}" target="clean" />
-    </target>
-
-    <target name="clean">
-        <delete failonerror="false">
-            <fileset refid="classes" />
-            <fileset dir="${hy.instrument.bin.test}" />
-        </delete>
-    </target>
-
-    <target name="compile.java">
-        <echo message="Compiling INSTRUMENT classes" />
-
-        <mkdir dir="${hy.build}" />
-
-        <javac sourcepath=""
-            srcdir="${hy.instrument.src.main.java}"
-            destdir="${hy.build}"
-            source="${hy.javac.source}"
-            target="${hy.javac.target}"
-            debug="${hy.javac.debug}">
-
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-        </javac>
-    </target>
-
-    <target name="copy.resources">
-        <mkdir dir="${hy.build}" />
-        <copy todir="${hy.build}" includeemptydirs="false">
-            <fileset dir="${hy.instrument.src.main.java}">
-                <exclude name="**/*.java" />
-            </fileset>
-        </copy>
-    </target>
-
-    <target name="build.jar" depends="svn-info">
-        <jar destfile="${hy.jdk}/jre/lib/boot/instrument.jar"
-             manifest="${hy.instrument}/META-INF/MANIFEST.MF">
-            <fileset refid="classes" />
-            <manifest>
-                <attribute name="Implementation-Version" value="${svn.info}"/> 
-            </manifest>
-        </jar>
-    </target>
-
-    <target name="compile.tests" depends="copy.test.resources">
-        <echo message="Compiling INSTRUMENT tests" />
-
-        <mkdir dir="${hy.instrument.bin.test}" />
-
-        <javac srcdir="${hy.instrument.src.test.java}"
-            destdir="${hy.instrument.bin.test}"
-            sourcepath=""
-            source="${hy.javac.source}"
-            target="${hy.javac.target}"
-            debug="${hy.javac.debug}">
-
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-            <classpath location="${hy.hdk}/build/test/support.jar" />
-        </javac>
-    </target>
-
-    <target name="run.tests">
-
-        <mkdir dir="${hy.tests.reports}" />
-
-        <property name="test.jre.home" value="${hy.jdk}/jre" />
-
-        <junit fork="yes"
-            forkmode="once"
-            printsummary="withOutAndErr"
-            errorproperty="test.errors"
-            failureproperty="test.failures"
-            showoutput="on"
-            dir="${basedir}"
-            jvm="${test.jre.home}/bin/java">
-
-            <jvmarg value="-showversion"/>
-
-            <env key="JAVA_HOME" value="${test.jre.home}"/>
-
-            <classpath>
-                <pathelement path="${hy.instrument.bin.test}"/>
-            </classpath>
-            <classpath location="${hy.hdk}/build/test/support.jar" />
-
-            <formatter type="xml" />
-
-            <test name="${test.case}" todir="${hy.tests.reports}"
-                  if="test.case" />
-
-            <batchtest todir="${hy.tests.reports}" haltonfailure="no"
-                unless="test.case">
-
-                <fileset dir="${hy.instrument.src.test.java}">
-                    <include name="**/*Test.java"/>
-                </fileset>
-            </batchtest>
-        </junit>
-        <antcall target="touch-failures-file" />
-        <antcall target="touch-errors-file" />
-    </target>
-
-    <target name="touch-failures-file" if="test.failures">
-        <echo file="${hy.tests.reports}/test.failures"
-            append="true">instrument${line.separator}</echo>
-    </target>
-
-    <target name="touch-errors-file" if="test.errors">
-        <echo file="${hy.tests.reports}/test.errors"
-            append="true">instrument${line.separator}</echo>
-    </target>
-
-    <target name="copy.test.resources">
-        <mkdir dir="${hy.instrument.bin.test}" />
-        <copy todir="${hy.instrument.bin.test}" includeemptydirs="false">
-            <fileset dir="${hy.instrument.src.test.resources}">
-                <exclude name="**/*.java" />
-            </fileset>
-        </copy>
-    </target>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright 2006 The Apache Software Foundation or its
+    licensors, as applicable.
+  
+    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.
+-->
+
+<project name="INSTRUMENT Build" default="build" basedir=".">
+    <description>Build for INSTRUMENT component</description>
+
+    <!-- import common properties -->
+    <import file="${basedir}/../../make/properties.xml" />
+
+    <!-- set global properties for this build. -->
+    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
+
+    <fileset id="classes" dir="${hy.build}">
+        <includesfile name="${hy.instrument}/make/patternset.txt" />
+        <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
+        <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
+    </fileset>
+                               
+    <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
+         use the Eclipse Java compiler. -->
+    <property name="build.compiler" value="modern" />
+    
+    <property name="iculib.zip" location="${depends.oss}/icu4c-3.4-harmony.zip" />
+
+    <target name="build" depends="compile.java, copy.resources, build.jar" />
+
+    <target name="test" depends="build, compile.tests, run.tests" />
+    
+    <target name="overlay-oss">
+    <mkdir dir="${hy.instrument.src.main.native}/icu4c/unicode" />
+    <unzip src="${iculib.zip}" dest="${hy.instrument.src.main.native}/icu4c/unicode" />
+    <chmod dir="${hy.instrument.src.main.native}/icu4c/unicode" perm="ugo+r" />
+    </target>
+    
+    <target name="clean-overlay-oss">
+    <delete dir="${hy.instrument.src.main.native}/icu4c" quiet="true" />
+    </target>
+    
+    <!-- Build native code -->
+    <target name="build.native" >
+    <make dir="${hy.instrument.src.main.native}/instrument/${hy.os}" />
+
+    <!-- Copy the built shared libs over to the jre/bin dir -->
+    <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
+        <fileset dir="${hy.instrument.src.main.native}/instrument">
+                <patternset includes="*${shlib.suffix}*" />
+            </fileset>
+        </copy>
+    </target>
+    
+    <!-- Clean natives -->
+    <target name="clean.native">
+    <make dir="${hy.instrument.src.main.native}/instrument/${hy.os}" target="clean" />
+    </target>
+
+    <target name="clean">
+        <delete failonerror="false">
+            <fileset refid="classes" />
+            <fileset dir="${hy.instrument.bin.test}" />
+        </delete>
+    </target>
+
+    <target name="compile.java">
+        <echo message="Compiling INSTRUMENT classes" />
+
+        <mkdir dir="${hy.build}" />
+
+        <javac sourcepath=""
+            srcdir="${hy.instrument.src.main.java}"
+            destdir="${hy.build}"
+            source="${hy.javac.source}"
+            target="${hy.javac.target}"
+            debug="${hy.javac.debug}">
+
+            <bootclasspath>
+                <fileset dir="${hy.jdk}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
+            </bootclasspath>
+        </javac>
+    </target>
+
+    <target name="copy.resources">
+        <mkdir dir="${hy.build}" />
+        <copy todir="${hy.build}" includeemptydirs="false">
+            <fileset dir="${hy.instrument.src.main.java}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="build.jar" depends="svn-info">
+        <jar destfile="${hy.jdk}/jre/lib/boot/instrument.jar"
+             manifest="${hy.instrument}/META-INF/MANIFEST.MF">
+            <fileset refid="classes" />
+            <manifest>
+                <attribute name="Implementation-Version" value="${svn.info}"/> 
+            </manifest>
+        </jar>
+    </target>
+
+    <target name="compile.tests" depends="copy.test.resources">
+        <echo message="Compiling INSTRUMENT tests" />
+
+        <mkdir dir="${hy.instrument.bin.test}" />
+
+        <javac srcdir="${hy.instrument.src.test.java}"
+            destdir="${hy.instrument.bin.test}"
+            sourcepath=""
+            source="${hy.javac.source}"
+            target="${hy.javac.target}"
+            debug="${hy.javac.debug}">
+
+            <bootclasspath>
+                <fileset dir="${hy.jdk}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
+            </bootclasspath>
+            <classpath location="${hy.hdk}/build/test/support.jar" />
+        </javac>
+    </target>
+
+    <target name="run.tests">
+
+        <mkdir dir="${hy.tests.reports}" />
+
+        <property name="test.jre.home" value="${hy.jdk}/jre" />
+
+        <junit fork="yes"
+            forkmode="once"
+            printsummary="withOutAndErr"
+            errorproperty="test.errors"
+            failureproperty="test.failures"
+            showoutput="on"
+            dir="${basedir}"
+            jvm="${test.jre.home}/bin/java">
+
+            <jvmarg value="-showversion"/>
+
+            <env key="JAVA_HOME" value="${test.jre.home}"/>
+
+            <classpath>
+                <pathelement path="${hy.instrument.bin.test}"/>
+            </classpath>
+            <classpath location="${hy.hdk}/build/test/support.jar" />
+
+            <formatter type="xml" />
+
+            <test name="${test.case}" todir="${hy.tests.reports}"
+                  if="test.case" />
+
+            <batchtest todir="${hy.tests.reports}" haltonfailure="no"
+                unless="test.case">
+
+                <fileset dir="${hy.instrument.src.test.java}">
+                    <include name="**/*Test.java" />
+                    <exclude name="org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java"
/>
+                </fileset>
+            </batchtest>
+        </junit>
+        <antcall target="touch-failures-file" />
+        <antcall target="touch-errors-file" />
+    </target>
+
+    <target name="touch-failures-file" if="test.failures">
+        <echo file="${hy.tests.reports}/test.failures"
+            append="true">instrument${line.separator}</echo>
+    </target>
+
+    <target name="touch-errors-file" if="test.errors">
+        <echo file="${hy.tests.reports}/test.errors"
+            append="true">instrument${line.separator}</echo>
+    </target>
+
+    <target name="copy.test.resources">
+        <mkdir dir="${hy.instrument.bin.test}" />
+        <copy todir="${hy.instrument.bin.test}" includeemptydirs="false">
+            <fileset dir="${hy.instrument.src.test.resources}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+    </target>
+
+</project>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/main/java/org/apache/harmony/instrument/internal/InstrumentationImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/main/java/org/apache/harmony/instrument/internal/InstrumentationImpl.java?rev=438430&r1=438429&r2=438430&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/main/java/org/apache/harmony/instrument/internal/InstrumentationImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/main/java/org/apache/harmony/instrument/internal/InstrumentationImpl.java
Wed Aug 30 02:16:39 2006
@@ -69,7 +69,6 @@
      * @see java.lang.instrument.Instrumentation#addTransformer(java.lang.instrument.ClassFileTransformer)
      */
     public void addTransformer(ClassFileTransformer transformer) {
-        System.out.println("Coming!");
         if (null == transformer) {
             throw new NullPointerException();
         }

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java?rev=438430&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java
Wed Aug 30 02:16:39 2006
@@ -0,0 +1,203 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * 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.harmony.tests.java.lang.instrument;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import tests.support.Support_Exec;
+
+public class InstrumentTest extends TestCase {
+
+    /**
+     * @tests try to add a null Transformer 
+     */
+    public void test_addTransformer_null() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_addTransformer_null.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        String result = Support_Exec.execJava(arg, path, true);
+        assertEquals("", result);
+    }
+
+    /**
+     * @tests try to remove a null Transformer 
+     */
+    public void test_removeTransformer_null() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_null.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        String result = Support_Exec.execJava(arg, path, true);
+        assertEquals("", result);
+    }
+
+    /**
+     * @tests try to remove a non-exists Transformer 
+     */
+    public void test_removeTransformer_notExists() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_notExists.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        String result = Support_Exec.execJava(arg, path, true);
+        assertEquals("", result);
+    }
+    
+    /**
+     * @tests try to load a class that does not exist
+     */
+    public void test_loadClass_null() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/loading_class.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        try{
+            Support_Exec.execJava(arg, path, true);
+            fail("Should fail here!");
+        } catch (AssertionFailedError e){
+            // class loader changes, can not load classes
+            assertTrue(-1 != e.getMessage().indexOf("NoClassDefFoundError"));
+        }
+    }
+    
+    /**
+     * @tests try to use a new ClassLoader 
+     */
+    public void test_new_classLoader_Exists() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/new_classloader.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        String result = Support_Exec.execJava(arg, path, true);
+        assertNotNull(result);
+    }
+    
+    /**
+     * @tests test if attribute of "Premain-Class" is null
+     */
+    public void test_Property_Premain_null() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/Property_Premain_null.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        try{
+            Support_Exec.execJava(arg, path, true);
+            fail("Should fail here!");
+        } catch (AssertionFailedError e){
+            // expected
+            assertTrue(-1 != e.getMessage().indexOf("Failed") || -1 != e.getMessage().indexOf("error")
);
+            assertTrue(-1 != e.getMessage().indexOf("Premain-Class"));
+            assertTrue(-1 != e.getMessage().indexOf("attribute"));
+        }
+    }
+
+    /**
+     * @tests test if attributes of "Can-Redefine-Classes" and "Boot-Class-Path" is null
+     */
+    public void test_Property_other_null() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/Property_other_null.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        String result = Support_Exec.execJava(arg, path, true);
+        assertNotNull(result);
+    }
+    
+    /**
+     * @tests test if the attributes is case-sensitive
+     */
+    public void test_Properity_case_sensitive() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/Properity_case_sensitive.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        String result = Support_Exec.execJava(arg, path, true);
+        assertEquals("",result);
+    }
+    
+    /**
+     * @tests test if the jar file is bad
+     */
+    public void test_BadFormatJar() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/BadFormatJar.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        try{
+            Support_Exec.execJava(arg, path, true);
+            fail("Should fail here!");
+        } catch (AssertionFailedError e){
+            // expected
+            assertTrue(-1 != e.getMessage().indexOf("error") || -1 != e.getMessage().indexOf("Error")
);
+            assertTrue(-1 != e.getMessage().indexOf("open"));
+            assertTrue(-1 != e.getMessage().indexOf("file"));
+        }
+    }
+    
+    /**
+     * @tests test if premain class is null
+     */
+    public void test_Premain_Class_null() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_Class_null.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        try{
+            Support_Exec.execJava(arg, path, true);
+            fail("Should fail here!");
+        } catch (AssertionFailedError e){
+            // expected
+            assertTrue(-1 != e.getMessage().indexOf("ClassNotFoundException"));
+        }
+    }
+    
+    /**
+     * @tests test transforming all classes to a zero byte
+     */
+    public void test_zero_byte_transformer() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/zero_byte_class.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        String result = Support_Exec.execJava(arg, path, true);
+        assertEquals("",result);
+    }
+    
+    /**
+     * @tests test if complied by version 1.4
+     */
+    public void test_old_version() throws Exception {
+        String[] arg = new String[2];
+        arg[0] = "-javaagent:src/test/resources/jars/org/apache/harmony/tests/instrument/old_version_class.jar";
+        arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain";
+        String[] path = new String[1];
+        path[0] = "";
+        String result = Support_Exec.execJava(arg, path, true);
+        assertEquals("",result);
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/TestMain.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/TestMain.java?rev=438430&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/TestMain.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/TestMain.java
Wed Aug 30 02:16:39 2006
@@ -0,0 +1,26 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * 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.harmony.tests.java.lang.instrument;
+
+/*
+ * For instrument test only
+ */
+public class TestMain {
+    public static void main(String[] args) {
+        // do nothing, only as execuable main class
+        return;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BadFormatJar.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BadFormatJar.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BadFormatJar.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_Class_null.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_Class_null.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_Class_null.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_addTransformer_null.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_addTransformer_null.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_addTransformer_null.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_notExists.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_notExists.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_notExists.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_null.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_null.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Premain_removeTransformer_null.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Properity_case_sensitive.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Properity_case_sensitive.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Properity_case_sensitive.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Property_Premain_null.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Property_Premain_null.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Property_Premain_null.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Property_other_null.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Property_other_null.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/Property_other_null.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/loading_class.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/loading_class.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/loading_class.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/new_classloader.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/new_classloader.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/new_classloader.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/old_version_class.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/old_version_class.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/old_version_class.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/zero_byte_class.jar
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/zero_byte_class.jar?rev=438430&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/zero_byte_class.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message