You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by iv...@apache.org on 2007/07/17 10:42:21 UTC
svn commit: r556849 [1/2] - in
/harmony/enhanced/buildtest/branches/2.0/tests/reliability: run/
src/java/org/apache/harmony/test/reliability/api/kernel/compiler/
src/java/org/apache/harmony/test/reliability/api/net/
src/java/org/apache/harmony/test/rel...
Author: ivavladimir
Date: Tue Jul 17 01:42:18 2007
New Revision: 556849
URL: http://svn.apache.org/viewvc?view=rev&rev=556849
Log:
patch for HARMONY-4291 was appliead
Added:
harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.security.xml (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.serialization.xml (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/kernel/compiler/
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/kernel/compiler/JitCompilerTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/DatagramTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/JarUrlConnectionTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/MultiConnectTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/SingleConnectTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/security/
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/security/SecurityClassRelatedTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/serialization/
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/serialization/SerializableClassesTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/ClassMultiTestBase.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassCastTest.java (with props)
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/gc/WeakRefsTest.java (with props)
Modified:
harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.kernel.xml
harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.net.xml
harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.normal.mode.settings.xml
harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.vm.xml
harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.xml
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/JarFilesScanner.java
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassAttributesTest.java
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassMultiTestBase.java
harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassReflectionTest.java
Modified: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.kernel.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.kernel.xml?view=diff&rev=556849&r1=556848&r2=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.kernel.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.kernel.xml Tue Jul 17 01:42:18 2007
@@ -24,7 +24,7 @@
<target name="run.api.kernel" depends="run.api.kernel.args, run.api.kernel.exec, run.api.kernel.hooks,
run.api.kernel.object, run.api.kernel.pckg, run.api.kernel.string,
run.api.kernel.thread, run.api.kernel.throwable,
- run.api.kernel.management" />
+ run.api.kernel.management, run.api.kernel.compiler" />
<target name="run.api.kernel.args">
@@ -72,6 +72,12 @@
</target>
+
+ <target name="run.api.kernel.compiler">
+
+ <run-pjava-test test="api.kernel.compiler.JitCompilerTest" args="" />
+
+ </target>
<target name="run.api.kernel.pckg">
Modified: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.net.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.net.xml?view=diff&rev=556849&r1=556848&r2=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.net.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.net.xml Tue Jul 17 01:42:18 2007
@@ -22,6 +22,22 @@
<target name="run.api.net">
+ <run-pjava-test test="api.net.JarUrlConnectionTest"
+ args="${api.net.JarUrlConnectionTest.n_threads}"/>
+
+ <run-pjava-test test="api.net.HttpConnectionTest"
+ args="${api.net.HttpConnectionTest.URLs}"/>
+
+ <run-pjava-test test="api.net.DatagramTest"
+ args="${api.net.DatagramTest.n_sender_threads} "/>
+
+ <run-pjava-test test="api.net.MultiConnectTest"
+ args="${api.net.MultiConnectTest.n_threads}
+ ${api.net.MultiConnectTest.n_ports}"/>
+
+ <run-pjava-test test="api.net.SingleConnectTest"
+ args="${api.net.SingleConnectTest.n_threads}"/>
+
<run-pjava-test test="api.net.NetClient"
args="${api.net.NetClient.n_clients}
${test.source.dir}/org/apache/harmony/test/reliability/api/net/auxiliary
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.security.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.security.xml?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.security.xml (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.security.xml Tue Jul 17 01:42:18 2007
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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="run.api.security.tests" default="run.api.security" basedir=".">
+
+ <description> Runs all tests from api/security </description>
+
+ <target name="run.api.security">
+
+ <run-pjava-test test="api.security.SecurityClassRelatedTest"
+ args=""/>
+
+ </target>
+
+</project>
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.security.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.serialization.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.serialization.xml?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.serialization.xml (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.serialization.xml Tue Jul 17 01:42:18 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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="run.api.serialization.tests" default="run.api.serialization" basedir=".">
+
+ <description> Runs all tests from api/security </description>
+
+ <target name="run.api.serialization">
+
+ <run-pjava-test test="api.serialization.SerializableClassesTest"
+ args="${api.serialization.SerializableClassesTest.n_threads}
+ ${api.serialization.SerializableClassesTest.n_subthreads} ${work.dir}"/>
+
+ </target>
+
+</project>
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.api.serialization.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.normal.mode.settings.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.normal.mode.settings.xml?view=diff&rev=556849&r1=556848&r2=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.normal.mode.settings.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.normal.mode.settings.xml Tue Jul 17 01:42:18 2007
@@ -471,6 +471,28 @@
<!-- number of files to work with -->
<property name="api.io.IOTest.n_files" value="50" />
+
+<!-- api.net.MultiConnectTest -->
+
+ <!-- number of simultaneously executed clients -->
+ <property name="api.net.MultiConnectTest.n_threads" value="10" />
+
+ <!-- port to use -->
+ <property name="api.net.MultiConnectTest.n_ports" value="1000" />
+
+<!-- api.net.SingleConnectTest -->
+
+ <!-- number of simultaneously executed clients -->
+ <property name="api.net.SingleConnectTest.n_threads" value="400" />
+
+<!-- api.serialization.SerializableClassesTest -->
+
+ <!-- number of simultaneously executed serialize threads -->
+ <property name="api.serialization.SerializableClassesTest.n_threads" value="3" />
+
+ <!-- number of simultaneously executed deserialize threads -->
+ <property name="api.serialization.SerializableClassesTest.n_subthreads" value="10" />
+
<!-- api.net.NetClient -->
<!-- number of simultaneously executed clients -->
@@ -482,6 +504,21 @@
<!-- number of threads to run -->
<property name="api.net.NetClient.n_threads" value="5" />
+<!-- api.net.DatagramTest -->
+
+ <!-- number of sender threads -->
+ <property name="api.net.DatagramTest.n_sender_threads" value="30" />
+
+<!-- api.net.JarUrlConnectionTest -->
+
+ <!-- Number of threads to start -->
+ <property name="api.net.JarUrlConnectionTest.n_threads" value="100" />
+
+<!-- api.net.HttpConnectionTest -->
+
+ <!-- URLs to scan -->
+ <property name="api.net.HttpConnectionTest.URLs" value="http://harmony.apache.org/;http://issues.apache.org/jira/browse/HARMONY;http://harmony.apache.org/quickhelp_contributors.html" />
+
<!-- vm.classloading.ClassUnloadingTest -->
<!-- number of running in parallel threads -->
@@ -532,6 +569,12 @@
<!-- number of running in parallel threads -->
<property name="vm.gc.GCTest.n_threads" value="32" />
+
+<!-- vm.gc.WeakRefsTest -->
+
+ <!-- number of running in parallel threads -->
+ <property name="vm.gc.WeakRefsTest.n_threads" value="32" />
+
<!-- vm.stack.StackFramesRestoreTest -->
Modified: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.vm.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.vm.xml?view=diff&rev=556849&r1=556848&r2=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.vm.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.vm.xml Tue Jul 17 01:42:18 2007
@@ -40,6 +40,9 @@
<run-pjava-test test="vm.classloading.ClassReflectionTest"
args="${vm.classloading.ClassReflectionTest.n_threads}"/>
+ <run-pjava-test test="vm.classloading.ClassCastTest" args=""/>
+
+
</target>
<target name="run.vm.finalization">
@@ -54,6 +57,9 @@
</target>
<target name="run.vm.gc">
+
+ <run-pjava-test test="vm.gc.WeakRefsTest"
+ args="${vm.gc.WeakRefsTest.n_threads}"/>
<run-pjava-test test="vm.gc.GCTest"
args="${vm.gc.GCTest.n_threads}"/>
Modified: harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.xml?view=diff&rev=556849&r1=556848&r2=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/run/run.xml Tue Jul 17 01:42:18 2007
@@ -233,11 +233,12 @@
<import file="run.api.net.xml"/>
<import file="run.vm.xml"/>
<import file="run.api.util.xml"/>
-
+ <import file="run.api.security.xml"/>
+ <import file="run.api.serialization.xml"/>
<target name="run" depends="run.api.zip, run.api.kernel,
run.api.text, run.api.nio,
- run.api.io, run.api.net, run.vm, run.api.util"/>
+ run.api.io, run.api.net, run.vm, run.api.util, run.api.security, run.api.serialization"/>
<fail message="There were test failures" if="failed"/>
<target name="clean">
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/kernel/compiler/JitCompilerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/kernel/compiler/JitCompilerTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/kernel/compiler/JitCompilerTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/kernel/compiler/JitCompilerTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+/**
+ * GOAL: Test j.l.Compiler functionality
+ * see additional description in ClassMultiBas
+ *
+ * The test does:
+ * a. finds all class files from JRE
+ * b. tries to load all these classes
+ * c. calls compileClass for every successfully loaded Class
+ * d. for every NUMBER_OF_CYCLE_TO_DISABLE_COMPILER-th iteration try
+ * to compile class in Compiler.disable(); mode
+ *
+ * No hangs, fails, crashes or hangs are expected.
+ * Note: due to spec to test JIT compiler "java.compiler" property is to be set
+ * and VM is to support j.l.Compiler functionality
+ */
+
+package org.apache.harmony.test.reliability.api.kernel.compiler;
+
+import org.apache.harmony.test.reliability.share.ClassMultiTestBase;
+
+public class JitCompilerTest extends ClassMultiTestBase{
+ int class_compiled_counter = 0;
+ final int NUMBER_OF_CYCLE_TO_DISABLE_COMPILER = 10;
+
+ public static void main(String[] args){
+ System.exit(new JitCompilerTest().test(args));
+ }
+
+ public void initCycle() {
+ // do nothing
+ }
+ public void releaseCycle() {
+ // do nothing
+ }
+
+ public void testContent(Class cls) {
+ // for every NUMBER_OF_CYCLE_TO_DISABLE_COMPILER-th iteration
+ // try to compile class in Compiler.disable(); mode
+ if ((class_compiled_counter%NUMBER_OF_CYCLE_TO_DISABLE_COMPILER) == 0){
+ Compiler.disable();
+ Compiler.compileClass(cls);
+ Compiler.enable();
+ }
+
+ Compiler.compileClass(cls);
+
+ class_compiled_counter++;
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/kernel/compiler/JitCompilerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/DatagramTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/DatagramTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/DatagramTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/DatagramTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+package org.apache.harmony.test.reliability.api.net;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Random;
+import java.net.InetAddress;
+
+import org.apache.harmony.test.reliability.share.Test;
+
+/*
+ * Goal: Test datagram packets send/receive operations
+ * passed parameters:
+ * parameter[0] - number of threads to start to send packets
+ *
+ * The test Thread does the following:
+ * parameter[1] number of receiver threads is started, every thread:
+ * * starts receiving data by DatagramSocket
+
+ * parameter[0] number of sender threads is started, every thread:
+ * * starts sending datagram packets to localhost with predefined port numbers
+ *
+ * The test is stopped after TIME_FOR_ONE_ITERATION_TO_WORK timeout
+ *
+ * No hangs, crashes or fails are expected
+ * */
+
+public class DatagramTest extends Test{
+ static volatile boolean failed = false;
+ static final int NUMBER_OF_THREADS = 30;
+ static int numberOfThreads = NUMBER_OF_THREADS;
+ volatile static boolean stopThreads = false;
+ final static int STARTING_PORT_NUMBER = 8100;
+ final static int NUMBER_OF_TRIES_TO_CREATE_SOCKET = 1000;
+ final static int NUMBER_OF_RECEIVERS = 10;
+ final static int TIME_FOR_ONE_ITERATION_TO_WORK = 1; //minutes
+ int[] portNumbers = null;
+
+ public static void main(String[] params){
+ System.exit(new DatagramTest().test(params));
+ }
+
+ public int test(String[] params){
+ parseParams(params);
+ stopThreads = false;
+ Thread[] rthrds = new Thread[NUMBER_OF_RECEIVERS];
+ Thread[] sthrds = new Thread[numberOfThreads];
+ portNumbers = new int[NUMBER_OF_RECEIVERS];
+ for (int i = 0; i<NUMBER_OF_RECEIVERS; i++){
+ receiveRunner rr = null;;
+ rthrds[i] = rr = new receiveRunner(STARTING_PORT_NUMBER + i, this);
+ portNumbers[i] = rr.initialize();
+ if (portNumbers[i] == -1 || failed == true){
+ return fail("Failed to create DatagramSocket with port number " + (STARTING_PORT_NUMBER + i));
+ }
+ rthrds[i].start();
+ }
+
+ for (int i = 0; i<numberOfThreads; i++){
+ sthrds[i] = new sendRunner(this);
+ if (failed == true){
+ return fail("FAILED");
+ }
+ sthrds[i].start();
+ }
+
+ try {
+ Thread.currentThread().sleep(TIME_FOR_ONE_ITERATION_TO_WORK * 60 * 1000);
+ } catch (InterruptedException e1) {
+ return fail("Main thread was interrupted");
+ }
+ stopThreads = true;
+
+ for (int i = 0; i<NUMBER_OF_RECEIVERS; i++){
+ try {
+ rthrds[i].join();
+ } catch (InterruptedException e) {
+ return fail("FAILED");
+ }
+ }
+ for (int i = 0; i<numberOfThreads; i++){
+ try {
+ sthrds[i].join();
+ } catch (InterruptedException e) {
+ return fail("FAILED");
+ }
+ }
+
+ if (failed == true){
+ return fail("FAILED");
+ }
+
+ return pass("OK");
+ }
+
+ public void parseParams(String[] params) {
+
+ if (params.length >= 1) {
+ numberOfThreads = Integer.parseInt(params[0]);
+ }
+ }
+}
+
+class receiveRunner extends Thread{
+ Random rm = new Random();
+ int port = 0;
+ DatagramSocket ds = null;
+ static final int NUMBER_BYTES_TO_RECEIVE = 100;
+ DatagramTest base = null;
+
+ receiveRunner(int p, DatagramTest b){
+ base = b;
+ port = p;
+ initialize();
+ }
+
+ int initialize(){
+ int counter = 0;
+ while (counter < DatagramTest.NUMBER_OF_TRIES_TO_CREATE_SOCKET){
+ try {
+ ds = new DatagramSocket(port + counter);
+ } catch (SocketException e) {
+ //DatagramTest.log.add("Failed to create DatagramSocket on port " + port);
+ counter++;
+ continue;
+ }
+ break;
+ }
+ if (ds != null){
+ return (port + counter);
+ }else{
+ return -1;
+ }
+ }
+
+ public void run (){
+ while (!DatagramTest.stopThreads){
+ byte buf[] = new byte[NUMBER_BYTES_TO_RECEIVE];
+ DatagramPacket dp = new DatagramPacket(buf, buf.length);
+ try {
+ ds.receive(dp);
+ } catch (IOException e) {
+ // possible
+ }
+ byte[] data = dp.getData();
+ dp.getLength();
+ String msg = new String(data);
+ //System.out.println(msg);
+ dp.getOffset();
+ dp.getPort();
+ }
+ ds.close();
+ }
+
+}
+
+class sendRunner extends Thread{
+ Random rm = new Random();
+ DatagramSocket ds = null;
+ DatagramTest base = null;
+
+ sendRunner(DatagramTest b){
+ base = b;
+ try {
+ ds = new DatagramSocket();
+ } catch (SocketException e) {
+ DatagramTest.stopThreads = true;
+ DatagramTest.log.add("Failed to create DatagramSocket in " + getId() + " thread");
+ DatagramTest.failed = true;
+ }
+ }
+
+ public void run (){
+ while (!DatagramTest.stopThreads){
+ String msg = "Thread " + getId() + " sends you Hello";
+ DatagramPacket dp;
+ int port = base.portNumbers [rm.nextInt(DatagramTest.NUMBER_OF_RECEIVERS)];
+ try {
+ dp = new DatagramPacket(msg.getBytes(), msg.getBytes().length ,InetAddress.getLocalHost(), port);
+ } catch (UnknownHostException e) {
+ DatagramTest.stopThreads = true;
+ DatagramTest.log.add("Failed to create DatagramPacket in " + getId() + " thread, localhost, port " + port);
+ DatagramTest.failed = true;
+ return;
+ }
+
+ try {
+ ds.send(dp);
+ } catch (IOException e) {
+ DatagramTest.stopThreads = true;
+ DatagramTest.log.add("Failed to send packet in " + getId() + " thread, localhost, port " + port);
+ DatagramTest.failed = true;
+ }
+ }
+ ds.close();
+ }
+
+}
+
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/DatagramTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+package org.apache.harmony.test.reliability.api.net;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.Proxy;
+import java.net.URL;
+import java.util.regex.Pattern;
+
+import org.apache.harmony.test.reliability.share.Test;
+
+/*
+ * Goal: Test HttpURLConnection functionality
+ *
+ * passed parameters:
+ * parameter[0] - urls for web pages you want to get, all urls are to be listed consequently
+ * via ";" with no blanks or tabs
+ * E.g http://harmony.apache.org/;http://issues.apache.org/jira/browse/HARMONY
+ * parameter[1] - proxy adress if any
+ * parameter[2] - proxy port if any
+ * The test does the following:
+ * - For every url from parameter[0] establishes HttpURLConnection and tries to GET
+ * web page from it and read some info about connection.
+ *
+ * No crash, hang or fail is excpected.
+ *
+ * Note: All input parameters are to be set properly as test could fail due to wrong
+ * set proxy or Url address.
+ * */
+
+public class HttpConnectionTest extends Test{
+ String[] testedUrlStrings = null;
+ Proxy prx = null;
+
+ public static void main(String[] params){
+ System.exit(new HttpConnectionTest().test(params));
+ }
+
+ public int test(String[] params){
+ parseParams(params);
+ if (testedUrlStrings == null){
+ return fail("Urls to test are not set");
+ }
+
+ for (int i=0; i<testedUrlStrings.length;i++){
+ URL url = null;
+ try {
+ url = new URL(testedUrlStrings[i]);
+ } catch (MalformedURLException e2) {
+ return fail("Failed to create URL of " + testedUrlStrings[i]);
+ }
+
+ if (!checkUrl(url)){
+ return fail("FAILED");
+ }
+ }
+
+ return pass("OK");
+ }
+
+ boolean checkUrl(URL url){
+ HttpURLConnection hur = null;
+ try {
+ if (prx == null){
+ hur = (HttpURLConnection)url.openConnection();
+ }else{
+ hur = (HttpURLConnection)url.openConnection(prx);
+ }
+ } catch (IOException e) {
+ log.add("Failed to open connection of " + url);
+ return false;
+ }
+
+ BufferedReader br = null;
+ try {
+ hur.setDoOutput(true);
+ hur.connect();
+ // get some info about http connection
+ hur.getFollowRedirects();
+ hur.getInstanceFollowRedirects();
+ hur.getPermission();
+ hur.getRequestMethod();
+ hur.getResponseCode();
+ hur.usingProxy();
+
+ // get html page and scan it
+ br = new BufferedReader(new InputStreamReader(hur.getInputStream()));
+ String resultedString = "";
+ String buf;
+ while((buf = br.readLine()) != null){
+ resultedString += buf;
+ }
+ //System.out.println(resultedString);
+ hur.disconnect();
+
+ } catch (IOException e) {
+ log.add("Failed to connect to " + hur.getURL() + " : " + e.getMessage());
+ return false;
+ }
+
+ return true;
+ }
+
+ public void parseParams(String[] params) {
+ if (params.length >= 1) {
+ String urls = params[0];
+ Pattern p = Pattern.compile(";");
+ testedUrlStrings = p.split(urls);
+ }
+ if (params.length >= 3) {
+ prx = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(params[1], Integer.parseInt(params[2])));
+ }
+
+ }
+}
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/JarUrlConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/JarUrlConnectionTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/JarUrlConnectionTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/JarUrlConnectionTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+package org.apache.harmony.test.reliability.api.net;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.cert.Certificate;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Random;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.harmony.test.reliability.share.JarFilesScanner;
+
+import org.apache.harmony.test.reliability.share.Test;
+
+/*
+ * Goal: Test JavaUrlConnection functionality
+ * the idea is to create JavaUrlConnection for existing jar file in JRE
+ * + scan jar files and create JavaUrlConnection on jar entries
+ * and read some information about scanned jar files and entries
+ * passed parameters:
+ * parameter[0] - number of threads to start
+ *
+ * The test Thread does the following:
+ * * scans jar files in JRE
+ * * creates parameter[0] threads for every jar files found
+ * Every thread:
+ * * creates JavaUrlConnection for every jar file
+ * * reads some info about jar file
+ * * scans read jar files for entries and reads info about these entries
+ *
+ * */
+
+public class JarUrlConnectionTest extends Test{
+ static volatile boolean failed = false;
+ static final int NUMBER_OF_THREADS = 100;
+ static int numberOfThreads = NUMBER_OF_THREADS;
+ static ArrayList<String> jarFiles = null;
+
+ public static void main(String[] params){
+ System.exit(new JarUrlConnectionTest().test(params));
+ }
+
+ public int test(String[] params){
+ parseParams(params);
+ jarFiles = JarFilesScanner.getJarFilesInJRE();
+
+ if (jarFiles == null){
+ return fail("Failed to scan jar files in JRE.");
+ }
+
+ if (numberOfThreads > jarFiles.size()){
+ numberOfThreads = jarFiles.size();
+ }
+
+ Thread[] thrds = new Thread[numberOfThreads];
+ for (int i = 0; i<thrds.length; i++){
+ File file = new File(jarFiles.get(i));
+ try {
+ thrds[i] = new scanRunner(file.toURL());
+ } catch (MalformedURLException e) {
+ return fail("Failed to get URL for " + jarFiles.get(i));
+ }
+ thrds[i].start();
+ }
+
+ for (int i = 0; i<thrds.length; i++){
+ try {
+ thrds[i].join();
+ } catch (InterruptedException e) {
+ return fail("FAILED");
+ }
+ }
+
+ if (failed == true){
+ return fail("FAILED");
+ }
+
+ return pass("OK");
+ }
+
+ public void parseParams(String[] params) {
+
+ if (params.length >= 1) {
+ numberOfThreads = Integer.parseInt(params[0]);
+ }
+ }
+}
+
+class scanRunner extends Thread{
+ Random rm = new Random();
+ URL url = null;
+
+ scanRunner(URL u){
+ url = u;
+ }
+
+ public void run (){
+ JarURLConnection juc = null;
+
+ String jarUrlString = "jar:" + url + "!/";
+ //System.out.println(jarUrlString);
+ URL jurl = null;
+ try {
+ jurl = new URL(jarUrlString);
+ } catch (MalformedURLException e1) {
+ JarUrlConnectionTest.log.add("Failed to convert URI name to jar URL for " + url);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ try {
+ juc = (JarURLConnection)jurl.openConnection();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to open JarURLConnection for " + url);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ Attributes atts = null;
+ try {
+ atts = juc.getAttributes();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to get Attributes for " + url);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ Attributes mAtts = null;
+ try {
+ mAtts = juc.getMainAttributes();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to get Attributes for " + url);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ Certificate[] ct = null;
+ try {
+ ct = juc.getCertificates();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to get certificates for " + url);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ Manifest msft = null;
+ try {
+ msft = juc.getManifest();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to get manifest for " + url);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ JarFile jf = null;
+ try {
+ jf = juc.getJarFile();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to get manifest for " + url);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ Enumeration<JarEntry> en = jf.entries();
+ while (en.hasMoreElements()){
+ JarEntry je = en.nextElement();
+ je.getName();
+ //System.out.println(je.getName());
+ je.getCertificates();
+ je.getExtra();
+ je.getCrc();
+ je.getTime();
+ je.getComment();
+ je.getCodeSigners();
+
+ // try to create JarURLConnection for JarEntries
+ String eUrlString = jarUrlString + je.getName();
+ URL eUrl;
+ try {
+ eUrl = new URL(eUrlString);
+ } catch (MalformedURLException e) {
+ JarUrlConnectionTest.log.add("Failed to Create URL to jar entry " + eUrlString);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+ JarURLConnection juce = null;
+ try {
+ juce = (JarURLConnection)eUrl.openConnection();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to Create JarURLConnection to jar entry " + eUrlString);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+ try {
+ juce.getContent();
+ } catch (IOException e) {
+ // ignore
+ }
+ try {
+ juce.getAttributes();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to getAttributes for " + eUrlString);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ juce.getAllowUserInteraction();
+ try {
+ juce.getCertificates();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to get certificates for " + eUrlString);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ try {
+ juce.getManifest();
+ } catch (IOException e) {
+ JarUrlConnectionTest.log.add("Failed to get manifest for " + eUrlString);
+ JarUrlConnectionTest.failed = true;
+ return;
+ }
+
+ }
+
+ }
+
+}
+
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/JarUrlConnectionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/MultiConnectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/MultiConnectTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/MultiConnectTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/MultiConnectTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+package org.apache.harmony.test.reliability.api.net;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.net.InetAddress;
+
+import org.apache.harmony.test.reliability.share.Test;
+
+/*
+ * Goal: Test making connections to many ports on localHost
+ * passed parameters:
+ * parameter[0] - number of scanner threads to start
+ * parameter[1] - number of ports opened simultaneously
+ *
+ * The test Thread does the following:
+ * parameter[1] number of server threads are started, every thread:
+ * * has own unique port number to process requests
+ * * starts receiving connections by ServerSocket.accept() method in a cycle
+ * * cycle is numberOfAcceptedRequests times
+
+ * parameter[0] number of sender threads is started, every thread:
+ * * starts creating socket conections to localHost by every reserved port number
+ *
+ * No hangs, crashes or fails are expected
+ *
+ * Note: choose input parameters values properly to avoid "max allowed connections exceeded" error to appear
+ * */
+
+public class MultiConnectTest extends Test{
+ static volatile boolean failed = false;
+ static final int NUMBER_OF_THREADS = 10;
+ static int numberOfThreads = NUMBER_OF_THREADS;
+ final static int STARTING_PORT_NUMBER = 8100;
+ static int numberOfPortsToOpen = 2000;
+ static int numberOfAcceptedRequests = 1000;
+ static ServerRunner[] sPorts = null;
+
+ public static void main(String[] params){
+ System.exit(new MultiConnectTest().test(params));
+ }
+
+ public int test(String[] params){
+ parseParams(params);
+
+ sPorts = new ServerRunner[numberOfPortsToOpen];
+ for (int i=0; i<numberOfPortsToOpen; i++){
+ sPorts[i] = new ServerRunner(STARTING_PORT_NUMBER + i);
+ }
+
+ Thread[] thrds = new Thread[numberOfThreads];
+ for (int i=0; i< numberOfThreads; i++){
+ thrds[i] = new portScannerRunner();
+ thrds[i].start();
+ }
+
+ for (int i=0; i< numberOfThreads; i++){
+ try {
+ thrds[i].join();
+ } catch (InterruptedException e) {
+ log.add("Failed to join thread " + thrds[i].getId());
+ failed = true;
+ }
+ }
+
+ if (failed == true){
+ return fail("FAILED");
+ }
+
+ return pass("OK");
+ }
+
+ public void parseParams(String[] params) {
+
+ if (params.length >= 1) {
+ numberOfThreads = Integer.parseInt(params[0]);
+ }
+ if (params.length >= 2) {
+ numberOfPortsToOpen = Integer.parseInt(params[1]);
+ }
+
+ }
+}
+
+class ServerRunner extends Thread{
+ int port = 0;
+ int counter = 0;
+ ServerRunner(int p){
+ port = p;
+ start();
+ }
+ public void run (){
+ ServerSocket ss = null;
+ try {
+ ss = new ServerSocket(port);
+ } catch (IOException e1) {
+ // Ignore - the port could already be used
+ return;
+ }
+ while (counter < MultiConnectTest.numberOfAcceptedRequests){
+ try {
+ ss.accept();
+ } catch (IOException e) {
+ MultiConnectTest.log.add("Server thread " + getId() + " could not accept request: " + e.getMessage());
+ MultiConnectTest.failed = true;
+ return;
+ }
+ counter++;
+ }
+ try {
+ ss.close();
+ } catch (IOException e) {
+ MultiConnectTest.log.add("Failed to close ServerSocket on port " + port);
+ MultiConnectTest.failed = true;
+ return;
+ }
+
+ }
+
+}
+
+
+class portScannerRunner extends Thread{
+
+ public void run (){
+
+ ArrayList<Socket> connections = new ArrayList<Socket>();
+ for (int i=0; i<MultiConnectTest.numberOfPortsToOpen; i++){
+ Socket sc = null;
+ try {
+ sc = new Socket(InetAddress.getLocalHost(), MultiConnectTest.STARTING_PORT_NUMBER + i);
+ connections.add(sc);
+ } catch (UnknownHostException e) {
+ MultiConnectTest.log.add("Failed to locate localhost.");
+ MultiConnectTest.failed = true;
+ return;
+ } catch (IOException e) {
+ // Ignore - server could already be down
+ return;
+ }
+
+ try {
+ sc.close();
+ } catch (IOException e) {
+ MultiConnectTest.log.add("Failed to close socket to localhost by port " + (MultiConnectTest.STARTING_PORT_NUMBER + i) + " : " + e.getMessage());
+ MultiConnectTest.failed = true;
+ }
+ }
+
+ }
+
+}
+
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/MultiConnectTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/SingleConnectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/SingleConnectTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/SingleConnectTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/SingleConnectTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+package org.apache.harmony.test.reliability.api.net;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.net.InetAddress;
+
+import org.apache.harmony.test.reliability.share.Test;
+
+/*
+ * Goal: Test making connections to one port on localHost
+ * passed parameters:
+ * parameter[0] - number of threads to start to send packets
+ *
+ * parameter[0] number of sender threads are started, every thread:
+ * * starts creating socket conections to localHost by reserved port number
+ *
+ * No hangs, crashes or fails are expected
+ *
+ * */
+
+public class SingleConnectTest extends Test{
+ static volatile boolean failed = false;
+ static final int NUMBER_OF_THREADS = 100;
+ static int numberOfThreads = NUMBER_OF_THREADS;
+ final static int STARTING_PORT_NUMBER = 8100;
+ static int numberOfAcceptedRequests = 1000000;
+ static int numberOfTriesToOpenPort = 200;
+ static int portStarted = 0;
+
+ public static void main(String[] params){
+ System.exit(new SingleConnectTest().test(params));
+ }
+
+ public int test(String[] params){
+ parseParams(params);
+
+ ServerRunner1 sPort = null;
+ for (int i=0; i<numberOfTriesToOpenPort; i++){
+ sPort = new ServerRunner1(STARTING_PORT_NUMBER + i);
+ if (sPort.started){
+ break;
+ }
+ }
+ if (!sPort.isAlive()){
+ return fail("Failed to start any server");
+ }
+ portStarted = sPort.port;
+
+ Thread[] thrds = new Thread[numberOfThreads];
+ for (int i=0; i< numberOfThreads; i++){
+ thrds[i] = new portScannerRunner1();
+ thrds[i].start();
+ }
+
+ for (int i=0; i< numberOfThreads; i++){
+ try {
+ thrds[i].join();
+ } catch (InterruptedException e) {
+ log.add("Failed to join thread " + thrds[i].getId());
+ failed = true;
+ }
+ }
+
+ if (failed == true){
+ return fail("FAILED");
+ }
+
+ return pass("OK");
+ }
+
+ public void parseParams(String[] params) {
+
+ if (params.length >= 1) {
+ numberOfThreads = Integer.parseInt(params[0]);
+ }
+
+ }
+}
+
+class ServerRunner1 extends Thread{
+ int port = 0;
+ int counter = 0;
+ boolean started = false;
+ ServerRunner1(int p){
+ port = p;
+ start();
+ }
+ public void run (){
+ ServerSocket ss = null;
+ try {
+ ss = new ServerSocket(port);
+ } catch (IOException e1) {
+ // Ignore - the port could already be used
+ return;
+ }
+ started = true;
+ while (counter < SingleConnectTest.numberOfAcceptedRequests){
+ try {
+ ss.accept();
+ } catch (IOException e) {
+ SingleConnectTest.log.add("Server thread " + getId() + " could not accept request: " + e.getMessage());
+ SingleConnectTest.failed = true;
+ return;
+ }
+ counter++;
+ }
+ try {
+ ss.close();
+ } catch (IOException e) {
+ SingleConnectTest.log.add("Failed to close ServerSocket on port " + port);
+ SingleConnectTest.failed = true;
+ return;
+ }
+
+ }
+
+}
+
+
+class portScannerRunner1 extends Thread{
+
+ public void run (){
+
+ ArrayList<Socket> connections = new ArrayList<Socket>();
+ while (true){
+ Socket sc = null;
+ try {
+ sc = new Socket(InetAddress.getLocalHost(), SingleConnectTest.portStarted);
+ connections.add(sc);
+ } catch (UnknownHostException e) {
+ SingleConnectTest.log.add("Failed to locate localhost.");
+ SingleConnectTest.failed = true;
+ return;
+ } catch (IOException e) {
+ // Ignore - server could already down or max allowed connections number is reached
+ break;
+
+ }
+
+ try {
+ sc.close();
+ } catch (IOException e) {
+ SingleConnectTest.log.add("Failed to close socket to localhost by port " + (SingleConnectTest.portStarted) + " : " + e.getMessage());
+ SingleConnectTest.failed = true;
+ }
+ }
+
+ }
+
+}
+
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/SingleConnectTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/security/SecurityClassRelatedTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/security/SecurityClassRelatedTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/security/SecurityClassRelatedTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/security/SecurityClassRelatedTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+package org.apache.harmony.test.reliability.api.security;
+
+import java.lang.reflect.Member;
+import java.security.Principal;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+import org.apache.harmony.test.reliability.share.ClassMultiTestBase;
+
+/**
+ * GOAL: Test security related functionality on the basis of loaded classed
+ * see additional description in ClassMultiBas
+ *
+ * The test does:
+ * a. finds all class files from JRE
+ * b. tries to load all these classes
+ * c. eprforms sveral security related operations like checkMemberAccess on every
+ * loaded class
+ *
+ * No hangs, fails, crashes or hangs are expected.
+ * Note: testContent is able to be extended to any other operations avalaible
+ * with j.l.Class
+ */
+
+public class SecurityClassRelatedTest extends ClassMultiTestBase{
+ SecurityManager sm = null;
+ Subject sbj = null;
+
+ public static void main(String[] args){
+ System.exit(new SecurityClassRelatedTest().test(args));
+ }
+
+ public void initCycle() {
+ sm = new SecurityManager();
+ sbj = new Subject();
+ }
+ public void releaseCycle() {
+ // do nothing
+ }
+
+ public void testContent(Class cls) {
+ sm.checkAccess(Thread.currentThread());
+
+ try{
+ sm.checkMemberAccess(cls, Member.PUBLIC);
+ } catch(SecurityException e){
+ // Expected
+ } catch (Throwable e){
+ log.add("Failed to checkMemberAccess on class " + cls.getName() + " Reason: " + e.getMessage());
+ }
+
+ try{
+ sm.checkMemberAccess(cls, Member.DECLARED);
+ } catch(SecurityException e){
+ // Expected
+ } catch (Throwable e){
+ log.add("Failed to checkMemberAccess on class " + cls.getName() + " Reason: " + e.getMessage());
+ }
+
+ Set<Principal> prc = sbj.getPrincipals(cls);
+ Iterator it = prc.iterator();
+ while(it.hasNext()){
+ Principal p = (Principal) it.next();
+ p.getName();
+ }
+
+ Set pc = sbj.getPrivateCredentials(cls);
+ it = pc.iterator();
+ while(it.hasNext()){
+ Object o = it.next();
+ o.hashCode();
+ }
+
+
+ Set<Class> puc = sbj.getPublicCredentials(cls);
+ it = puc.iterator();
+ while(it.hasNext()){
+ Class c = (Class) it.next();
+ c.getName();
+ }
+
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/security/SecurityClassRelatedTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/serialization/SerializableClassesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/serialization/SerializableClassesTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/serialization/SerializableClassesTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/serialization/SerializableClassesTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,454 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Alexey Ignatenko
+ * @version $Revision: 1.1 $
+ */
+
+package org.apache.harmony.test.reliability.api.serialization;
+
+import org.apache.harmony.test.reliability.share.JarFilesScanner;
+import org.apache.harmony.test.reliability.share.Test;
+import java.io.File;
+import java.io.NotSerializableException;
+import java.io.OutputStream;
+import java.io.InputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+/*
+ * Goal: check that serialization of instances of J2SE serializable classes
+ * works as expected (ho crashes, hangs, etc.) in multi-threaded environment.
+ *
+ * The test does:
+ *
+ * 1. Reads parameters:
+ * param[1] - number of serialization threads
+ * param[2] - number of deserialization threads
+ * param[3] - directory where serizliation files will be created
+ *
+ * 2. Starts param[1] "controlling" threads, each thread:
+ *
+ * 1. Starts single serialization thread, which:
+ *
+ * a. Instantiates serializable classes. If instance of a class can not be created,
+ * then, it is ignored, otherwise,
+ *
+ * b. Writes created object into .ser file.
+ *
+ * 2. Waits for completion of the serializing thread. If serialization passed ok, then:
+ *
+ * 3. Starts param[2] deserialization threads, each of the threads:
+ *
+ * a. Reads an object from file.
+ *
+ * b. Checks that its class is the same as the class of the original (serialized) object.
+ *
+ * 4. Finally, removes created .ser file.
+ *
+ */
+
+public class SerializableClassesTest extends Test {
+
+ int NUMBER_OF_THREADS = 3;
+ int NUMBER_OF_SUBTHREADS = 10;
+ String OUT_DIR_NAME = ".";
+ Class jlSerializableClass = null;
+
+ volatile boolean failed = false;
+
+ public static void main(String[] args) {
+ System.exit(new SerializableClassesTest().test(args));
+ }
+
+ public int test(String[] params) {
+
+ parseParams(params);
+ try {
+ jlSerializableClass = Class.forName("java.io.Serializable");
+ } catch (ClassNotFoundException e1) {
+ log.add("Failed to load java.io.Serializable class");
+ e1.printStackTrace();
+ return fail("");
+ }
+ failed = false;
+
+ Thread thrds[] = new Thread[NUMBER_OF_THREADS];
+
+ // run NUMBER_OF_THREADS of threads, each of the RunSerializationThread thread
+ // does serialization of objects of serializable classes and then starts
+ // NUMBER_OF_SUBTHREADS of threads, each deserializing the objects
+
+ for (int i = 0; i < thrds.length; i++) {
+ thrds[i] = new RunSerializationThread(this);
+ thrds[i].start();
+ }
+
+ for (int j = 0; j < thrds.length; j++) {
+ try {
+ thrds[j].join();
+ } catch (InterruptedException e) {
+ log.add("" + e.getMessage() + " exception while joining " + j + "-th thread");
+ failed = true;
+ }
+ }
+
+ if (failed) {
+ return fail("FAILED");
+ }
+ return pass("OK");
+ }
+
+
+ public void parseParams(String[] params) {
+ if (params.length >= 1) {
+ NUMBER_OF_THREADS = Integer.parseInt(params[0]);
+ }
+ if (params.length >= 2) {
+ NUMBER_OF_SUBTHREADS = Integer.parseInt(params[1]);
+ }
+ if (params.length >= 3) {
+ OUT_DIR_NAME = params[2];
+ }
+ }
+}
+
+class RunSerializationThread extends Thread {
+
+ SerializableClassesTest base;
+
+ RunSerializationThread(SerializableClassesTest base){
+ this.base = base;
+ }
+
+ public void run(){
+ Hashtable<Object, Object> ht = new Hashtable<Object, Object>();
+
+ // First, do serialization into a file in a single SerializerThread thread
+
+ SerializerThread serializerThread = new SerializerThread(base, base.OUT_DIR_NAME);
+
+ serializerThread.start();
+ try {
+ serializerThread.join();
+ } catch (InterruptedException ie){
+ }
+
+ // If serialization passed with no problems, then, Second step - start
+ // NUMBER_OF_SUBTHREADS of threads which do deserialization from single file
+ // in parallel
+
+ if (serializerThread.failed == false){
+
+ SerThread[] t = new SerThread[base.NUMBER_OF_SUBTHREADS];
+
+ for (int i = 0; i < t.length; ++i){
+ t[i] = new DeSerializerThread(base, serializerThread.getSerFileName());
+ t[i].start();
+ }
+
+ for (int i = 0; i < t.length; ++i){
+ try {
+ t[i].join();
+ } catch (InterruptedException ie){
+ }
+ }
+
+ } else {
+ base.log.add("Thread " + this.getId() + ": no deserialization due to failure in serialization");
+ }
+
+ // Finally, remove created by the serizliation thread (SerializerThread) files
+
+ serializerThread.deleteSerFile();
+ }
+}
+
+abstract class SerThread extends Thread {
+
+ SerializableClassesTest base;
+
+ ArrayList<String> classNames;
+
+ volatile boolean failed = false;
+
+ SerThread(SerializableClassesTest base){
+ this.base = base;
+ }
+
+ // Receives a list of classes whose instances to be created and serialized
+ void getClassNames() {
+ classNames = ClassContainer.getSerializableClassNames();
+ }
+
+
+ public void run(){
+ getClassNames();
+ try {
+ createStreams();
+ int instantiated = 0, noninstantiated = 0;
+ for (int i = 0; i < classNames.size(); ++i){
+ Object o;
+ try {
+ o = instantiate(classNames.get(i));
+ if (o == null){
+ continue;
+ }
+ ++instantiated;
+ } catch (Throwable ex) {
+ // ex.printStackTrace();
+ // System.out.println(" Failed to instantiate: " + classNames.get(i));
+ ++noninstantiated;
+ continue;
+ }
+ process(classNames.get(i), o); // <-- this is where serialization and deserialization runs
+ }
+ // System.out.println("Instantiated " + instantiated +
+ // ", failed to create instance " + noninstantiated + " classes");
+ } catch (Throwable t){
+ // t.printStackTrace();
+ base.log.add("Thread " + this.getId() + ", unexpected exception: " + t + ", with message: " + t.getMessage());
+ t.printStackTrace();
+ base.failed = true;
+ failed = true;
+ } finally {
+ closeStreams();
+ }
+ }
+
+ abstract void process(String className, Object object) throws Throwable;
+
+ Object instantiate(String className) throws Throwable {
+ Class c = Class.forName(className);
+ if (!checkSerializableAndNotAbstract(c)){
+ return null;
+ }
+ Object o = null;
+ try{
+ o = c.newInstance();
+ }catch (Throwable e){
+ // Ignore
+ return null;
+ }
+ //System.out.println(className);
+ return o;
+ }
+
+ // Functions checks that class has Serializable interface and not abstract
+ boolean checkSerializableAndNotAbstract(Class c){
+
+ Class []intfs = c.getInterfaces();
+ // try to find jlSerializableClass in interfaces
+ for (int i = 0; i < intfs.length; i++){
+ if (intfs[i].equals(base.jlSerializableClass)){
+ int md = c.getModifiers();
+ if (Modifier.isAbstract(md)){
+ return false;
+ }
+ return true;
+ }
+ }
+
+ // jlSerializableClass not found - try to do find it in base class
+ Class baseCls = c.getSuperclass();
+ if (baseCls != null){
+ return checkSerializableAndNotAbstract(baseCls);
+ }
+
+ return false;
+ }
+
+ abstract void createStreams() throws Exception;
+ abstract void closeStreams();
+}
+
+
+class SerializerThread extends SerThread {
+ ObjectOutputStream oos;
+ OutputStream os;
+ String fileName;
+ String outDir;
+
+ SerializerThread(SerializableClassesTest base, String outDir){
+ super(base);
+ this.outDir = outDir;
+ }
+
+ void process(String className, Object object) throws Throwable {
+ try {
+ oos.writeObject(object);
+ // store class and its serialized object in order to compare class of deserialized
+ // object - later, in DeSerializerThread-s
+ //System.out.println(object.getClass().getName() + " : " + fileName);
+ } catch (NullPointerException e){
+ // skip
+ } catch (NotSerializableException e){
+ // skip - the test is not intendent to check NotSerializableException
+ } catch (Throwable t) {
+ base.log.add("Thread " + this.getId() + ": serialization of " + className + ": unexpected exception " + t);
+ throw t;
+ }
+ }
+
+ void createStreams() throws Exception {
+ this.oos = new ObjectOutputStream(createOutputStream());
+ }
+
+ OutputStream createOutputStream() throws Exception {
+ this.fileName = createSerFile().getAbsolutePath();
+ return (this.os = new FileOutputStream(fileName));
+ }
+
+ File createSerFile(){
+ File f = null;
+ synchronized (base){
+ f = new File(new File(outDir).getAbsolutePath() + File.separator +
+ "SerializableClassesTest" + File.separator + this.getId() + "_" + this.hashCode() + "_file.ser");
+ if (f.exists()){
+ f.delete();
+ } else {
+ File f2 = new File(f.getParent());
+ f2.mkdirs();
+ }
+ }
+ return f;
+ }
+
+ String getSerFileName(){
+ return this.fileName;
+ }
+
+ void deleteSerFile(){
+ File f = new File(fileName);
+ synchronized(base){
+ f.delete();
+ }
+ }
+
+ void closeStreams(){
+ if (os != null){
+ try {
+ this.os.close();
+ } catch (IOException ioe){
+ }
+ }
+ if (oos != null) {
+ try {
+ this.oos.close();
+ } catch (IOException ioe){
+ }
+ }
+ }
+}
+
+class DeSerializerThread extends SerThread {
+
+ ObjectInputStream ois;
+ InputStream is;
+ String fileName;
+
+ DeSerializerThread(SerializableClassesTest base, String fileName){
+ super(base);
+ this.fileName = fileName;
+ }
+
+ void process(String className, Object object) throws Throwable {
+ try {
+ Object deserializedObject = null;
+ try{
+ deserializedObject = ois.readObject();
+ } catch(IOException e){
+ // skip
+ return;
+ }
+ if (deserializedObject == null){
+ return;
+ }
+
+ synchronized(deserializedObject){ // just for additional testing, no special meaning
+ Thread.yield();
+ if (className == deserializedObject.getClass().getName()){
+ base.log.add("Thread " + this.getId() + ", deserialization of: " + className +
+ ": readObject() returned instance of " + deserializedObject.getClass() +
+ "instead of expected " + className + " : " + fileName);
+ base.failed = true;
+ failed = true;
+ }
+ //deserializedObject.notifyAll();
+ }
+ } catch (Throwable t) {
+ base.log.add("Deserialization of " + className + ": unexpected exception " + t);
+ throw t;
+ }
+ }
+
+ void createStreams() throws Exception {
+ this.ois = new ObjectInputStream(createInputStream());
+ }
+
+ InputStream createInputStream() throws Exception {
+ return (this.is = new FileInputStream(this.fileName));
+ }
+
+ void closeStreams(){
+ if (ois != null){
+ try {
+ this.ois.close();
+ } catch (IOException ioe){
+ }
+ }
+ if (is != null){
+ try {
+ this.is.close();
+ } catch (IOException ioe){
+ }
+ }
+ }
+}
+
+
+class ClassContainer {
+
+ static ArrayList<String> serializableClassNamesAL = null;
+
+ static synchronized ArrayList<String> getSerializableClassNames() {
+ if (serializableClassNamesAL == null){
+ serializableClassNamesAL = initAL();
+ }
+ return serializableClassNamesAL;
+ }
+
+ static ArrayList<String> initAL() {
+ ArrayList<String> al = JarFilesScanner.getClassFilesInJRE();
+ for (int i = 0; i< al.size(); i++){
+ String nm = al.get(i);
+ nm = nm.replace("/", ".");
+ nm = nm.replace("\\", ".");
+ nm = nm.replace(".class", "");
+ al.set(i, nm);
+ }
+ return al;
+ }
+
+}
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/api/serialization/SerializableClassesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/ClassMultiTestBase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/ClassMultiTestBase.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/ClassMultiTestBase.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/ClassMultiTestBase.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+/**
+ * GOAL: the test is intendent to process different operations on classes loaded
+ * from jar files in JRE folder
+ *
+ * passed parameters:
+ * parameter[0] - number of threads to launch for parallel loading and processing Classes
+ */
+
+package org.apache.harmony.test.reliability.share;
+
+import java.util.ArrayList;
+import org.apache.harmony.test.reliability.share.Test;
+import org.apache.harmony.test.reliability.share.JarFilesScanner;
+
+
+public abstract class ClassMultiTestBase extends Test implements Runnable{
+ volatile boolean failed = false;
+ final static String classFilesExt = ".class";
+ final static char slashCharDelimiter1 = '/';
+ final static char slashCharDelimiter2 = '\\';
+ final static char dotCharDelimiter = '.';
+ final static int NUMBER_OF_THREADS = 3;
+ int numberOfThreads = NUMBER_OF_THREADS;
+ int classCounter = 0;
+ ArrayList<String> jarFiles;
+
+ public abstract void initCycle();
+ public abstract void releaseCycle();
+ public abstract void testContent(Class cls);
+
+ public int test(String []args){
+ parseParams(args);
+ jarFiles = new JarFilesScanner().getClassFilesInJRE();
+ initCycle();
+
+ Thread[] thrds = new Thread[numberOfThreads];
+ for (int i = 0; i< thrds.length; i++){
+ thrds[i] = new Thread(this);
+ thrds[i].start();
+ }
+
+ for (int i = 0; i< thrds.length; i++){
+ try {
+ thrds[i].join();
+ } catch (InterruptedException e) {
+ failed = true;
+ log.add("Failed to join thread " + e);
+ }
+ }
+
+ releaseCycle();
+
+ if (failed){
+ return fail("FAILED");
+ }
+ //System.out.println("Number of classes tested "+ classCounter);
+ return pass("OK");
+ }
+
+
+ public void run(){
+ for (int i=0; i<jarFiles.size(); i++){
+ Class jlClass = null;
+ String classPureName = jarFiles.get(i).substring(0, jarFiles.get(i).length()-classFilesExt.length());
+ classPureName = classPureName.replace(slashCharDelimiter1, dotCharDelimiter);
+ classPureName = classPureName.replace(slashCharDelimiter2, dotCharDelimiter);
+ try {
+ // do not initialize loaded classes
+ jlClass = Class.forName(classPureName, false, this.getClass().getClassLoader());
+ } catch (Throwable e) {
+ // DO NOT CONSIDER failed to load classes - the test GOAL is different
+ // see HARMONY-2615 for issues
+ continue;
+ }
+ if (jlClass != null){
+ classCounter++;
+ try{
+ testContent(jlClass);
+ } catch (Throwable e){
+ if (e.getClass().getName() == "java.lang.InternalError") continue; // enables 100% pass on RI
+ log.add("Failed to test class: " + classPureName + " Issue:" + e);
+ e.printStackTrace();
+ failed = true;
+ }
+ }
+ }
+ }
+
+ public void parseParams(String[] params) {
+ if (params.length >= 1) {
+ numberOfThreads = Integer.parseInt(params[0]);
+ }
+ }
+
+}
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/ClassMultiTestBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/JarFilesScanner.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/JarFilesScanner.java?view=diff&rev=556849&r1=556848&r2=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/JarFilesScanner.java (original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/share/JarFilesScanner.java Tue Jul 17 01:42:18 2007
@@ -41,7 +41,7 @@
static ArrayList<String> classFiles = new ArrayList<String>(); // contains names of found class files
static Boolean cache = false;
- public ArrayList<String> getJarFilesInJRE(){
+ public static ArrayList<String> getJarFilesInJRE(){
if (cache == false) {
String rootDir = getDirToScanForJarFiles();
scanDirForJarFiles(rootDir);
@@ -50,7 +50,7 @@
return jarFiles;
}
- public ArrayList<String> getClassFilesInJRE(){
+ public static ArrayList<String> getClassFilesInJRE(){
if (cache == false)
{
getJarFilesInJRE();
@@ -74,11 +74,11 @@
return classFiles;
}
- String getDirToScanForJarFiles() {
+ static String getDirToScanForJarFiles() {
return System.getProperty("java.home");
}
- void scanDirForJarFiles(String rootDir) {
+ static void scanDirForJarFiles(String rootDir) {
try {
Modified: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassAttributesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassAttributesTest.java?view=diff&rev=556849&r1=556848&r2=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassAttributesTest.java (original)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassAttributesTest.java Tue Jul 17 01:42:18 2007
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
/**
* @author Aleksey Ignatenko
* @version $Revision: 1.0 $
*/
/**
- * GOAL: the test checks that for each loaded class (from "java.home") invocation of java.lang.Class methods
+ * GOAL: the test checks that for each loaded class (from "java.home") invocation of java.lang.Class methods
* in multiple threads running in parallel does not cause unexpected errors (crashes, hangs, exceptions).
*
* NOTE: see additional description in ClassMultiBase class.
@@ -42,14 +42,22 @@
import java.lang.reflect.GenericSignatureFormatError;
import java.lang.reflect.MalformedParameterizedTypeException;
+import org.apache.harmony.test.reliability.share.ClassMultiTestBase;
public class ClassAttributesTest extends ClassMultiTestBase{
public static void main(String[] args){
System.exit(new ClassAttributesTest().test(args));
}
+
+ public void initCycle() {
+ // do nothing
+ }
+ public void releaseCycle() {
+ // do nothing
+ }
- void testContent(Class cls) {
+ public void testContent(Class cls) {
cls.getName();
cls.getAnnotations();
try{
Added: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassCastTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassCastTest.java?view=auto&rev=556849
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassCastTest.java (added)
+++ harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassCastTest.java Tue Jul 17 01:42:18 2007
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2007 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.
+ */
+
+/**
+ * @author Aleksey Ignatenko
+ * @version $Revision: 1.0 $
+ */
+
+/**
+ * GOAL: Test Class cast functionality
+ * see additional description in ClassMultiBas
+ *
+ * The test does:
+ * a. finds all class files from JRE
+ * b. tries to load all these classes
+ * c. calls compileClass for every successfully loaded Class
+ * d. casting is done not more than RELEASE_CYCLE_TIME_LIMIT minutes (as it could take long on JRE)
+ * e. every loaded class is casted with Class.asSubclass to other loaded classes
+ * g. cast is checked with Class.isAssignableFrom function
+ * d. for every "java." class new Object is created by newInstance and
+ * checked that object has right Class with Class.isInstance()
+ *
+ * No hangs, fails, crashes or hangs are expected.
+ */
+
+package org.apache.harmony.test.reliability.vm.classloading;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.harmony.test.reliability.share.ClassMultiTestBase;
+
+public class ClassCastTest extends ClassMultiTestBase{
+ static final int RELEASE_CYCLE_TIME_LIMIT = 1; //minutes
+ Set<Class> syntMembers = null;
+ long timeStart = 0;
+
+ public static void main(String[] args){
+ System.exit(new ClassCastTest().test(args));
+ }
+
+ public void initCycle() {
+ syntMembers = new HashSet<Class>();
+ timeStart = System.currentTimeMillis();
+ }
+ public void releaseCycle() {
+ // do nothing
+ Iterator it1 = syntMembers.iterator();
+ while (it1.hasNext()){
+ long timePassed = (System.currentTimeMillis() - timeStart) / 1000 / 60; // time in minutes
+ if (timePassed > RELEASE_CYCLE_TIME_LIMIT){
+ break;
+ }
+ Iterator it2 = syntMembers.iterator();
+ Class c1 = (Class) it1.next();
+ while (it2.hasNext()){
+ Class c2 = (Class) it2.next();
+ if (c1.equals(c2)){
+ continue;
+ }
+ try{
+ c1.asSubclass(c2);
+ }catch (ClassCastException e){
+ // Expected
+ continue;
+ }catch(Throwable e){
+ log.add("Unexpected cast exception: " + e.getMessage());
+ return;
+ }
+ // class was casted properly: trying to find custed method in
+ // parent classes via reflection
+ if (!customCheckParent(c1,c2)){
+ log.add("Failed to check cast: " + c1.getName() + " failed to cast to " + c2.getName());
+ }
+ //System.out.println(c1.getName() + " casted to " + c2.getName());
+ }
+
+ // make newInstance only for "java." classes to avoid hangs, avoid "awt" and "swing" to avoid XServer up requirement
+ if (c1.getName().startsWith("java.") && !c1.getName().contains("awt") && !c1.getName().contains("swing")){
+ Object o = null;
+ try {
+ o = c1.newInstance();
+ } catch(IllegalAccessException e){
+ // Expectable
+ continue;
+ } catch (InstantiationException e){
+ // Expectable
+ continue;
+ } catch (ExceptionInInitializerError e){
+ // Expectable
+ continue;
+ } catch (SecurityException e){
+ // Expectable
+ continue;
+ }catch (Exception e){
+ // Expectable - propogated exception from class default constructor
+ continue;
+ }
+ if (!c1.isInstance(o)){
+ log.add("Failed to check instance of " + c1.getName());
+ return;
+ }
+ //System.out.println("OK for " + c1.getName());
+ }
+
+ }
+ }
+
+ boolean customCheckParent(Class c, Class parent){
+ return parent.isAssignableFrom(c);
+ }
+
+ public void testContent(Class cls) {
+ if (cls.getName().contains("$")){
+ return;
+ }
+ synchronized(syntMembers){
+ syntMembers.add(cls);
+ }
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/buildtest/branches/2.0/tests/reliability/src/java/org/apache/harmony/test/reliability/vm/classloading/ClassCastTest.java
------------------------------------------------------------------------------
svn:eol-style = native