Get the harmony test suite building.
Support_Jetty needs to be rewritten in terms of MockWebServer. I've removed the
concurrent tests on the assumption that we'll keep those separate for now (and
that they won't be updated by harmony ever again, even though the true upstream
will).
I've removed all the 'main' methods (which add a dependency on code we don't
have), and I've added the harmony support tree, which was classlib/support
rather than classlib/modules/support, so didn't get included last time.
Change-Id: Ifba2d420bb1cc4c3e4ee76d6a8ee68e7cf846ed9
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..091da0f
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,48 @@
+# -*- mode: makefile -*-
+
+LOCAL_PATH := $(call my-dir)
+
+define all-harmony-test-java-files-under
+ $(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/$(2) -name "*.java" 2> /dev/null)))
+endef
+
+harmony_test_dirs := annotation archive logging math nio nio_char prefs regex support text
+harmony_test_src_files := \
+ $(call all-harmony-test-java-files-under,$(harmony_test_dirs),src/test/java) \
+ $(call all-harmony-test-java-files-under,luni,src/test/{api,impl}/{common,unix})
+
+define harmony-test-resource-dirs
+ $(shell cd $(LOCAL_PATH) && ls -d $(1)/src/test/{java,resources} 2> /dev/null)
+endef
+harmony_test_resource_dirs := \
+ $(call harmony-test-resource-dirs,$(harmony_test_dirs)) \
+ $(call harmony-test-resource-dirs,luni)
+
+harmony_test_javac_flags=-encoding UTF-8
+harmony_test_javac_flags+=-Xmaxwarns 9999999
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(harmony_test_src_files)
+LOCAL_JAVA_RESOURCE_DIRS := $(harmony_test_resource_dirs)
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES := core core-junit
+LOCAL_JAVACFLAGS := $(harmony_test_javac_flags)
+LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE := apache-harmony-tests
+LOCAL_NO_EMMA_INSTRUMENT := true
+LOCAL_NO_EMMA_COMPILE := true
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+#ifeq ($(WITH_HOST_DALVIK),true)
+# include $(CLEAR_VARS)
+# LOCAL_SRC_FILES := $(harmony_test_src_files)
+# LOCAL_JAVA_RESOURCE_DIRS := $(harmony_test_resource_dirs)
+# LOCAL_NO_STANDARD_LIBRARIES := true
+# LOCAL_JAVA_LIBRARIES := core-hostdex core-junit #-hostdex
+# LOCAL_JAVACFLAGS := $(harmony_test_javac_flags)
+# LOCAL_MODULE_TAGS := tests
+# LOCAL_MODULE := apache-harmony-tests-host
+# LOCAL_NO_EMMA_INSTRUMENT := true
+# LOCAL_NO_EMMA_COMPILE := true
+# include $(BUILD_HOST_JAVA_LIBRARY)
+#endif
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/GeneratedTest.java b/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/GeneratedTest.java
deleted file mode 100644
index 50820fd..0000000
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/GeneratedTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.harmony.annotation.tests.javax.annotation;
-
-import javax.annotation.Generated;
-
-import junit.framework.TestCase;
-
-public class GeneratedTest extends TestCase {
- public void testGenerated() throws SecurityException, NoSuchFieldException {
- assertTrue(Generated.class.isAnnotation());
- }
-}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PostConstructTest.java b/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PostConstructTest.java
deleted file mode 100644
index 518a061..0000000
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PostConstructTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.harmony.annotation.tests.javax.annotation;
-
-import javax.annotation.PostConstruct;
-
-import junit.framework.TestCase;
-
-public class PostConstructTest extends TestCase {
- public void testPostConstruct() {
- assertTrue(PostConstruct.class.isAnnotation());
- }
-}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourceTest.java b/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourceTest.java
deleted file mode 100644
index 0fe4143..0000000
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourceTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.harmony.annotation.tests.javax.annotation;
-
-import javax.annotation.Resource;
-
-import junit.framework.TestCase;
-
-public class ResourceTest extends TestCase {
- public void testResource() {
- assertTrue(Resource.class.isAnnotation());
- }
-}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/Resource_AuthenticationTypeTest.java b/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/Resource_AuthenticationTypeTest.java
deleted file mode 100644
index 2add1b7..0000000
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/Resource_AuthenticationTypeTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.harmony.annotation.tests.javax.annotation;
-
-import javax.annotation.Resource;
-
-import junit.framework.TestCase;
-
-public class Resource_AuthenticationTypeTest extends TestCase {
- public void testValues() {
- Resource.AuthenticationType[] types = Resource.AuthenticationType
- .values();
- assertEquals(2, types.length);
- // the result array should be ordered
- assertEquals(Resource.AuthenticationType.CONTAINER, types[0]);
- assertEquals(Resource.AuthenticationType.APPLICATION, types[1]);
- }
-
- public void testValueOf() {
- Resource.AuthenticationType type = Resource.AuthenticationType
- .valueOf("CONTAINER");
- assertEquals(Resource.AuthenticationType.CONTAINER, type);
-
- type = Resource.AuthenticationType.valueOf("APPLICATION");
- assertEquals(Resource.AuthenticationType.APPLICATION, type);
-
- try {
- type = Resource.AuthenticationType.valueOf(null);
- fail("should throw NPE");
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- type = Resource.AuthenticationType.valueOf("wrong name");
- fail("should throw IAE");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/processing/AbstractProcessorTest.java b/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/processing/AbstractProcessorTest.java
deleted file mode 100644
index fdaa7d4..0000000
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/processing/AbstractProcessorTest.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * 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.
- */
-package org.apache.harmony.annotation.tests.javax.annotation.processing;
-
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Completion;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.Elements;
-import javax.lang.model.util.Types;
-
-import junit.framework.TestCase;
-
-public class AbstractProcessorTest extends TestCase {
-
- AbstractProcessor processor;
- AbstractProcessor annotatedProcessor;
-
- public void setUp() {
- processor = new MockAbstractProcessor();
- annotatedProcessor = new MockAbstractProcessorAnnotated();
- }
-
- /**
- * @tests javax.annotation.processing.AbstractProcessor.getSupportedOptions()
- */
- public void test_getSupportedOptions() {
- // check default options
- Set<String> supportedOptions = processor.getSupportedOptions();
- assertEquals(0, supportedOptions.size());
- // set should be unmodifiable
- try {
- supportedOptions.add("test");
- fail("Returned supported options set is not unmodifiable");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- // check annotated options
- supportedOptions = annotatedProcessor.getSupportedOptions();
- assertEquals(2, supportedOptions.size());
- assertTrue(supportedOptions.contains("option.one"));
- assertTrue(supportedOptions.contains("option.two"));
- // set should be unmodifiable
- try {
- supportedOptions.add("test");
- fail("Returned supported options set is not unmodifiable");
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
-
- /**
- * @tests javax.annotation.processing.AbstractProcessor.getSupportedAnnotationTypes()
- */
- public void test_getSupportedAnnotationTypes() {
- // check default types
- Set<String> supportedTypes = processor.getSupportedAnnotationTypes();
- assertEquals(0, supportedTypes.size());
- // set should be unmodifiable
- try {
- supportedTypes.add("test");
- fail("Returned supported annotation types set is not unmodifiable");
- } catch (UnsupportedOperationException e) {
- // expected
- }
-
- // check annotated types
- supportedTypes = annotatedProcessor.getSupportedAnnotationTypes();
- assertEquals(3, supportedTypes.size());
- assertTrue(supportedTypes.contains("type.one"));
- assertTrue(supportedTypes.contains("type.two"));
- assertTrue(supportedTypes.contains("type2.*"));
- // set should be unmodifiable
- try {
- supportedTypes.add("test");
- fail("Returned supported annotation types set is not unmodifiable");
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
-
- /**
- * @tests javax.annotation.processing.AbstractProcessor.getSupportedSourceVersion()
- */
- public void test_getSupportedSourceVersion() {
- // check default source version
- assertEquals(SourceVersion.RELEASE_6, processor
- .getSupportedSourceVersion());
-
- // check annotated version
- assertEquals(SourceVersion.RELEASE_5, annotatedProcessor
- .getSupportedSourceVersion());
- }
-
- /**
- * @tests javax.annotation.processing.AbstractProcessor.init(
- * javax.annotation.processing.ProcessingEnvironment)
- */
- public void test_init() {
- try {
- processor.init(null);
- fail("Calling init(null) should throw NPE");
- } catch (NullPointerException e) {
- // expected
- }
- ProcessingEnvironment processingEnv = new MockProcessingEnvironment();
- processor.init(processingEnv);
-
- assertEquals(processingEnv, ((MockAbstractProcessor) processor)
- .getEnvironment());
-
- try {
- processor.init(processingEnv);
- fail("Calling init twice should throw IllegalStateException");
- } catch (IllegalStateException e) {
- // expected
- }
-
- try {
- processor.init(new MockProcessingEnvironment());
- fail("Calling init twice should throw IllegalStateException");
- } catch (IllegalStateException e) {
- // expected
- }
- }
-
- /**
- * @tests javax.annotation.processing.AbstractProcessor.isInitialized()
- */
- public void test_isInitialized() {
- assertFalse(((MockAbstractProcessor) processor).isInitialized());
- processor.init(new MockProcessingEnvironment());
- assertTrue(((MockAbstractProcessor) processor).isInitialized());
- }
-
- /**
- * @tests javax.annotation.processing.AbstractProcessor.getCompletions()
- */
- public void test_getCompletions() {
- // check that the default implementation returns an empty iterator
- Iterable<? extends Completion> completions = processor.getCompletions(
- null, null, null, null);
- assertFalse(completions.iterator().hasNext());
- }
-
- class MockAbstractProcessor extends AbstractProcessor {
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- return false;
- }
-
- public ProcessingEnvironment getEnvironment() {
- return processingEnv;
- }
-
- public boolean isInitialized() {
- return super.isInitialized();
- }
- }
-
- @SupportedSourceVersion(SourceVersion.RELEASE_5)
- @SupportedAnnotationTypes( { "type.one", "type.two", "type2.*" })
- @SupportedOptions( { "option.one", "option.two", "option.one" })
- class MockAbstractProcessorAnnotated extends AbstractProcessor {
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
- return false;
- }
-
- public ProcessingEnvironment getEnvironment() {
- return processingEnv;
- }
-
- public boolean isInitialized() {
- return super.isInitialized();
- }
- }
-
- class MockProcessingEnvironment implements ProcessingEnvironment {
-
- public Elements getElementUtils() {
- return null;
- }
-
- public Filer getFiler() {
- return null;
- }
-
- public Locale getLocale() {
- return null;
- }
-
- public Messager getMessager() {
- return null;
- }
-
- public Map<String, String> getOptions() {
- return null;
- }
-
- public SourceVersion getSourceVersion() {
- return null;
- }
-
- public Types getTypeUtils() {
- return null;
- }
- }
-}
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java
index be28774..537efd6 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -85,7 +85,7 @@
*/
public void test_ConstructorLjava_io_OutputStreamLjava_util_zip_Deflater() throws Exception {
byte byteArray[] = { 1, 3, 4, 7, 8 };
- File f1 = new File("hyts_Constru(OD).tst");
+ File f1 = new File("hyts_ConstruOD.tst");
FileOutputStream fos = new FileOutputStream(f1);
Deflater defl = null;
MyDeflaterOutputStream dos;
@@ -111,7 +111,7 @@
* @tests java.util.zip.DeflaterOutputStream#DeflaterOutputStream(java.io.OutputStream)
*/
public void test_ConstructorLjava_io_OutputStream() throws Exception {
- File f1 = new File("hyts_Constru(O).tst");
+ File f1 = new File("hyts_ConstruO.tst");
FileOutputStream fos = new FileOutputStream(f1);
MyDeflaterOutputStream dos = new MyDeflaterOutputStream(fos);
@@ -134,7 +134,7 @@
int negBuf = -5;
int zeroBuf = 0;
byte byteArray[] = { 1, 3, 4, 7, 8, 3, 6 };
- File f1 = new File("hyts_Constru(ODI).tst");
+ File f1 = new File("hyts_ConstruODI.tst");
FileOutputStream fos = new FileOutputStream(f1);
Deflater defl = null;
MyDeflaterOutputStream dos;
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
index 98419ff..46266c0 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -32,7 +32,7 @@
public class InflaterInputStreamTest extends TestCase {
- // files hyts_constru(O),hyts_constru(OD),hyts_constru(ODI) needs to be
+ // files hyts_construO,hyts_construOD,hyts_construODI needs to be
// included as resources
byte outPutBuf[] = new byte[500];
@@ -63,7 +63,7 @@
int result = 0;
int buffer[] = new int[500];
InputStream infile = Support_Resources
- .getStream("hyts_constru(O).bin");
+ .getStream("hyts_construO.bin");
InflaterInputStream inflatIP = new InflaterInputStream(infile);
@@ -82,7 +82,7 @@
*/
public void test_ConstructorLjava_io_InputStreamLjava_util_zip_Inflater() throws IOException {
byte byteArray[] = new byte[100];
- InputStream infile = Support_Resources.getStream("hyts_constru(OD).bin");
+ InputStream infile = Support_Resources.getStream("hyts_construOD.bin");
Inflater inflate = new Inflater();
InflaterInputStream inflatIP = new InflaterInputStream(infile,
inflate);
@@ -98,7 +98,7 @@
public void test_ConstructorLjava_io_InputStreamLjava_util_zip_InflaterI() throws IOException {
int result = 0;
int buffer[] = new int[500];
- InputStream infile = Support_Resources.getStream("hyts_constru(ODI).bin");
+ InputStream infile = Support_Resources.getStream("hyts_construODI.bin");
Inflater inflate = new Inflater();
InflaterInputStream inflatIP = new InflaterInputStream(infile,
inflate, 1);
@@ -116,7 +116,7 @@
* java.util.zip.Inflater, int)
*/
public void test_ConstructorLjava_io_InputStreamLjava_util_zip_InflaterI_1() throws IOException {
- InputStream infile = Support_Resources.getStream("hyts_constru(ODI).bin");
+ InputStream infile = Support_Resources.getStream("hyts_construODI.bin");
Inflater inflate = new Inflater();
InflaterInputStream inflatIP = null;
try{
@@ -124,21 +124,21 @@
fail("NullPointerException expected");
}catch(NullPointerException NPE){
//expected
- }
+ }
try{
inflatIP = new InflaterInputStream(null, inflate, 1);
fail("NullPointerException expected");
}catch(NullPointerException NPE){
//expected
- }
-
+ }
+
try{
inflatIP = new InflaterInputStream(infile, inflate, -1);
fail("IllegalArgumentException expected");
}catch(IllegalArgumentException iae){
//expected
- }
+ }
}
/**
@@ -171,7 +171,7 @@
int buffer[] = new int[500];
byte orgBuffer[] = { 1, 3, 4, 7, 8 };
InputStream infile = Support_Resources
- .getStream("hyts_constru(OD).bin");
+ .getStream("hyts_construOD.bin");
Inflater inflate = new Inflater();
InflaterInputStream inflatIP = new InflaterInputStream(infile,
inflate);
@@ -195,10 +195,10 @@
*/
public void test_read_LBII() throws IOException {
int result = 0;
- InputStream infile = Support_Resources.getStream("hyts_constru(OD).bin");
+ InputStream infile = Support_Resources.getStream("hyts_construOD.bin");
Inflater inflate = new Inflater();
InflaterInputStream inflatIP = new InflaterInputStream(infile, inflate);
-
+
byte[] b = new byte[3];
try{
result = inflatIP.read(null, 0, 1);
@@ -206,16 +206,16 @@
}catch(NullPointerException npe){
//expected
}
-
+
assertEquals(0, inflatIP.read(b, 0, 0));
-
+
try{
result = inflatIP.read(b, 5, 2); //offset higher
fail("IndexOutOfBoundsException expected");
}catch(IndexOutOfBoundsException iobe){
//expected
}
-
+
inflatIP.close();
try {
inflatIP.read(b, 0, 1); //read after close
@@ -341,7 +341,7 @@
// correct
}
}
-
+
/**
* @tests java.util.zip.InflaterInputStream#skip(long)
*/
@@ -391,7 +391,7 @@
// testing for negative input to skip
InputStream infile = Support_Resources
- .getStream("hyts_constru(OD).bin");
+ .getStream("hyts_construOD.bin");
Inflater inflate = new Inflater();
InflaterInputStream inflatIP = new InflaterInputStream(infile,
inflate, 10);
@@ -406,7 +406,7 @@
// testing for number of bytes greater than input.
InputStream infile2 = Support_Resources
- .getStream("hyts_constru(OD).bin");
+ .getStream("hyts_construOD.bin");
InflaterInputStream inflatIP2 = new InflaterInputStream(infile2);
// looked at how many bytes the skip skipped. It is
@@ -419,7 +419,7 @@
// test for skipping of 2 bytes
InputStream infile3 = Support_Resources
- .getStream("hyts_constru(OD).bin");
+ .getStream("hyts_construOD.bin");
InflaterInputStream inflatIP3 = new InflaterInputStream(infile3);
skip = inflatIP3.skip(2);
assertEquals("the number of bytes returned by skip did not correspond with its input parameters",
diff --git a/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java b/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java
index 48fe267..bfdd82f 100644
--- a/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java
+++ b/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java
@@ -29,7 +29,7 @@
/**
* Test class for java.beans.beancontext.BeanContextServicesSupport.
* <p>
- *
+ *
* @author Sergey A. Krivenko
*/
@@ -48,7 +48,7 @@
/**
* Constructs this test case with the given name.
* <p>
- *
+ *
* @param name -
* The name for this test case.
* <p>
@@ -63,7 +63,7 @@
* Test constructor with BeanContextServices, Locale, boolean, boolean
* parameters.
* <p>
- *
+ *
* @see BeanContextServicesSupport#BeanContextServicesSupport(
* BeanContextServices, Locale, boolean, boolean)
*/
@@ -73,7 +73,7 @@
/**
* Test constructor with BeanContextServices, Locale, boolean parameters
- *
+ *
* @see BeanContextServicesSupport#BeanContextServicesSupport(
* BeanContextServices, Locale, boolean)
*/
@@ -84,7 +84,7 @@
/**
* Test constructor with BeanContextServices, Locale parameters.
* <p>
- *
+ *
* @see BeanContextServicesSupport#BeanContextServicesSupport(
* BeanContextServices, Locale)
*/
@@ -95,7 +95,7 @@
/**
* Test constructor with BeanContextServices parameter.
* <p>
- *
+ *
* @see BeanContextServicesSupport#BeanContextServicesSupport(
* BeanContextServices)
*/
@@ -106,7 +106,7 @@
/**
* * Test constructor with no parameters.
* <p>
- *
+ *
* @see BeanContextServicesSupport#BeanContextServicesSupport()
*/
public void testConstructor() {
@@ -279,7 +279,7 @@
private BeanContextServiceProvider getProvider() {
return new BeanContextServiceProvider() {
-
+
public java.util.Iterator getCurrentServiceSelectors(
BeanContextServices bcs, Class serviceClass) {
@@ -307,16 +307,4 @@
public static Test suite() {
return new TestSuite(BeanContextServicesSupportTest.class);
}
-
- /**
- * Start testing from the command line.
- * <p>
- *
- * @param args -
- * Command line parameters.
- * <p>
- */
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
- }
}
diff --git a/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java b/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java
index c333a8a..da7d210 100644
--- a/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java
+++ b/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java
@@ -46,7 +46,7 @@
/**
* Constructs this test case with the given name.
* <p>
- *
+ *
* @param name -
* The name for this test case.
* <p>
@@ -60,7 +60,7 @@
/**
* * Test constructor with BeanContext, Locale, boolean, boolean parameters.
* <p>
- *
+ *
* @see BeanContextSupport#BeanContextSupport(BeanContext, Locale, boolean,
* boolean)
*/
@@ -71,7 +71,7 @@
/**
* * Test constructor with BeanContext, Locale, boolean parameters.
* <p>
- *
+ *
* @see BeanContextSupport#BeanContextSupport(BeanContext, Locale, boolean)
*/
public void testConstructorBeanContextLocaleboolean() {
@@ -81,7 +81,7 @@
/**
* * Test constructor with BeanContext, Locale parameters.
* <p>
- *
+ *
* @see BeanContextSupport#BeanContextSupport(BeanContext, Locale)
*/
public void testConstructorBeanContextLocale() {
@@ -91,7 +91,7 @@
/**
* * Test constructor with BeanContext parameter.
* <p>
- *
+ *
* @see BeanContextSupport#BeanContextSupport(BeanContext)
*/
public void testConstructorBeanContext() {
@@ -101,7 +101,7 @@
/**
* * Test constructor with no parameters.
* <p>
- *
+ *
* @see BeanContextSupport#BeanContextSupport()
*/
public void testConstructor() {
@@ -205,11 +205,11 @@
* BeanContextChildSupport(); Object obj = new Object(); sup.add(ch);
* sup.add(obj); // Create collection with BCS children that just were
* added java.util.Collection col = new java.util.ArrayList();
- *
+ *
* for (java.util.Iterator it = sup.bcsChildren(); it.hasNext(); ) {
* col.add(it.next()); } // Two collections have the same elements if
* (!sup.containsAll(col)) { fail("True should be returned"); }
- *
+ *
* sup.remove(obj); // Now they are different if (sup.containsAll(col)) {
* fail("False should be returned"); }
*/
@@ -441,7 +441,7 @@
* // Create BeanContext instance BeanContextSupport sup = new
* BeanContextSupport(); // Add a child and then clear sup.add(new
* Object()); sup.clear();
- *
+ *
* if (!sup.isEmpty()) { fail("The collection of children should be
* empty"); }
*/
@@ -495,7 +495,7 @@
/**
* Test method vetoableChange() with PropertyChangeEvent=null parameter.
* <p>
- *
+ *
* @throws Exception
*/
public void test_vetoableChangeLjava_beans_PropertyChangeEvent()
@@ -562,15 +562,4 @@
return new TestSuite(BeanContextSupportTest.class);
}
- /**
- * Start testing from the command line.
- * <p>
- *
- * @param args -
- * Command line parameters.
- * <p>
- */
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
- }
}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
index b893962..8db7888 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -36,7 +36,6 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.apache.harmony.beans.tests.support.SampleBean;
import org.apache.harmony.beans.tests.support.mock.CorruptedSerBean;
@@ -290,7 +289,7 @@
// public void
// testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean_SER()
// throws IOException, ClassNotFoundException {
- //
+ //
// String beanName = MockAppletBean2.class.getName(); BeanContext context =
// new BeanContextSupport(); MockAppletInitializer appInit = new
// MockAppletInitializer(); MockAppletBean2 bean = (MockAppletBean2)
@@ -301,18 +300,18 @@
// assertTrue(appInit.activateHasBeenCalled());
// assertTrue(appInit.initializeHasBeenCalled());
// assertFalse(bean.initHasBeenCalled());
- //
+ //
// }
// public void
// testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean_2()
// throws IOException, ClassNotFoundException {
- //
+ //
// String beanName = MockAppletBean.class.getName(); BeanContext context =
// new BeanContextSupport(); MockAppletInitializer appInit = new
// MockAppletInitializer(); MockAppletBean bean = (MockAppletBean)
// Beans.instantiate(null, beanName, context, null);
- //
+ //
// }
/*
@@ -512,10 +511,6 @@
return new TestSuite(BeansTest.class);
}
- public static void main(String[] args) {
- TestRunner.run(suite());
- }
-
private ClassLoader createSpecificClassLoader() {
return new ClassLoader() {
};
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
index e53d899..65eaf39 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -37,10 +37,6 @@
@SuppressWarnings("unchecked")
public class EncoderTest extends TestCase {
- public static void main(String[] args) throws Exception {
- junit.textui.TestRunner.run(EncoderTest.class);
- }
-
public static class VerboseEncoder extends Encoder {
private PrintWriter out;
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java
index c403651..e16764c 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -30,7 +30,6 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.apache.harmony.beans.tests.support.SampleEvent;
import org.apache.harmony.beans.tests.support.SampleListener;
import org.apache.harmony.beans.tests.support.mock.MockButton;
@@ -227,7 +226,7 @@
assertEquals("setSomeValue", getMethodName());
}
-
+
/**
* fileSampleEvent scenario by throwing RuntimeException
*/
@@ -244,7 +243,7 @@
}
/**
- *
+ *
*/
public static Test suite() {
// TestSuite suite = new TestSuite();
@@ -255,13 +254,6 @@
return new TestSuite(EventHandlerTest.class);
}
- /**
- *
- */
- public static void main(String[] args) {
- TestRunner.run(suite());
- }
-
public void logMethodCall(Object object, String methodName, Object[] params) {
this.object = object;
this.methodName = methodName;
@@ -428,7 +420,7 @@
fail("should throw NPE");
} catch (NullPointerException e) {
- }
+ }
}
/*
@@ -563,7 +555,7 @@
fail("should throw NPE");
} catch (NullPointerException e) {
- }
+ }
}
/*
@@ -1003,8 +995,8 @@
/**
* Checks some invalid property cases Regression for HARMONY-1884
- *
- * Note: this test fails on RI and it is considered as Non-Bug Difference,
+ *
+ * Note: this test fails on RI and it is considered as Non-Bug Difference,
* please refer HARMONY-1884 for details
*/
public void testInvalidProperties_HY1884() {
@@ -1278,7 +1270,7 @@
logMethodCall(this, "setSomeValue", new Object[] { new Integer(
intValue) });
}
-
+
public void throwRuntimeException() {
throw new RuntimeException("forced throw RuntimeException");
}
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
index c7ef440..4fd1d3c 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -26,7 +26,6 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import junit.textui.TestRunner;
import org.apache.harmony.beans.tests.support.SampleException;
import org.apache.harmony.beans.tests.support.TInspectorCluster;
@@ -137,46 +136,39 @@
}
/**
- *
+ *
*/
public static int getTestId() {
return testId;
}
/**
- *
+ *
*/
public static void nextTestId() {
++testId;
}
/**
- *
+ *
*/
public static void methodWithException() throws Exception {
throw new SampleException("sample");
}
/**
- *
+ *
*/
public static void methodWithIntArray(int[] array) {
}
/**
- *
+ *
*/
public static Test suite() {
return new TestSuite(StatementTest.class);
}
- /**
- *
- */
- public static void main(String[] args) {
- TestRunner.run(suite());
- }
-
public class Bean {
private String text;
@@ -585,7 +577,7 @@
t = new Statement(MockObject.class, "new", arguments);
t.execute();
//FIXME: the following 2 commented assert cannot pass neither in RI nor in Harmony (HARMONY-4392),
- // waiting for dev-list approval to fix Harmony implementation following spec
+ // waiting for dev-list approval to fix Harmony implementation following spec
// MockObject.assertCalled("new3", arguments);
Object[] arguments2 = new Object[] { new Integer(1) };
@@ -593,7 +585,7 @@
t.execute();
// MockObject.assertCalled("new1-2", arguments2);
}
-
+
/*
* Test the method execute() with the Class object, a static method name and
* valid arguments.
@@ -759,7 +751,7 @@
* Test the method execute() with a normal object with overloaded methods
* (primitive type VS wrapper class), a valid method name and valid
* arguments.
- *
+ *
* Note: decided by definition position!
*/
public void testExecute_PrimitiveVSWrapper() throws Exception {
@@ -810,7 +802,7 @@
/*
* Test the method execute() with two equal specific methods.
- *
+ *
* Note: decided by definition position!
*/
// public void testExecute_EqualSpecificMethods() throws Exception {
@@ -824,7 +816,7 @@
/*
* Test the method execute() with two equal specific methods but one
* declaring thrown exception.
- *
+ *
* Note: decided by definition position!
*/
// public void testExecute_EqualSpecificMethodsException() throws Exception
@@ -883,8 +875,8 @@
// expected
}
}
-
-
+
+
/*
* Test for special case of overloaded method execute
*/
@@ -894,12 +886,12 @@
Statement t = new Statement(mo, "overloadedMethod", arguments);
t.execute();
MockObject.assertCalled("overloadedmethod", arguments);
-
+
arguments = new Object[] { new MockParent(), new MockParent() };
t = new Statement(mo, "overloadedMethod", arguments);
t.execute();
MockObject.assertCalled("overloadedmethod2", arguments);
-
+
arguments = new Object[] { new MockObject(), new MockObject() };
t = new Statement(mo, "overloadedMethodB", arguments);
try{
@@ -907,13 +899,13 @@
fail("should throw Exception");
}catch(Exception e){
}
-
+
arguments = new Object[] { new MockObject(), new MockParent() };
t = new Statement(mo, "overloadedMethodB", arguments);
t.execute();
MockObject.assertCalled("overloadedmethodB", arguments);
}
-
+
/*
* Test for special case of the same signature but different return type
*/
@@ -1156,13 +1148,13 @@
calledMethod = "new1";
}
}
-
+
public MockObject(String o) {
reset();
calledMethod = "new3";
receivedArguments.add(o);
}
-
+
public MockObject(Object o) {
reset();
calledMethod = "new2";
@@ -1220,42 +1212,42 @@
calledMethod = "methodB2";
receivedArguments.add(new Boolean(b));
}
-
+
public void overloadedMethod(MockObject o1, MockObject o2){
reset();
calledMethod = "overloadedmethod";
receivedArguments.add(o1);
receivedArguments.add(o2);
}
-
+
public void overloadedMethod(MockParent o1, MockParent o2){
reset();
calledMethod = "overloadedmethod2";
receivedArguments.add(o1);
receivedArguments.add(o2);
}
-
+
public void overloadedMethod(MockObject o1, MockParent o2){
reset();
calledMethod = "overloadedmethod2";
receivedArguments.add(o1);
receivedArguments.add(o2);
}
-
+
public void overloadedMethodB(MockObject o1, MockParent o2){
reset();
calledMethod = "overloadedmethodB";
receivedArguments.add(o1);
receivedArguments.add(o2);
}
-
+
public void overloadedMethodB(MockParent o1, MockObject o2){
reset();
calledMethod = "overloadedmethodB2";
receivedArguments.add(o1);
receivedArguments.add(o2);
}
-
+
public static void staticMethod(Object o) {
reset();
calledMethod = "staticMethod";
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
index 7d32b78..d001ba6 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -49,10 +49,6 @@
*/
public class XMLDecoderTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(XMLDecoderTest.class);
- }
-
private InputStream getCodedXML(Class clazz, String xmlFile)
throws Exception {
InputStream refIn;
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
index ec28a9d..a77cb6a 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -66,7 +66,7 @@
public boolean vetoBeanContext = false;
/**
- *
+ *
*/
public MockBeanContextChildSupport() {
super();
@@ -91,7 +91,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextChildSupport#initializeBeanContextResources()
*/
@Override
@@ -101,7 +101,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextChildSupport#releaseBeanContextResources()
*/
@Override
@@ -116,7 +116,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextChildSupport#validatePendingSetBeanContext(java.beans.beancontext.BeanContext)
*/
@Override
@@ -128,10 +128,6 @@
}
}
- public static void main(String[] args) throws Exception {
- junit.textui.TestRunner.run(BeanContextChildSupportTest.class);
- }
-
public void testAddPropertyChangeListener_NullParam() {
BeanContextChildSupport support = new MockBeanContextChildSupport();
support.addPropertyChangeListener(null, new MockPropertyChangeListener());
@@ -916,7 +912,7 @@
/**
* * Test constructor with BeanContextChild parameter.
* <p>
- *
+ *
* @see BeanContextChildSupport#BeanContextChildSupport(BeanContextChild)
*/
public void testConstructorBeanContextChild() throws Exception {
@@ -926,7 +922,7 @@
/**
* * Test constructor with no parameters.
* <p>
- *
+ *
* @see BeanContextChildSupport#BeanContextChildSupport()
*/
public void testConstructor() throws Exception {
@@ -945,7 +941,7 @@
assertNotNull("BeanContext should not be null", sup.getBeanContext());
}
-
+
public void testSetBeanContextBeanContextWithPropertyVetoException()
throws Exception {
MyBeanContextChildSupport myBeanContextChildSupport = new MyBeanContextChildSupport();
@@ -955,39 +951,39 @@
try {
myBeanContextChildSupport.setBeanContext(beanContext);
fail("should throw PropertyVetoException");
- } catch (PropertyVetoException e) {
+ } catch (PropertyVetoException e) {
// expected
}
assertTrue(myBeanContextChildSupport.getRejectedSetBCOnce());
assertNull(myBeanContextChildSupport.getBeanContext());
-
+
myBeanContextChildSupport.setBeanContext(beanContext);
assertFalse(myBeanContextChildSupport.getRejectedSetBCOnce());
assertNotNull(myBeanContextChildSupport.getBeanContext());
-
+
try {
myBeanContextChildSupport.setBeanContext(new BeanContextSupport());
fail("should throw PropertyVetoException");
} catch (PropertyVetoException e) {
// expected
}
-
+
myBeanContextChildSupport
.removeVetoableChangeListener("beanContext", vcl);
myBeanContextChildSupport.setBeanContext(beanContext);
assertTrue(myBeanContextChildSupport.getRejectedSetBCOnce());
assertSame(beanContext, myBeanContextChildSupport.getBeanContext());
}
-
-
- class MyVetoableChangeListener implements VetoableChangeListener
- {
- public void vetoableChange(PropertyChangeEvent arg0) throws PropertyVetoException {
- throw new PropertyVetoException("TESTSTRING", null);
- }
+
+ class MyVetoableChangeListener implements VetoableChangeListener
+ {
+
+ public void vetoableChange(PropertyChangeEvent arg0) throws PropertyVetoException {
+ throw new PropertyVetoException("TESTSTRING", null);
+ }
}
-
+
class MyBeanContextChildSupport extends BeanContextChildSupport {
public boolean getRejectedSetBCOnce() {
return rejectedSetBCOnce;
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java
index 2de7bbd..85cb2fe 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -54,11 +54,7 @@
assertSame(bc, getBeanContext());
assertNull(this.propagatedFrom);
}
-
- }
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BeanContextEventTest.class);
}
public void testBeanContextEvent_NullParam() {
@@ -132,7 +128,7 @@
event.setPropagatedFrom(null);
assertNull(event.getPropagatedFrom());
}
-
+
public void testSerialization() throws Exception {
final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
null, Locale.FRANCE, false, false);
@@ -151,7 +147,7 @@
}
});
}
-
+
public static void assertEqualsSerially(BeanContextServicesSupport orig,
BeanContextServicesSupport ser) {
@@ -197,14 +193,14 @@
}
}
assertEquals(count, serServices.size());
- }
+ }
public void testSerializationComptibility() throws Exception {
final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
null, Locale.ITALY, true, true);
final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
null, Locale.CHINA, true, true);
-
+
BeanContextEvent event = new MockBeanContextEvent(ctx);
event.setPropagatedFrom(ctx2);
SerializationTest.verifyGolden(this, event, new SerializableAssert(){
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java
index e37b333..f90fb3d 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -68,10 +68,6 @@
}
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BeanContextMembershipEventTest.class);
- }
-
public void testBeanContextMembershipEvent_NullParam() {
BeanContext ctx = new MockBeanContext();
Collection<String> c = new ArrayList<String>();
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java
index 4751147..58aef44 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -57,10 +57,6 @@
}
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BeanContextServiceAvailableEventTest.class);
- }
-
public void testBeanContextServiceAvailableEvent_NullParam() {
BeanContextServices services = new MockBeanContextServices();
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
index db72824..7ec9200 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -71,10 +71,6 @@
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BeanContextServiceRevokedEventTest.class);
- }
-
public void testBeanContextServiceRevokedEvent_NullParam() {
BeanContextServices services = new MockBeanContextServices();
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
index e301218..ee147a8 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -107,7 +107,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#initialize()
*/
@Override
@@ -121,7 +121,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextServicesSupport#addService(java.lang.Class,
* java.beans.beancontext.BeanContextServiceProvider, boolean)
*/
@@ -133,7 +133,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#childJustRemovedHook(java.lang.Object,
* java.beans.beancontext.BeanContextSupport.BCSChild)
*/
@@ -145,7 +145,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextServicesSupport#createBCSSServiceProvider(java.lang.Class,
* java.beans.beancontext.BeanContextServiceProvider)
*/
@@ -181,7 +181,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextServicesListener#serviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent)
*/
@Override
@@ -192,7 +192,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextServiceRevokedListener#serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent)
*/
@Override
@@ -202,10 +202,6 @@
}
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BeanContextServicesSupportTest.class);
- }
-
public void testAddBeanContextServicesListener_NullParam() {
MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
try {
@@ -1037,7 +1033,7 @@
provider.records.assertEndOfRecords();
assertNull(l.lastEvent);
}
-
+
/*
* regression test for HARMONY-4272
*/
@@ -1045,8 +1041,8 @@
throws TooManyListenersException {
MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
MockBeanContextChild child = new MockBeanContextChild();
- support.add(child);
- support.releaseService(child, child, new Object());
+ support.add(child);
+ support.releaseService(child, child, new Object());
}
public void testReleaseService() throws TooManyListenersException,
@@ -1283,9 +1279,9 @@
beanContextServicesSupport.add(mockChildBeanContextServicesSupport);
BeanContextServiceRevokedEvent beanContextServiceRevokedEvent = new BeanContextServiceRevokedEvent(new BeanContextServicesSupport(), Collection.class,false);
beanContextServicesSupport.serviceRevoked(beanContextServiceRevokedEvent);
- assertTrue(mockChildBeanContextServicesSupport.revokeCalled);
+ assertTrue(mockChildBeanContextServicesSupport.revokeCalled);
}
-
+
public static class MockChildBeanContextServicesSupport extends
BeanContextServicesSupport {
private static final long serialVersionUID = 1L;
@@ -1323,7 +1319,7 @@
(BeanContextServicesSupport) SerializationTester
.getDeserilizedObject(support));
}
-
+
static int serviceRevoked = 0;
@@ -1346,7 +1342,7 @@
public void serviceRevoked(BeanContextServiceRevokedEvent event) {
serviceRevoked++;
}
-
+
public void serviceAvailable(BeanContextServiceAvailableEvent event) {
serviceAvailable++;
}
@@ -1388,7 +1384,7 @@
support.serviceRevoked(revokeEvent);
assertEquals(0, serviceRevoked);
assertEquals(2, serviceAvailable);
-
+
}
public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
@@ -1405,11 +1401,11 @@
support.serviceAvailable(availableEvent);
assertEquals(0, serviceRevoked);
assertEquals(2, serviceAvailable);
-
+
}
-
-
-
+
+
+
public void testSerialization_Compatibility() throws Exception {
BeanContextServicesSupport support = new BeanContextServicesSupport(
null, Locale.ITALY, true, true);
@@ -1438,7 +1434,7 @@
}
});
}
-
+
public static void assertEqualsSerially(BeanContextServicesSupport orig,
BeanContextServicesSupport ser) {
@@ -1486,7 +1482,7 @@
}
assertEquals(count, serServices.size());
}
-
+
//Regression for HARMONY-3830
public void testAddService_with_fireEvent_false() {
MyBeanContextServicesSupport myBeanContextServicesSupport = new MyBeanContextServicesSupport();
@@ -1508,7 +1504,7 @@
public static class MyService implements Serializable {
private static final long serialVersionUID = 1L;
}
-
+
public static class MyBeanContextServiceProvider implements
BeanContextServiceProvider {
public Iterator getCurrentServiceSelectors(BeanContextServices arg0,
@@ -1520,12 +1516,12 @@
Class arg2, Object arg3) {
return null;
}
-
+
public void releaseService(BeanContextServices arg0, Object arg1,
Object arg2) {
}
}
-
+
/*
* @see TestCase#setUp()
*/
diff --git a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java
index f6c86b1..06a1027 100644
--- a/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java
+++ b/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -86,11 +86,11 @@
transient MethodInvocationRecords records;
transient boolean vetoAddRemove = false;
-
+
transient boolean waitOnChildInHooks = true;
/**
- *
+ *
*/
public MockBeanContextSupport() {
super();
@@ -198,7 +198,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#bcsPreDeserializationHook(java.io.ObjectInputStream)
*/
@Override
@@ -213,7 +213,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#bcsPreSerializationHook(java.io.ObjectOutputStream)
*/
@Override
@@ -225,7 +225,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#childDeserializedHook(java.lang.Object,
* java.beans.beancontext.BeanContextSupport.BCSChild)
*/
@@ -237,7 +237,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#childJustAddedHook(java.lang.Object,
* java.beans.beancontext.BeanContextSupport.BCSChild)
*/
@@ -257,7 +257,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#childJustRemovedHook(java.lang.Object,
* java.beans.beancontext.BeanContextSupport.BCSChild)
*/
@@ -277,7 +277,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#createBCSChild(java.lang.Object,
* java.lang.Object)
*/
@@ -290,7 +290,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#initialize()
*/
@Override
@@ -304,7 +304,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
@@ -315,7 +315,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#validatePendingAdd(java.lang.Object)
*/
@Override
@@ -329,7 +329,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.beancontext.BeanContextSupport#validatePendingRemove(java.lang.Object)
*/
@Override
@@ -343,7 +343,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent)
*/
@Override
@@ -391,17 +391,6 @@
}
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BeanContextSupportTest.class);
-
- // MockBeanContextSupport support = new MockBeanContextSupport();
- // BeanContextChild childPeer = new MockBeanContextChild();
- // BeanContextProxy child = new MockBeanContextProxy(childPeer);
- // support.add(child);
- // System.out.println(support.records);
- // System.out.println(support.children());
- }
-
public void testAdd_NullParam() {
MockBeanContextSupport support = new MockBeanContextSupport();
@@ -1171,7 +1160,7 @@
final String RESOURCE_NAME = "org/apache/harmony/beans/tests/support/beancontext/mock/mockdata.txt";
URL url = support.getResource(RESOURCE_NAME, child);
assertTrue(url.toString().endsWith(RESOURCE_NAME));
-
+
BeanContextSupport beanContextSupport = new BeanContextSupport();
beanContextSupport.add(child);
url = beanContextSupport.getResource(RESOURCE_NAME, child);
@@ -1313,7 +1302,7 @@
/*
* MockBeanContextSupport support = new MockBeanContextSupport();
* assertFalse(support.needsGui());
- *
+ *
* Component child = new Component() {/* mock
*/
// };
@@ -1883,7 +1872,7 @@
return childSupport;
}
}
-
+
// Regression test for HARMONY-1829
BeanContextSupport obj = new BeanContextSupport();
obj.add(new TestBean());
@@ -2120,7 +2109,7 @@
}
});
}
-
+
private byte[] serialize(Serializable obj) {
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
@@ -2230,7 +2219,7 @@
p.addPropertyChangeListener(s);
p.firePropertyChange(null, new Object(), new Object());
}
-
+
//Regression Test for HARMONY-3757
public void testSelfSerializatoin() throws Exception {
BeanContextSupport beanContextSupport = new BeanContextSupport();
@@ -2241,33 +2230,33 @@
Object obj = oin.readObject();
assertTrue(obj instanceof BeanContextSupport);
}
-
+
public void testAvoidGui() throws Exception
{
MockBeanContextSupport1 mockBeanContextSupport1 = new MockBeanContextSupport1();
mockBeanContextSupport1.setOkToUseGui(false);
assertFalse(mockBeanContextSupport1.avoidingGui());
-
+
mockBeanContextSupport1 = new MockBeanContextSupport1();
mockBeanContextSupport1.setOkToUseGui(true);
assertFalse(mockBeanContextSupport1.avoidingGui());
-
+
mockBeanContextSupport1 = new MockBeanContextSupport1();
Component component = new Button();
mockBeanContextSupport1.add(component);
mockBeanContextSupport1.setOkToUseGui(false);
assertTrue(mockBeanContextSupport1.needsGui());
assertTrue(mockBeanContextSupport1.avoidingGui());
-
+
mockBeanContextSupport1 = new MockBeanContextSupport1();
component = new Button();
- mockBeanContextSupport1.add(component);
+ mockBeanContextSupport1.add(component);
mockBeanContextSupport1.setOkToUseGui(true);
assertTrue(mockBeanContextSupport1.needsGui());
- assertFalse(mockBeanContextSupport1.avoidingGui());
+ assertFalse(mockBeanContextSupport1.avoidingGui());
}
-
-
+
+
public class MockBeanContextSupport1 extends BeanContextSupport
{
private static final long serialVersionUID = 1L;
@@ -2275,7 +2264,7 @@
public void setOkToUseGui(boolean ok)
{
this.okToUseGui = ok;
- }
+ }
}
}
diff --git a/concurrent/README.txt b/concurrent/README.txt
deleted file mode 100644
index f413494..0000000
--- a/concurrent/README.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-The majority of this code base is sourced from the Concurrency Interest site and the
-associated ViewCVS server.
-
-URL: http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/?only_with_tag=JSR166_PFD
\ No newline at end of file
diff --git a/concurrent/src/test/java/AbstractExecutorServiceTest.java b/concurrent/src/test/java/AbstractExecutorServiceTest.java
deleted file mode 100644
index 9393feb..0000000
--- a/concurrent/src/test/java/AbstractExecutorServiceTest.java
+++ /dev/null
@@ -1,807 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.math.BigInteger;
-import java.security.*;
-
-public class AbstractExecutorServiceTest extends JSR166TestCase{
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AbstractExecutorServiceTest.class);
- }
-
- /**
- * A no-frills implementation of AbstractExecutorService, designed
- * to test the submit methods only.
- */
- static class DirectExecutorService extends AbstractExecutorService {
- public void execute(Runnable r) { r.run(); }
- public void shutdown() { shutdown = true; }
- public List<Runnable> shutdownNow() { shutdown = true; return Collections.EMPTY_LIST; }
- public boolean isShutdown() { return shutdown; }
- public boolean isTerminated() { return isShutdown(); }
- public boolean awaitTermination(long timeout, TimeUnit unit) { return isShutdown(); }
- private volatile boolean shutdown = false;
- }
-
- /**
- * execute(runnable) runs it to completion
- */
- public void testExecuteRunnable() {
- try {
- ExecutorService e = new DirectExecutorService();
- TrackedShortRunnable task = new TrackedShortRunnable();
- assertFalse(task.done);
- Future<?> future = e.submit(task);
- future.get();
- assertTrue(task.done);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * Completed submit(callable) returns result
- */
- public void testSubmitCallable() {
- try {
- ExecutorService e = new DirectExecutorService();
- Future<String> future = e.submit(new StringTask());
- String result = future.get();
- assertSame(TEST_STRING, result);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- }
- }
-
- /**
- * Completed submit(runnable) returns successfully
- */
- public void testSubmitRunnable() {
- try {
- ExecutorService e = new DirectExecutorService();
- Future<?> future = e.submit(new NoOpRunnable());
- future.get();
- assertTrue(future.isDone());
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- }
- }
-
- /**
- * Completed submit(runnable, result) returns result
- */
- public void testSubmitRunnable2() {
- try {
- ExecutorService e = new DirectExecutorService();
- Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
- String result = future.get();
- assertSame(TEST_STRING, result);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * A submitted privileged action to completion
- */
- public void testSubmitPrivilegedAction() {
- Policy savedPolicy = null;
- try {
- savedPolicy = Policy.getPolicy();
- AdjustablePolicy policy = new AdjustablePolicy();
- policy.addPermission(new RuntimePermission("getContextClassLoader"));
- policy.addPermission(new RuntimePermission("setContextClassLoader"));
- Policy.setPolicy(policy);
- } catch(AccessControlException ok) {
- return;
- }
- try {
- ExecutorService e = new DirectExecutorService();
- Future future = e.submit(Executors.callable(new PrivilegedAction() {
- public Object run() {
- return TEST_STRING;
- }}));
-
- Object result = future.get();
- assertSame(TEST_STRING, result);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- }
- finally {
- try {
- Policy.setPolicy(savedPolicy);
- } catch(AccessControlException ok) {
- return;
- }
- }
- }
-
- /**
- * A submitted a privileged exception action runs to completion
- */
- public void testSubmitPrivilegedExceptionAction() {
- Policy savedPolicy = null;
- try {
- savedPolicy = Policy.getPolicy();
- AdjustablePolicy policy = new AdjustablePolicy();
- policy.addPermission(new RuntimePermission("getContextClassLoader"));
- policy.addPermission(new RuntimePermission("setContextClassLoader"));
- Policy.setPolicy(policy);
- } catch(AccessControlException ok) {
- return;
- }
-
- try {
- ExecutorService e = new DirectExecutorService();
- Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
- public Object run() {
- return TEST_STRING;
- }}));
-
- Object result = future.get();
- assertSame(TEST_STRING, result);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- }
- finally {
- Policy.setPolicy(savedPolicy);
- }
- }
-
- /**
- * A submitted failed privileged exception action reports exception
- */
- public void testSubmitFailedPrivilegedExceptionAction() {
- Policy savedPolicy = null;
- try {
- savedPolicy = Policy.getPolicy();
- AdjustablePolicy policy = new AdjustablePolicy();
- policy.addPermission(new RuntimePermission("getContextClassLoader"));
- policy.addPermission(new RuntimePermission("setContextClassLoader"));
- Policy.setPolicy(policy);
- } catch(AccessControlException ok) {
- return;
- }
-
-
- try {
- ExecutorService e = new DirectExecutorService();
- Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- throw new IndexOutOfBoundsException();
- }}));
-
- Object result = future.get();
- shouldThrow();
- }
- catch (ExecutionException success) {
- }
- catch (InterruptedException ex) {
- unexpectedException();
- }
- finally {
- Policy.setPolicy(savedPolicy);
- }
- }
-
- /**
- * execute(null runnable) throws NPE
- */
- public void testExecuteNullRunnable() {
- try {
- ExecutorService e = new DirectExecutorService();
- TrackedShortRunnable task = null;
- Future<?> future = e.submit(task);
- shouldThrow();
- }
- catch (NullPointerException success) {
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * submit(null callable) throws NPE
- */
- public void testSubmitNullCallable() {
- try {
- ExecutorService e = new DirectExecutorService();
- StringTask t = null;
- Future<String> future = e.submit(t);
- shouldThrow();
- }
- catch (NullPointerException success) {
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * submit(runnable) throws RejectedExecutionException if
- * executor is saturated.
- */
- public void testExecute1() {
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1));
- try {
-
- for(int i = 0; i < 5; ++i){
- p.submit(new MediumRunnable());
- }
- shouldThrow();
- } catch(RejectedExecutionException success){}
- joinPool(p);
- }
-
- /**
- * submit(callable) throws RejectedExecutionException
- * if executor is saturated.
- */
- public void testExecute2() {
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1));
- try {
- for(int i = 0; i < 5; ++i) {
- p.submit(new SmallCallable());
- }
- shouldThrow();
- } catch(RejectedExecutionException e){}
- joinPool(p);
- }
-
-
- /**
- * Blocking on submit(callable) throws InterruptedException if
- * caller interrupted.
- */
- public void testInterruptedSubmit() {
- final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- p.submit(new Callable<Object>() {
- public Object call() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- shouldThrow();
- } catch(InterruptedException e){
- }
- return null;
- }
- }).get();
- } catch(InterruptedException success){
- } catch(Exception e) {
- unexpectedException();
- }
-
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- } catch(Exception e){
- unexpectedException();
- }
- joinPool(p);
- }
-
- /**
- * get of submitted callable throws Exception if callable
- * interrupted
- */
- public void testSubmitIE() {
- final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
-
- final Callable c = new Callable() {
- public Object call() {
- try {
- p.submit(new SmallCallable()).get();
- shouldThrow();
- } catch(InterruptedException e){}
- catch(RejectedExecutionException e2){}
- catch(ExecutionException e3){}
- return Boolean.TRUE;
- }
- };
-
-
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- c.call();
- } catch(Exception e){}
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
-
- joinPool(p);
- }
-
- /**
- * get of submit(callable) throws ExecutionException if callable
- * throws exception
- */
- public void testSubmitEE() {
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
-
- try {
- Callable c = new Callable() {
- public Object call() {
- int i = 5/0;
- return Boolean.TRUE;
- }
- };
-
- for(int i =0; i < 5; i++){
- p.submit(c).get();
- }
-
- shouldThrow();
- }
- catch(ExecutionException success){
- } catch(Exception e) {
- unexpectedException();
- }
- joinPool(p);
- }
-
- /**
- * invokeAny(null) throws NPE
- */
- public void testInvokeAny1() {
- ExecutorService e = new DirectExecutorService();
- try {
- e.invokeAny(null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(empty collection) throws IAE
- */
- public void testInvokeAny2() {
- ExecutorService e = new DirectExecutorService();
- try {
- e.invokeAny(new ArrayList<Callable<String>>());
- } catch (IllegalArgumentException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) throws NPE if c has null elements
- */
- public void testInvokeAny3() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAny(l);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- ex.printStackTrace();
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) throws ExecutionException if no task in c completes
- */
- public void testInvokeAny4() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- e.invokeAny(l);
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) returns result of some task in c if at least one completes
- */
- public void testInvokeAny5() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- String result = e.invokeAny(l);
- assertSame(TEST_STRING, result);
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(null) throws NPE
- */
- public void testInvokeAll1() {
- ExecutorService e = new DirectExecutorService();
- try {
- e.invokeAll(null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(empty collection) returns empty collection
- */
- public void testInvokeAll2() {
- ExecutorService e = new DirectExecutorService();
- try {
- List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
- assertTrue(r.isEmpty());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(c) throws NPE if c has null elements
- */
- public void testInvokeAll3() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAll(l);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * get of returned element of invokeAll(c) throws exception on failed task
- */
- public void testInvokeAll4() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- List<Future<String>> result = e.invokeAll(l);
- assertEquals(1, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- it.next().get();
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(c) returns results of all completed tasks in c
- */
- public void testInvokeAll5() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l);
- assertEquals(2, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- assertSame(TEST_STRING, it.next().get());
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
-
- /**
- * timed invokeAny(null) throws NPE
- */
- public void testTimedInvokeAny1() {
- ExecutorService e = new DirectExecutorService();
- try {
- e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(null time unit) throws NPE
- */
- public void testTimedInvokeAnyNullTimeUnit() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- e.invokeAny(l, MEDIUM_DELAY_MS, null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(empty collection) throws IAE
- */
- public void testTimedInvokeAny2() {
- ExecutorService e = new DirectExecutorService();
- try {
- e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (IllegalArgumentException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) throws NPE if c has null elements
- */
- public void testTimedInvokeAny3() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- ex.printStackTrace();
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) throws ExecutionException if no task completes
- */
- public void testTimedInvokeAny4() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) returns result of some task in c
- */
- public void testTimedInvokeAny5() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertSame(TEST_STRING, result);
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(null) throws NPE
- */
- public void testTimedInvokeAll1() {
- ExecutorService e = new DirectExecutorService();
- try {
- e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(null time unit) throws NPE
- */
- public void testTimedInvokeAllNullTimeUnit() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- e.invokeAll(l, MEDIUM_DELAY_MS, null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(empty collection) returns empty collection
- */
- public void testTimedInvokeAll2() {
- ExecutorService e = new DirectExecutorService();
- try {
- List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertTrue(r.isEmpty());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(c) throws NPE if c has null elements
- */
- public void testTimedInvokeAll3() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * get of returned element of invokeAll(c) throws exception on failed task
- */
- public void testTimedInvokeAll4() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(1, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- it.next().get();
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(c) returns results of all completed tasks in c
- */
- public void testTimedInvokeAll5() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(2, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- assertSame(TEST_STRING, it.next().get());
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll cancels tasks not completed by timeout
- */
- public void testTimedInvokeAll6() {
- ExecutorService e = new DirectExecutorService();
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l, SMALL_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(3, result.size());
- Iterator<Future<String>> it = result.iterator();
- Future<String> f1 = it.next();
- Future<String> f2 = it.next();
- Future<String> f3 = it.next();
- assertTrue(f1.isDone());
- assertFalse(f1.isCancelled());
- assertTrue(f2.isDone());
- assertTrue(f3.isDone());
- assertTrue(f3.isCancelled());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
-}
diff --git a/concurrent/src/test/java/AbstractQueueTest.java b/concurrent/src/test/java/AbstractQueueTest.java
deleted file mode 100644
index cc3aca4..0000000
--- a/concurrent/src/test/java/AbstractQueueTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.locks.*;
-import java.io.*;
-
-public class AbstractQueueTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AbstractQueueTest.class);
- }
-
- static class Succeed extends AbstractQueue<Integer> {
- public boolean offer(Integer x) {
- if (x == null) throw new NullPointerException();
- return true;
- }
- public Integer peek() { return one; }
- public Integer poll() { return one; }
- public int size() { return 0; }
- public Iterator iterator() { return null; } // not needed
- }
-
- static class Fail extends AbstractQueue<Integer> {
- public boolean offer(Integer x) {
- if (x == null) throw new NullPointerException();
- return false;
- }
- public Integer peek() { return null; }
- public Integer poll() { return null; }
- public int size() { return 0; }
- public Iterator iterator() { return null; } // not needed
- }
-
- /**
- * add returns true if offer succeeds
- */
- public void testAddS() {
- Succeed q = new Succeed();
- assertTrue(q.add(two));
- }
-
- /**
- * add throws ISE true if offer fails
- */
- public void testAddF() {
- Fail q = new Fail();
- try {
- q.add(one);
- shouldThrow();
- } catch (IllegalStateException success) {
- }
- }
-
- /**
- * add throws NPE if offer does
- */
- public void testAddNPE() {
- Succeed q = new Succeed();
- try {
- q.add(null);
- shouldThrow();
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * remove returns normally if poll succeeds
- */
- public void testRemoveS() {
- Succeed q = new Succeed();
- q.remove();
- }
-
- /**
- * remove throws NSEE if poll returns null
- */
- public void testRemoveF() {
- Fail q = new Fail();
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success) {
- }
- }
-
-
- /**
- * element returns normally if peek succeeds
- */
- public void testElementS() {
- Succeed q = new Succeed();
- q.element();
- }
-
- /**
- * element throws NSEE if peek returns null
- */
- public void testElementF() {
- Fail q = new Fail();
- try {
- q.element();
- shouldThrow();
- } catch (NoSuchElementException success) {
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- Succeed q = new Succeed();
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * addAll(this) throws IAE
- */
- public void testAddAllSelf() {
- try {
- Succeed q = new Succeed();
- q.addAll(q);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
-
- /**
- * addAll of a collection with null elements throws NPE
- */
- public void testAddAll2() {
- try {
- Succeed q = new Succeed();
- Integer[] ints = new Integer[SIZE];
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll of a collection with any null elements throws NPE after
- * possibly adding some elements
- */
- public void testAddAll3() {
- try {
- Succeed q = new Succeed();
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll throws ISE if an add fails
- */
- public void testAddAll4() {
- try {
- Fail q = new Fail();
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (IllegalStateException success) {}
- }
-
-}
diff --git a/concurrent/src/test/java/AbstractQueuedSynchronizerTest.java b/concurrent/src/test/java/AbstractQueuedSynchronizerTest.java
deleted file mode 100644
index 4f44027..0000000
--- a/concurrent/src/test/java/AbstractQueuedSynchronizerTest.java
+++ /dev/null
@@ -1,1301 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.locks.*;
-import java.io.*;
-
-public class AbstractQueuedSynchronizerTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AbstractQueuedSynchronizerTest.class);
- }
-
- /**
- * A simple mutex class, adapted from the
- * AbstractQueuedSynchronizer javadoc. Exclusive acquire tests
- * exercise this as a sample user extension. Other
- * methods/features of AbstractQueuedSynchronizerTest are tested
- * via other test classes, including those for ReentrantLock,
- * ReentrantReadWriteLock, and Semaphore
- */
- static class Mutex extends AbstractQueuedSynchronizer {
- public boolean isHeldExclusively() { return getState() == 1; }
-
- public boolean tryAcquire(int acquires) {
- assertTrue(acquires == 1);
- return compareAndSetState(0, 1);
- }
-
- public boolean tryRelease(int releases) {
- if (getState() == 0) throw new IllegalMonitorStateException();
- setState(0);
- return true;
- }
-
- public AbstractQueuedSynchronizer.ConditionObject newCondition() { return new AbstractQueuedSynchronizer.ConditionObject(); }
-
- }
-
-
- /**
- * A simple latch class, to test shared mode.
- */
- static class BooleanLatch extends AbstractQueuedSynchronizer {
- public boolean isSignalled() { return getState() != 0; }
-
- public int tryAcquireShared(int ignore) {
- return isSignalled()? 1 : -1;
- }
-
- public boolean tryReleaseShared(int ignore) {
- setState(1);
- return true;
- }
- }
-
- /**
- * A runnable calling acquireInterruptibly
- */
- class InterruptibleSyncRunnable implements Runnable {
- final Mutex sync;
- InterruptibleSyncRunnable(Mutex l) { sync = l; }
- public void run() {
- try {
- sync.acquireInterruptibly(1);
- } catch(InterruptedException success){}
- }
- }
-
-
- /**
- * A runnable calling acquireInterruptibly that expects to be
- * interrupted
- */
- class InterruptedSyncRunnable implements Runnable {
- final Mutex sync;
- InterruptedSyncRunnable(Mutex l) { sync = l; }
- public void run() {
- try {
- sync.acquireInterruptibly(1);
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- }
-
- /**
- * isHeldExclusively is false upon construction
- */
- public void testIsHeldExclusively() {
- Mutex rl = new Mutex();
- assertFalse(rl.isHeldExclusively());
- }
-
- /**
- * acquiring released sync succeeds
- */
- public void testAcquire() {
- Mutex rl = new Mutex();
- rl.acquire(1);
- assertTrue(rl.isHeldExclusively());
- rl.release(1);
- assertFalse(rl.isHeldExclusively());
- }
-
- /**
- * tryAcquire on an released sync succeeds
- */
- public void testTryAcquire() {
- Mutex rl = new Mutex();
- assertTrue(rl.tryAcquire(1));
- assertTrue(rl.isHeldExclusively());
- rl.release(1);
- }
-
- /**
- * hasQueuedThreads reports whether there are waiting threads
- */
- public void testhasQueuedThreads() {
- final Mutex sync = new Mutex();
- Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
- Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
- try {
- assertFalse(sync.hasQueuedThreads());
- sync.acquire(1);
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasQueuedThreads());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasQueuedThreads());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasQueuedThreads());
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.hasQueuedThreads());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * isQueued(null) throws NPE
- */
- public void testIsQueuedNPE() {
- final Mutex sync = new Mutex();
- try {
- sync.isQueued(null);
- shouldThrow();
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * isQueued reports whether a thread is queued.
- */
- public void testIsQueued() {
- final Mutex sync = new Mutex();
- Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
- Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
- try {
- assertFalse(sync.isQueued(t1));
- assertFalse(sync.isQueued(t2));
- sync.acquire(1);
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.isQueued(t1));
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.isQueued(t1));
- assertTrue(sync.isQueued(t2));
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.isQueued(t1));
- assertTrue(sync.isQueued(t2));
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.isQueued(t1));
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.isQueued(t2));
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getFirstQueuedThread returns first waiting thread or null if none
- */
- public void testGetFirstQueuedThread() {
- final Mutex sync = new Mutex();
- Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
- Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
- try {
- assertNull(sync.getFirstQueuedThread());
- sync.acquire(1);
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(t1, sync.getFirstQueuedThread());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(t1, sync.getFirstQueuedThread());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(t2, sync.getFirstQueuedThread());
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- assertNull(sync.getFirstQueuedThread());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * hasContended reports false if no thread has ever blocked, else true
- */
- public void testHasContended() {
- final Mutex sync = new Mutex();
- Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
- Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
- try {
- assertFalse(sync.hasContended());
- sync.acquire(1);
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasContended());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasContended());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasContended());
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasContended());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getQueuedThreads includes waiting threads
- */
- public void testGetQueuedThreads() {
- final Mutex sync = new Mutex();
- Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
- Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
- try {
- assertTrue(sync.getQueuedThreads().isEmpty());
- sync.acquire(1);
- assertTrue(sync.getQueuedThreads().isEmpty());
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getQueuedThreads().contains(t1));
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getQueuedThreads().contains(t1));
- assertTrue(sync.getQueuedThreads().contains(t2));
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.getQueuedThreads().contains(t1));
- assertTrue(sync.getQueuedThreads().contains(t2));
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getQueuedThreads().isEmpty());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getExclusiveQueuedThreads includes waiting threads
- */
- public void testGetExclusiveQueuedThreads() {
- final Mutex sync = new Mutex();
- Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
- Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
- try {
- assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
- sync.acquire(1);
- assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getExclusiveQueuedThreads().contains(t1));
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getExclusiveQueuedThreads().contains(t1));
- assertTrue(sync.getExclusiveQueuedThreads().contains(t2));
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.getExclusiveQueuedThreads().contains(t1));
- assertTrue(sync.getExclusiveQueuedThreads().contains(t2));
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getSharedQueuedThreads does not include exclusively waiting threads
- */
- public void testGetSharedQueuedThreads() {
- final Mutex sync = new Mutex();
- Thread t1 = new Thread(new InterruptedSyncRunnable(sync));
- Thread t2 = new Thread(new InterruptibleSyncRunnable(sync));
- try {
- assertTrue(sync.getSharedQueuedThreads().isEmpty());
- sync.acquire(1);
- assertTrue(sync.getSharedQueuedThreads().isEmpty());
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getSharedQueuedThreads().isEmpty());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getSharedQueuedThreads().isEmpty());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getSharedQueuedThreads().isEmpty());
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.getSharedQueuedThreads().isEmpty());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * tryAcquireNanos is interruptible.
- */
- public void testInterruptedException2() {
- final Mutex sync = new Mutex();
- sync.acquire(1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- sync.tryAcquireNanos(1, MEDIUM_DELAY_MS * 1000 * 1000);
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- try {
- t.start();
- t.interrupt();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * TryAcquire on exclusively held sync fails
- */
- public void testTryAcquireWhenSynced() {
- final Mutex sync = new Mutex();
- sync.acquire(1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertFalse(sync.tryAcquire(1));
- }
- });
- try {
- t.start();
- t.join();
- sync.release(1);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * tryAcquireNanos on an exclusively held sync times out
- */
- public void testAcquireNanos_Timeout() {
- final Mutex sync = new Mutex();
- sync.acquire(1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(sync.tryAcquireNanos(1, 1000 * 1000));
- } catch (Exception ex) {
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- t.join();
- sync.release(1);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * getState is true when acquired and false when not
- */
- public void testGetState() {
- final Mutex sync = new Mutex();
- sync.acquire(1);
- assertTrue(sync.isHeldExclusively());
- sync.release(1);
- assertFalse(sync.isHeldExclusively());
- Thread t = new Thread(new Runnable() {
- public void run() {
- sync.acquire(1);
- try {
- Thread.sleep(SMALL_DELAY_MS);
- }
- catch(Exception e) {
- threadUnexpectedException();
- }
- sync.release(1);
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.isHeldExclusively());
- t.join();
- assertFalse(sync.isHeldExclusively());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * acquireInterruptibly is interruptible.
- */
- public void testAcquireInterruptibly1() {
- final Mutex sync = new Mutex();
- sync.acquire(1);
- Thread t = new Thread(new InterruptedSyncRunnable(sync));
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- sync.release(1);
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * acquireInterruptibly succeeds when released, else is interruptible
- */
- public void testAcquireInterruptibly2() {
- final Mutex sync = new Mutex();
- try {
- sync.acquireInterruptibly(1);
- } catch(Exception e) {
- unexpectedException();
- }
- Thread t = new Thread(new InterruptedSyncRunnable(sync));
- try {
- t.start();
- t.interrupt();
- assertTrue(sync.isHeldExclusively());
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * owns is true for a condition created by sync else false
- */
- public void testOwns() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- final Mutex sync2 = new Mutex();
- assertTrue(sync.owns(c));
- assertFalse(sync2.owns(c));
- }
-
- /**
- * Calling await without holding sync throws IllegalMonitorStateException
- */
- public void testAwait_IllegalMonitor() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- try {
- c.await();
- shouldThrow();
- }
- catch (IllegalMonitorStateException success) {
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * Calling signal without holding sync throws IllegalMonitorStateException
- */
- public void testSignal_IllegalMonitor() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- try {
- c.signal();
- shouldThrow();
- }
- catch (IllegalMonitorStateException success) {
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitNanos without a signal times out
- */
- public void testAwaitNanos_Timeout() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- try {
- sync.acquire(1);
- long t = c.awaitNanos(100);
- assertTrue(t <= 0);
- sync.release(1);
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * Timed await without a signal times out
- */
- public void testAwait_Timeout() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- try {
- sync.acquire(1);
- assertFalse(c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- sync.release(1);
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitUntil without a signal times out
- */
- public void testAwaitUntil_Timeout() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- try {
- sync.acquire(1);
- java.util.Date d = new java.util.Date();
- assertFalse(c.awaitUntil(new java.util.Date(d.getTime() + 10)));
- sync.release(1);
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * await returns when signalled
- */
- public void testAwait() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- c.await();
- sync.release(1);
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- sync.acquire(1);
- c.signal();
- sync.release(1);
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
-
- /**
- * hasWaiters throws NPE if null
- */
- public void testHasWaitersNPE() {
- final Mutex sync = new Mutex();
- try {
- sync.hasWaiters(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength throws NPE if null
- */
- public void testGetWaitQueueLengthNPE() {
- final Mutex sync = new Mutex();
- try {
- sync.getWaitQueueLength(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitingThreads throws NPE if null
- */
- public void testGetWaitingThreadsNPE() {
- final Mutex sync = new Mutex();
- try {
- sync.getWaitingThreads(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * hasWaiters throws IAE if not owned
- */
- public void testHasWaitersIAE() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition());
- final Mutex sync2 = new Mutex();
- try {
- sync2.hasWaiters(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * hasWaiters throws IMSE if not synced
- */
- public void testHasWaitersIMSE() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition());
- try {
- sync.hasWaiters(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitQueueLength throws IAE if not owned
- */
- public void testGetWaitQueueLengthIAE() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition());
- final Mutex sync2 = new Mutex();
- try {
- sync2.getWaitQueueLength(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength throws IMSE if not synced
- */
- public void testGetWaitQueueLengthIMSE() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition());
- try {
- sync.getWaitQueueLength(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitingThreads throws IAE if not owned
- */
- public void testGetWaitingThreadsIAE() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition());
- final Mutex sync2 = new Mutex();
- try {
- sync2.getWaitingThreads(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitingThreads throws IMSE if not synced
- */
- public void testGetWaitingThreadsIMSE() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = (sync.newCondition());
- try {
- sync.getWaitingThreads(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
-
- /**
- * hasWaiters returns true when a thread is waiting, else false
- */
- public void testHasWaiters() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- threadAssertFalse(sync.hasWaiters(c));
- threadAssertEquals(0, sync.getWaitQueueLength(c));
- c.await();
- sync.release(1);
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- sync.acquire(1);
- assertTrue(sync.hasWaiters(c));
- assertEquals(1, sync.getWaitQueueLength(c));
- c.signal();
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- sync.acquire(1);
- assertFalse(sync.hasWaiters(c));
- assertEquals(0, sync.getWaitQueueLength(c));
- sync.release(1);
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength returns number of waiting threads
- */
- public void testGetWaitQueueLength() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- threadAssertFalse(sync.hasWaiters(c));
- threadAssertEquals(0, sync.getWaitQueueLength(c));
- c.await();
- sync.release(1);
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- threadAssertTrue(sync.hasWaiters(c));
- threadAssertEquals(1, sync.getWaitQueueLength(c));
- c.await();
- sync.release(1);
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- sync.acquire(1);
- assertTrue(sync.hasWaiters(c));
- assertEquals(2, sync.getWaitQueueLength(c));
- c.signalAll();
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- sync.acquire(1);
- assertFalse(sync.hasWaiters(c));
- assertEquals(0, sync.getWaitQueueLength(c));
- sync.release(1);
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitingThreads returns only and all waiting threads
- */
- public void testGetWaitingThreads() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- threadAssertTrue(sync.getWaitingThreads(c).isEmpty());
- c.await();
- sync.release(1);
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- threadAssertFalse(sync.getWaitingThreads(c).isEmpty());
- c.await();
- sync.release(1);
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- sync.acquire(1);
- assertTrue(sync.getWaitingThreads(c).isEmpty());
- sync.release(1);
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- sync.acquire(1);
- assertTrue(sync.hasWaiters(c));
- assertTrue(sync.getWaitingThreads(c).contains(t1));
- assertTrue(sync.getWaitingThreads(c).contains(t2));
- c.signalAll();
- sync.release(1);
- Thread.sleep(SHORT_DELAY_MS);
- sync.acquire(1);
- assertFalse(sync.hasWaiters(c));
- assertTrue(sync.getWaitingThreads(c).isEmpty());
- sync.release(1);
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
-
- /**
- * awaitUninterruptibly doesn't abort on interrupt
- */
- public void testAwaitUninterruptibly() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- sync.acquire(1);
- c.awaitUninterruptibly();
- sync.release(1);
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- sync.acquire(1);
- c.signal();
- sync.release(1);
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * await is interruptible
- */
- public void testAwait_Interrupt() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- c.await();
- sync.release(1);
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitNanos is interruptible
- */
- public void testAwaitNanos_Interrupt() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- c.awaitNanos(1000 * 1000 * 1000); // 1 sec
- sync.release(1);
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitUntil is interruptible
- */
- public void testAwaitUntil_Interrupt() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- java.util.Date d = new java.util.Date();
- c.awaitUntil(new java.util.Date(d.getTime() + 10000));
- sync.release(1);
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * signalAll wakes up all threads
- */
- public void testSignalAll() {
- final Mutex sync = new Mutex();
- final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- c.await();
- sync.release(1);
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- sync.acquire(1);
- c.await();
- sync.release(1);
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- sync.acquire(1);
- c.signalAll();
- sync.release(1);
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * toString indicates current state
- */
- public void testToString() {
- Mutex sync = new Mutex();
- String us = sync.toString();
- assertTrue(us.indexOf("State = 0") >= 0);
- sync.acquire(1);
- String ls = sync.toString();
- assertTrue(ls.indexOf("State = 1") >= 0);
- }
-
- /**
- * A serialized AQS deserializes with current state
- */
- public void testSerialization() {
- Mutex l = new Mutex();
- l.acquire(1);
- assertTrue(l.isHeldExclusively());
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- Mutex r = (Mutex) in.readObject();
- assertTrue(r.isHeldExclusively());
- } catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
-
- /**
- * tryReleaseShared setting state changes getState
- */
- public void testGetStateWithReleaseShared() {
- final BooleanLatch l = new BooleanLatch();
- assertFalse(l.isSignalled());
- l.releaseShared(0);
- assertTrue(l.isSignalled());
- }
-
- /**
- * releaseShared has no effect when already signalled
- */
- public void testReleaseShared() {
- final BooleanLatch l = new BooleanLatch();
- assertFalse(l.isSignalled());
- l.releaseShared(0);
- assertTrue(l.isSignalled());
- l.releaseShared(0);
- assertTrue(l.isSignalled());
- }
-
- /**
- * acquireSharedInterruptibly returns after release, but not before
- */
- public void testAcquireSharedInterruptibly() {
- final BooleanLatch l = new BooleanLatch();
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(l.isSignalled());
- l.acquireSharedInterruptibly(0);
- threadAssertTrue(l.isSignalled());
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- assertFalse(l.isSignalled());
- Thread.sleep(SHORT_DELAY_MS);
- l.releaseShared(0);
- assertTrue(l.isSignalled());
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
-
- /**
- * acquireSharedTimed returns after release
- */
- public void testAsquireSharedTimed() {
- final BooleanLatch l = new BooleanLatch();
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(l.isSignalled());
- threadAssertTrue(l.tryAcquireSharedNanos(0, MEDIUM_DELAY_MS* 1000 * 1000));
- threadAssertTrue(l.isSignalled());
-
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- assertFalse(l.isSignalled());
- Thread.sleep(SHORT_DELAY_MS);
- l.releaseShared(0);
- assertTrue(l.isSignalled());
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * acquireSharedInterruptibly throws IE if interrupted before released
- */
- public void testAcquireSharedInterruptibly_InterruptedException() {
- final BooleanLatch l = new BooleanLatch();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(l.isSignalled());
- l.acquireSharedInterruptibly(0);
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- t.start();
- try {
- assertFalse(l.isSignalled());
- t.interrupt();
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * acquireSharedTimed throws IE if interrupted before released
- */
- public void testAcquireSharedNanos_InterruptedException() {
- final BooleanLatch l = new BooleanLatch();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(l.isSignalled());
- l.tryAcquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000);
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(l.isSignalled());
- t.interrupt();
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * acquireSharedTimed times out if not released before timeout
- */
- public void testAcquireSharedNanos_Timeout() {
- final BooleanLatch l = new BooleanLatch();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(l.isSignalled());
- threadAssertFalse(l.tryAcquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000));
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(l.isSignalled());
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
-
-}
diff --git a/concurrent/src/test/java/ArrayBlockingQueueTest.java b/concurrent/src/test/java/ArrayBlockingQueueTest.java
deleted file mode 100644
index 760bc0c..0000000
--- a/concurrent/src/test/java/ArrayBlockingQueueTest.java
+++ /dev/null
@@ -1,1059 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class ArrayBlockingQueueTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ArrayBlockingQueueTest.class);
- }
-
- /**
- * Create a queue of given size containing consecutive
- * Integers 0 ... n.
- */
- private ArrayBlockingQueue populatedQueue(int n) {
- ArrayBlockingQueue q = new ArrayBlockingQueue(n);
- assertTrue(q.isEmpty());
- for(int i = 0; i < n; i++)
- assertTrue(q.offer(new Integer(i)));
- assertFalse(q.isEmpty());
- assertEquals(0, q.remainingCapacity());
- assertEquals(n, q.size());
- return q;
- }
-
- /**
- * A new queue has the indicated capacity
- */
- public void testConstructor1() {
- assertEquals(SIZE, new ArrayBlockingQueue(SIZE).remainingCapacity());
- }
-
- /**
- * Constructor throws IAE if capacity argument nonpositive
- */
- public void testConstructor2() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(0);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * Initializing from null Collection throws NPE
- */
- public void testConstructor3() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(1, true, null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection of null elements throws NPE
- */
- public void testConstructor4() {
- try {
- Integer[] ints = new Integer[SIZE];
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE, false, Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection with some null elements throws NPE
- */
- public void testConstructor5() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE, false, Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from too large collection throws IAE
- */
- public void testConstructor6() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- ArrayBlockingQueue q = new ArrayBlockingQueue(1, false, Arrays.asList(ints));
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * Queue contains all elements of collection used to initialize
- */
- public void testConstructor7() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE, true, Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * Queue transitions from empty to full when elements added
- */
- public void testEmptyFull() {
- ArrayBlockingQueue q = new ArrayBlockingQueue(2);
- assertTrue(q.isEmpty());
- assertEquals(2, q.remainingCapacity());
- q.add(one);
- assertFalse(q.isEmpty());
- q.add(two);
- assertFalse(q.isEmpty());
- assertEquals(0, q.remainingCapacity());
- assertFalse(q.offer(three));
- }
-
- /**
- * remainingCapacity decreases on add, increases on remove
- */
- public void testRemainingCapacity() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.remainingCapacity());
- assertEquals(SIZE-i, q.size());
- q.remove();
- }
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(SIZE-i, q.remainingCapacity());
- assertEquals(i, q.size());
- q.add(new Integer(i));
- }
- }
-
- /**
- * offer(null) throws NPE
- */
- public void testOfferNull() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(1);
- q.offer(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * add(null) throws NPE
- */
- public void testAddNull() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(1);
- q.add(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * Offer succeeds if not full; fails if full
- */
- public void testOffer() {
- ArrayBlockingQueue q = new ArrayBlockingQueue(1);
- assertTrue(q.offer(zero));
- assertFalse(q.offer(one));
- }
-
- /**
- * add succeeds if not full; throws ISE if full
- */
- public void testAdd() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.add(new Integer(i)));
- }
- assertEquals(0, q.remainingCapacity());
- q.add(new Integer(SIZE));
- } catch (IllegalStateException success){
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(1);
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * addAll(this) throws IAE
- */
- public void testAddAllSelf() {
- try {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- q.addAll(q);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
-
- /**
- * addAll of a collection with null elements throws NPE
- */
- public void testAddAll2() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll of a collection with any null elements throws NPE after
- * possibly adding some elements
- */
- public void testAddAll3() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll throws ISE if not enough room
- */
- public void testAddAll4() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(1);
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (IllegalStateException success) {}
- }
- /**
- * Queue contains all elements, in traversal order, of successful addAll
- */
- public void testAddAll5() {
- try {
- Integer[] empty = new Integer[0];
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
- assertFalse(q.addAll(Arrays.asList(empty)));
- assertTrue(q.addAll(Arrays.asList(ints)));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * put(null) throws NPE
- */
- public void testPutNull() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
- q.put(null);
- shouldThrow();
- }
- catch (NullPointerException success){
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * all elements successfully put are contained
- */
- public void testPut() {
- try {
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- Integer I = new Integer(i);
- q.put(I);
- assertTrue(q.contains(I));
- }
- assertEquals(0, q.remainingCapacity());
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * put blocks interruptibly if full
- */
- public void testBlockingPut() {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE);
- Thread t = new Thread(new Runnable() {
- public void run() {
- int added = 0;
- try {
- for (int i = 0; i < SIZE; ++i) {
- q.put(new Integer(i));
- ++added;
- }
- q.put(new Integer(SIZE));
- threadShouldThrow();
- } catch (InterruptedException ie){
- threadAssertEquals(added, SIZE);
- }
- }});
- try {
- t.start();
- Thread.sleep(MEDIUM_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * put blocks waiting for take when full
- */
- public void testPutWithTake() {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- int added = 0;
- try {
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- threadShouldThrow();
- } catch (InterruptedException e){
- threadAssertTrue(added >= 2);
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- q.take();
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * timed offer times out if full and elements not taken
- */
- public void testTimedOffer() {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(new Object());
- q.put(new Object());
- threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS/2, TimeUnit.MILLISECONDS));
- q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success){}
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * take retrieves elements in FIFO order
- */
- public void testTake() {
- try {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.take()).intValue());
- }
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * take blocks interruptibly when empty
- */
- public void testTakeFromEmpty() {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){ }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Take removes existing elements until empty, then blocks interruptibly
- */
- public void testBlockingTake() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- threadAssertEquals(i, ((Integer)q.take()).intValue());
- }
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){
- }
- }});
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
-
- /**
- * poll succeeds unless empty
- */
- public void testPoll() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll()).intValue());
- }
- assertNull(q.poll());
- }
-
- /**
- * timed pool with zero timeout succeeds when non-empty, else times out
- */
- public void testTimedPoll0() {
- try {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue());
- }
- assertNull(q.poll(0, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * timed pool with nonzero timeout succeeds when non-empty, else times out
- */
- public void testTimedPoll() {
- try {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
- }
- assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * Interrupted timed poll throws InterruptedException instead of
- * returning timeout status
- */
- public void testInterruptedTimedPoll() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
- }
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException success){
- }
- }});
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * timed poll before a delayed offer fails; after offer succeeds;
- * on interruption throws
- */
- public void testTimedPollWithOffer() {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success) { }
- }
- });
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * peek returns next element, or null if empty
- */
- public void testPeek() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.peek()).intValue());
- q.poll();
- assertTrue(q.peek() == null ||
- i != ((Integer)q.peek()).intValue());
- }
- assertNull(q.peek());
- }
-
- /**
- * element returns next element, or throws NSEE if empty
- */
- public void testElement() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.element()).intValue());
- q.poll();
- }
- try {
- q.element();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * remove removes next element, or throws NSEE if empty
- */
- public void testRemove() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.remove()).intValue());
- }
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success){
- }
- }
-
- /**
- * remove(x) removes x and returns true if present
- */
- public void testRemoveElement() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 1; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- }
- for (int i = 0; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- assertFalse(q.remove(new Integer(i+1)));
- }
- assertTrue(q.isEmpty());
- }
-
- /**
- * contains(x) reports true when elements added but not yet removed
- */
- public void testContains() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.contains(new Integer(i)));
- q.poll();
- assertFalse(q.contains(new Integer(i)));
- }
- }
-
- /**
- * clear removes all elements
- */
- public void testClear() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- q.clear();
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- assertEquals(SIZE, q.remainingCapacity());
- q.add(one);
- assertFalse(q.isEmpty());
- assertTrue(q.contains(one));
- q.clear();
- assertTrue(q.isEmpty());
- }
-
- /**
- * containsAll(c) is true when c contains a subset of elements
- */
- public void testContainsAll() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- ArrayBlockingQueue p = new ArrayBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.containsAll(p));
- assertFalse(p.containsAll(q));
- p.add(new Integer(i));
- }
- assertTrue(p.containsAll(q));
- }
-
- /**
- * retainAll(c) retains only those elements of c and reports true if changed
- */
- public void testRetainAll() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- ArrayBlockingQueue p = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- boolean changed = q.retainAll(p);
- if (i == 0)
- assertFalse(changed);
- else
- assertTrue(changed);
-
- assertTrue(q.containsAll(p));
- assertEquals(SIZE-i, q.size());
- p.remove();
- }
- }
-
- /**
- * removeAll(c) removes only those elements of c and reports true if changed
- */
- public void testRemoveAll() {
- for (int i = 1; i < SIZE; ++i) {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- ArrayBlockingQueue p = populatedQueue(i);
- assertTrue(q.removeAll(p));
- assertEquals(SIZE-i, q.size());
- for (int j = 0; j < i; ++j) {
- Integer I = (Integer)(p.remove());
- assertFalse(q.contains(I));
- }
- }
- }
-
- /**
- * toArray contains all elements
- */
- public void testToArray() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- Object[] o = q.toArray();
- try {
- for(int i = 0; i < o.length; i++)
- assertEquals(o[i], q.take());
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * toArray(a) contains all elements
- */
- public void testToArray2() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- ints = (Integer[])q.toArray(ints);
- try {
- for(int i = 0; i < ints.length; i++)
- assertEquals(ints[i], q.take());
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * toArray(null) throws NPE
- */
- public void testToArray_BadArg() {
- try {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(null);
- shouldThrow();
- } catch(NullPointerException success){}
- }
-
- /**
- * toArray with incompatible array type throws CCE
- */
- public void testToArray1_BadArg() {
- try {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(new String[10] );
- shouldThrow();
- } catch(ArrayStoreException success){}
- }
-
-
- /**
- * iterator iterates through all elements
- */
- public void testIterator() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- Iterator it = q.iterator();
- try {
- while(it.hasNext()){
- assertEquals(it.next(), q.take());
- }
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * iterator.remove removes current element
- */
- public void testIteratorRemove () {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(3);
- q.add(two);
- q.add(one);
- q.add(three);
-
- Iterator it = q.iterator();
- it.next();
- it.remove();
-
- it = q.iterator();
- assertEquals(it.next(), one);
- assertEquals(it.next(), three);
- assertFalse(it.hasNext());
- }
-
- /**
- * iterator ordering is FIFO
- */
- public void testIteratorOrdering() {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(3);
- q.add(one);
- q.add(two);
- q.add(three);
-
- assertEquals("queue should be full", 0, q.remainingCapacity());
-
- int k = 0;
- for (Iterator it = q.iterator(); it.hasNext();) {
- int i = ((Integer)(it.next())).intValue();
- assertEquals(++k, i);
- }
- assertEquals(3, k);
- }
-
- /**
- * Modifications do not cause iterators to fail
- */
- public void testWeaklyConsistentIteration () {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(3);
- q.add(one);
- q.add(two);
- q.add(three);
- try {
- for (Iterator it = q.iterator(); it.hasNext();) {
- q.remove();
- it.next();
- }
- }
- catch (ConcurrentModificationException e) {
- unexpectedException();
- }
- assertEquals(0, q.size());
- }
-
-
- /**
- * toString contains toStrings of elements
- */
- public void testToString() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- String s = q.toString();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
-
- /**
- * offer transfers elements across Executor tasks
- */
- public void testOfferInExecutor() {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
- q.add(one);
- q.add(two);
- ExecutorService executor = Executors.newFixedThreadPool(2);
- executor.execute(new Runnable() {
- public void run() {
- threadAssertFalse(q.offer(three));
- try {
- threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertEquals(0, q.remainingCapacity());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- executor.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- threadAssertEquals(one, q.take());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- joinPool(executor);
-
- }
-
- /**
- * poll retrieves elements across Executor threads
- */
- public void testPollInExecutor() {
- final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
- ExecutorService executor = Executors.newFixedThreadPool(2);
- executor.execute(new Runnable() {
- public void run() {
- threadAssertNull(q.poll());
- try {
- threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(q.isEmpty());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- executor.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- q.put(one);
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- joinPool(executor);
- }
-
- /**
- * A deserialized serialized queue has same elements in same order
- */
- public void testSerialization() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- ArrayBlockingQueue r = (ArrayBlockingQueue)in.readObject();
- assertEquals(q.size(), r.size());
- while (!q.isEmpty())
- assertEquals(q.remove(), r.remove());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null) throws NPE
- */
- public void testDrainToNull() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(null);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this) throws IAE
- */
- public void testDrainToSelf() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(q);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c) empties queue into another collection c
- */
- public void testDrainTo() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- assertEquals(l.size(), SIZE);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(l.get(i), new Integer(i));
- q.add(zero);
- q.add(one);
- assertFalse(q.isEmpty());
- assertTrue(q.contains(zero));
- assertTrue(q.contains(one));
- l.clear();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- assertEquals(l.size(), 2);
- for (int i = 0; i < 2; ++i)
- assertEquals(l.get(i), new Integer(i));
- }
-
- /**
- * drainTo empties full queue, unblocking a waiting put.
- */
- public void testDrainToWithActivePut() {
- final ArrayBlockingQueue q = populatedQueue(SIZE);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(new Integer(SIZE+1));
- } catch (InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertTrue(l.size() >= SIZE);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(l.get(i), new Integer(i));
- t.join();
- assertTrue(q.size() + l.size() >= SIZE);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null, n) throws NPE
- */
- public void testDrainToNullN() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(null, 0);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this, n) throws IAE
- */
- public void testDrainToSelfN() {
- ArrayBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(q, 0);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c, n) empties first max {n, size} elements of queue into c
- */
- public void testDrainToN() {
- ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE*2);
- for (int i = 0; i < SIZE + 2; ++i) {
- for(int j = 0; j < SIZE; j++)
- assertTrue(q.offer(new Integer(j)));
- ArrayList l = new ArrayList();
- q.drainTo(l, i);
- int k = (i < SIZE)? i : SIZE;
- assertEquals(l.size(), k);
- assertEquals(q.size(), SIZE-k);
- for (int j = 0; j < k; ++j)
- assertEquals(l.get(j), new Integer(j));
- while (q.poll() != null) ;
- }
- }
-
-
-}
diff --git a/concurrent/src/test/java/AtomicBooleanTest.java b/concurrent/src/test/java/AtomicBooleanTest.java
deleted file mode 100644
index f2619b8..0000000
--- a/concurrent/src/test/java/AtomicBooleanTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-import java.io.*;
-
-public class AtomicBooleanTest extends JSR166TestCase {
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicBooleanTest.class);
- }
-
- /**
- * constructor initializes to given value
- */
- public void testConstructor() {
- AtomicBoolean ai = new AtomicBoolean(true);
- assertEquals(true,ai.get());
- }
-
- /**
- * default constructed initializes to false
- */
- public void testConstructor2() {
- AtomicBoolean ai = new AtomicBoolean();
- assertEquals(false,ai.get());
- }
-
- /**
- * get returns the last value set
- */
- public void testGetSet() {
- AtomicBoolean ai = new AtomicBoolean(true);
- assertEquals(true,ai.get());
- ai.set(false);
- assertEquals(false,ai.get());
- ai.set(true);
- assertEquals(true,ai.get());
-
- }
-
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet() {
- AtomicBoolean ai = new AtomicBoolean(true);
- assertTrue(ai.compareAndSet(true,false));
- assertEquals(false,ai.get());
- assertTrue(ai.compareAndSet(false,false));
- assertEquals(false,ai.get());
- assertFalse(ai.compareAndSet(true,false));
- assertFalse((ai.get()));
- assertTrue(ai.compareAndSet(false,true));
- assertEquals(true,ai.get());
- }
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicBoolean ai = new AtomicBoolean(true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!ai.compareAndSet(false, true)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(ai.compareAndSet(true, false));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet() {
- AtomicBoolean ai = new AtomicBoolean(true);
- while(!ai.weakCompareAndSet(true,false));
- assertEquals(false,ai.get());
- while(!ai.weakCompareAndSet(false,false));
- assertEquals(false,ai.get());
- while(!ai.weakCompareAndSet(false,true));
- assertEquals(true,ai.get());
- }
-
- /**
- * getAndSet returns previous value and sets to given value
- */
- public void testGetAndSet() {
- AtomicBoolean ai = new AtomicBoolean(true);
- assertEquals(true,ai.getAndSet(false));
- assertEquals(false,ai.getAndSet(false));
- assertEquals(false,ai.getAndSet(true));
- assertEquals(true,ai.get());
- }
-
- /**
- * a deserialized serialized atomic holds same value
- */
- public void testSerialization() {
- AtomicBoolean l = new AtomicBoolean();
-
- try {
- l.set(true);
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- AtomicBoolean r = (AtomicBoolean) in.readObject();
- assertEquals(l.get(), r.get());
- } catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
- /**
- * toString returns current value.
- */
- public void testToString() {
- AtomicBoolean ai = new AtomicBoolean();
- assertEquals(ai.toString(), Boolean.toString(false));
- ai.set(true);
- assertEquals(ai.toString(), Boolean.toString(true));
- }
-
-}
diff --git a/concurrent/src/test/java/AtomicIntegerArrayTest.java b/concurrent/src/test/java/AtomicIntegerArrayTest.java
deleted file mode 100644
index 850c2cb..0000000
--- a/concurrent/src/test/java/AtomicIntegerArrayTest.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-import java.io.*;
-import java.util.*;
-
-public class AtomicIntegerArrayTest extends JSR166TestCase {
-
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicIntegerArrayTest.class);
- }
-
-
- /**
- * constructor creates array of given size with all elements zero
- */
- public void testConstructor() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(0,ai.get(i));
- }
-
- /**
- * constructor with null array throws NPE
- */
- public void testConstructor2NPE() {
- try {
- int[] a = null;
- AtomicIntegerArray ai = new AtomicIntegerArray(a);
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * constructor with array is of same size and has all elements
- */
- public void testConstructor2() {
- int[] a = { 17, 3, -42, 99, -7};
- AtomicIntegerArray ai = new AtomicIntegerArray(a);
- assertEquals(a.length, ai.length());
- for (int i = 0; i < a.length; ++i)
- assertEquals(a[i], ai.get(i));
- }
-
- /**
- * get and set for out of bound indices throw IndexOutOfBoundsException
- */
- public void testIndexing(){
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- try {
- ai.get(SIZE);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.get(-1);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.set(SIZE, 0);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.set(-1, 0);
- } catch(IndexOutOfBoundsException success){
- }
- }
-
- /**
- * get returns the last value set at index
- */
- public void testGetSet() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.get(i));
- ai.set(i, 2);
- assertEquals(2,ai.get(i));
- ai.set(i, -3);
- assertEquals(-3,ai.get(i));
- }
- }
-
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertTrue(ai.compareAndSet(i, 1,2));
- assertTrue(ai.compareAndSet(i, 2,-4));
- assertEquals(-4,ai.get(i));
- assertFalse(ai.compareAndSet(i, -5,7));
- assertFalse((7 == ai.get(i)));
- assertTrue(ai.compareAndSet(i, -4,7));
- assertEquals(7,ai.get(i));
- }
- }
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicIntegerArray a = new AtomicIntegerArray(1);
- a.set(0, 1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!a.compareAndSet(0, 2, 3)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(a.compareAndSet(0, 1, 2));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(a.get(0), 3);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- while(!ai.weakCompareAndSet(i, 1,2));
- while(!ai.weakCompareAndSet(i, 2,-4));
- assertEquals(-4,ai.get(i));
- while(!ai.weakCompareAndSet(i, -4,7));
- assertEquals(7,ai.get(i));
- }
- }
-
- /**
- * getAndSet returns previous value and sets to given value at given index
- */
- public void testGetAndSet() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.getAndSet(i,0));
- assertEquals(0,ai.getAndSet(i,-10));
- assertEquals(-10,ai.getAndSet(i,1));
- }
- }
-
- /**
- * getAndAdd returns previous value and adds given value
- */
- public void testGetAndAdd() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.getAndAdd(i,2));
- assertEquals(3,ai.get(i));
- assertEquals(3,ai.getAndAdd(i,-4));
- assertEquals(-1,ai.get(i));
- }
- }
-
- /**
- * getAndDecrement returns previous value and decrements
- */
- public void testGetAndDecrement() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.getAndDecrement(i));
- assertEquals(0,ai.getAndDecrement(i));
- assertEquals(-1,ai.getAndDecrement(i));
- }
- }
-
- /**
- * getAndIncrement returns previous value and increments
- */
- public void testGetAndIncrement() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.getAndIncrement(i));
- assertEquals(2,ai.get(i));
- ai.set(i,-2);
- assertEquals(-2,ai.getAndIncrement(i));
- assertEquals(-1,ai.getAndIncrement(i));
- assertEquals(0,ai.getAndIncrement(i));
- assertEquals(1,ai.get(i));
- }
- }
-
- /**
- * addAndGet adds given value to current, and returns current value
- */
- public void testAddAndGet() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(3,ai.addAndGet(i,2));
- assertEquals(3,ai.get(i));
- assertEquals(-1,ai.addAndGet(i,-4));
- assertEquals(-1,ai.get(i));
- }
- }
-
- /**
- * decrementAndGet decrements and returns current value
- */
- public void testDecrementAndGet() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(0,ai.decrementAndGet(i));
- assertEquals(-1,ai.decrementAndGet(i));
- assertEquals(-2,ai.decrementAndGet(i));
- assertEquals(-2,ai.get(i));
- }
- }
-
- /**
- * incrementAndGet increments and returns current value
- */
- public void testIncrementAndGet() {
- AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(2,ai.incrementAndGet(i));
- assertEquals(2,ai.get(i));
- ai.set(i, -2);
- assertEquals(-1,ai.incrementAndGet(i));
- assertEquals(0,ai.incrementAndGet(i));
- assertEquals(1,ai.incrementAndGet(i));
- assertEquals(1,ai.get(i));
- }
- }
-
- static final int COUNTDOWN = 100000;
-
- class Counter implements Runnable {
- final AtomicIntegerArray ai;
- volatile int counts;
- Counter(AtomicIntegerArray a) { ai = a; }
- public void run() {
- for (;;) {
- boolean done = true;
- for (int i = 0; i < ai.length(); ++i) {
- int v = ai.get(i);
- threadAssertTrue(v >= 0);
- if (v != 0) {
- done = false;
- if (ai.compareAndSet(i, v, v-1))
- ++counts;
- }
- }
- if (done)
- break;
- }
- }
- }
-
- /**
- * Multiple threads using same array of counters successfully
- * update a number of times equal to total count
- */
- public void testCountingInMultipleThreads() {
- try {
- final AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i)
- ai.set(i, COUNTDOWN);
- Counter c1 = new Counter(ai);
- Counter c2 = new Counter(ai);
- Thread t1 = new Thread(c1);
- Thread t2 = new Thread(c2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- assertEquals(c1.counts+c2.counts, SIZE * COUNTDOWN);
- }
- catch(InterruptedException ie) {
- unexpectedException();
- }
- }
-
-
- /**
- * a deserialized serialized array holds same values
- */
- public void testSerialization() {
- AtomicIntegerArray l = new AtomicIntegerArray(SIZE);
- for (int i = 0; i < SIZE; ++i)
- l.set(i, -i);
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- AtomicIntegerArray r = (AtomicIntegerArray) in.readObject();
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(l.get(i), r.get(i));
- }
- } catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
-
- /**
- * toString returns current value.
- */
- public void testToString() {
- int[] a = { 17, 3, -42, 99, -7};
- AtomicIntegerArray ai = new AtomicIntegerArray(a);
- assertEquals(Arrays.toString(a), ai.toString());
- }
-
-}
diff --git a/concurrent/src/test/java/AtomicIntegerFieldUpdaterTest.java b/concurrent/src/test/java/AtomicIntegerFieldUpdaterTest.java
deleted file mode 100644
index 6b0d12f..0000000
--- a/concurrent/src/test/java/AtomicIntegerFieldUpdaterTest.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import java.util.concurrent.atomic.*;
-import junit.framework.*;
-import java.util.*;
-
-public class AtomicIntegerFieldUpdaterTest extends JSR166TestCase {
- volatile int x = 0;
- int w;
- long z;
- public static void main(String[] args){
- junit.textui.TestRunner.run(suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicIntegerFieldUpdaterTest.class);
- }
-
- /**
- * Construction with non-existent field throws RuntimeException
- */
- public void testConstructor() {
- try{
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>
- a = AtomicIntegerFieldUpdater.newUpdater
- (AtomicIntegerFieldUpdaterTest.class, "y");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- /**
- * construction with field not of given type throws RuntimeException
- */
- public void testConstructor2() {
- try{
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>
- a = AtomicIntegerFieldUpdater.newUpdater
- (AtomicIntegerFieldUpdaterTest.class, "z");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- /**
- * construction with non-volatile field throws RuntimeException
- */
- public void testConstructor3() {
- try{
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>
- a = AtomicIntegerFieldUpdater.newUpdater
- (AtomicIntegerFieldUpdaterTest.class, "w");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- static class Base {
- protected volatile int f = 0;
- }
- static class Sub1 extends Base {
- AtomicIntegerFieldUpdater<Base> fUpdater
- = AtomicIntegerFieldUpdater.newUpdater(Base.class, "f");
- }
- static class Sub2 extends Base {}
-
- public void testProtectedFieldOnAnotherSubtype() {
- Sub1 sub1 = new Sub1();
- Sub2 sub2 = new Sub2();
-
- sub1.fUpdater.set(sub1, 1);
- try {
- sub1.fUpdater.set(sub2, 2);
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- /**
- * get returns the last value set or assigned
- */
- public void testGetSet() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.get(this));
- a.set(this,2);
- assertEquals(2,a.get(this));
- a.set(this,-3);
- assertEquals(-3,a.get(this));
-
- }
-
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertTrue(a.compareAndSet(this,1,2));
- assertTrue(a.compareAndSet(this,2,-4));
- assertEquals(-4,a.get(this));
- assertFalse(a.compareAndSet(this,-5,7));
- assertFalse((7 == a.get(this)));
- assertTrue(a.compareAndSet(this,-4,7));
- assertEquals(7,a.get(this));
- }
-
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- x = 1;
- final AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!a.compareAndSet(AtomicIntegerFieldUpdaterTest.this, 2, 3)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(a.compareAndSet(this, 1, 2));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(a.get(this), 3);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- while(!a.weakCompareAndSet(this,1,2));
- while(!a.weakCompareAndSet(this,2,-4));
- assertEquals(-4,a.get(this));
- while(!a.weakCompareAndSet(this,-4,7));
- assertEquals(7,a.get(this));
- }
-
- /**
- * getAndSet returns previous value and sets to given value
- */
- public void testGetAndSet() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.getAndSet(this, 0));
- assertEquals(0,a.getAndSet(this,-10));
- assertEquals(-10,a.getAndSet(this,1));
- }
-
- /**
- * getAndAdd returns previous value and adds given value
- */
- public void testGetAndAdd() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.getAndAdd(this,2));
- assertEquals(3,a.get(this));
- assertEquals(3,a.getAndAdd(this,-4));
- assertEquals(-1,a.get(this));
- }
-
- /**
- * getAndDecrement returns previous value and decrements
- */
- public void testGetAndDecrement() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.getAndDecrement(this));
- assertEquals(0,a.getAndDecrement(this));
- assertEquals(-1,a.getAndDecrement(this));
- }
-
- /**
- * getAndIncrement returns previous value and increments
- */
- public void testGetAndIncrement() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.getAndIncrement(this));
- assertEquals(2,a.get(this));
- a.set(this,-2);
- assertEquals(-2,a.getAndIncrement(this));
- assertEquals(-1,a.getAndIncrement(this));
- assertEquals(0,a.getAndIncrement(this));
- assertEquals(1,a.get(this));
- }
-
- /**
- * addAndGet adds given value to current, and returns current value
- */
- public void testAddAndGet() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(3,a.addAndGet(this,2));
- assertEquals(3,a.get(this));
- assertEquals(-1,a.addAndGet(this,-4));
- assertEquals(-1,a.get(this));
- }
-
- /**
- * decrementAndGet decrements and returns current value
- */
- public void testDecrementAndGet() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(0,a.decrementAndGet(this));
- assertEquals(-1,a.decrementAndGet(this));
- assertEquals(-2,a.decrementAndGet(this));
- assertEquals(-2,a.get(this));
- }
-
- /**
- * incrementAndGet increments and returns current value
- */
- public void testIncrementAndGet() {
- AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
- try {
- a = AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(2,a.incrementAndGet(this));
- assertEquals(2,a.get(this));
- a.set(this,-2);
- assertEquals(-1,a.incrementAndGet(this));
- assertEquals(0,a.incrementAndGet(this));
- assertEquals(1,a.incrementAndGet(this));
- assertEquals(1,a.get(this));
- }
-
-}
diff --git a/concurrent/src/test/java/AtomicIntegerTest.java b/concurrent/src/test/java/AtomicIntegerTest.java
deleted file mode 100644
index 7fc4a47..0000000
--- a/concurrent/src/test/java/AtomicIntegerTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-import java.io.*;
-
-public class AtomicIntegerTest extends JSR166TestCase {
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicIntegerTest.class);
- }
-
- /**
- * constructor initializes to given value
- */
- public void testConstructor(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(1,ai.get());
- }
-
- /**
- * default constructed initializes to zero
- */
- public void testConstructor2(){
- AtomicInteger ai = new AtomicInteger();
- assertEquals(0,ai.get());
- }
-
- /**
- * get returns the last value set
- */
- public void testGetSet(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(1,ai.get());
- ai.set(2);
- assertEquals(2,ai.get());
- ai.set(-3);
- assertEquals(-3,ai.get());
-
- }
-
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet(){
- AtomicInteger ai = new AtomicInteger(1);
- assertTrue(ai.compareAndSet(1,2));
- assertTrue(ai.compareAndSet(2,-4));
- assertEquals(-4,ai.get());
- assertFalse(ai.compareAndSet(-5,7));
- assertFalse((7 == ai.get()));
- assertTrue(ai.compareAndSet(-4,7));
- assertEquals(7,ai.get());
- }
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicInteger ai = new AtomicInteger(1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!ai.compareAndSet(2, 3)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(ai.compareAndSet(1, 2));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(ai.get(), 3);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- AtomicInteger ai = new AtomicInteger(1);
- while(!ai.weakCompareAndSet(1,2));
- while(!ai.weakCompareAndSet(2,-4));
- assertEquals(-4,ai.get());
- while(!ai.weakCompareAndSet(-4,7));
- assertEquals(7,ai.get());
- }
-
- /**
- * getAndSet returns previous value and sets to given value
- */
- public void testGetAndSet(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(1,ai.getAndSet(0));
- assertEquals(0,ai.getAndSet(-10));
- assertEquals(-10,ai.getAndSet(1));
- }
-
- /**
- * getAndAdd returns previous value and adds given value
- */
- public void testGetAndAdd(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(1,ai.getAndAdd(2));
- assertEquals(3,ai.get());
- assertEquals(3,ai.getAndAdd(-4));
- assertEquals(-1,ai.get());
- }
-
- /**
- * getAndDecrement returns previous value and decrements
- */
- public void testGetAndDecrement(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(1,ai.getAndDecrement());
- assertEquals(0,ai.getAndDecrement());
- assertEquals(-1,ai.getAndDecrement());
- }
-
- /**
- * getAndIncrement returns previous value and increments
- */
- public void testGetAndIncrement(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(1,ai.getAndIncrement());
- assertEquals(2,ai.get());
- ai.set(-2);
- assertEquals(-2,ai.getAndIncrement());
- assertEquals(-1,ai.getAndIncrement());
- assertEquals(0,ai.getAndIncrement());
- assertEquals(1,ai.get());
- }
-
- /**
- * addAndGet adds given value to current, and returns current value
- */
- public void testAddAndGet(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(3,ai.addAndGet(2));
- assertEquals(3,ai.get());
- assertEquals(-1,ai.addAndGet(-4));
- assertEquals(-1,ai.get());
- }
-
- /**
- * decrementAndGet decrements and returns current value
- */
- public void testDecrementAndGet(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(0,ai.decrementAndGet());
- assertEquals(-1,ai.decrementAndGet());
- assertEquals(-2,ai.decrementAndGet());
- assertEquals(-2,ai.get());
- }
-
- /**
- * incrementAndGet increments and returns current value
- */
- public void testIncrementAndGet(){
- AtomicInteger ai = new AtomicInteger(1);
- assertEquals(2,ai.incrementAndGet());
- assertEquals(2,ai.get());
- ai.set(-2);
- assertEquals(-1,ai.incrementAndGet());
- assertEquals(0,ai.incrementAndGet());
- assertEquals(1,ai.incrementAndGet());
- assertEquals(1,ai.get());
- }
-
- /**
- * a deserialized serialized atomic holds same value
- */
- public void testSerialization() {
- AtomicInteger l = new AtomicInteger();
-
- try {
- l.set(22);
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- AtomicInteger r = (AtomicInteger) in.readObject();
- assertEquals(l.get(), r.get());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * toString returns current value.
- */
- public void testToString() {
- AtomicInteger ai = new AtomicInteger();
- for (int i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals(ai.toString(), Integer.toString(i));
- }
- }
-
- /**
- * intValue returns current value.
- */
- public void testIntValue() {
- AtomicInteger ai = new AtomicInteger();
- for (int i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals(i, ai.intValue());
- }
- }
-
-
- /**
- * longValue returns current value.
- */
- public void testLongValue() {
- AtomicInteger ai = new AtomicInteger();
- for (int i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals((long)i, ai.longValue());
- }
- }
-
- /**
- * floatValue returns current value.
- */
- public void testFloatValue() {
- AtomicInteger ai = new AtomicInteger();
- for (int i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals((float)i, ai.floatValue());
- }
- }
-
- /**
- * doubleValue returns current value.
- */
- public void testDoubleValue() {
- AtomicInteger ai = new AtomicInteger();
- for (int i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals((double)i, ai.doubleValue());
- }
- }
-
-
-
-}
diff --git a/concurrent/src/test/java/AtomicLongArrayTest.java b/concurrent/src/test/java/AtomicLongArrayTest.java
deleted file mode 100644
index 1564629..0000000
--- a/concurrent/src/test/java/AtomicLongArrayTest.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-import java.io.*;
-import java.util.*;
-
-public class AtomicLongArrayTest extends JSR166TestCase {
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicLongArrayTest.class);
- }
-
- /**
- * constructor creates array of given size with all elements zero
- */
- public void testConstructor(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(0,ai.get(i));
- }
-
- /**
- * constructor with null array throws NPE
- */
- public void testConstructor2NPE() {
- try {
- long[] a = null;
- AtomicLongArray ai = new AtomicLongArray(a);
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * constructor with array is of same size and has all elements
- */
- public void testConstructor2() {
- long[] a = { 17L, 3L, -42L, 99L, -7L};
- AtomicLongArray ai = new AtomicLongArray(a);
- assertEquals(a.length, ai.length());
- for (int i = 0; i < a.length; ++i)
- assertEquals(a[i], ai.get(i));
- }
-
- /**
- * get and set for out of bound indices throw IndexOutOfBoundsException
- */
- public void testIndexing(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- try {
- ai.get(SIZE);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.get(-1);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.set(SIZE, 0);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.set(-1, 0);
- } catch(IndexOutOfBoundsException success){
- }
- }
-
- /**
- * get returns the last value set at index
- */
- public void testGetSet(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.get(i));
- ai.set(i, 2);
- assertEquals(2,ai.get(i));
- ai.set(i, -3);
- assertEquals(-3,ai.get(i));
- }
- }
-
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertTrue(ai.compareAndSet(i, 1,2));
- assertTrue(ai.compareAndSet(i, 2,-4));
- assertEquals(-4,ai.get(i));
- assertFalse(ai.compareAndSet(i, -5,7));
- assertFalse((7 == ai.get(i)));
- assertTrue(ai.compareAndSet(i, -4,7));
- assertEquals(7,ai.get(i));
- }
- }
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicLongArray a = new AtomicLongArray(1);
- a.set(0, 1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!a.compareAndSet(0, 2, 3)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(a.compareAndSet(0, 1, 2));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(a.get(0), 3);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- while(!ai.weakCompareAndSet(i, 1,2));
- while(!ai.weakCompareAndSet(i, 2,-4));
- assertEquals(-4,ai.get(i));
- while(!ai.weakCompareAndSet(i, -4,7));
- assertEquals(7,ai.get(i));
- }
- }
-
- /**
- * getAndSet returns previous value and sets to given value at given index
- */
- public void testGetAndSet(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.getAndSet(i,0));
- assertEquals(0,ai.getAndSet(i,-10));
- assertEquals(-10,ai.getAndSet(i,1));
- }
- }
-
- /**
- * getAndAdd returns previous value and adds given value
- */
- public void testGetAndAdd(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.getAndAdd(i,2));
- assertEquals(3,ai.get(i));
- assertEquals(3,ai.getAndAdd(i,-4));
- assertEquals(-1,ai.get(i));
- }
- }
-
- /**
- * getAndDecrement returns previous value and decrements
- */
- public void testGetAndDecrement(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.getAndDecrement(i));
- assertEquals(0,ai.getAndDecrement(i));
- assertEquals(-1,ai.getAndDecrement(i));
- }
- }
-
- /**
- * getAndIncrement returns previous value and increments
- */
- public void testGetAndIncrement(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(1,ai.getAndIncrement(i));
- assertEquals(2,ai.get(i));
- ai.set(i,-2);
- assertEquals(-2,ai.getAndIncrement(i));
- assertEquals(-1,ai.getAndIncrement(i));
- assertEquals(0,ai.getAndIncrement(i));
- assertEquals(1,ai.get(i));
- }
- }
-
- /**
- * addAndGet adds given value to current, and returns current value
- */
- public void testAddAndGet() {
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(3,ai.addAndGet(i,2));
- assertEquals(3,ai.get(i));
- assertEquals(-1,ai.addAndGet(i,-4));
- assertEquals(-1,ai.get(i));
- }
- }
-
- /**
- * decrementAndGet decrements and returns current value
- */
- public void testDecrementAndGet(){
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(0,ai.decrementAndGet(i));
- assertEquals(-1,ai.decrementAndGet(i));
- assertEquals(-2,ai.decrementAndGet(i));
- assertEquals(-2,ai.get(i));
- }
- }
-
- /**
- * incrementAndGet increments and returns current value
- */
- public void testIncrementAndGet() {
- AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, 1);
- assertEquals(2,ai.incrementAndGet(i));
- assertEquals(2,ai.get(i));
- ai.set(i, -2);
- assertEquals(-1,ai.incrementAndGet(i));
- assertEquals(0,ai.incrementAndGet(i));
- assertEquals(1,ai.incrementAndGet(i));
- assertEquals(1,ai.get(i));
- }
- }
-
- static final long COUNTDOWN = 100000;
-
- class Counter implements Runnable {
- final AtomicLongArray ai;
- volatile long counts;
- Counter(AtomicLongArray a) { ai = a; }
- public void run() {
- for (;;) {
- boolean done = true;
- for (int i = 0; i < ai.length(); ++i) {
- long v = ai.get(i);
- threadAssertTrue(v >= 0);
- if (v != 0) {
- done = false;
- if (ai.compareAndSet(i, v, v-1))
- ++counts;
- }
- }
- if (done)
- break;
- }
- }
- }
-
- /**
- * Multiple threads using same array of counters successfully
- * update a number of times equal to total count
- */
- public void testCountingInMultipleThreads() {
- try {
- final AtomicLongArray ai = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i)
- ai.set(i, COUNTDOWN);
- Counter c1 = new Counter(ai);
- Counter c2 = new Counter(ai);
- Thread t1 = new Thread(c1);
- Thread t2 = new Thread(c2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- assertEquals(c1.counts+c2.counts, SIZE * COUNTDOWN);
- }
- catch(InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * a deserialized serialized array holds same values
- */
- public void testSerialization() {
- AtomicLongArray l = new AtomicLongArray(SIZE);
- for (int i = 0; i < SIZE; ++i)
- l.set(i, -i);
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- AtomicLongArray r = (AtomicLongArray) in.readObject();
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(l.get(i), r.get(i));
- }
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * toString returns current value.
- */
- public void testToString() {
- long[] a = { 17, 3, -42, 99, -7};
- AtomicLongArray ai = new AtomicLongArray(a);
- assertEquals(Arrays.toString(a), ai.toString());
- }
-
-
-}
diff --git a/concurrent/src/test/java/AtomicLongFieldUpdaterTest.java b/concurrent/src/test/java/AtomicLongFieldUpdaterTest.java
deleted file mode 100644
index 4a6121c..0000000
--- a/concurrent/src/test/java/AtomicLongFieldUpdaterTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import java.util.concurrent.atomic.*;
-import junit.framework.*;
-import java.util.*;
-
-public class AtomicLongFieldUpdaterTest extends JSR166TestCase {
- volatile long x = 0;
- int z;
- long w;
-
- public static void main(String[] args){
- junit.textui.TestRunner.run(suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicLongFieldUpdaterTest.class);
- }
-
- /**
- * Construction with non-existent field throws RuntimeException
- */
- public void testConstructor(){
- try{
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest>
- a = AtomicLongFieldUpdater.newUpdater
- (AtomicLongFieldUpdaterTest.class, "y");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- /**
- * construction with field not of given type throws RuntimeException
- */
- public void testConstructor2(){
- try{
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest>
- a = AtomicLongFieldUpdater.newUpdater
- (AtomicLongFieldUpdaterTest.class, "z");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- /**
- * construction with non-volatile field throws RuntimeException
- */
- public void testConstructor3(){
- try{
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest>
- a = AtomicLongFieldUpdater.newUpdater
- (AtomicLongFieldUpdaterTest.class, "w");
- shouldThrow();
- }
-
- catch (RuntimeException rt) {}
- }
-
- static class Base {
- protected volatile long f = 0;
- }
- static class Sub1 extends Base {
- AtomicLongFieldUpdater<Base> fUpdater
- = AtomicLongFieldUpdater.newUpdater(Base.class, "f");
- }
- static class Sub2 extends Base {}
-
- public void testProtectedFieldOnAnotherSubtype() {
- Sub1 sub1 = new Sub1();
- Sub2 sub2 = new Sub2();
-
- sub1.fUpdater.set(sub1, 1);
- try {
- sub1.fUpdater.set(sub2, 2);
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- /**
- * get returns the last value set or assigned
- */
- public void testGetSet(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.get(this));
- a.set(this,2);
- assertEquals(2,a.get(this));
- a.set(this,-3);
- assertEquals(-3,a.get(this));
-
- }
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertTrue(a.compareAndSet(this,1,2));
- assertTrue(a.compareAndSet(this,2,-4));
- assertEquals(-4,a.get(this));
- assertFalse(a.compareAndSet(this,-5,7));
- assertFalse((7 == a.get(this)));
- assertTrue(a.compareAndSet(this,-4,7));
- assertEquals(7,a.get(this));
- }
-
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- x = 1;
- final AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest>a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!a.compareAndSet(AtomicLongFieldUpdaterTest.this, 2, 3)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(a.compareAndSet(this, 1, 2));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(a.get(this), 3);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- while(!a.weakCompareAndSet(this,1,2));
- while(!a.weakCompareAndSet(this,2,-4));
- assertEquals(-4,a.get(this));
- while(!a.weakCompareAndSet(this,-4,7));
- assertEquals(7,a.get(this));
- }
-
- /**
- * getAndSet returns previous value and sets to given value
- */
- public void testGetAndSet(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.getAndSet(this, 0));
- assertEquals(0,a.getAndSet(this,-10));
- assertEquals(-10,a.getAndSet(this,1));
- }
-
- /**
- * getAndAdd returns previous value and adds given value
- */
- public void testGetAndAdd(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.getAndAdd(this,2));
- assertEquals(3,a.get(this));
- assertEquals(3,a.getAndAdd(this,-4));
- assertEquals(-1,a.get(this));
- }
-
- /**
- * getAndDecrement returns previous value and decrements
- */
- public void testGetAndDecrement(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.getAndDecrement(this));
- assertEquals(0,a.getAndDecrement(this));
- assertEquals(-1,a.getAndDecrement(this));
- }
-
- /**
- * getAndIncrement returns previous value and increments
- */
- public void testGetAndIncrement(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(1,a.getAndIncrement(this));
- assertEquals(2,a.get(this));
- a.set(this,-2);
- assertEquals(-2,a.getAndIncrement(this));
- assertEquals(-1,a.getAndIncrement(this));
- assertEquals(0,a.getAndIncrement(this));
- assertEquals(1,a.get(this));
- }
-
- /**
- * addAndGet adds given value to current, and returns current value
- */
- public void testAddAndGet(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(3,a.addAndGet(this,2));
- assertEquals(3,a.get(this));
- assertEquals(-1,a.addAndGet(this,-4));
- assertEquals(-1,a.get(this));
- }
-
- /**
- * decrementAndGet decrements and returns current value
- */
- public void testDecrementAndGet(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(0,a.decrementAndGet(this));
- assertEquals(-1,a.decrementAndGet(this));
- assertEquals(-2,a.decrementAndGet(this));
- assertEquals(-2,a.get(this));
- }
-
- /**
- * incrementAndGet increments and returns current value
- */
- public void testIncrementAndGet(){
- AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a;
- try {
- a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = 1;
- assertEquals(2,a.incrementAndGet(this));
- assertEquals(2,a.get(this));
- a.set(this,-2);
- assertEquals(-1,a.incrementAndGet(this));
- assertEquals(0,a.incrementAndGet(this));
- assertEquals(1,a.incrementAndGet(this));
- assertEquals(1,a.get(this));
- }
-
-}
diff --git a/concurrent/src/test/java/AtomicLongTest.java b/concurrent/src/test/java/AtomicLongTest.java
deleted file mode 100644
index ecb54be..0000000
--- a/concurrent/src/test/java/AtomicLongTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-import java.io.*;
-
-public class AtomicLongTest extends JSR166TestCase {
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicLongTest.class);
- }
-
- /**
- * constructor initializes to given value
- */
- public void testConstructor(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(1,ai.get());
- }
-
- /**
- * default constructed initializes to zero
- */
- public void testConstructor2(){
- AtomicLong ai = new AtomicLong();
- assertEquals(0,ai.get());
- }
-
- /**
- * get returns the last value set
- */
- public void testGetSet(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(1,ai.get());
- ai.set(2);
- assertEquals(2,ai.get());
- ai.set(-3);
- assertEquals(-3,ai.get());
-
- }
-
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet(){
- AtomicLong ai = new AtomicLong(1);
- assertTrue(ai.compareAndSet(1,2));
- assertTrue(ai.compareAndSet(2,-4));
- assertEquals(-4,ai.get());
- assertFalse(ai.compareAndSet(-5,7));
- assertFalse((7 == ai.get()));
- assertTrue(ai.compareAndSet(-4,7));
- assertEquals(7,ai.get());
- }
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicLong ai = new AtomicLong(1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!ai.compareAndSet(2, 3)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(ai.compareAndSet(1, 2));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(ai.get(), 3);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- AtomicLong ai = new AtomicLong(1);
- while(!ai.weakCompareAndSet(1,2));
- while(!ai.weakCompareAndSet(2,-4));
- assertEquals(-4,ai.get());
- while(!ai.weakCompareAndSet(-4,7));
- assertEquals(7,ai.get());
- }
-
- /**
- * getAndSet returns previous value and sets to given value
- */
- public void testGetAndSet(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(1,ai.getAndSet(0));
- assertEquals(0,ai.getAndSet(-10));
- assertEquals(-10,ai.getAndSet(1));
- }
-
- /**
- * getAndAdd returns previous value and adds given value
- */
- public void testGetAndAdd(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(1,ai.getAndAdd(2));
- assertEquals(3,ai.get());
- assertEquals(3,ai.getAndAdd(-4));
- assertEquals(-1,ai.get());
- }
-
- /**
- * getAndDecrement returns previous value and decrements
- */
- public void testGetAndDecrement(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(1,ai.getAndDecrement());
- assertEquals(0,ai.getAndDecrement());
- assertEquals(-1,ai.getAndDecrement());
- }
-
- /**
- * getAndIncrement returns previous value and increments
- */
- public void testGetAndIncrement(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(1,ai.getAndIncrement());
- assertEquals(2,ai.get());
- ai.set(-2);
- assertEquals(-2,ai.getAndIncrement());
- assertEquals(-1,ai.getAndIncrement());
- assertEquals(0,ai.getAndIncrement());
- assertEquals(1,ai.get());
- }
-
- /**
- * addAndGet adds given value to current, and returns current value
- */
- public void testAddAndGet(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(3,ai.addAndGet(2));
- assertEquals(3,ai.get());
- assertEquals(-1,ai.addAndGet(-4));
- assertEquals(-1,ai.get());
- }
-
- /**
- * decrementAndGet decrements and returns current value
- */
- public void testDecrementAndGet(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(0,ai.decrementAndGet());
- assertEquals(-1,ai.decrementAndGet());
- assertEquals(-2,ai.decrementAndGet());
- assertEquals(-2,ai.get());
- }
-
- /**
- * incrementAndGet increments and returns current value
- */
- public void testIncrementAndGet(){
- AtomicLong ai = new AtomicLong(1);
- assertEquals(2,ai.incrementAndGet());
- assertEquals(2,ai.get());
- ai.set(-2);
- assertEquals(-1,ai.incrementAndGet());
- assertEquals(0,ai.incrementAndGet());
- assertEquals(1,ai.incrementAndGet());
- assertEquals(1,ai.get());
- }
-
- /**
- * a deserialized serialized atomic holds same value
- */
- public void testSerialization() {
- AtomicLong l = new AtomicLong();
-
- try {
- l.set(-22);
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- AtomicLong r = (AtomicLong) in.readObject();
- assertEquals(l.get(), r.get());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * toString returns current value.
- */
- public void testToString() {
- AtomicLong ai = new AtomicLong();
- for (long i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals(ai.toString(), Long.toString(i));
- }
- }
-
- /**
- * longValue returns current value.
- */
- public void testLongValue() {
- AtomicLong ai = new AtomicLong();
- for (int i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals((long)i, ai.longValue());
- }
- }
-
- /**
- * floatValue returns current value.
- */
- public void testFloatValue() {
- AtomicLong ai = new AtomicLong();
- for (int i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals((float)i, ai.floatValue());
- }
- }
-
- /**
- * doubleValue returns current value.
- */
- public void testDoubleValue() {
- AtomicLong ai = new AtomicLong();
- for (int i = -12; i < 6; ++i) {
- ai.set(i);
- assertEquals((double)i, ai.doubleValue());
- }
- }
-
-
-}
diff --git a/concurrent/src/test/java/AtomicMarkableReferenceTest.java b/concurrent/src/test/java/AtomicMarkableReferenceTest.java
deleted file mode 100644
index ad581f9..0000000
--- a/concurrent/src/test/java/AtomicMarkableReferenceTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-
-public class AtomicMarkableReferenceTest extends JSR166TestCase{
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicMarkableReferenceTest.class);
- }
-
- /**
- * constructor initializes to given reference and mark
- */
- public void testConstructor(){
- AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
- assertEquals(one,ai.getReference());
- assertFalse(ai.isMarked());
- AtomicMarkableReference a2 = new AtomicMarkableReference(null, true);
- assertNull(a2.getReference());
- assertTrue(a2.isMarked());
-
- }
-
- /**
- * get returns the last values of reference and mark set
- */
- public void testGetSet(){
- boolean[] mark = new boolean[1];
- AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
- assertEquals(one,ai.getReference());
- assertFalse(ai.isMarked());
- assertEquals(one, ai.get(mark));
- assertFalse(mark[0]);
- ai.set(two, false);
- assertEquals(two,ai.getReference());
- assertFalse(ai.isMarked());
- assertEquals(two, ai.get(mark));
- assertFalse(mark[0]);
- ai.set(one, true);
- assertEquals(one,ai.getReference());
- assertTrue(ai.isMarked());
- assertEquals(one, ai.get(mark));
- assertTrue(mark[0]);
- }
-
- /**
- * attemptMark succeeds in single thread
- */
- public void testAttemptMark(){
- boolean[] mark = new boolean[1];
- AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
- assertFalse(ai.isMarked());
- assertTrue(ai.attemptMark(one, true));
- assertTrue(ai.isMarked());
- assertEquals(one, ai.get(mark));
- assertTrue(mark[0]);
- }
-
- /**
- * compareAndSet succeeds in changing values if equal to expected reference
- * and mark else fails
- */
- public void testCompareAndSet(){
- boolean[] mark = new boolean[1];
- AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
- assertEquals(one, ai.get(mark));
- assertFalse(ai.isMarked());
- assertFalse(mark[0]);
-
- assertTrue(ai.compareAndSet(one, two, false, false));
- assertEquals(two, ai.get(mark));
- assertFalse(mark[0]);
-
- assertTrue(ai.compareAndSet(two, m3, false, true));
- assertEquals(m3, ai.get(mark));
- assertTrue(mark[0]);
-
- assertFalse(ai.compareAndSet(two, m3, true, true));
- assertEquals(m3, ai.get(mark));
- assertTrue(mark[0]);
- }
-
- /**
- * compareAndSet in one thread enables another waiting for reference value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!ai.compareAndSet(two, three, false, false)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(ai.compareAndSet(one, two, false, false));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(ai.getReference(), three);
- assertFalse(ai.isMarked());
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * compareAndSet in one thread enables another waiting for mark value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads2() {
- final AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!ai.compareAndSet(one, one, true, false)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(ai.compareAndSet(one, one, false, true));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(ai.getReference(), one);
- assertFalse(ai.isMarked());
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing values when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- boolean[] mark = new boolean[1];
- AtomicMarkableReference ai = new AtomicMarkableReference(one, false);
- assertEquals(one, ai.get(mark));
- assertFalse(ai.isMarked());
- assertFalse(mark[0]);
-
- while(!ai.weakCompareAndSet(one, two, false, false));
- assertEquals(two, ai.get(mark));
- assertFalse(mark[0]);
-
- while(!ai.weakCompareAndSet(two, m3, false, true));
- assertEquals(m3, ai.get(mark));
- assertTrue(mark[0]);
- }
-
-}
diff --git a/concurrent/src/test/java/AtomicReferenceArrayTest.java b/concurrent/src/test/java/AtomicReferenceArrayTest.java
deleted file mode 100644
index eaf32b3..0000000
--- a/concurrent/src/test/java/AtomicReferenceArrayTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-import java.io.*;
-import java.util.*;
-
-public class AtomicReferenceArrayTest extends JSR166TestCase
-{
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicReferenceArrayTest.class);
- }
-
- /**
- * constructor creates array of given size with all elements null
- */
- public void testConstructor(){
- AtomicReferenceArray<Integer> ai = new AtomicReferenceArray<Integer>(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertNull(ai.get(i));
- }
- }
-
- /**
- * constructor with null array throws NPE
- */
- public void testConstructor2NPE() {
- try {
- Integer[] a = null;
- AtomicReferenceArray<Integer> ai = new AtomicReferenceArray<Integer>(a);
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * constructor with array is of same size and has all elements
- */
- public void testConstructor2() {
- Integer[] a = { two, one, three, four, seven};
- AtomicReferenceArray<Integer> ai = new AtomicReferenceArray<Integer>(a);
- assertEquals(a.length, ai.length());
- for (int i = 0; i < a.length; ++i)
- assertEquals(a[i], ai.get(i));
- }
-
-
- /**
- * get and set for out of bound indices throw IndexOutOfBoundsException
- */
- public void testIndexing(){
- AtomicReferenceArray<Integer> ai = new AtomicReferenceArray<Integer>(SIZE);
- try {
- ai.get(SIZE);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.get(-1);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.set(SIZE, null);
- } catch(IndexOutOfBoundsException success){
- }
- try {
- ai.set(-1, null);
- } catch(IndexOutOfBoundsException success){
- }
- }
-
- /**
- * get returns the last value set at index
- */
- public void testGetSet(){
- AtomicReferenceArray ai = new AtomicReferenceArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, one);
- assertEquals(one,ai.get(i));
- ai.set(i, two);
- assertEquals(two,ai.get(i));
- ai.set(i, m3);
- assertEquals(m3,ai.get(i));
- }
- }
-
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet(){
- AtomicReferenceArray ai = new AtomicReferenceArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, one);
- assertTrue(ai.compareAndSet(i, one,two));
- assertTrue(ai.compareAndSet(i, two,m4));
- assertEquals(m4,ai.get(i));
- assertFalse(ai.compareAndSet(i, m5,seven));
- assertFalse((seven.equals(ai.get(i))));
- assertTrue(ai.compareAndSet(i, m4,seven));
- assertEquals(seven,ai.get(i));
- }
- }
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicReferenceArray a = new AtomicReferenceArray(1);
- a.set(0, one);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!a.compareAndSet(0, two, three)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(a.compareAndSet(0, one, two));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(a.get(0), three);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- AtomicReferenceArray ai = new AtomicReferenceArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, one);
- while(!ai.weakCompareAndSet(i, one,two));
- while(!ai.weakCompareAndSet(i, two,m4));
- assertEquals(m4,ai.get(i));
- while(!ai.weakCompareAndSet(i, m4,seven));
- assertEquals(seven,ai.get(i));
- }
- }
-
- /**
- * getAndSet returns previous value and sets to given value at given index
- */
- public void testGetAndSet(){
- AtomicReferenceArray ai = new AtomicReferenceArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- ai.set(i, one);
- assertEquals(one,ai.getAndSet(i,zero));
- assertEquals(0,ai.getAndSet(i,m10));
- assertEquals(m10,ai.getAndSet(i,one));
- }
- }
-
- /**
- * a deserialized serialized array holds same values
- */
- public void testSerialization() {
- AtomicReferenceArray l = new AtomicReferenceArray(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- l.set(i, new Integer(-i));
- }
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- AtomicReferenceArray r = (AtomicReferenceArray) in.readObject();
- assertEquals(l.length(), r.length());
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(r.get(i), l.get(i));
- }
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * toString returns current value.
- */
- public void testToString() {
- Integer[] a = { two, one, three, four, seven};
- AtomicReferenceArray<Integer> ai = new AtomicReferenceArray<Integer>(a);
- assertEquals(Arrays.toString(a), ai.toString());
- }
-}
diff --git a/concurrent/src/test/java/AtomicReferenceFieldUpdaterTest.java b/concurrent/src/test/java/AtomicReferenceFieldUpdaterTest.java
deleted file mode 100644
index 808cbba..0000000
--- a/concurrent/src/test/java/AtomicReferenceFieldUpdaterTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import java.util.concurrent.atomic.*;
-import junit.framework.*;
-import java.util.*;
-
-public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase{
- volatile Integer x = null;
- Object z;
- Integer w;
-
- public static void main(String[] args){
- junit.textui.TestRunner.run(suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicReferenceFieldUpdaterTest.class);
- }
-
- /**
- * Construction with non-existent field throws RuntimeException
- */
- public void testConstructor(){
- try{
- AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>
- a = AtomicReferenceFieldUpdater.newUpdater
- (AtomicReferenceFieldUpdaterTest.class, Integer.class, "y");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
-
- /**
- * construction with field not of given type throws RuntimeException
- */
- public void testConstructor2(){
- try{
- AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>
- a = AtomicReferenceFieldUpdater.newUpdater
- (AtomicReferenceFieldUpdaterTest.class, Integer.class, "z");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- /**
- * Constructor with non-volatile field throws exception
- */
- public void testConstructor3(){
- try{
- AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>
- a = AtomicReferenceFieldUpdater.newUpdater
- (AtomicReferenceFieldUpdaterTest.class, Integer.class, "w");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- static class Base {
- protected volatile Object f = null;
- }
- static class Sub1 extends Base {
- AtomicReferenceFieldUpdater<Base, Object> fUpdater
- = AtomicReferenceFieldUpdater.newUpdater(Base.class, Object.class, "f");
- }
- static class Sub2 extends Base {}
-
- public void testProtectedFieldOnAnotherSubtype() {
- Sub1 sub1 = new Sub1();
- Sub2 sub2 = new Sub2();
-
- sub1.fUpdater.set(sub1, "f");
- try {
- sub1.fUpdater.set(sub2, "g");
- shouldThrow();
- }
- catch (RuntimeException rt) {}
- }
-
- /**
- * get returns the last value set or assigned
- */
- public void testGetSet(){
- AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a;
- try {
- a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = one;
- assertEquals(one,a.get(this));
- a.set(this,two);
- assertEquals(two,a.get(this));
- a.set(this,m3);
- assertEquals(m3,a.get(this));
- }
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet(){
- AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a;
- try {
- a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = one;
- assertTrue(a.compareAndSet(this,one,two));
- assertTrue(a.compareAndSet(this,two,m4));
- assertEquals(m4,a.get(this));
- assertFalse(a.compareAndSet(this,m5,seven));
- assertFalse((seven == a.get(this)));
- assertTrue(a.compareAndSet(this,m4,seven));
- assertEquals(seven,a.get(this));
- }
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- x = one;
- final AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a;
- try {
- a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!a.compareAndSet(AtomicReferenceFieldUpdaterTest.this, two, three)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(a.compareAndSet(this, one, two));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(a.get(this), three);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a;
- try {
- a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = one;
- while(!a.weakCompareAndSet(this,one,two));
- while(!a.weakCompareAndSet(this,two,m4));
- assertEquals(m4,a.get(this));
- while(!a.weakCompareAndSet(this,m4,seven));
- assertEquals(seven,a.get(this));
- }
-
- /**
- * getAndSet returns previous value and sets to given value
- */
- public void testGetAndSet(){
- AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a;
- try {
- a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
- } catch (RuntimeException ok) {
- return;
- }
- x = one;
- assertEquals(one,a.getAndSet(this, zero));
- assertEquals(zero,a.getAndSet(this,m10));
- assertEquals(m10,a.getAndSet(this,1));
- }
-
-}
diff --git a/concurrent/src/test/java/AtomicReferenceTest.java b/concurrent/src/test/java/AtomicReferenceTest.java
deleted file mode 100644
index eb2eb78..0000000
--- a/concurrent/src/test/java/AtomicReferenceTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-import java.io.*;
-
-public class AtomicReferenceTest extends JSR166TestCase {
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicReferenceTest.class);
- }
-
- /**
- * constructor initializes to given value
- */
- public void testConstructor(){
- AtomicReference ai = new AtomicReference(one);
- assertEquals(one,ai.get());
- }
-
- /**
- * default constructed initializes to null
- */
- public void testConstructor2(){
- AtomicReference ai = new AtomicReference();
- assertNull(ai.get());
- }
-
- /**
- * get returns the last value set
- */
- public void testGetSet(){
- AtomicReference ai = new AtomicReference(one);
- assertEquals(one,ai.get());
- ai.set(two);
- assertEquals(two,ai.get());
- ai.set(m3);
- assertEquals(m3,ai.get());
-
- }
- /**
- * compareAndSet succeeds in changing value if equal to expected else fails
- */
- public void testCompareAndSet(){
- AtomicReference ai = new AtomicReference(one);
- assertTrue(ai.compareAndSet(one,two));
- assertTrue(ai.compareAndSet(two,m4));
- assertEquals(m4,ai.get());
- assertFalse(ai.compareAndSet(m5,seven));
- assertFalse((seven.equals(ai.get())));
- assertTrue(ai.compareAndSet(m4,seven));
- assertEquals(seven,ai.get());
- }
-
- /**
- * compareAndSet in one thread enables another waiting for value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicReference ai = new AtomicReference(one);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!ai.compareAndSet(two, three)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(ai.compareAndSet(one, two));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(ai.get(), three);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing value when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- AtomicReference ai = new AtomicReference(one);
- while(!ai.weakCompareAndSet(one,two));
- while(!ai.weakCompareAndSet(two,m4));
- assertEquals(m4,ai.get());
- while(!ai.weakCompareAndSet(m4,seven));
- assertEquals(seven,ai.get());
- }
-
- /**
- * getAndSet returns previous value and sets to given value
- */
- public void testGetAndSet(){
- AtomicReference ai = new AtomicReference(one);
- assertEquals(one,ai.getAndSet(zero));
- assertEquals(zero,ai.getAndSet(m10));
- assertEquals(m10,ai.getAndSet(one));
- }
-
- /**
- * a deserialized serialized atomic holds same value
- */
- public void testSerialization() {
- AtomicReference l = new AtomicReference();
-
- try {
- l.set(one);
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- AtomicReference r = (AtomicReference) in.readObject();
- assertEquals(l.get(), r.get());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * toString returns current value.
- */
- public void testToString() {
- AtomicReference<Integer> ai = new AtomicReference<Integer>(one);
- assertEquals(ai.toString(), one.toString());
- ai.set(two);
- assertEquals(ai.toString(), two.toString());
- }
-
-}
-
diff --git a/concurrent/src/test/java/AtomicStampedReferenceTest.java b/concurrent/src/test/java/AtomicStampedReferenceTest.java
deleted file mode 100644
index c1f0416..0000000
--- a/concurrent/src/test/java/AtomicStampedReferenceTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.atomic.*;
-
-public class AtomicStampedReferenceTest extends JSR166TestCase{
- public static void main (String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(AtomicStampedReferenceTest.class);
- }
-
- /**
- * constructor initializes to given reference and stamp
- */
- public void testConstructor(){
- AtomicStampedReference ai = new AtomicStampedReference(one, 0);
- assertEquals(one,ai.getReference());
- assertEquals(0, ai.getStamp());
- AtomicStampedReference a2 = new AtomicStampedReference(null, 1);
- assertNull(a2.getReference());
- assertEquals(1, a2.getStamp());
-
- }
-
- /**
- * get returns the last values of reference and stamp set
- */
- public void testGetSet(){
- int[] mark = new int[1];
- AtomicStampedReference ai = new AtomicStampedReference(one, 0);
- assertEquals(one,ai.getReference());
- assertEquals(0, ai.getStamp());
- assertEquals(one, ai.get(mark));
- assertEquals(0, mark[0]);
- ai.set(two, 0);
- assertEquals(two,ai.getReference());
- assertEquals(0, ai.getStamp());
- assertEquals(two, ai.get(mark));
- assertEquals(0, mark[0]);
- ai.set(one, 1);
- assertEquals(one,ai.getReference());
- assertEquals(1, ai.getStamp());
- assertEquals(one, ai.get(mark));
- assertEquals(1,mark[0]);
- }
-
- /**
- * attemptStamp succeeds in single thread
- */
- public void testAttemptStamp(){
- int[] mark = new int[1];
- AtomicStampedReference ai = new AtomicStampedReference(one, 0);
- assertEquals(0, ai.getStamp());
- assertTrue(ai.attemptStamp(one, 1));
- assertEquals(1, ai.getStamp());
- assertEquals(one, ai.get(mark));
- assertEquals(1, mark[0]);
- }
-
- /**
- * compareAndSet succeeds in changing values if equal to expected reference
- * and stamp else fails
- */
- public void testCompareAndSet(){
- int[] mark = new int[1];
- AtomicStampedReference ai = new AtomicStampedReference(one, 0);
- assertEquals(one, ai.get(mark));
- assertEquals(0, ai.getStamp());
- assertEquals(0, mark[0]);
-
- assertTrue(ai.compareAndSet(one, two, 0, 0));
- assertEquals(two, ai.get(mark));
- assertEquals(0, mark[0]);
-
- assertTrue(ai.compareAndSet(two, m3, 0, 1));
- assertEquals(m3, ai.get(mark));
- assertEquals(1, mark[0]);
-
- assertFalse(ai.compareAndSet(two, m3, 1, 1));
- assertEquals(m3, ai.get(mark));
- assertEquals(1, mark[0]);
- }
-
- /**
- * compareAndSet in one thread enables another waiting for reference value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads() {
- final AtomicStampedReference ai = new AtomicStampedReference(one, 0);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!ai.compareAndSet(two, three, 0, 0)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(ai.compareAndSet(one, two, 0, 0));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(ai.getReference(), three);
- assertEquals(ai.getStamp(), 0);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * compareAndSet in one thread enables another waiting for stamp value
- * to succeed
- */
- public void testCompareAndSetInMultipleThreads2() {
- final AtomicStampedReference ai = new AtomicStampedReference(one, 0);
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(!ai.compareAndSet(one, one, 1, 2)) Thread.yield();
- }});
- try {
- t.start();
- assertTrue(ai.compareAndSet(one, one, 0, 1));
- t.join(LONG_DELAY_MS);
- assertFalse(t.isAlive());
- assertEquals(ai.getReference(), one);
- assertEquals(ai.getStamp(), 2);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * repeated weakCompareAndSet succeeds in changing values when equal
- * to expected
- */
- public void testWeakCompareAndSet(){
- int[] mark = new int[1];
- AtomicStampedReference ai = new AtomicStampedReference(one, 0);
- assertEquals(one, ai.get(mark));
- assertEquals(0, ai.getStamp ());
- assertEquals(0, mark[0]);
-
- while(!ai.weakCompareAndSet(one, two, 0, 0));
- assertEquals(two, ai.get(mark));
- assertEquals(0, mark[0]);
-
- while(!ai.weakCompareAndSet(two, m3, 0, 1));
- assertEquals(m3, ai.get(mark));
- assertEquals(1, mark[0]);
- }
-
-}
diff --git a/concurrent/src/test/java/ConcurrentHashMapTest.java b/concurrent/src/test/java/ConcurrentHashMapTest.java
deleted file mode 100644
index 2a276bb..0000000
--- a/concurrent/src/test/java/ConcurrentHashMapTest.java
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.Enumeration;
-import java.io.*;
-
-public class ConcurrentHashMapTest extends JSR166TestCase{
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ConcurrentHashMapTest.class);
- }
-
- /**
- * Create a map from Integers 1-5 to Strings "A"-"E".
- */
- private static ConcurrentHashMap map5() {
- ConcurrentHashMap map = new ConcurrentHashMap(5);
- assertTrue(map.isEmpty());
- map.put(one, "A");
- map.put(two, "B");
- map.put(three, "C");
- map.put(four, "D");
- map.put(five, "E");
- assertFalse(map.isEmpty());
- assertEquals(5, map.size());
- return map;
- }
-
- /**
- * clear removes all pairs
- */
- public void testClear() {
- ConcurrentHashMap map = map5();
- map.clear();
- assertEquals(map.size(), 0);
- }
-
- /**
- * Maps with same contents are equal
- */
- public void testEquals() {
- ConcurrentHashMap map1 = map5();
- ConcurrentHashMap map2 = map5();
- assertEquals(map1, map2);
- assertEquals(map2, map1);
- map1.clear();
- assertFalse(map1.equals(map2));
- assertFalse(map2.equals(map1));
- }
-
- /**
- * contains returns true for contained value
- */
- public void testContains() {
- ConcurrentHashMap map = map5();
- assertTrue(map.contains("A"));
- assertFalse(map.contains("Z"));
- }
-
- /**
- * containsKey returns true for contained key
- */
- public void testContainsKey() {
- ConcurrentHashMap map = map5();
- assertTrue(map.containsKey(one));
- assertFalse(map.containsKey(zero));
- }
-
- /**
- * containsValue returns true for held values
- */
- public void testContainsValue() {
- ConcurrentHashMap map = map5();
- assertTrue(map.containsValue("A"));
- assertFalse(map.containsValue("Z"));
- }
-
- /**
- * enumeration returns an enumeration containing the correct
- * elements
- */
- public void testEnumeration() {
- ConcurrentHashMap map = map5();
- Enumeration e = map.elements();
- int count = 0;
- while(e.hasMoreElements()){
- count++;
- e.nextElement();
- }
- assertEquals(5, count);
- }
-
- /**
- * get returns the correct element at the given key,
- * or null if not present
- */
- public void testGet() {
- ConcurrentHashMap map = map5();
- assertEquals("A", (String)map.get(one));
- ConcurrentHashMap empty = new ConcurrentHashMap();
- assertNull(map.get("anything"));
- }
-
- /**
- * isEmpty is true of empty map and false for non-empty
- */
- public void testIsEmpty() {
- ConcurrentHashMap empty = new ConcurrentHashMap();
- ConcurrentHashMap map = map5();
- assertTrue(empty.isEmpty());
- assertFalse(map.isEmpty());
- }
-
- /**
- * keys returns an enumeration containing all the keys from the map
- */
- public void testKeys() {
- ConcurrentHashMap map = map5();
- Enumeration e = map.keys();
- int count = 0;
- while(e.hasMoreElements()){
- count++;
- e.nextElement();
- }
- assertEquals(5, count);
- }
-
- /**
- * keySet returns a Set containing all the keys
- */
- public void testKeySet() {
- ConcurrentHashMap map = map5();
- Set s = map.keySet();
- assertEquals(5, s.size());
- assertTrue(s.contains(one));
- assertTrue(s.contains(two));
- assertTrue(s.contains(three));
- assertTrue(s.contains(four));
- assertTrue(s.contains(five));
- }
-
- /**
- * keySet.toArray returns contains all keys
- */
- public void testKeySetToArray() {
- ConcurrentHashMap map = map5();
- Set s = map.keySet();
- Object[] ar = s.toArray();
- assertTrue(s.containsAll(Arrays.asList(ar)));
- assertEquals(5, ar.length);
- ar[0] = m10;
- assertFalse(s.containsAll(Arrays.asList(ar)));
- }
-
- /**
- * Values.toArray contains all values
- */
- public void testValuesToArray() {
- ConcurrentHashMap map = map5();
- Collection v = map.values();
- Object[] ar = v.toArray();
- ArrayList s = new ArrayList(Arrays.asList(ar));
- assertEquals(5, ar.length);
- assertTrue(s.contains("A"));
- assertTrue(s.contains("B"));
- assertTrue(s.contains("C"));
- assertTrue(s.contains("D"));
- assertTrue(s.contains("E"));
- }
-
- /**
- * entrySet.toArray contains all entries
- */
- public void testEntrySetToArray() {
- ConcurrentHashMap map = map5();
- Set s = map.entrySet();
- Object[] ar = s.toArray();
- assertEquals(5, ar.length);
- for (int i = 0; i < 5; ++i) {
- assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey()));
- assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue()));
- }
- }
-
- /**
- * values collection contains all values
- */
- public void testValues() {
- ConcurrentHashMap map = map5();
- Collection s = map.values();
- assertEquals(5, s.size());
- assertTrue(s.contains("A"));
- assertTrue(s.contains("B"));
- assertTrue(s.contains("C"));
- assertTrue(s.contains("D"));
- assertTrue(s.contains("E"));
- }
-
- /**
- * entrySet contains all pairs
- */
- public void testEntrySet() {
- ConcurrentHashMap map = map5();
- Set s = map.entrySet();
- assertEquals(5, s.size());
- Iterator it = s.iterator();
- while (it.hasNext()) {
- Map.Entry e = (Map.Entry) it.next();
- assertTrue(
- (e.getKey().equals(one) && e.getValue().equals("A")) ||
- (e.getKey().equals(two) && e.getValue().equals("B")) ||
- (e.getKey().equals(three) && e.getValue().equals("C")) ||
- (e.getKey().equals(four) && e.getValue().equals("D")) ||
- (e.getKey().equals(five) && e.getValue().equals("E")));
- }
- }
-
- /**
- * putAll adds all key-value pairs from the given map
- */
- public void testPutAll() {
- ConcurrentHashMap empty = new ConcurrentHashMap();
- ConcurrentHashMap map = map5();
- empty.putAll(map);
- assertEquals(5, empty.size());
- assertTrue(empty.containsKey(one));
- assertTrue(empty.containsKey(two));
- assertTrue(empty.containsKey(three));
- assertTrue(empty.containsKey(four));
- assertTrue(empty.containsKey(five));
- }
-
- /**
- * putIfAbsent works when the given key is not present
- */
- public void testPutIfAbsent() {
- ConcurrentHashMap map = map5();
- map.putIfAbsent(six, "Z");
- assertTrue(map.containsKey(six));
- }
-
- /**
- * putIfAbsent does not add the pair if the key is already present
- */
- public void testPutIfAbsent2() {
- ConcurrentHashMap map = map5();
- assertEquals("A", map.putIfAbsent(one, "Z"));
- }
-
- /**
- * replace fails when the given key is not present
- */
- public void testReplace() {
- ConcurrentHashMap map = map5();
- assertNull(map.replace(six, "Z"));
- assertFalse(map.containsKey(six));
- }
-
- /**
- * replace succeeds if the key is already present
- */
- public void testReplace2() {
- ConcurrentHashMap map = map5();
- assertNotNull(map.replace(one, "Z"));
- assertEquals("Z", map.get(one));
- }
-
-
- /**
- * replace value fails when the given key not mapped to expected value
- */
- public void testReplaceValue() {
- ConcurrentHashMap map = map5();
- assertEquals("A", map.get(one));
- assertFalse(map.replace(one, "Z", "Z"));
- assertEquals("A", map.get(one));
- }
-
- /**
- * replace value succeeds when the given key mapped to expected value
- */
- public void testReplaceValue2() {
- ConcurrentHashMap map = map5();
- assertEquals("A", map.get(one));
- assertTrue(map.replace(one, "A", "Z"));
- assertEquals("Z", map.get(one));
- }
-
-
- /**
- * remove removes the correct key-value pair from the map
- */
- public void testRemove() {
- ConcurrentHashMap map = map5();
- map.remove(five);
- assertEquals(4, map.size());
- assertFalse(map.containsKey(five));
- }
-
- /**
- * remove(key,value) removes only if pair present
- */
- public void testRemove2() {
- ConcurrentHashMap map = map5();
- map.remove(five, "E");
- assertEquals(4, map.size());
- assertFalse(map.containsKey(five));
- map.remove(four, "A");
- assertEquals(4, map.size());
- assertTrue(map.containsKey(four));
-
- }
-
- /**
- * size returns the correct values
- */
- public void testSize() {
- ConcurrentHashMap map = map5();
- ConcurrentHashMap empty = new ConcurrentHashMap();
- assertEquals(0, empty.size());
- assertEquals(5, map.size());
- }
-
- /**
- * toString contains toString of elements
- */
- public void testToString() {
- ConcurrentHashMap map = map5();
- String s = map.toString();
- for (int i = 1; i <= 5; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
- // Exception tests
-
- /**
- * Cannot create with negative capacity
- */
- public void testConstructor1() {
- try {
- new ConcurrentHashMap(-1,0,1);
- shouldThrow();
- } catch(IllegalArgumentException e){}
- }
-
- /**
- * Cannot create with negative concurrency level
- */
- public void testConstructor2() {
- try {
- new ConcurrentHashMap(1,0,-1);
- shouldThrow();
- } catch(IllegalArgumentException e){}
- }
-
- /**
- * Cannot create with only negative capacity
- */
- public void testConstructor3() {
- try {
- new ConcurrentHashMap(-1);
- shouldThrow();
- } catch(IllegalArgumentException e){}
- }
-
- /**
- * get(null) throws NPE
- */
- public void testGet_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.get(null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * containsKey(null) throws NPE
- */
- public void testContainsKey_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.containsKey(null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * containsValue(null) throws NPE
- */
- public void testContainsValue_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.containsValue(null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * contains(null) throws NPE
- */
- public void testContains_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.contains(null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * put(null,x) throws NPE
- */
- public void testPut1_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.put(null, "whatever");
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * put(x, null) throws NPE
- */
- public void testPut2_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.put("whatever", null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * putIfAbsent(null, x) throws NPE
- */
- public void testPutIfAbsent1_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.putIfAbsent(null, "whatever");
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * replace(null, x) throws NPE
- */
- public void testReplace_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.replace(null, "whatever");
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * replace(null, x, y) throws NPE
- */
- public void testReplaceValue_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.replace(null, one, "whatever");
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * putIfAbsent(x, null) throws NPE
- */
- public void testPutIfAbsent2_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.putIfAbsent("whatever", null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
-
- /**
- * replace(x, null) throws NPE
- */
- public void testReplace2_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.replace("whatever", null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * replace(x, null, y) throws NPE
- */
- public void testReplaceValue2_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.replace("whatever", null, "A");
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * replace(x, y, null) throws NPE
- */
- public void testReplaceValue3_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.replace("whatever", one, null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
-
- /**
- * remove(null) throws NPE
- */
- public void testRemove1_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.put("sadsdf", "asdads");
- c.remove(null);
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * remove(null, x) throws NPE
- */
- public void testRemove2_NullPointerException() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.put("sadsdf", "asdads");
- c.remove(null, "whatever");
- shouldThrow();
- } catch(NullPointerException e){}
- }
-
- /**
- * remove(x, null) returns false
- */
- public void testRemove3() {
- try {
- ConcurrentHashMap c = new ConcurrentHashMap(5);
- c.put("sadsdf", "asdads");
- assertFalse(c.remove("sadsdf", null));
- } catch(NullPointerException e){
- fail();
- }
- }
-
- /**
- * A deserialized map equals original
- */
- public void testSerialization() {
- ConcurrentHashMap q = map5();
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- ConcurrentHashMap r = (ConcurrentHashMap)in.readObject();
- assertEquals(q.size(), r.size());
- assertTrue(q.equals(r));
- assertTrue(r.equals(q));
- } catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
-
- /**
- * SetValue of an EntrySet entry sets value in the map.
- */
- public void testSetValueWriteThrough() {
- // Adapted from a bug report by Eric Zoerner
- ConcurrentHashMap map = new ConcurrentHashMap(2, 5.0f, 1);
- assertTrue(map.isEmpty());
- for (int i = 0; i < 20; i++)
- map.put(new Integer(i), new Integer(i));
- assertFalse(map.isEmpty());
- Map.Entry entry1 = (Map.Entry)map.entrySet().iterator().next();
-
- // assert that entry1 is not 16
- assertTrue("entry is 16, test not valid",
- !entry1.getKey().equals(new Integer(16)));
-
- // remove 16 (a different key) from map
- // which just happens to cause entry1 to be cloned in map
- map.remove(new Integer(16));
- entry1.setValue("XYZ");
- assertTrue(map.containsValue("XYZ")); // fails
- }
-
-}
diff --git a/concurrent/src/test/java/ConcurrentLinkedQueueTest.java b/concurrent/src/test/java/ConcurrentLinkedQueueTest.java
deleted file mode 100644
index 7f54a28..0000000
--- a/concurrent/src/test/java/ConcurrentLinkedQueueTest.java
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class ConcurrentLinkedQueueTest extends JSR166TestCase {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
-
- public static Test suite() {
- return new TestSuite(ConcurrentLinkedQueueTest.class);
- }
-
- /**
- * Create a queue of given size containing consecutive
- * Integers 0 ... n.
- */
- private ConcurrentLinkedQueue populatedQueue(int n) {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- assertTrue(q.isEmpty());
- for(int i = 0; i < n; ++i)
- assertTrue(q.offer(new Integer(i)));
- assertFalse(q.isEmpty());
- assertEquals(n, q.size());
- return q;
- }
-
- /**
- * new queue is empty
- */
- public void testConstructor1() {
- assertEquals(0, new ConcurrentLinkedQueue().size());
- }
-
- /**
- * Initializing from null Collection throws NPE
- */
- public void testConstructor3() {
- try {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue((Collection)null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection of null elements throws NPE
- */
- public void testConstructor4() {
- try {
- Integer[] ints = new Integer[SIZE];
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection with some null elements throws NPE
- */
- public void testConstructor5() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of collection used to initialize
- */
- public void testConstructor6() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * isEmpty is true before add, false after
- */
- public void testEmpty() {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- assertTrue(q.isEmpty());
- q.add(one);
- assertFalse(q.isEmpty());
- q.add(two);
- q.remove();
- q.remove();
- assertTrue(q.isEmpty());
- }
-
- /**
- * size changes when elements added and removed
- */
- public void testSize() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(SIZE-i, q.size());
- q.remove();
- }
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.size());
- q.add(new Integer(i));
- }
- }
-
- /**
- * offer(null) throws NPE
- */
- public void testOfferNull() {
- try {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- q.offer(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * add(null) throws NPE
- */
- public void testAddNull() {
- try {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- q.add(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
-
- /**
- * Offer returns true
- */
- public void testOffer() {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- assertTrue(q.offer(zero));
- assertTrue(q.offer(one));
- }
-
- /**
- * add returns true
- */
- public void testAdd() {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.size());
- assertTrue(q.add(new Integer(i)));
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * addAll(this) throws IAE
- */
- public void testAddAllSelf() {
- try {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- q.addAll(q);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * addAll of a collection with null elements throws NPE
- */
- public void testAddAll2() {
- try {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- Integer[] ints = new Integer[SIZE];
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll of a collection with any null elements throws NPE after
- * possibly adding some elements
- */
- public void testAddAll3() {
- try {
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements, in traversal order, of successful addAll
- */
- public void testAddAll5() {
- try {
- Integer[] empty = new Integer[0];
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- assertFalse(q.addAll(Arrays.asList(empty)));
- assertTrue(q.addAll(Arrays.asList(ints)));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * poll succeeds unless empty
- */
- public void testPoll() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll()).intValue());
- }
- assertNull(q.poll());
- }
-
- /**
- * peek returns next element, or null if empty
- */
- public void testPeek() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.peek()).intValue());
- q.poll();
- assertTrue(q.peek() == null ||
- i != ((Integer)q.peek()).intValue());
- }
- assertNull(q.peek());
- }
-
- /**
- * element returns next element, or throws NSEE if empty
- */
- public void testElement() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.element()).intValue());
- q.poll();
- }
- try {
- q.element();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * remove removes next element, or throws NSEE if empty
- */
- public void testRemove() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.remove()).intValue());
- }
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success){
- }
- }
-
- /**
- * remove(x) removes x and returns true if present
- */
- public void testRemoveElement() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- for (int i = 1; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- }
- for (int i = 0; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- assertFalse(q.remove(new Integer(i+1)));
- }
- assertTrue(q.isEmpty());
- }
-
- /**
- * contains(x) reports true when elements added but not yet removed
- */
- public void testContains() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.contains(new Integer(i)));
- q.poll();
- assertFalse(q.contains(new Integer(i)));
- }
- }
-
- /**
- * clear removes all elements
- */
- public void testClear() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- q.clear();
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- q.add(one);
- assertFalse(q.isEmpty());
- q.clear();
- assertTrue(q.isEmpty());
- }
-
- /**
- * containsAll(c) is true when c contains a subset of elements
- */
- public void testContainsAll() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- ConcurrentLinkedQueue p = new ConcurrentLinkedQueue();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.containsAll(p));
- assertFalse(p.containsAll(q));
- p.add(new Integer(i));
- }
- assertTrue(p.containsAll(q));
- }
-
- /**
- * retainAll(c) retains only those elements of c and reports true if change
- */
- public void testRetainAll() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- ConcurrentLinkedQueue p = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- boolean changed = q.retainAll(p);
- if (i == 0)
- assertFalse(changed);
- else
- assertTrue(changed);
-
- assertTrue(q.containsAll(p));
- assertEquals(SIZE-i, q.size());
- p.remove();
- }
- }
-
- /**
- * removeAll(c) removes only those elements of c and reports true if changed
- */
- public void testRemoveAll() {
- for (int i = 1; i < SIZE; ++i) {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- ConcurrentLinkedQueue p = populatedQueue(i);
- assertTrue(q.removeAll(p));
- assertEquals(SIZE-i, q.size());
- for (int j = 0; j < i; ++j) {
- Integer I = (Integer)(p.remove());
- assertFalse(q.contains(I));
- }
- }
- }
-
- /**
- * toArray contains all elements
- */
- public void testToArray() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- Object[] o = q.toArray();
- Arrays.sort(o);
- for(int i = 0; i < o.length; i++)
- assertEquals(o[i], q.poll());
- }
-
- /**
- * toArray(a) contains all elements
- */
- public void testToArray2() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- ints = (Integer[])q.toArray(ints);
- Arrays.sort(ints);
- for(int i = 0; i < ints.length; i++)
- assertEquals(ints[i], q.poll());
- }
-
- /**
- * toArray(null) throws NPE
- */
- public void testToArray_BadArg() {
- try {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(null);
- shouldThrow();
- } catch(NullPointerException success){}
- }
-
- /**
- * toArray with incompatible array type throws CCE
- */
- public void testToArray1_BadArg() {
- try {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(new String[10] );
- shouldThrow();
- } catch(ArrayStoreException success){}
- }
-
- /**
- * iterator iterates through all elements
- */
- public void testIterator() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- int i = 0;
- Iterator it = q.iterator();
- while(it.hasNext()) {
- assertTrue(q.contains(it.next()));
- ++i;
- }
- assertEquals(i, SIZE);
- }
-
- /**
- * iterator ordering is FIFO
- */
- public void testIteratorOrdering() {
- final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- q.add(one);
- q.add(two);
- q.add(three);
-
- int k = 0;
- for (Iterator it = q.iterator(); it.hasNext();) {
- int i = ((Integer)(it.next())).intValue();
- assertEquals(++k, i);
- }
-
- assertEquals(3, k);
- }
-
- /**
- * Modifications do not cause iterators to fail
- */
- public void testWeaklyConsistentIteration () {
- final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- q.add(one);
- q.add(two);
- q.add(three);
-
- try {
- for (Iterator it = q.iterator(); it.hasNext();) {
- q.remove();
- it.next();
- }
- }
- catch (ConcurrentModificationException e) {
- shouldThrow();
- }
-
- assertEquals("queue should be empty again", 0, q.size());
- }
-
- /**
- * iterator.remove removes current element
- */
- public void testIteratorRemove () {
- final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
- q.add(one);
- q.add(two);
- q.add(three);
- Iterator it = q.iterator();
- it.next();
- it.remove();
- it = q.iterator();
- assertEquals(it.next(), two);
- assertEquals(it.next(), three);
- assertFalse(it.hasNext());
- }
-
-
- /**
- * toString contains toStrings of elements
- */
- public void testToString() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- String s = q.toString();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
- /**
- * A deserialized serialized queue has same elements in same order
- */
- public void testSerialization() {
- ConcurrentLinkedQueue q = populatedQueue(SIZE);
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- ConcurrentLinkedQueue r = (ConcurrentLinkedQueue)in.readObject();
- assertEquals(q.size(), r.size());
- while (!q.isEmpty())
- assertEquals(q.remove(), r.remove());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-}
diff --git a/concurrent/src/test/java/CopyOnWriteArrayListTest.java b/concurrent/src/test/java/CopyOnWriteArrayListTest.java
deleted file mode 100644
index f468d14..0000000
--- a/concurrent/src/test/java/CopyOnWriteArrayListTest.java
+++ /dev/null
@@ -1,621 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class CopyOnWriteArrayListTest extends JSR166TestCase{
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
-
- public static Test suite() {
- return new TestSuite(CopyOnWriteArrayListTest.class);
- }
-
- static CopyOnWriteArrayList populatedArray(int n){
- CopyOnWriteArrayList a = new CopyOnWriteArrayList();
- assertTrue(a.isEmpty());
- for (int i = 0; i < n; ++i)
- a.add(new Integer(i));
- assertFalse(a.isEmpty());
- assertEquals(n, a.size());
- return a;
- }
-
-
- /**
- * a new list is empty
- */
- public void testConstructor() {
- CopyOnWriteArrayList a = new CopyOnWriteArrayList();
- assertTrue(a.isEmpty());
- }
-
- /**
- * new list contains all elements of initializing array
- */
- public void testConstructor2() {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- CopyOnWriteArrayList a = new CopyOnWriteArrayList(ints);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], a.get(i));
- }
-
- /**
- * new list contains all elements of initializing collection
- */
- public void testConstructor3() {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- CopyOnWriteArrayList a = new CopyOnWriteArrayList(Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], a.get(i));
- }
-
-
- /**
- * addAll adds each element from the given collection
- */
- public void testAddAll() {
- CopyOnWriteArrayList full = populatedArray(3);
- Vector v = new Vector();
- v.add(three);
- v.add(four);
- v.add(five);
- full.addAll(v);
- assertEquals(6, full.size());
- }
-
- /**
- * addAllAbsent adds each element from the given collection that did not
- * already exist in the List
- */
- public void testAddAllAbsent() {
- CopyOnWriteArrayList full = populatedArray(3);
- Vector v = new Vector();
- v.add(three);
- v.add(four);
- v.add(one); // will not add this element
- full.addAllAbsent(v);
- assertEquals(5, full.size());
- }
-
- /**
- * addIfAbsent will not add the element if it already exists in the list
- */
- public void testAddIfAbsent() {
- CopyOnWriteArrayList full = populatedArray(SIZE);
- full.addIfAbsent(one);
- assertEquals(SIZE, full.size());
- }
-
- /**
- * addIfAbsent adds the element when it does not exist in the list
- */
- public void testAddIfAbsent2() {
- CopyOnWriteArrayList full = populatedArray(SIZE);
- full.addIfAbsent(three);
- assertTrue(full.contains(three));
- }
-
- /**
- * clear removes all elements from the list
- */
- public void testClear() {
- CopyOnWriteArrayList full = populatedArray(SIZE);
- full.clear();
- assertEquals(0, full.size());
- }
-
-
- /**
- * Cloned list is equal
- */
- public void testClone() {
- CopyOnWriteArrayList l1 = populatedArray(SIZE);
- CopyOnWriteArrayList l2 = (CopyOnWriteArrayList)(l1.clone());
- assertEquals(l1, l2);
- l1.clear();
- assertFalse(l1.equals(l2));
- }
-
- /**
- * contains is true for added elements
- */
- public void testContains() {
- CopyOnWriteArrayList full = populatedArray(3);
- assertTrue(full.contains(one));
- assertFalse(full.contains(five));
- }
-
- /**
- * adding at an index places it in the indicated index
- */
- public void testAddIndex() {
- CopyOnWriteArrayList full = populatedArray(3);
- full.add(0, m1);
- assertEquals(4, full.size());
- assertEquals(m1, full.get(0));
- assertEquals(zero, full.get(1));
-
- full.add(2, m2);
- assertEquals(5, full.size());
- assertEquals(m2, full.get(2));
- assertEquals(two, full.get(4));
- }
-
- /**
- * lists with same elements are equal and have same hashCode
- */
- public void testEquals() {
- CopyOnWriteArrayList a = populatedArray(3);
- CopyOnWriteArrayList b = populatedArray(3);
- assertTrue(a.equals(b));
- assertTrue(b.equals(a));
- assertEquals(a.hashCode(), b.hashCode());
- a.add(m1);
- assertFalse(a.equals(b));
- assertFalse(b.equals(a));
- b.add(m1);
- assertTrue(a.equals(b));
- assertTrue(b.equals(a));
- assertEquals(a.hashCode(), b.hashCode());
- }
-
-
- /**
- * containsAll returns true for collection with subset of elements
- */
- public void testContainsAll() {
- CopyOnWriteArrayList full = populatedArray(3);
- Vector v = new Vector();
- v.add(one);
- v.add(two);
- assertTrue(full.containsAll(v));
- v.add(six);
- assertFalse(full.containsAll(v));
- }
-
- /**
- * get returns the value at the given index
- */
- public void testGet() {
- CopyOnWriteArrayList full = populatedArray(3);
- assertEquals(0, ((Integer)full.get(0)).intValue());
- }
-
- /**
- * indexOf gives the index for the given object
- */
- public void testIndexOf() {
- CopyOnWriteArrayList full = populatedArray(3);
- assertEquals(1, full.indexOf(one));
- assertEquals(-1, full.indexOf("puppies"));
- }
-
- /**
- * indexOf gives the index based on the given index
- * at which to start searching
- */
- public void testIndexOf2() {
- CopyOnWriteArrayList full = populatedArray(3);
- assertEquals(1, full.indexOf(one, 0));
- assertEquals(-1, full.indexOf(one, 2));
- }
-
- /**
- * isEmpty returns true when empty, else false
- */
- public void testIsEmpty() {
- CopyOnWriteArrayList empty = new CopyOnWriteArrayList();
- CopyOnWriteArrayList full = populatedArray(SIZE);
- assertTrue(empty.isEmpty());
- assertFalse(full.isEmpty());
- }
-
- /**
- * iterator() returns an iterator containing the elements of the list
- */
- public void testIterator() {
- CopyOnWriteArrayList full = populatedArray(SIZE);
- Iterator i = full.iterator();
- int j;
- for(j = 0; i.hasNext(); j++)
- assertEquals(j, ((Integer)i.next()).intValue());
- assertEquals(SIZE, j);
- }
-
- /**
- * iterator.remove throws UnsupportedOperationException
- */
- public void testIteratorRemove () {
- CopyOnWriteArrayList full = populatedArray(SIZE);
- Iterator it = full.iterator();
- it.next();
- try {
- it.remove();
- shouldThrow();
- }
- catch (UnsupportedOperationException success) {}
- }
-
- /**
- * toString contains toString of elements
- */
- public void testToString() {
- CopyOnWriteArrayList full = populatedArray(3);
- String s = full.toString();
- for (int i = 0; i < 3; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
- /**
- * lastIndexOf returns the index for the given object
- */
- public void testLastIndexOf1() {
- CopyOnWriteArrayList full = populatedArray(3);
- full.add(one);
- full.add(three);
- assertEquals(3, full.lastIndexOf(one));
- assertEquals(-1, full.lastIndexOf(six));
- }
-
- /**
- * lastIndexOf returns the index from the given starting point
- */
- public void testlastIndexOf2() {
- CopyOnWriteArrayList full = populatedArray(3);
- full.add(one);
- full.add(three);
- assertEquals(3, full.lastIndexOf(one, 4));
- assertEquals(-1, full.lastIndexOf(three, 3));
- }
-
- /**
- * listIterator traverses all elements
- */
- public void testListIterator1() {
- CopyOnWriteArrayList full = populatedArray(SIZE);
- ListIterator i = full.listIterator();
- int j;
- for(j = 0; i.hasNext(); j++)
- assertEquals(j, ((Integer)i.next()).intValue());
- assertEquals(SIZE, j);
- }
-
- /**
- * listIterator only returns those elements after the given index
- */
- public void testListIterator2() {
- CopyOnWriteArrayList full = populatedArray(3);
- ListIterator i = full.listIterator(1);
- int j;
- for(j = 0; i.hasNext(); j++)
- assertEquals(j+1, ((Integer)i.next()).intValue());
- assertEquals(2, j);
- }
-
- /**
- * remove removes and returns the object at the given index
- */
- public void testRemove() {
- CopyOnWriteArrayList full = populatedArray(3);
- assertEquals(two, full.remove(2));
- assertEquals(2, full.size());
- }
-
- /**
- * removeAll removes all elements from the given collection
- */
- public void testRemoveAll() {
- CopyOnWriteArrayList full = populatedArray(3);
- Vector v = new Vector();
- v.add(one);
- v.add(two);
- full.removeAll(v);
- assertEquals(1, full.size());
- }
-
- /**
- * set changes the element at the given index
- */
- public void testSet() {
- CopyOnWriteArrayList full = populatedArray(3);
- assertEquals(two, full.set(2, four));
- assertEquals(4, ((Integer)full.get(2)).intValue());
- }
-
- /**
- * size returns the number of elements
- */
- public void testSize() {
- CopyOnWriteArrayList empty = new CopyOnWriteArrayList();
- CopyOnWriteArrayList full = populatedArray(SIZE);
- assertEquals(SIZE, full.size());
- assertEquals(0, empty.size());
- }
-
- /**
- * toArray returns an Object array containing all elements from the list
- */
- public void testToArray() {
- CopyOnWriteArrayList full = populatedArray(3);
- Object[] o = full.toArray();
- assertEquals(3, o.length);
- assertEquals(0, ((Integer)o[0]).intValue());
- assertEquals(1, ((Integer)o[1]).intValue());
- assertEquals(2, ((Integer)o[2]).intValue());
- }
-
- /**
- * toArray returns an Integer array containing all elements from
- * the list
- */
- public void testToArray2() {
- CopyOnWriteArrayList full = populatedArray(3);
- Integer[] i = new Integer[3];
- i = (Integer[])full.toArray(i);
- assertEquals(3, i.length);
- assertEquals(0, i[0].intValue());
- assertEquals(1, i[1].intValue());
- assertEquals(2, i[2].intValue());
- }
-
-
- /**
- * sublists contains elements at indexes offset from their base
- */
- public void testSubList() {
- CopyOnWriteArrayList a = populatedArray(10);
- assertTrue(a.subList(1,1).isEmpty());
- for(int j = 0; j < 9; ++j) {
- for(int i = j ; i < 10; ++i) {
- List b = a.subList(j,i);
- for(int k = j; k < i; ++k) {
- assertEquals(new Integer(k), b.get(k-j));
- }
- }
- }
-
- List s = a.subList(2, 5);
- assertEquals(s.size(), 3);
- s.set(2, m1);
- assertEquals(a.get(4), m1);
- s.clear();
- assertEquals(a.size(), 7);
- }
-
- // Exception tests
-
- /**
- * toArray throws an ArrayStoreException when the given array
- * can not store the objects inside the list
- */
- public void testToArray_ArrayStoreException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add("zfasdfsdf");
- c.add("asdadasd");
- c.toArray(new Long[5]);
- shouldThrow();
- } catch(ArrayStoreException e){}
- }
-
- /**
- * get throws an IndexOutOfBoundsException on a negative index
- */
- public void testGet1_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.get(-1);
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * get throws an IndexOutOfBoundsException on a too high index
- */
- public void testGet2_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add("asdasd");
- c.add("asdad");
- c.get(100);
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * set throws an IndexOutOfBoundsException on a negative index
- */
- public void testSet1_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.set(-1,"qwerty");
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * set throws an IndexOutOfBoundsException on a too high index
- */
- public void testSet2() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add("asdasd");
- c.add("asdad");
- c.set(100, "qwerty");
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * add throws an IndexOutOfBoundsException on a negative index
- */
- public void testAdd1_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add(-1,"qwerty");
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * add throws an IndexOutOfBoundsException on a too high index
- */
- public void testAdd2_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add("asdasd");
- c.add("asdasdasd");
- c.add(100, "qwerty");
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * remove throws an IndexOutOfBoundsException on a negative index
- */
- public void testRemove1_IndexOutOfBounds() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.remove(-1);
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * remove throws an IndexOutOfBoundsException on a too high index
- */
- public void testRemove2_IndexOutOfBounds() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add("asdasd");
- c.add("adasdasd");
- c.remove(100);
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * addAll throws an IndexOutOfBoundsException on a negative index
- */
- public void testAddAll1_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.addAll(-1,new LinkedList());
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * addAll throws an IndexOutOfBoundsException on a too high index
- */
- public void testAddAll2_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add("asdasd");
- c.add("asdasdasd");
- c.addAll(100, new LinkedList());
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * listIterator throws an IndexOutOfBoundsException on a negative index
- */
- public void testListIterator1_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.listIterator(-1);
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * listIterator throws an IndexOutOfBoundsException on a too high index
- */
- public void testListIterator2_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add("adasd");
- c.add("asdasdas");
- c.listIterator(100);
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * subList throws an IndexOutOfBoundsException on a negative index
- */
- public void testSubList1_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.subList(-1,100);
-
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * subList throws an IndexOutOfBoundsException on a too high index
- */
- public void testSubList2_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.add("asdasd");
- c.subList(1,100);
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * subList throws IndexOutOfBoundsException when the second index
- * is lower then the first
- */
- public void testSubList3_IndexOutOfBoundsException() {
- try {
- CopyOnWriteArrayList c = new CopyOnWriteArrayList();
- c.subList(3,1);
-
- shouldThrow();
- } catch(IndexOutOfBoundsException e){}
- }
-
- /**
- * a deserialized serialiszed list is equal
- */
- public void testSerialization() {
- CopyOnWriteArrayList q = populatedArray(SIZE);
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- CopyOnWriteArrayList r = (CopyOnWriteArrayList)in.readObject();
- assertEquals(q.size(), r.size());
- assertTrue(q.equals(r));
- assertTrue(r.equals(q));
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-}
diff --git a/concurrent/src/test/java/CopyOnWriteArraySetTest.java b/concurrent/src/test/java/CopyOnWriteArraySetTest.java
deleted file mode 100644
index 51bc886..0000000
--- a/concurrent/src/test/java/CopyOnWriteArraySetTest.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class CopyOnWriteArraySetTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(CopyOnWriteArraySetTest.class);
- }
-
- static CopyOnWriteArraySet populatedSet(int n){
- CopyOnWriteArraySet a = new CopyOnWriteArraySet();
- assertTrue(a.isEmpty());
- for (int i = 0; i < n; ++i)
- a.add(new Integer(i));
- assertFalse(a.isEmpty());
- assertEquals(n, a.size());
- return a;
- }
-
- /**
- * Default-constructed set is empty
- */
- public void testConstructor() {
- CopyOnWriteArraySet a = new CopyOnWriteArraySet();
- assertTrue(a.isEmpty());
- }
-
- /**
- * Collection-constructed set holds all of its elements
- */
- public void testConstructor3() {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- CopyOnWriteArraySet a = new CopyOnWriteArraySet(Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertTrue(a.contains(ints[i]));
- }
-
-
- /**
- * addAll adds each element from the given collection
- */
- public void testAddAll() {
- CopyOnWriteArraySet full = populatedSet(3);
- Vector v = new Vector();
- v.add(three);
- v.add(four);
- v.add(five);
- full.addAll(v);
- assertEquals(6, full.size());
- }
-
- /**
- * addAll adds each element from the given collection that did not
- * already exist in the set
- */
- public void testAddAll2() {
- CopyOnWriteArraySet full = populatedSet(3);
- Vector v = new Vector();
- v.add(three);
- v.add(four);
- v.add(one); // will not add this element
- full.addAll(v);
- assertEquals(5, full.size());
- }
-
- /**
- * add will not add the element if it already exists in the set
- */
- public void testAdd2() {
- CopyOnWriteArraySet full = populatedSet(3);
- full.add(one);
- assertEquals(3, full.size());
- }
-
- /**
- * add adds the element when it does not exist
- * in the set
- */
- public void testAdd3() {
- CopyOnWriteArraySet full = populatedSet(3);
- full.add(three);
- assertTrue(full.contains(three));
- }
-
- /**
- * clear removes all elements from the set
- */
- public void testClear() {
- CopyOnWriteArraySet full = populatedSet(3);
- full.clear();
- assertEquals(0, full.size());
- }
-
- /**
- * contains returns true for added elements
- */
- public void testContains() {
- CopyOnWriteArraySet full = populatedSet(3);
- assertTrue(full.contains(one));
- assertFalse(full.contains(five));
- }
-
- /**
- * Sets with equal elements are equal
- */
- public void testEquals() {
- CopyOnWriteArraySet a = populatedSet(3);
- CopyOnWriteArraySet b = populatedSet(3);
- assertTrue(a.equals(b));
- assertTrue(b.equals(a));
- assertEquals(a.hashCode(), b.hashCode());
- a.add(m1);
- assertFalse(a.equals(b));
- assertFalse(b.equals(a));
- b.add(m1);
- assertTrue(a.equals(b));
- assertTrue(b.equals(a));
- assertEquals(a.hashCode(), b.hashCode());
- }
-
-
- /**
- * containsAll returns true for collections with subset of elements
- */
- public void testContainsAll() {
- CopyOnWriteArraySet full = populatedSet(3);
- Vector v = new Vector();
- v.add(one);
- v.add(two);
- assertTrue(full.containsAll(v));
- v.add(six);
- assertFalse(full.containsAll(v));
- }
-
- /**
- * isEmpty is true when empty, else false
- */
- public void testIsEmpty() {
- CopyOnWriteArraySet empty = new CopyOnWriteArraySet();
- CopyOnWriteArraySet full = populatedSet(3);
- assertTrue(empty.isEmpty());
- assertFalse(full.isEmpty());
- }
-
- /**
- * iterator() returns an iterator containing the elements of the set
- */
- public void testIterator() {
- CopyOnWriteArraySet full = populatedSet(3);
- Iterator i = full.iterator();
- int j;
- for(j = 0; i.hasNext(); j++)
- assertEquals(j, ((Integer)i.next()).intValue());
- assertEquals(3, j);
- }
-
- /**
- * iterator remove is unsupported
- */
- public void testIteratorRemove () {
- CopyOnWriteArraySet full = populatedSet(3);
- Iterator it = full.iterator();
- it.next();
- try {
- it.remove();
- shouldThrow();
- }
- catch (UnsupportedOperationException success) {}
- }
-
- /**
- * toString holds toString of elements
- */
- public void testToString() {
- CopyOnWriteArraySet full = populatedSet(3);
- String s = full.toString();
- for (int i = 0; i < 3; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
-
- /**
- * removeAll removes all elements from the given collection
- */
- public void testRemoveAll() {
- CopyOnWriteArraySet full = populatedSet(3);
- Vector v = new Vector();
- v.add(one);
- v.add(two);
- full.removeAll(v);
- assertEquals(1, full.size());
- }
-
-
- /**
- * remove removes an element
- */
- public void testRemove() {
- CopyOnWriteArraySet full = populatedSet(3);
- full.remove(one);
- assertFalse(full.contains(one));
- assertEquals(2, full.size());
- }
-
- /**
- * size returns the number of elements
- */
- public void testSize() {
- CopyOnWriteArraySet empty = new CopyOnWriteArraySet();
- CopyOnWriteArraySet full = populatedSet(3);
- assertEquals(3, full.size());
- assertEquals(0, empty.size());
- }
-
- /**
- * toArray returns an Object array containing all elements from the set
- */
- public void testToArray() {
- CopyOnWriteArraySet full = populatedSet(3);
- Object[] o = full.toArray();
- assertEquals(3, o.length);
- assertEquals(0, ((Integer)o[0]).intValue());
- assertEquals(1, ((Integer)o[1]).intValue());
- assertEquals(2, ((Integer)o[2]).intValue());
- }
-
- /**
- * toArray returns an Integer array containing all elements from
- * the set
- */
- public void testToArray2() {
- CopyOnWriteArraySet full = populatedSet(3);
- Integer[] i = new Integer[3];
- i = (Integer[])full.toArray(i);
- assertEquals(3, i.length);
- assertEquals(0, i[0].intValue());
- assertEquals(1, i[1].intValue());
- assertEquals(2, i[2].intValue());
- }
-
-
- /**
- * toArray throws an ArrayStoreException when the given array can
- * not store the objects inside the set
- */
- public void testToArray_ArrayStoreException() {
- try {
- CopyOnWriteArraySet c = new CopyOnWriteArraySet();
- c.add("zfasdfsdf");
- c.add("asdadasd");
- c.toArray(new Long[5]);
- shouldThrow();
- } catch(ArrayStoreException e){}
- }
-
- /**
- * A deserialized serialized set is equal
- */
- public void testSerialization() {
- CopyOnWriteArraySet q = populatedSet(SIZE);
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- CopyOnWriteArraySet r = (CopyOnWriteArraySet)in.readObject();
- assertEquals(q.size(), r.size());
- assertTrue(q.equals(r));
- assertTrue(r.equals(q));
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-}
diff --git a/concurrent/src/test/java/CountDownLatchTest.java b/concurrent/src/test/java/CountDownLatchTest.java
deleted file mode 100644
index 04b0bf1..0000000
--- a/concurrent/src/test/java/CountDownLatchTest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-public class CountDownLatchTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(CountDownLatchTest.class);
- }
-
- /**
- * negative constructor argument throws IAE
- */
- public void testConstructor() {
- try {
- new CountDownLatch(-1);
- shouldThrow();
- } catch(IllegalArgumentException success){}
- }
-
- /**
- * getCount returns initial count and decreases after countDown
- */
- public void testGetCount() {
- final CountDownLatch l = new CountDownLatch(2);
- assertEquals(2, l.getCount());
- l.countDown();
- assertEquals(1, l.getCount());
- }
-
- /**
- * countDown decrements count when positive and has no effect when zero
- */
- public void testCountDown() {
- final CountDownLatch l = new CountDownLatch(1);
- assertEquals(1, l.getCount());
- l.countDown();
- assertEquals(0, l.getCount());
- l.countDown();
- assertEquals(0, l.getCount());
- }
-
- /**
- * await returns after countDown to zero, but not before
- */
- public void testAwait() {
- final CountDownLatch l = new CountDownLatch(2);
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertTrue(l.getCount() > 0);
- l.await();
- threadAssertTrue(l.getCount() == 0);
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
- t.start();
- try {
- assertEquals(l.getCount(), 2);
- Thread.sleep(SHORT_DELAY_MS);
- l.countDown();
- assertEquals(l.getCount(), 1);
- l.countDown();
- assertEquals(l.getCount(), 0);
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
-
- /**
- * timed await returns after countDown to zero
- */
- public void testTimedAwait() {
- final CountDownLatch l = new CountDownLatch(2);
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertTrue(l.getCount() > 0);
- threadAssertTrue(l.await(SMALL_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
- t.start();
- try {
- assertEquals(l.getCount(), 2);
- Thread.sleep(SHORT_DELAY_MS);
- l.countDown();
- assertEquals(l.getCount(), 1);
- l.countDown();
- assertEquals(l.getCount(), 0);
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * await throws IE if interrupted before counted down
- */
- public void testAwait_InterruptedException() {
- final CountDownLatch l = new CountDownLatch(1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertTrue(l.getCount() > 0);
- l.await();
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- t.start();
- try {
- assertEquals(l.getCount(), 1);
- t.interrupt();
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * timed await throws IE if interrupted before counted down
- */
- public void testTimedAwait_InterruptedException() {
- final CountDownLatch l = new CountDownLatch(1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertTrue(l.getCount() > 0);
- l.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(l.getCount(), 1);
- t.interrupt();
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * timed await times out if not counted down before timeout
- */
- public void testAwaitTimeout() {
- final CountDownLatch l = new CountDownLatch(1);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertTrue(l.getCount() > 0);
- threadAssertFalse(l.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(l.getCount() > 0);
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- t.start();
- try {
- assertEquals(l.getCount(), 1);
- t.join();
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * toString indicates current count
- */
- public void testToString() {
- CountDownLatch s = new CountDownLatch(2);
- String us = s.toString();
- assertTrue(us.indexOf("Count = 2") >= 0);
- s.countDown();
- String s1 = s.toString();
- assertTrue(s1.indexOf("Count = 1") >= 0);
- s.countDown();
- String s2 = s.toString();
- assertTrue(s2.indexOf("Count = 0") >= 0);
- }
-
-}
diff --git a/concurrent/src/test/java/CyclicBarrierTest.java b/concurrent/src/test/java/CyclicBarrierTest.java
deleted file mode 100644
index ea82ef8..0000000
--- a/concurrent/src/test/java/CyclicBarrierTest.java
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.locks.*;
-import java.util.concurrent.atomic.*;
-
-public class CyclicBarrierTest extends JSR166TestCase{
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(CyclicBarrierTest.class);
- }
-
- private volatile int countAction;
- private class MyAction implements Runnable {
- public void run() { ++countAction; }
- }
-
- /**
- * Creating with negative parties throws IAE
- */
- public void testConstructor1() {
- try {
- new CyclicBarrier(-1, (Runnable)null);
- shouldThrow();
- } catch(IllegalArgumentException e){}
- }
-
- /**
- * Creating with negative parties and no action throws IAE
- */
- public void testConstructor2() {
- try {
- new CyclicBarrier(-1);
- shouldThrow();
- } catch(IllegalArgumentException e){}
- }
-
- /**
- * getParties returns the number of parties given in constructor
- */
- public void testGetParties() {
- CyclicBarrier b = new CyclicBarrier(2);
- assertEquals(2, b.getParties());
- assertEquals(0, b.getNumberWaiting());
- }
-
- /**
- * A 1-party barrier triggers after single await
- */
- public void testSingleParty() {
- try {
- CyclicBarrier b = new CyclicBarrier(1);
- assertEquals(1, b.getParties());
- assertEquals(0, b.getNumberWaiting());
- b.await();
- b.await();
- assertEquals(0, b.getNumberWaiting());
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * The supplied barrier action is run at barrier
- */
- public void testBarrierAction() {
- try {
- countAction = 0;
- CyclicBarrier b = new CyclicBarrier(1, new MyAction());
- assertEquals(1, b.getParties());
- assertEquals(0, b.getNumberWaiting());
- b.await();
- b.await();
- assertEquals(0, b.getNumberWaiting());
- assertEquals(countAction, 2);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * A 2-party/thread barrier triggers after both threads invoke await
- */
- public void testTwoParties() {
- final CyclicBarrier b = new CyclicBarrier(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- b.await();
- b.await();
- b.await();
- b.await();
- } catch(Exception e){
- threadUnexpectedException();
- }}});
-
- try {
- t.start();
- b.await();
- b.await();
- b.await();
- b.await();
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * An interruption in one party causes others waiting in await to
- * throw BrokenBarrierException
- */
- public void testAwait1_Interrupted_BrokenBarrier() {
- final CyclicBarrier c = new CyclicBarrier(3);
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await();
- threadShouldThrow();
- } catch(InterruptedException success){}
- catch(Exception b){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await();
- threadShouldThrow();
- } catch(BrokenBarrierException success){
- } catch(Exception i){
- threadUnexpectedException();
- }
- }
- });
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- t1.interrupt();
- t1.join();
- t2.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * An interruption in one party causes others waiting in timed await to
- * throw BrokenBarrierException
- */
- public void testAwait2_Interrupted_BrokenBarrier() {
- final CyclicBarrier c = new CyclicBarrier(3);
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){
- } catch(Exception b){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(BrokenBarrierException success){
- } catch(Exception i){
- threadUnexpectedException();
- }
- }
- });
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- t1.interrupt();
- t1.join();
- t2.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A timeout in timed await throws TimeoutException
- */
- public void testAwait3_TimeOutException() {
- final CyclicBarrier c = new CyclicBarrier(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(TimeoutException success){
- } catch(Exception b){
- threadUnexpectedException();
-
- }
- }
- });
- try {
- t.start();
- t.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A timeout in one party causes others waiting in timed await to
- * throw BrokenBarrierException
- */
- public void testAwait4_Timeout_BrokenBarrier() {
- final CyclicBarrier c = new CyclicBarrier(3);
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(TimeoutException success){
- } catch(Exception b){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(BrokenBarrierException success){
- } catch(Exception i){
- threadUnexpectedException();
- }
- }
- });
- try {
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A timeout in one party causes others waiting in await to
- * throw BrokenBarrierException
- */
- public void testAwait5_Timeout_BrokenBarrier() {
- final CyclicBarrier c = new CyclicBarrier(3);
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(TimeoutException success){
- } catch(Exception b){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await();
- threadShouldThrow();
- } catch(BrokenBarrierException success){
- } catch(Exception i){
- threadUnexpectedException();
- }
- }
- });
- try {
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A reset of an active barrier causes waiting threads to throw
- * BrokenBarrierException
- */
- public void testReset_BrokenBarrier() {
- final CyclicBarrier c = new CyclicBarrier(3);
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await();
- threadShouldThrow();
- } catch(BrokenBarrierException success){}
- catch(Exception b){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await();
- threadShouldThrow();
- } catch(BrokenBarrierException success){
- } catch(Exception i){
- threadUnexpectedException();
- }
- }
- });
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- c.reset();
- t1.join();
- t2.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A reset before threads enter barrier does not throw
- * BrokenBarrierException
- */
- public void testReset_NoBrokenBarrier() {
- final CyclicBarrier c = new CyclicBarrier(3);
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await();
- } catch(Exception b){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- c.await();
- } catch(Exception i){
- threadUnexpectedException();
- }
- }
- });
- try {
- c.reset();
- t1.start();
- t2.start();
- c.await();
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * All threads block while a barrier is broken.
- */
- public void testReset_Leakage() {
- try {
- final CyclicBarrier c = new CyclicBarrier(2);
- final AtomicBoolean done = new AtomicBoolean();
- Thread t = new Thread() {
- public void run() {
- while (!done.get()) {
- try {
- while (c.isBroken())
- c.reset();
-
- c.await();
- threadFail("await should not return");
- }
- catch (BrokenBarrierException e) {
- }
- catch (InterruptedException ie) {
- }
- }
- }
- };
-
- t.start();
- for( int i = 0; i < 4; i++) {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- }
- done.set(true);
- t.interrupt();
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * Reset of a non-broken barrier does not break barrier
- */
- public void testResetWithoutBreakage() {
- try {
- final CyclicBarrier start = new CyclicBarrier(3);
- final CyclicBarrier barrier = new CyclicBarrier(3);
- for (int i = 0; i < 3; i++) {
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try { start.await(); }
- catch (Exception ie) {
- threadFail("start barrier");
- }
- try { barrier.await(); }
- catch (Throwable thrown) {
- unexpectedException();
- }}});
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try { start.await(); }
- catch (Exception ie) {
- threadFail("start barrier");
- }
- try { barrier.await(); }
- catch (Throwable thrown) {
- unexpectedException();
- }}});
-
-
- t1.start();
- t2.start();
- try { start.await(); }
- catch (Exception ie) { threadFail("start barrier"); }
- barrier.await();
- t1.join();
- t2.join();
- assertFalse(barrier.isBroken());
- assertEquals(0, barrier.getNumberWaiting());
- if (i == 1) barrier.reset();
- assertFalse(barrier.isBroken());
- assertEquals(0, barrier.getNumberWaiting());
- }
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * Reset of a barrier after interruption reinitializes it.
- */
- public void testResetAfterInterrupt() {
- try {
- final CyclicBarrier start = new CyclicBarrier(3);
- final CyclicBarrier barrier = new CyclicBarrier(3);
- for (int i = 0; i < 2; i++) {
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try { start.await(); }
- catch (Exception ie) {
- threadFail("start barrier");
- }
- try { barrier.await(); }
- catch(InterruptedException ok) {}
- catch (Throwable thrown) {
- unexpectedException();
- }}});
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try { start.await(); }
- catch (Exception ie) {
- threadFail("start barrier");
- }
- try { barrier.await(); }
- catch(BrokenBarrierException ok) {}
- catch (Throwable thrown) {
- unexpectedException();
- }}});
-
- t1.start();
- t2.start();
- try { start.await(); }
- catch (Exception ie) { threadFail("start barrier"); }
- t1.interrupt();
- t1.join();
- t2.join();
- assertTrue(barrier.isBroken());
- assertEquals(0, barrier.getNumberWaiting());
- barrier.reset();
- assertFalse(barrier.isBroken());
- assertEquals(0, barrier.getNumberWaiting());
- }
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * Reset of a barrier after timeout reinitializes it.
- */
- public void testResetAfterTimeout() {
- try {
- final CyclicBarrier start = new CyclicBarrier(3);
- final CyclicBarrier barrier = new CyclicBarrier(3);
- for (int i = 0; i < 2; i++) {
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try { start.await(); }
- catch (Exception ie) {
- threadFail("start barrier");
- }
- try { barrier.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); }
- catch(TimeoutException ok) {}
- catch (Throwable thrown) {
- unexpectedException();
- }}});
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try { start.await(); }
- catch (Exception ie) {
- threadFail("start barrier");
- }
- try { barrier.await(); }
- catch(BrokenBarrierException ok) {}
- catch (Throwable thrown) {
- unexpectedException();
- }}});
-
- t1.start();
- t2.start();
- try { start.await(); }
- catch (Exception ie) { threadFail("start barrier"); }
- t1.join();
- t2.join();
- assertTrue(barrier.isBroken());
- assertEquals(0, barrier.getNumberWaiting());
- barrier.reset();
- assertFalse(barrier.isBroken());
- assertEquals(0, barrier.getNumberWaiting());
- }
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * Reset of a barrier after a failed command reinitializes it.
- */
- public void testResetAfterCommandException() {
- try {
- final CyclicBarrier start = new CyclicBarrier(3);
- final CyclicBarrier barrier =
- new CyclicBarrier(3, new Runnable() {
- public void run() {
- throw new NullPointerException(); }});
- for (int i = 0; i < 2; i++) {
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try { start.await(); }
- catch (Exception ie) {
- threadFail("start barrier");
- }
- try { barrier.await(); }
- catch(BrokenBarrierException ok) {}
- catch (Throwable thrown) {
- unexpectedException();
- }}});
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try { start.await(); }
- catch (Exception ie) {
- threadFail("start barrier");
- }
- try { barrier.await(); }
- catch(BrokenBarrierException ok) {}
- catch (Throwable thrown) {
- unexpectedException();
- }}});
-
- t1.start();
- t2.start();
- try { start.await(); }
- catch (Exception ie) { threadFail("start barrier"); }
- while (barrier.getNumberWaiting() < 2) { Thread.yield(); }
- try { barrier.await(); }
- catch (Exception ok) { }
- t1.join();
- t2.join();
- assertTrue(barrier.isBroken());
- assertEquals(0, barrier.getNumberWaiting());
- barrier.reset();
- assertFalse(barrier.isBroken());
- assertEquals(0, barrier.getNumberWaiting());
- }
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-}
diff --git a/concurrent/src/test/java/DelayQueueTest.java b/concurrent/src/test/java/DelayQueueTest.java
deleted file mode 100644
index 1971ab0..0000000
--- a/concurrent/src/test/java/DelayQueueTest.java
+++ /dev/null
@@ -1,1033 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-public class DelayQueueTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
-
- public static Test suite() {
- return new TestSuite(DelayQueueTest.class);
- }
-
- private static final int NOCAP = Integer.MAX_VALUE;
-
- /**
- * A delayed implementation for testing.
- * Most tests use Pseudodelays, where delays are all elapsed
- * (so, no blocking solely for delays) but are still ordered
- */
- static class PDelay implements Delayed {
- int pseudodelay;
- PDelay(int i) { pseudodelay = Integer.MIN_VALUE + i; }
- public int compareTo(PDelay y) {
- int i = pseudodelay;
- int j = ((PDelay)y).pseudodelay;
- if (i < j) return -1;
- if (i > j) return 1;
- return 0;
- }
-
- public int compareTo(Delayed y) {
- int i = pseudodelay;
- int j = ((PDelay)y).pseudodelay;
- if (i < j) return -1;
- if (i > j) return 1;
- return 0;
- }
-
- public boolean equals(Object other) {
- return ((PDelay)other).pseudodelay == pseudodelay;
- }
- public boolean equals(PDelay other) {
- return ((PDelay)other).pseudodelay == pseudodelay;
- }
-
-
- public long getDelay(TimeUnit ignore) {
- return pseudodelay;
- }
- public int intValue() {
- return pseudodelay;
- }
-
- public String toString() {
- return String.valueOf(pseudodelay);
- }
- }
-
-
- /**
- * Delayed implementation that actually delays
- */
- static class NanoDelay implements Delayed {
- long trigger;
- NanoDelay(long i) {
- trigger = System.nanoTime() + i;
- }
- public int compareTo(NanoDelay y) {
- long i = trigger;
- long j = ((NanoDelay)y).trigger;
- if (i < j) return -1;
- if (i > j) return 1;
- return 0;
- }
-
- public int compareTo(Delayed y) {
- long i = trigger;
- long j = ((NanoDelay)y).trigger;
- if (i < j) return -1;
- if (i > j) return 1;
- return 0;
- }
-
- public boolean equals(Object other) {
- return ((NanoDelay)other).trigger == trigger;
- }
- public boolean equals(NanoDelay other) {
- return ((NanoDelay)other).trigger == trigger;
- }
-
- public long getDelay(TimeUnit unit) {
- long n = trigger - System.nanoTime();
- return unit.convert(n, TimeUnit.NANOSECONDS);
- }
-
- public long getTriggerTime() {
- return trigger;
- }
-
- public String toString() {
- return String.valueOf(trigger);
- }
- }
-
-
- /**
- * Create a queue of given size containing consecutive
- * PDelays 0 ... n.
- */
- private DelayQueue populatedQueue(int n) {
- DelayQueue q = new DelayQueue();
- assertTrue(q.isEmpty());
- for(int i = n-1; i >= 0; i-=2)
- assertTrue(q.offer(new PDelay(i)));
- for(int i = (n & 1); i < n; i+=2)
- assertTrue(q.offer(new PDelay(i)));
- assertFalse(q.isEmpty());
- assertEquals(NOCAP, q.remainingCapacity());
- assertEquals(n, q.size());
- return q;
- }
-
- /**
- * A new queue has unbounded capacity
- */
- public void testConstructor1() {
- assertEquals(NOCAP, new DelayQueue().remainingCapacity());
- }
-
- /**
- * Initializing from null Collection throws NPE
- */
- public void testConstructor3() {
- try {
- DelayQueue q = new DelayQueue(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection of null elements throws NPE
- */
- public void testConstructor4() {
- try {
- PDelay[] ints = new PDelay[SIZE];
- DelayQueue q = new DelayQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection with some null elements throws NPE
- */
- public void testConstructor5() {
- try {
- PDelay[] ints = new PDelay[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new PDelay(i);
- DelayQueue q = new DelayQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of collection used to initialize
- */
- public void testConstructor6() {
- try {
- PDelay[] ints = new PDelay[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new PDelay(i);
- DelayQueue q = new DelayQueue(Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * isEmpty is true before add, false after
- */
- public void testEmpty() {
- DelayQueue q = new DelayQueue();
- assertTrue(q.isEmpty());
- assertEquals(NOCAP, q.remainingCapacity());
- q.add(new PDelay(1));
- assertFalse(q.isEmpty());
- q.add(new PDelay(2));
- q.remove();
- q.remove();
- assertTrue(q.isEmpty());
- }
-
- /**
- * remainingCapacity does not change when elementa added or removed,
- * but size does
- */
- public void testRemainingCapacity() {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(NOCAP, q.remainingCapacity());
- assertEquals(SIZE-i, q.size());
- q.remove();
- }
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(NOCAP, q.remainingCapacity());
- assertEquals(i, q.size());
- q.add(new PDelay(i));
- }
- }
-
- /**
- * offer(null) throws NPE
- */
- public void testOfferNull() {
- try {
- DelayQueue q = new DelayQueue();
- q.offer(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * add(null) throws NPE
- */
- public void testAddNull() {
- try {
- DelayQueue q = new DelayQueue();
- q.add(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * offer non-null succeeds
- */
- public void testOffer() {
- DelayQueue q = new DelayQueue();
- assertTrue(q.offer(new PDelay(0)));
- assertTrue(q.offer(new PDelay(1)));
- }
-
- /**
- * add succeeds
- */
- public void testAdd() {
- DelayQueue q = new DelayQueue();
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.size());
- assertTrue(q.add(new PDelay(i)));
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- DelayQueue q = new DelayQueue();
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
-
- /**
- * addAll(this) throws IAE
- */
- public void testAddAllSelf() {
- try {
- DelayQueue q = populatedQueue(SIZE);
- q.addAll(q);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * addAll of a collection with null elements throws NPE
- */
- public void testAddAll2() {
- try {
- DelayQueue q = new DelayQueue();
- PDelay[] ints = new PDelay[SIZE];
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll of a collection with any null elements throws NPE after
- * possibly adding some elements
- */
- public void testAddAll3() {
- try {
- DelayQueue q = new DelayQueue();
- PDelay[] ints = new PDelay[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new PDelay(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of successful addAll
- */
- public void testAddAll5() {
- try {
- PDelay[] empty = new PDelay[0];
- PDelay[] ints = new PDelay[SIZE];
- for (int i = SIZE-1; i >= 0; --i)
- ints[i] = new PDelay(i);
- DelayQueue q = new DelayQueue();
- assertFalse(q.addAll(Arrays.asList(empty)));
- assertTrue(q.addAll(Arrays.asList(ints)));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * put(null) throws NPE
- */
- public void testPutNull() {
- try {
- DelayQueue q = new DelayQueue();
- q.put(null);
- shouldThrow();
- }
- catch (NullPointerException success){
- }
- }
-
- /**
- * all elements successfully put are contained
- */
- public void testPut() {
- try {
- DelayQueue q = new DelayQueue();
- for (int i = 0; i < SIZE; ++i) {
- PDelay I = new PDelay(i);
- q.put(I);
- assertTrue(q.contains(I));
- }
- assertEquals(SIZE, q.size());
- }
- finally {
- }
- }
-
- /**
- * put doesn't block waiting for take
- */
- public void testPutWithTake() {
- final DelayQueue q = new DelayQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- int added = 0;
- try {
- q.put(new PDelay(0));
- ++added;
- q.put(new PDelay(0));
- ++added;
- q.put(new PDelay(0));
- ++added;
- q.put(new PDelay(0));
- ++added;
- threadAssertTrue(added == 4);
- } finally {
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- q.take();
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * timed offer does not time out
- */
- public void testTimedOffer() {
- final DelayQueue q = new DelayQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(new PDelay(0));
- q.put(new PDelay(0));
- threadAssertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(q.offer(new PDelay(0), LONG_DELAY_MS, TimeUnit.MILLISECONDS));
- } finally { }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * take retrieves elements in priority order
- */
- public void testTake() {
- try {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(new PDelay(i), ((PDelay)q.take()));
- }
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * take blocks interruptibly when empty
- */
- public void testTakeFromEmpty() {
- final DelayQueue q = new DelayQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){ }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Take removes existing elements until empty, then blocks interruptibly
- */
- public void testBlockingTake() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- threadAssertEquals(new PDelay(i), ((PDelay)q.take()));
- }
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
-
- /**
- * poll succeeds unless empty
- */
- public void testPoll() {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(new PDelay(i), ((PDelay)q.poll()));
- }
- assertNull(q.poll());
- }
-
- /**
- * timed pool with zero timeout succeeds when non-empty, else times out
- */
- public void testTimedPoll0() {
- try {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(new PDelay(i), ((PDelay)q.poll(0, TimeUnit.MILLISECONDS)));
- }
- assertNull(q.poll(0, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * timed pool with nonzero timeout succeeds when non-empty, else times out
- */
- public void testTimedPoll() {
- try {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)));
- }
- assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * Interrupted timed poll throws InterruptedException instead of
- * returning timeout status
- */
- public void testInterruptedTimedPoll() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- threadAssertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)));
- }
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException success){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * timed poll before a delayed offer fails; after offer succeeds;
- * on interruption throws
- */
- public void testTimedPollWithOffer() {
- final DelayQueue q = new DelayQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadFail("Should block");
- } catch (InterruptedException success) { }
- }
- });
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- assertTrue(q.offer(new PDelay(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * peek returns next element, or null if empty
- */
- public void testPeek() {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(new PDelay(i), ((PDelay)q.peek()));
- q.poll();
- if (q.isEmpty())
- assertNull(q.peek());
- else
- assertTrue(i != ((PDelay)q.peek()).intValue());
- }
- assertNull(q.peek());
- }
-
- /**
- * element returns next element, or throws NSEE if empty
- */
- public void testElement() {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(new PDelay(i), ((PDelay)q.element()));
- q.poll();
- }
- try {
- q.element();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * remove removes next element, or throws NSEE if empty
- */
- public void testRemove() {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(new PDelay(i), ((PDelay)q.remove()));
- }
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success){
- }
- }
-
- /**
- * remove(x) removes x and returns true if present
- */
- public void testRemoveElement() {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 1; i < SIZE; i+=2) {
- assertTrue(q.remove(new PDelay(i)));
- }
- for (int i = 0; i < SIZE; i+=2) {
- assertTrue(q.remove(new PDelay(i)));
- assertFalse(q.remove(new PDelay(i+1)));
- }
- assertTrue(q.isEmpty());
- }
-
- /**
- * contains(x) reports true when elements added but not yet removed
- */
- public void testContains() {
- DelayQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.contains(new PDelay(i)));
- q.poll();
- assertFalse(q.contains(new PDelay(i)));
- }
- }
-
- /**
- * clear removes all elements
- */
- public void testClear() {
- DelayQueue q = populatedQueue(SIZE);
- q.clear();
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- assertEquals(NOCAP, q.remainingCapacity());
- PDelay x = new PDelay(1);
- q.add(x);
- assertFalse(q.isEmpty());
- assertTrue(q.contains(x));
- q.clear();
- assertTrue(q.isEmpty());
- }
-
- /**
- * containsAll(c) is true when c contains a subset of elements
- */
- public void testContainsAll() {
- DelayQueue q = populatedQueue(SIZE);
- DelayQueue p = new DelayQueue();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.containsAll(p));
- assertFalse(p.containsAll(q));
- p.add(new PDelay(i));
- }
- assertTrue(p.containsAll(q));
- }
-
- /**
- * retainAll(c) retains only those elements of c and reports true if changed
- */
- public void testRetainAll() {
- DelayQueue q = populatedQueue(SIZE);
- DelayQueue p = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- boolean changed = q.retainAll(p);
- if (i == 0)
- assertFalse(changed);
- else
- assertTrue(changed);
-
- assertTrue(q.containsAll(p));
- assertEquals(SIZE-i, q.size());
- p.remove();
- }
- }
-
- /**
- * removeAll(c) removes only those elements of c and reports true if changed
- */
- public void testRemoveAll() {
- for (int i = 1; i < SIZE; ++i) {
- DelayQueue q = populatedQueue(SIZE);
- DelayQueue p = populatedQueue(i);
- assertTrue(q.removeAll(p));
- assertEquals(SIZE-i, q.size());
- for (int j = 0; j < i; ++j) {
- PDelay I = (PDelay)(p.remove());
- assertFalse(q.contains(I));
- }
- }
- }
-
- /**
- * toArray contains all elements
- */
- public void testToArray() {
- DelayQueue q = populatedQueue(SIZE);
- Object[] o = q.toArray();
- Arrays.sort(o);
- try {
- for(int i = 0; i < o.length; i++)
- assertEquals(o[i], q.take());
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * toArray(a) contains all elements
- */
- public void testToArray2() {
- DelayQueue q = populatedQueue(SIZE);
- PDelay[] ints = new PDelay[SIZE];
- ints = (PDelay[])q.toArray(ints);
- Arrays.sort(ints);
- try {
- for(int i = 0; i < ints.length; i++)
- assertEquals(ints[i], q.take());
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
-
- /**
- * toArray(null) throws NPE
- */
- public void testToArray_BadArg() {
- try {
- DelayQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(null);
- shouldThrow();
- } catch(NullPointerException success){}
- }
-
- /**
- * toArray with incompatible array type throws CCE
- */
- public void testToArray1_BadArg() {
- try {
- DelayQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(new String[10] );
- shouldThrow();
- } catch(ArrayStoreException success){}
- }
-
- /**
- * iterator iterates through all elements
- */
- public void testIterator() {
- DelayQueue q = populatedQueue(SIZE);
- int i = 0;
- Iterator it = q.iterator();
- while(it.hasNext()) {
- assertTrue(q.contains(it.next()));
- ++i;
- }
- assertEquals(i, SIZE);
- }
-
- /**
- * iterator.remove removes current element
- */
- public void testIteratorRemove () {
- final DelayQueue q = new DelayQueue();
- q.add(new PDelay(2));
- q.add(new PDelay(1));
- q.add(new PDelay(3));
- Iterator it = q.iterator();
- it.next();
- it.remove();
- it = q.iterator();
- assertEquals(it.next(), new PDelay(2));
- assertEquals(it.next(), new PDelay(3));
- assertFalse(it.hasNext());
- }
-
-
- /**
- * toString contains toStrings of elements
- */
- public void testToString() {
- DelayQueue q = populatedQueue(SIZE);
- String s = q.toString();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(s.indexOf(String.valueOf(Integer.MIN_VALUE+i)) >= 0);
- }
- }
-
- /**
- * offer transfers elements across Executor tasks
- */
- public void testPollInExecutor() {
- final DelayQueue q = new DelayQueue();
- ExecutorService executor = Executors.newFixedThreadPool(2);
- executor.execute(new Runnable() {
- public void run() {
- threadAssertNull(q.poll());
- try {
- threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(q.isEmpty());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- executor.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SHORT_DELAY_MS);
- q.put(new PDelay(1));
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
- joinPool(executor);
-
- }
-
-
- /**
- * Delayed actions do not occur until their delay elapses
- */
- public void testDelay() {
- DelayQueue q = new DelayQueue();
- NanoDelay[] elements = new NanoDelay[SIZE];
- for (int i = 0; i < SIZE; ++i) {
- elements[i] = new NanoDelay(1000000000L + 1000000L * (SIZE - i));
- }
- for (int i = 0; i < SIZE; ++i) {
- q.add(elements[i]);
- }
-
- try {
- long last = 0;
- for (int i = 0; i < SIZE; ++i) {
- NanoDelay e = (NanoDelay)(q.take());
- long tt = e.getTriggerTime();
- assertTrue(tt <= System.nanoTime());
- if (i != 0)
- assertTrue(tt >= last);
- last = tt;
- }
- }
- catch(InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * peek of a non-empty queue returns non-null even if not expired
- */
- public void testPeekDelayed() {
- DelayQueue q = new DelayQueue();
- q.add(new NanoDelay(Long.MAX_VALUE));
- assert(q.peek() != null);
- }
-
-
- /**
- * poll of a non-empty queue returns null if no expired elements.
- */
- public void testPollDelayed() {
- DelayQueue q = new DelayQueue();
- q.add(new NanoDelay(Long.MAX_VALUE));
- assertNull(q.poll());
- }
-
- /**
- * timed poll of a non-empty queue returns null if no expired elements.
- */
- public void testTimedPollDelayed() {
- DelayQueue q = new DelayQueue();
- q.add(new NanoDelay(LONG_DELAY_MS * 1000000L));
- try {
- assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null) throws NPE
- */
- public void testDrainToNull() {
- DelayQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(null);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this) throws IAE
- */
- public void testDrainToSelf() {
- DelayQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(q);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c) empties queue into another collection c
- */
- public void testDrainTo() {
- DelayQueue q = new DelayQueue();
- PDelay[] elems = new PDelay[SIZE];
- for (int i = 0; i < SIZE; ++i) {
- elems[i] = new PDelay(i);
- q.add(elems[i]);
- }
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(l.get(i), elems[i]);
- q.add(elems[0]);
- q.add(elems[1]);
- assertFalse(q.isEmpty());
- assertTrue(q.contains(elems[0]));
- assertTrue(q.contains(elems[1]));
- l.clear();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- assertEquals(l.size(), 2);
- for (int i = 0; i < 2; ++i)
- assertEquals(l.get(i), elems[i]);
- }
-
- /**
- * drainTo empties queue
- */
- public void testDrainToWithActivePut() {
- final DelayQueue q = populatedQueue(SIZE);
- Thread t = new Thread(new Runnable() {
- public void run() {
- q.put(new PDelay(SIZE+1));
- }
- });
- try {
- t.start();
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertTrue(l.size() >= SIZE);
- t.join();
- assertTrue(q.size() + l.size() >= SIZE);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null, n) throws NPE
- */
- public void testDrainToNullN() {
- DelayQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(null, 0);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this, n) throws IAE
- */
- public void testDrainToSelfN() {
- DelayQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(q, 0);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c, n) empties first max {n, size} elements of queue into c
- */
- public void testDrainToN() {
- for (int i = 0; i < SIZE + 2; ++i) {
- DelayQueue q = populatedQueue(SIZE);
- ArrayList l = new ArrayList();
- q.drainTo(l, i);
- int k = (i < SIZE)? i : SIZE;
- assertEquals(q.size(), SIZE-k);
- assertEquals(l.size(), k);
- }
- }
-
-
-}
diff --git a/concurrent/src/test/java/ExchangerTest.java b/concurrent/src/test/java/ExchangerTest.java
deleted file mode 100644
index a508d6c..0000000
--- a/concurrent/src/test/java/ExchangerTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-public class ExchangerTest extends JSR166TestCase {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ExchangerTest.class);
- }
-
- /**
- * exchange exchanges objects across two threads
- */
- public void testExchange() {
- final Exchanger e = new Exchanger();
- Thread t1 = new Thread(new Runnable(){
- public void run(){
- try {
- Object v = e.exchange(one);
- threadAssertEquals(v, two);
- Object w = e.exchange(v);
- threadAssertEquals(w, one);
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable(){
- public void run(){
- try {
- Object v = e.exchange(two);
- threadAssertEquals(v, one);
- Object w = e.exchange(v);
- threadAssertEquals(w, two);
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- } catch(InterruptedException ex) {
- unexpectedException();
- }
- }
-
- /**
- * timed exchange exchanges objects across two threads
- */
- public void testTimedExchange() {
- final Exchanger e = new Exchanger();
- Thread t1 = new Thread(new Runnable(){
- public void run(){
- try {
- Object v = e.exchange(one, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- threadAssertEquals(v, two);
- Object w = e.exchange(v, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- threadAssertEquals(w, one);
- } catch(InterruptedException e){
- threadUnexpectedException();
- } catch(TimeoutException toe) {
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable(){
- public void run(){
- try {
- Object v = e.exchange(two, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- threadAssertEquals(v, one);
- Object w = e.exchange(v, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- threadAssertEquals(w, two);
- } catch(InterruptedException e){
- threadUnexpectedException();
- } catch(TimeoutException toe) {
- threadUnexpectedException();
- }
- }
- });
- try {
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- } catch(InterruptedException ex) {
- unexpectedException();
- }
- }
-
- /**
- * interrupt during wait for exchange throws IE
- */
- public void testExchange_InterruptedException(){
- final Exchanger e = new Exchanger();
- Thread t = new Thread(new Runnable() {
- public void run(){
- try {
- e.exchange(one);
- threadShouldThrow();
- } catch(InterruptedException success){
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(InterruptedException ex) {
- unexpectedException();
- }
- }
-
- /**
- * interrupt during wait for timed exchange throws IE
- */
- public void testTimedExchange_InterruptedException(){
- final Exchanger e = new Exchanger();
- Thread t = new Thread(new Runnable() {
- public void run(){
- try {
- e.exchange(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){
- } catch(Exception e2){
- threadFail("should throw IE");
- }
- }
- });
- try {
- t.start();
- t.interrupt();
- t.join();
- } catch(InterruptedException ex){
- unexpectedException();
- }
- }
-
- /**
- * timeout during wait for timed exchange throws TOE
- */
- public void testExchange_TimeOutException(){
- final Exchanger e = new Exchanger();
- Thread t = new Thread(new Runnable() {
- public void run(){
- try {
- e.exchange(null, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(TimeoutException success){
- } catch(InterruptedException e2){
- threadFail("should throw TOE");
- }
- }
- });
- try {
- t.start();
- t.join();
- } catch(InterruptedException ex){
- unexpectedException();
- }
- }
-
- /**
- * If one exchanging thread is interrupted, another succeeds.
- */
- public void testReplacementAfterExchange() {
- final Exchanger e = new Exchanger();
- Thread t1 = new Thread(new Runnable(){
- public void run(){
- try {
- Object v = e.exchange(one);
- threadAssertEquals(v, two);
- Object w = e.exchange(v);
- threadShouldThrow();
- } catch(InterruptedException success){
- }
- }
- });
- Thread t2 = new Thread(new Runnable(){
- public void run(){
- try {
- Object v = e.exchange(two);
- threadAssertEquals(v, one);
- Thread.sleep(SMALL_DELAY_MS);
- Object w = e.exchange(v);
- threadAssertEquals(w, three);
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
- Thread t3 = new Thread(new Runnable(){
- public void run(){
- try {
- Thread.sleep(SMALL_DELAY_MS);
- Object w = e.exchange(three);
- threadAssertEquals(w, one);
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t1.start();
- t2.start();
- t3.start();
- Thread.sleep(SHORT_DELAY_MS);
- t1.interrupt();
- t1.join();
- t2.join();
- t3.join();
- } catch(InterruptedException ex) {
- unexpectedException();
- }
- }
-
-}
diff --git a/concurrent/src/test/java/ExecutorCompletionServiceTest.java b/concurrent/src/test/java/ExecutorCompletionServiceTest.java
deleted file mode 100644
index bef6c1f..0000000
--- a/concurrent/src/test/java/ExecutorCompletionServiceTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-import java.math.BigInteger;
-import java.security.*;
-
-public class ExecutorCompletionServiceTest extends JSR166TestCase{
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ExecutorCompletionServiceTest.class);
- }
-
-
- /**
- * Creating a new ECS with null Executor throw NPE
- */
- public void testConstructorNPE() {
- try {
- ExecutorCompletionService ecs = new ExecutorCompletionService(null);
- shouldThrow();
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * Creating a new ECS with null queue throw NPE
- */
- public void testConstructorNPE2() {
- try {
- ExecutorService e = Executors.newCachedThreadPool();
- ExecutorCompletionService ecs = new ExecutorCompletionService(e, null);
- shouldThrow();
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * Submitting a null callable throws NPE
- */
- public void testSubmitNPE() {
- ExecutorService e = Executors.newCachedThreadPool();
- ExecutorCompletionService ecs = new ExecutorCompletionService(e);
- try {
- Callable c = null;
- ecs.submit(c);
- shouldThrow();
- } catch (NullPointerException success) {
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * Submitting a null runnable throws NPE
- */
- public void testSubmitNPE2() {
- ExecutorService e = Executors.newCachedThreadPool();
- ExecutorCompletionService ecs = new ExecutorCompletionService(e);
- try {
- Runnable r = null;
- ecs.submit(r, Boolean.TRUE);
- shouldThrow();
- } catch (NullPointerException success) {
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * A taken submitted task is completed
- */
- public void testTake() {
- ExecutorService e = Executors.newCachedThreadPool();
- ExecutorCompletionService ecs = new ExecutorCompletionService(e);
- try {
- Callable c = new StringTask();
- ecs.submit(c);
- Future f = ecs.take();
- assertTrue(f.isDone());
- } catch (Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * Take returns the same future object returned by submit
- */
- public void testTake2() {
- ExecutorService e = Executors.newCachedThreadPool();
- ExecutorCompletionService ecs = new ExecutorCompletionService(e);
- try {
- Callable c = new StringTask();
- Future f1 = ecs.submit(c);
- Future f2 = ecs.take();
- assertSame(f1, f2);
- } catch (Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * If poll returns non-null, the returned task is completed
- */
- public void testPoll1() {
- ExecutorService e = Executors.newCachedThreadPool();
- ExecutorCompletionService ecs = new ExecutorCompletionService(e);
- try {
- assertNull(ecs.poll());
- Callable c = new StringTask();
- ecs.submit(c);
- Thread.sleep(SHORT_DELAY_MS);
- for (;;) {
- Future f = ecs.poll();
- if (f != null) {
- assertTrue(f.isDone());
- break;
- }
- }
- } catch (Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * If timed poll returns non-null, the returned task is completed
- */
- public void testPoll2() {
- ExecutorService e = Executors.newCachedThreadPool();
- ExecutorCompletionService ecs = new ExecutorCompletionService(e);
- try {
- assertNull(ecs.poll());
- Callable c = new StringTask();
- ecs.submit(c);
- Future f = ecs.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- if (f != null)
- assertTrue(f.isDone());
- } catch (Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-}
diff --git a/concurrent/src/test/java/ExecutorsTest.java b/concurrent/src/test/java/ExecutorsTest.java
deleted file mode 100644
index a7d217d..0000000
--- a/concurrent/src/test/java/ExecutorsTest.java
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.math.BigInteger;
-import java.security.*;
-
-public class ExecutorsTest extends JSR166TestCase{
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ExecutorsTest.class);
- }
-
- static class TimedCallable<T> implements Callable<T> {
- private final ExecutorService exec;
- private final Callable<T> func;
- private final long msecs;
-
- TimedCallable(ExecutorService exec, Callable<T> func, long msecs) {
- this.exec = exec;
- this.func = func;
- this.msecs = msecs;
- }
-
- public T call() throws Exception {
- Future<T> ftask = exec.submit(func);
- try {
- return ftask.get(msecs, TimeUnit.MILLISECONDS);
- } finally {
- ftask.cancel(true);
- }
- }
- }
-
-
- private static class Fib implements Callable<BigInteger> {
- private final BigInteger n;
- Fib(long n) {
- if (n < 0) throw new IllegalArgumentException("need non-negative arg, but got " + n);
- this.n = BigInteger.valueOf(n);
- }
- public BigInteger call() {
- BigInteger f1 = BigInteger.ONE;
- BigInteger f2 = f1;
- for (BigInteger i = BigInteger.ZERO; i.compareTo(n) < 0; i = i.add(BigInteger.ONE)) {
- BigInteger t = f1.add(f2);
- f1 = f2;
- f2 = t;
- }
- return f1;
- }
- };
-
- /**
- * A newCachedThreadPool can execute runnables
- */
- public void testNewCachedThreadPool1() {
- ExecutorService e = Executors.newCachedThreadPool();
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- joinPool(e);
- }
-
- /**
- * A newCachedThreadPool with given ThreadFactory can execute runnables
- */
- public void testNewCachedThreadPool2() {
- ExecutorService e = Executors.newCachedThreadPool(new SimpleThreadFactory());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- joinPool(e);
- }
-
- /**
- * A newCachedThreadPool with null ThreadFactory throws NPE
- */
- public void testNewCachedThreadPool3() {
- try {
- ExecutorService e = Executors.newCachedThreadPool(null);
- shouldThrow();
- }
- catch(NullPointerException success) {
- }
- }
-
-
- /**
- * A new SingleThreadExecutor can execute runnables
- */
- public void testNewSingleThreadExecutor1() {
- ExecutorService e = Executors.newSingleThreadExecutor();
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- joinPool(e);
- }
-
- /**
- * A new SingleThreadExecutor with given ThreadFactory can execute runnables
- */
- public void testNewSingleThreadExecutor2() {
- ExecutorService e = Executors.newSingleThreadExecutor(new SimpleThreadFactory());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- joinPool(e);
- }
-
- /**
- * A new SingleThreadExecutor with null ThreadFactory throws NPE
- */
- public void testNewSingleThreadExecutor3() {
- try {
- ExecutorService e = Executors.newSingleThreadExecutor(null);
- shouldThrow();
- }
- catch(NullPointerException success) {
- }
- }
-
- /**
- * A new SingleThreadExecutor cannot be casted to concrete implementation
- */
- public void testCastNewSingleThreadExecutor() {
- ExecutorService e = Executors.newSingleThreadExecutor();
- try {
- ThreadPoolExecutor tpe = (ThreadPoolExecutor)e;
- } catch (ClassCastException success) {
- } finally {
- joinPool(e);
- }
- }
-
-
- /**
- * A new newFixedThreadPool can execute runnables
- */
- public void testNewFixedThreadPool1() {
- ExecutorService e = Executors.newFixedThreadPool(2);
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- joinPool(e);
- }
-
- /**
- * A new newFixedThreadPool with given ThreadFactory can execute runnables
- */
- public void testNewFixedThreadPool2() {
- ExecutorService e = Executors.newFixedThreadPool(2, new SimpleThreadFactory());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- joinPool(e);
- }
-
- /**
- * A new newFixedThreadPool with null ThreadFactory throws NPE
- */
- public void testNewFixedThreadPool3() {
- try {
- ExecutorService e = Executors.newFixedThreadPool(2, null);
- shouldThrow();
- }
- catch(NullPointerException success) {
- }
- }
-
- /**
- * A new newFixedThreadPool with 0 threads throws IAE
- */
- public void testNewFixedThreadPool4() {
- try {
- ExecutorService e = Executors.newFixedThreadPool(0);
- shouldThrow();
- }
- catch(IllegalArgumentException success) {
- }
- }
-
-
- /**
- * An unconfigurable newFixedThreadPool can execute runnables
- */
- public void testunconfigurableExecutorService() {
- ExecutorService e = Executors.unconfigurableExecutorService(Executors.newFixedThreadPool(2));
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- e.execute(new NoOpRunnable());
- joinPool(e);
- }
-
- /**
- * unconfigurableExecutorService(null) throws NPE
- */
- public void testunconfigurableExecutorServiceNPE() {
- try {
- ExecutorService e = Executors.unconfigurableExecutorService(null);
- }
- catch (NullPointerException success) {
- }
- }
-
- /**
- * unconfigurableScheduledExecutorService(null) throws NPE
- */
- public void testunconfigurableScheduledExecutorServiceNPE() {
- try {
- ExecutorService e = Executors.unconfigurableScheduledExecutorService(null);
- }
- catch (NullPointerException success) {
- }
- }
-
-
- /**
- * a newSingleThreadScheduledExecutor successfully runs delayed task
- */
- public void testNewSingleThreadScheduledExecutor() {
- try {
- TrackedCallable callable = new TrackedCallable();
- ScheduledExecutorService p1 = Executors.newSingleThreadScheduledExecutor();
- Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- assertFalse(callable.done);
- Thread.sleep(MEDIUM_DELAY_MS);
- assertTrue(callable.done);
- assertEquals(Boolean.TRUE, f.get());
- joinPool(p1);
- } catch(RejectedExecutionException e){}
- catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
- /**
- * a newScheduledThreadPool successfully runs delayed task
- */
- public void testnewScheduledThreadPool() {
- try {
- TrackedCallable callable = new TrackedCallable();
- ScheduledExecutorService p1 = Executors.newScheduledThreadPool(2);
- Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- assertFalse(callable.done);
- Thread.sleep(MEDIUM_DELAY_MS);
- assertTrue(callable.done);
- assertEquals(Boolean.TRUE, f.get());
- joinPool(p1);
- } catch(RejectedExecutionException e){}
- catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
- /**
- * an unconfigurable newScheduledThreadPool successfully runs delayed task
- */
- public void testunconfigurableScheduledExecutorService() {
- try {
- TrackedCallable callable = new TrackedCallable();
- ScheduledExecutorService p1 = Executors.unconfigurableScheduledExecutorService(Executors.newScheduledThreadPool(2));
- Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- assertFalse(callable.done);
- Thread.sleep(MEDIUM_DELAY_MS);
- assertTrue(callable.done);
- assertEquals(Boolean.TRUE, f.get());
- joinPool(p1);
- } catch(RejectedExecutionException e){}
- catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
- /**
- * timeouts from execute will time out if they compute too long.
- */
- public void testTimedCallable() {
- int N = 10000;
- ExecutorService executor = Executors.newSingleThreadExecutor();
- List<Callable<BigInteger>> tasks = new ArrayList<Callable<BigInteger>>(N);
- try {
- long startTime = System.currentTimeMillis();
-
- long i = 0;
- while (tasks.size() < N) {
- tasks.add(new TimedCallable<BigInteger>(executor, new Fib(i), 1));
- i += 10;
- }
-
- int iters = 0;
- BigInteger sum = BigInteger.ZERO;
- for (Iterator<Callable<BigInteger>> it = tasks.iterator(); it.hasNext();) {
- try {
- ++iters;
- sum = sum.add(it.next().call());
- }
- catch (TimeoutException success) {
- assertTrue(iters > 0);
- return;
- }
- catch (Exception e) {
- unexpectedException();
- }
- }
- // if by chance we didn't ever time out, total time must be small
- long elapsed = System.currentTimeMillis() - startTime;
- assertTrue(elapsed < N);
- }
- finally {
- joinPool(executor);
- }
- }
-
-
- /**
- * ThreadPoolExecutor using defaultThreadFactory has
- * specified group, priority, daemon status, and name
- */
- public void testDefaultThreadFactory() {
- final ThreadGroup egroup = Thread.currentThread().getThreadGroup();
- Runnable r = new Runnable() {
- public void run() {
- try {
- Thread current = Thread.currentThread();
- threadAssertTrue(!current.isDaemon());
- threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY);
- ThreadGroup g = current.getThreadGroup();
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- threadAssertTrue(g == s.getThreadGroup());
- else
- threadAssertTrue(g == egroup);
- String name = current.getName();
- threadAssertTrue(name.endsWith("thread-1"));
- } catch (SecurityException ok) {
- // Also pass if not allowed to change setting
- }
- }
- };
- ExecutorService e = Executors.newSingleThreadExecutor(Executors.defaultThreadFactory());
-
- e.execute(r);
- try {
- e.shutdown();
- } catch(SecurityException ok) {
- }
-
- try {
- Thread.sleep(SHORT_DELAY_MS);
- } catch (Exception eX) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * ThreadPoolExecutor using privilegedThreadFactory has
- * specified group, priority, daemon status, name,
- * access control context and context class loader
- */
- public void testPrivilegedThreadFactory() {
- Policy savedPolicy = null;
- try {
- savedPolicy = Policy.getPolicy();
- AdjustablePolicy policy = new AdjustablePolicy();
- policy.addPermission(new RuntimePermission("getContextClassLoader"));
- policy.addPermission(new RuntimePermission("setContextClassLoader"));
- Policy.setPolicy(policy);
- } catch (AccessControlException ok) {
- return;
- }
- final ThreadGroup egroup = Thread.currentThread().getThreadGroup();
- final ClassLoader thisccl = Thread.currentThread().getContextClassLoader();
- final AccessControlContext thisacc = AccessController.getContext();
- Runnable r = new Runnable() {
- public void run() {
- try {
- Thread current = Thread.currentThread();
- threadAssertTrue(!current.isDaemon());
- threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY);
- ThreadGroup g = current.getThreadGroup();
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- threadAssertTrue(g == s.getThreadGroup());
- else
- threadAssertTrue(g == egroup);
- String name = current.getName();
- threadAssertTrue(name.endsWith("thread-1"));
- threadAssertTrue(thisccl == current.getContextClassLoader());
- threadAssertTrue(thisacc.equals(AccessController.getContext()));
- } catch(SecurityException ok) {
- // Also pass if not allowed to change settings
- }
- }
- };
- ExecutorService e = Executors.newSingleThreadExecutor(Executors.privilegedThreadFactory());
-
- Policy.setPolicy(savedPolicy);
- e.execute(r);
- try {
- e.shutdown();
- } catch(SecurityException ok) {
- }
- try {
- Thread.sleep(SHORT_DELAY_MS);
- } catch (Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
-
- }
-
- void checkCCL() {
- AccessController.getContext().checkPermission(new RuntimePermission("getContextClassLoader"));
- }
-
- class CheckCCL implements Callable<Object> {
- public Object call() {
- checkCCL();
- return null;
- }
- }
-
-
- /**
- * Without class loader permissions, creating
- * privilegedCallableUsingCurrentClassLoader throws ACE
- */
- public void testCreatePrivilegedCallableUsingCCLWithNoPrivs() {
- Policy savedPolicy = null;
- try {
- savedPolicy = Policy.getPolicy();
- AdjustablePolicy policy = new AdjustablePolicy();
- Policy.setPolicy(policy);
- } catch (AccessControlException ok) {
- return;
- }
-
- // Check if program still has too many permissions to run test
- try {
- checkCCL();
- // too many privileges to test; so return
- Policy.setPolicy(savedPolicy);
- return;
- } catch(AccessControlException ok) {
- }
-
- try {
- Callable task = Executors.privilegedCallableUsingCurrentClassLoader(new NoOpCallable());
- shouldThrow();
- } catch(AccessControlException success) {
- } catch(Exception ex) {
- unexpectedException();
- }
- finally {
- Policy.setPolicy(savedPolicy);
- }
- }
-
- /**
- * With class loader permissions, calling
- * privilegedCallableUsingCurrentClassLoader does not throw ACE
- */
- public void testprivilegedCallableUsingCCLWithPrivs() {
- Policy savedPolicy = null;
- try {
- savedPolicy = Policy.getPolicy();
- AdjustablePolicy policy = new AdjustablePolicy();
- policy.addPermission(new RuntimePermission("getContextClassLoader"));
- policy.addPermission(new RuntimePermission("setContextClassLoader"));
- Policy.setPolicy(policy);
- } catch (AccessControlException ok) {
- return;
- }
-
- try {
- Callable task = Executors.privilegedCallableUsingCurrentClassLoader(new NoOpCallable());
- task.call();
- } catch(Exception ex) {
- unexpectedException();
- }
- finally {
- Policy.setPolicy(savedPolicy);
- }
- }
-
- /**
- * Without permissions, calling privilegedCallable throws ACE
- */
- public void testprivilegedCallableWithNoPrivs() {
- Callable task;
- Policy savedPolicy = null;
- AdjustablePolicy policy = null;
- AccessControlContext noprivAcc = null;
- try {
- savedPolicy = Policy.getPolicy();
- policy = new AdjustablePolicy();
- Policy.setPolicy(policy);
- noprivAcc = AccessController.getContext();
- task = Executors.privilegedCallable(new CheckCCL());
- Policy.setPolicy(savedPolicy);
- } catch (AccessControlException ok) {
- return; // program has too few permissions to set up test
- }
-
- // Make sure that program doesn't have too many permissions
- try {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- checkCCL();
- return null;
- }}, noprivAcc);
- // too many permissions; skip test
- return;
- } catch(AccessControlException ok) {
- }
-
- try {
- task.call();
- shouldThrow();
- } catch(AccessControlException success) {
- } catch(Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * With permissions, calling privilegedCallable succeeds
- */
- public void testprivilegedCallableWithPrivs() {
- Policy savedPolicy = null;
- try {
- savedPolicy = Policy.getPolicy();
- AdjustablePolicy policy = new AdjustablePolicy();
- policy.addPermission(new RuntimePermission("getContextClassLoader"));
- policy.addPermission(new RuntimePermission("setContextClassLoader"));
- Policy.setPolicy(policy);
- } catch (AccessControlException ok) {
- return;
- }
-
- Callable task = Executors.privilegedCallable(new CheckCCL());
- try {
- task.call();
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- Policy.setPolicy(savedPolicy);
- }
- }
-
- /**
- * callable(Runnable) returns null when called
- */
- public void testCallable1() {
- try {
- Callable c = Executors.callable(new NoOpRunnable());
- assertNull(c.call());
- } catch(Exception ex) {
- unexpectedException();
- }
-
- }
-
- /**
- * callable(Runnable, result) returns result when called
- */
- public void testCallable2() {
- try {
- Callable c = Executors.callable(new NoOpRunnable(), one);
- assertEquals(one, c.call());
- } catch(Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * callable(PrivilegedAction) returns its result when called
- */
- public void testCallable3() {
- try {
- Callable c = Executors.callable(new PrivilegedAction() {
- public Object run() { return one; }});
- assertEquals(one, c.call());
- } catch(Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * callable(PrivilegedExceptionAction) returns its result when called
- */
- public void testCallable4() {
- try {
- Callable c = Executors.callable(new PrivilegedExceptionAction() {
- public Object run() { return one; }});
- assertEquals(one, c.call());
- } catch(Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * callable(null Runnable) throws NPE
- */
- public void testCallableNPE1() {
- try {
- Runnable r = null;
- Callable c = Executors.callable(r);
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * callable(null, result) throws NPE
- */
- public void testCallableNPE2() {
- try {
- Runnable r = null;
- Callable c = Executors.callable(r, one);
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * callable(null PrivilegedAction) throws NPE
- */
- public void testCallableNPE3() {
- try {
- PrivilegedAction r = null;
- Callable c = Executors.callable(r);
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * callable(null PrivilegedExceptionAction) throws NPE
- */
- public void testCallableNPE4() {
- try {
- PrivilegedExceptionAction r = null;
- Callable c = Executors.callable(r);
- } catch (NullPointerException success) {
- }
- }
-
-
-}
diff --git a/concurrent/src/test/java/FutureTaskTest.java b/concurrent/src/test/java/FutureTaskTest.java
deleted file mode 100644
index f14788a..0000000
--- a/concurrent/src/test/java/FutureTaskTest.java
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.*;
-import java.util.*;
-
-public class FutureTaskTest extends JSR166TestCase {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(FutureTaskTest.class);
- }
-
- /**
- * Subclass to expose protected methods
- */
- static class PublicFutureTask extends FutureTask {
- public PublicFutureTask(Callable r) { super(r); }
- public boolean runAndReset() { return super.runAndReset(); }
- public void set(Object x) { super.set(x); }
- public void setException(Throwable t) { super.setException(t); }
- }
-
- /**
- * Creating a future with a null callable throws NPE
- */
- public void testConstructor() {
- try {
- FutureTask task = new FutureTask(null);
- shouldThrow();
- }
- catch(NullPointerException success) {
- }
- }
-
- /**
- * creating a future with null runnable fails
- */
- public void testConstructor2() {
- try {
- FutureTask task = new FutureTask(null, Boolean.TRUE);
- shouldThrow();
- }
- catch(NullPointerException success) {
- }
- }
-
- /**
- * isDone is true when a task completes
- */
- public void testIsDone() {
- FutureTask task = new FutureTask( new NoOpCallable());
- task.run();
- assertTrue(task.isDone());
- assertFalse(task.isCancelled());
- }
-
- /**
- * runAndReset of a non-cancelled task succeeds
- */
- public void testRunAndReset() {
- PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
- assertTrue(task.runAndReset());
- assertFalse(task.isDone());
- }
-
- /**
- * runAndReset after cancellation fails
- */
- public void testResetAfterCancel() {
- PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
- assertTrue(task.cancel(false));
- assertFalse(task.runAndReset());
- assertTrue(task.isDone());
- assertTrue(task.isCancelled());
- }
-
-
-
- /**
- * setting value causes get to return it
- */
- public void testSet() {
- PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
- task.set(one);
- try {
- assertEquals(task.get(), one);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * setException causes get to throw ExecutionException
- */
- public void testSetException() {
- Exception nse = new NoSuchElementException();
- PublicFutureTask task = new PublicFutureTask(new NoOpCallable());
- task.setException(nse);
- try {
- Object x = task.get();
- shouldThrow();
- }
- catch(ExecutionException ee) {
- Throwable cause = ee.getCause();
- assertEquals(cause, nse);
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * Cancelling before running succeeds
- */
- public void testCancelBeforeRun() {
- FutureTask task = new FutureTask( new NoOpCallable());
- assertTrue(task.cancel(false));
- task.run();
- assertTrue(task.isDone());
- assertTrue(task.isCancelled());
- }
-
- /**
- * Cancel(true) before run succeeds
- */
- public void testCancelBeforeRun2() {
- FutureTask task = new FutureTask( new NoOpCallable());
- assertTrue(task.cancel(true));
- task.run();
- assertTrue(task.isDone());
- assertTrue(task.isCancelled());
- }
-
- /**
- * cancel of a completed task fails
- */
- public void testCancelAfterRun() {
- FutureTask task = new FutureTask( new NoOpCallable());
- task.run();
- assertFalse(task.cancel(false));
- assertTrue(task.isDone());
- assertFalse(task.isCancelled());
- }
-
- /**
- * cancel(true) interrupts a running task
- */
- public void testCancelInterrupt() {
- FutureTask task = new FutureTask( new Callable() {
- public Object call() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- threadShouldThrow();
- }
- catch (InterruptedException success) {}
- return Boolean.TRUE;
- } });
- Thread t = new Thread(task);
- t.start();
-
- try {
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(task.cancel(true));
- t.join();
- assertTrue(task.isDone());
- assertTrue(task.isCancelled());
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
-
- /**
- * cancel(false) does not interrupt a running task
- */
- public void testCancelNoInterrupt() {
- FutureTask task = new FutureTask( new Callable() {
- public Object call() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- }
- catch (InterruptedException success) {
- threadFail("should not interrupt");
- }
- return Boolean.TRUE;
- } });
- Thread t = new Thread(task);
- t.start();
-
- try {
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(task.cancel(false));
- t.join();
- assertTrue(task.isDone());
- assertTrue(task.isCancelled());
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * set in one thread causes get in another thread to retrieve value
- */
- public void testGet1() {
- final FutureTask ft = new FutureTask(new Callable() {
- public Object call() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- return Boolean.TRUE;
- }
- });
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- ft.get();
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- assertFalse(ft.isDone());
- assertFalse(ft.isCancelled());
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- ft.run();
- t.join();
- assertTrue(ft.isDone());
- assertFalse(ft.isCancelled());
- } catch(InterruptedException e){
- unexpectedException();
-
- }
- }
-
- /**
- * set in one thread causes timed get in another thread to retrieve value
- */
- public void testTimedGet1() {
- final FutureTask ft = new FutureTask(new Callable() {
- public Object call() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- return Boolean.TRUE;
- }
- });
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- ft.get(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch(TimeoutException success) {
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- assertFalse(ft.isDone());
- assertFalse(ft.isCancelled());
- t.start();
- ft.run();
- t.join();
- assertTrue(ft.isDone());
- assertFalse(ft.isCancelled());
- } catch(InterruptedException e){
- unexpectedException();
-
- }
- }
-
- /**
- * Cancelling a task causes timed get in another thread to throw CancellationException
- */
- public void testTimedGet_Cancellation() {
- final FutureTask ft = new FutureTask(new Callable() {
- public Object call() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- threadShouldThrow();
- } catch(InterruptedException e) {
- }
- return Boolean.TRUE;
- }
- });
- try {
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- ft.get(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(CancellationException success) {}
- catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(ft);
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- ft.cancel(true);
- t1.join();
- t2.join();
- } catch(InterruptedException ie){
- unexpectedException();
- }
- }
-
- /**
- * Cancelling a task causes get in another thread to throw CancellationException
- */
- public void testGet_Cancellation() {
- final FutureTask ft = new FutureTask(new Callable() {
- public Object call() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- threadShouldThrow();
- } catch(InterruptedException e){
- }
- return Boolean.TRUE;
- }
- });
- try {
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- ft.get();
- threadShouldThrow();
- } catch(CancellationException success){
- }
- catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(ft);
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- ft.cancel(true);
- t1.join();
- t2.join();
- } catch(InterruptedException success){
- unexpectedException();
- }
- }
-
-
- /**
- * A runtime exception in task causes get to throw ExecutionException
- */
- public void testGet_ExecutionException() {
- final FutureTask ft = new FutureTask(new Callable() {
- public Object call() {
- int i = 5/0;
- return Boolean.TRUE;
- }
- });
- try {
- ft.run();
- ft.get();
- shouldThrow();
- } catch(ExecutionException success){
- }
- catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * A runtime exception in task causes timed get to throw ExecutionException
- */
- public void testTimedGet_ExecutionException2() {
- final FutureTask ft = new FutureTask(new Callable() {
- public Object call() {
- int i = 5/0;
- return Boolean.TRUE;
- }
- });
- try {
- ft.run();
- ft.get(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(ExecutionException success) {
- } catch(TimeoutException success) { } // unlikely but OK
- catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * Interrupting a waiting get causes it to throw InterruptedException
- */
- public void testGet_InterruptedException() {
- final FutureTask ft = new FutureTask(new NoOpCallable());
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- ft.get();
- threadShouldThrow();
- } catch(InterruptedException success){
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Interrupting a waiting timed get causes it to throw InterruptedException
- */
- public void testTimedGet_InterruptedException2() {
- final FutureTask ft = new FutureTask(new NoOpCallable());
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- ft.get(LONG_DELAY_MS,TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){}
- catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * A timed out timed get throws TimeoutException
- */
- public void testGet_TimeoutException() {
- try {
- FutureTask ft = new FutureTask(new NoOpCallable());
- ft.get(1,TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(TimeoutException success){}
- catch(Exception success){
- unexpectedException();
- }
- }
-
-}
diff --git a/concurrent/src/test/java/JSR166TestCase.java b/concurrent/src/test/java/JSR166TestCase.java
deleted file mode 100644
index 3b38be7..0000000
--- a/concurrent/src/test/java/JSR166TestCase.java
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-import java.security.*;
-
-/**
- * Base class for JSR166 Junit TCK tests. Defines some constants,
- * utility methods and classes, as well as a simple framework for
- * helping to make sure that assertions failing in generated threads
- * cause the associated test that generated them to itself fail (which
- * JUnit does not otherwise arrange). The rules for creating such
- * tests are:
- *
- * <ol>
- *
- * <li> All assertions in code running in generated threads must use
- * the forms {@link #threadFail}, {@link #threadAssertTrue}, {@link
- * #threadAssertEquals}, or {@link #threadAssertNull}, (not
- * <tt>fail</tt>, <tt>assertTrue</tt>, etc.) It is OK (but not
- * particularly recommended) for other code to use these forms too.
- * Only the most typically used JUnit assertion methods are defined
- * this way, but enough to live with.</li>
- *
- * <li> If you override {@link #setUp} or {@link #tearDown}, make sure
- * to invoke <tt>super.setUp</tt> and <tt>super.tearDown</tt> within
- * them. These methods are used to clear and check for thread
- * assertion failures.</li>
- *
- * <li>All delays and timeouts must use one of the constants <tt>
- * SHORT_DELAY_MS</tt>, <tt> SMALL_DELAY_MS</tt>, <tt> MEDIUM_DELAY_MS</tt>,
- * <tt> LONG_DELAY_MS</tt>. The idea here is that a SHORT is always
- * discriminable from zero time, and always allows enough time for the
- * small amounts of computation (creating a thread, calling a few
- * methods, etc) needed to reach a timeout point. Similarly, a SMALL
- * is always discriminable as larger than SHORT and smaller than
- * MEDIUM. And so on. These constants are set to conservative values,
- * but even so, if there is ever any doubt, they can all be increased
- * in one spot to rerun tests on slower platforms.</li>
- *
- * <li> All threads generated must be joined inside each test case
- * method (or <tt>fail</tt> to do so) before returning from the
- * method. The <tt> joinPool</tt> method can be used to do this when
- * using Executors.</li>
- *
- * </ol>
- *
- * <p> <b>Other notes</b>
- * <ul>
- *
- * <li> Usually, there is one testcase method per JSR166 method
- * covering "normal" operation, and then as many exception-testing
- * methods as there are exceptions the method can throw. Sometimes
- * there are multiple tests per JSR166 method when the different
- * "normal" behaviors differ significantly. And sometimes testcases
- * cover multiple methods when they cannot be tested in
- * isolation.</li>
- *
- * <li> The documentation style for testcases is to provide as javadoc
- * a simple sentence or two describing the property that the testcase
- * method purports to test. The javadocs do not say anything about how
- * the property is tested. To find out, read the code.</li>
- *
- * <li> These tests are "conformance tests", and do not attempt to
- * test throughput, latency, scalability or other performance factors
- * (see the separate "jtreg" tests for a set intended to check these
- * for the most central aspects of functionality.) So, most tests use
- * the smallest sensible numbers of threads, collection sizes, etc
- * needed to check basic conformance.</li>
- *
- * <li>The test classes currently do not declare inclusion in
- * any particular package to simplify things for people integrating
- * them in TCK test suites.</li>
- *
- * <li> As a convenience, the <tt>main</tt> of this class (JSR166TestCase)
- * runs all JSR166 unit tests.</li>
- *
- * </ul>
- */
-public class JSR166TestCase extends TestCase {
- /**
- * Runs all JSR166 unit tests using junit.textui.TestRunner
- */
- public static void main (String[] args) {
- int iters = 1;
- if (args.length > 0)
- iters = Integer.parseInt(args[0]);
- Test s = suite();
- for (int i = 0; i < iters; ++i) {
- junit.textui.TestRunner.run (s);
- System.gc();
- System.runFinalization();
- }
- System.exit(0);
- }
-
- /**
- * Collects all JSR166 unit tests as one suite
- */
- public static Test suite ( ) {
- TestSuite suite = new TestSuite("JSR166 Unit Tests");
-
- suite.addTest(new TestSuite(AbstractExecutorServiceTest.class));
- suite.addTest(new TestSuite(AbstractQueueTest.class));
- suite.addTest(new TestSuite(AbstractQueuedSynchronizerTest.class));
- suite.addTest(new TestSuite(ArrayBlockingQueueTest.class));
- suite.addTest(new TestSuite(AtomicBooleanTest.class));
- suite.addTest(new TestSuite(AtomicIntegerArrayTest.class));
- suite.addTest(new TestSuite(AtomicIntegerFieldUpdaterTest.class));
- suite.addTest(new TestSuite(AtomicIntegerTest.class));
- suite.addTest(new TestSuite(AtomicLongArrayTest.class));
- suite.addTest(new TestSuite(AtomicLongFieldUpdaterTest.class));
- suite.addTest(new TestSuite(AtomicLongTest.class));
- suite.addTest(new TestSuite(AtomicMarkableReferenceTest.class));
- suite.addTest(new TestSuite(AtomicReferenceArrayTest.class));
- suite.addTest(new TestSuite(AtomicReferenceFieldUpdaterTest.class));
- suite.addTest(new TestSuite(AtomicReferenceTest.class));
- suite.addTest(new TestSuite(AtomicStampedReferenceTest.class));
- suite.addTest(new TestSuite(ConcurrentHashMapTest.class));
- suite.addTest(new TestSuite(ConcurrentLinkedQueueTest.class));
- suite.addTest(new TestSuite(CopyOnWriteArrayListTest.class));
- suite.addTest(new TestSuite(CopyOnWriteArraySetTest.class));
- suite.addTest(new TestSuite(CountDownLatchTest.class));
- suite.addTest(new TestSuite(CyclicBarrierTest.class));
- suite.addTest(new TestSuite(DelayQueueTest.class));
- suite.addTest(new TestSuite(ExchangerTest.class));
- suite.addTest(new TestSuite(ExecutorsTest.class));
- suite.addTest(new TestSuite(ExecutorCompletionServiceTest.class));
- suite.addTest(new TestSuite(FutureTaskTest.class));
- suite.addTest(new TestSuite(LinkedBlockingQueueTest.class));
- suite.addTest(new TestSuite(LinkedListTest.class));
- suite.addTest(new TestSuite(LockSupportTest.class));
- suite.addTest(new TestSuite(PriorityBlockingQueueTest.class));
- suite.addTest(new TestSuite(PriorityQueueTest.class));
- suite.addTest(new TestSuite(ReentrantLockTest.class));
- suite.addTest(new TestSuite(ReentrantReadWriteLockTest.class));
- suite.addTest(new TestSuite(ScheduledExecutorTest.class));
- suite.addTest(new TestSuite(SemaphoreTest.class));
- suite.addTest(new TestSuite(SynchronousQueueTest.class));
- suite.addTest(new TestSuite(SystemTest.class));
- suite.addTest(new TestSuite(ThreadLocalTest.class));
- suite.addTest(new TestSuite(ThreadPoolExecutorTest.class));
- suite.addTest(new TestSuite(ThreadTest.class));
- suite.addTest(new TestSuite(TimeUnitTest.class));
-
- return suite;
- }
-
-
- public static long SHORT_DELAY_MS;
- public static long SMALL_DELAY_MS;
- public static long MEDIUM_DELAY_MS;
- public static long LONG_DELAY_MS;
-
-
- /**
- * Returns the shortest timed delay. This could
- * be reimplemented to use for example a Property.
- */
- protected long getShortDelay() {
- return 50;
- }
-
-
- /**
- * Sets delays as multiples of SHORT_DELAY.
- */
- protected void setDelays() {
- SHORT_DELAY_MS = getShortDelay();
- SMALL_DELAY_MS = SHORT_DELAY_MS * 5;
- MEDIUM_DELAY_MS = SHORT_DELAY_MS * 10;
- LONG_DELAY_MS = SHORT_DELAY_MS * 50;
- }
-
- /**
- * Flag set true if any threadAssert methods fail
- */
- volatile boolean threadFailed;
-
- /**
- * Initializes test to indicate that no thread assertions have failed
- */
- public void setUp() {
- setDelays();
- threadFailed = false;
- }
-
- /**
- * Triggers test case failure if any thread assertions have failed
- */
- public void tearDown() {
- assertFalse(threadFailed);
- }
-
- /**
- * Fail, also setting status to indicate current testcase should fail
- */
- public void threadFail(String reason) {
- threadFailed = true;
- fail(reason);
- }
-
- /**
- * If expression not true, set status to indicate current testcase
- * should fail
- */
- public void threadAssertTrue(boolean b) {
- if (!b) {
- threadFailed = true;
- assertTrue(b);
- }
- }
-
- /**
- * If expression not false, set status to indicate current testcase
- * should fail
- */
- public void threadAssertFalse(boolean b) {
- if (b) {
- threadFailed = true;
- assertFalse(b);
- }
- }
-
- /**
- * If argument not null, set status to indicate current testcase
- * should fail
- */
- public void threadAssertNull(Object x) {
- if (x != null) {
- threadFailed = true;
- assertNull(x);
- }
- }
-
- /**
- * If arguments not equal, set status to indicate current testcase
- * should fail
- */
- public void threadAssertEquals(long x, long y) {
- if (x != y) {
- threadFailed = true;
- assertEquals(x, y);
- }
- }
-
- /**
- * If arguments not equal, set status to indicate current testcase
- * should fail
- */
- public void threadAssertEquals(Object x, Object y) {
- if (x != y && (x == null || !x.equals(y))) {
- threadFailed = true;
- assertEquals(x, y);
- }
- }
-
- /**
- * threadFail with message "should throw exception"
- */
- public void threadShouldThrow() {
- try {
- threadFailed = true;
- fail("should throw exception");
- } catch (AssertionFailedError e) {
- e.printStackTrace();
- throw e;
- }
- }
-
- /**
- * threadFail with message "Unexpected exception"
- */
- public void threadUnexpectedException() {
- threadFailed = true;
- fail("Unexpected exception");
- }
-
- /**
- * threadFail with message "Unexpected exception", with argument
- */
- public void threadUnexpectedException(Throwable ex) {
- threadFailed = true;
- ex.printStackTrace();
- fail("Unexpected exception: " + ex);
- }
-
- /**
- * Wait out termination of a thread pool or fail doing so
- */
- public void joinPool(ExecutorService exec) {
- try {
- exec.shutdown();
- assertTrue(exec.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch(SecurityException ok) {
- // Allowed in case test doesn't have privs
- } catch(InterruptedException ie) {
- fail("Unexpected exception");
- }
- }
-
-
- /**
- * fail with message "should throw exception"
- */
- public void shouldThrow() {
- fail("Should throw exception");
- }
-
- /**
- * fail with message "Unexpected exception"
- */
- public void unexpectedException() {
- fail("Unexpected exception");
- }
-
-
- /**
- * The number of elements to place in collections, arrays, etc.
- */
- static final int SIZE = 20;
-
- // Some convenient Integer constants
-
- static final Integer zero = new Integer(0);
- static final Integer one = new Integer(1);
- static final Integer two = new Integer(2);
- static final Integer three = new Integer(3);
- static final Integer four = new Integer(4);
- static final Integer five = new Integer(5);
- static final Integer six = new Integer(6);
- static final Integer seven = new Integer(7);
- static final Integer eight = new Integer(8);
- static final Integer nine = new Integer(9);
- static final Integer m1 = new Integer(-1);
- static final Integer m2 = new Integer(-2);
- static final Integer m3 = new Integer(-3);
- static final Integer m4 = new Integer(-4);
- static final Integer m5 = new Integer(-5);
- static final Integer m6 = new Integer(-6);
- static final Integer m10 = new Integer(-10);
-
-
- /**
- * A security policy where new permissions can be dynamically added
- * or all cleared.
- */
- static class AdjustablePolicy extends java.security.Policy {
- Permissions perms = new Permissions();
- AdjustablePolicy() { }
- void addPermission(Permission perm) { perms.add(perm); }
- void clearPermissions() { perms = new Permissions(); }
- public PermissionCollection getPermissions(CodeSource cs) {
- return perms;
- }
- public PermissionCollection getPermissions(ProtectionDomain pd) {
- return perms;
- }
- public boolean implies(ProtectionDomain pd, Permission p) {
- return perms.implies(p);
- }
- public void refresh() {}
- }
-
-
- // Some convenient Runnable classes
-
- static class NoOpRunnable implements Runnable {
- public void run() {}
- }
-
- static class NoOpCallable implements Callable {
- public Object call() { return Boolean.TRUE; }
- }
-
- static final String TEST_STRING = "a test string";
-
- static class StringTask implements Callable<String> {
- public String call() { return TEST_STRING; }
- }
-
- static class NPETask implements Callable<String> {
- public String call() { throw new NullPointerException(); }
- }
-
- static class CallableOne implements Callable<Integer> {
- public Integer call() { return one; }
- }
-
- class ShortRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(SHORT_DELAY_MS);
- }
- catch(Exception e) {
- threadUnexpectedException(e);
- }
- }
- }
-
- class ShortInterruptedRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(SHORT_DELAY_MS);
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- }
-
- class SmallRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- }
- catch(Exception e) {
- threadUnexpectedException(e);
- }
- }
- }
-
- class SmallPossiblyInterruptedRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- }
- catch(Exception e) {
- }
- }
- }
-
- class SmallCallable implements Callable {
- public Object call() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- }
- catch(Exception e) {
- threadUnexpectedException(e);
- }
- return Boolean.TRUE;
- }
- }
-
- class SmallInterruptedRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- }
-
-
- class MediumRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- }
- catch(Exception e) {
- threadUnexpectedException(e);
- }
- }
- }
-
- class MediumInterruptedRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- }
-
- class MediumPossiblyInterruptedRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- }
- catch(InterruptedException success) {
- }
- }
- }
-
- class LongPossiblyInterruptedRunnable implements Runnable {
- public void run() {
- try {
- Thread.sleep(LONG_DELAY_MS);
- }
- catch(InterruptedException success) {
- }
- }
- }
-
- /**
- * For use as ThreadFactory in constructors
- */
- static class SimpleThreadFactory implements ThreadFactory{
- public Thread newThread(Runnable r){
- return new Thread(r);
- }
- }
-
- static class TrackedShortRunnable implements Runnable {
- volatile boolean done = false;
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- done = true;
- } catch(Exception e){
- }
- }
- }
-
- static class TrackedMediumRunnable implements Runnable {
- volatile boolean done = false;
- public void run() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- done = true;
- } catch(Exception e){
- }
- }
- }
-
- static class TrackedLongRunnable implements Runnable {
- volatile boolean done = false;
- public void run() {
- try {
- Thread.sleep(LONG_DELAY_MS);
- done = true;
- } catch(Exception e){
- }
- }
- }
-
- static class TrackedNoOpRunnable implements Runnable {
- volatile boolean done = false;
- public void run() {
- done = true;
- }
- }
-
- static class TrackedCallable implements Callable {
- volatile boolean done = false;
- public Object call() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- done = true;
- } catch(Exception e){
- }
- return Boolean.TRUE;
- }
- }
-
-
- /**
- * For use as RejectedExecutionHandler in constructors
- */
- static class NoOpREHandler implements RejectedExecutionHandler{
- public void rejectedExecution(Runnable r, ThreadPoolExecutor executor){}
- }
-
-
-}
diff --git a/concurrent/src/test/java/LinkedBlockingQueueTest.java b/concurrent/src/test/java/LinkedBlockingQueueTest.java
deleted file mode 100644
index a8b66be..0000000
--- a/concurrent/src/test/java/LinkedBlockingQueueTest.java
+++ /dev/null
@@ -1,1061 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class LinkedBlockingQueueTest extends JSR166TestCase {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
-
- public static Test suite() {
- return new TestSuite(LinkedBlockingQueueTest.class);
- }
-
-
- /**
- * Create a queue of given size containing consecutive
- * Integers 0 ... n.
- */
- private LinkedBlockingQueue populatedQueue(int n) {
- LinkedBlockingQueue q = new LinkedBlockingQueue(n);
- assertTrue(q.isEmpty());
- for(int i = 0; i < n; i++)
- assertTrue(q.offer(new Integer(i)));
- assertFalse(q.isEmpty());
- assertEquals(0, q.remainingCapacity());
- assertEquals(n, q.size());
- return q;
- }
-
- /**
- * A new queue has the indicated capacity, or Integer.MAX_VALUE if
- * none given
- */
- public void testConstructor1() {
- assertEquals(SIZE, new LinkedBlockingQueue(SIZE).remainingCapacity());
- assertEquals(Integer.MAX_VALUE, new LinkedBlockingQueue().remainingCapacity());
- }
-
- /**
- * Constructor throws IAE if capacity argument nonpositive
- */
- public void testConstructor2() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(0);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * Initializing from null Collection throws NPE
- */
- public void testConstructor3() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection of null elements throws NPE
- */
- public void testConstructor4() {
- try {
- Integer[] ints = new Integer[SIZE];
- LinkedBlockingQueue q = new LinkedBlockingQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection with some null elements throws NPE
- */
- public void testConstructor5() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- LinkedBlockingQueue q = new LinkedBlockingQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of collection used to initialize
- */
- public void testConstructor6() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- LinkedBlockingQueue q = new LinkedBlockingQueue(Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * Queue transitions from empty to full when elements added
- */
- public void testEmptyFull() {
- LinkedBlockingQueue q = new LinkedBlockingQueue(2);
- assertTrue(q.isEmpty());
- assertEquals("should have room for 2", 2, q.remainingCapacity());
- q.add(one);
- assertFalse(q.isEmpty());
- q.add(two);
- assertFalse(q.isEmpty());
- assertEquals(0, q.remainingCapacity());
- assertFalse(q.offer(three));
- }
-
- /**
- * remainingCapacity decreases on add, increases on remove
- */
- public void testRemainingCapacity() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.remainingCapacity());
- assertEquals(SIZE-i, q.size());
- q.remove();
- }
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(SIZE-i, q.remainingCapacity());
- assertEquals(i, q.size());
- q.add(new Integer(i));
- }
- }
-
- /**
- * offer(null) throws NPE
- */
- public void testOfferNull() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(1);
- q.offer(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * add(null) throws NPE
- */
- public void testAddNull() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(1);
- q.add(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * Offer succeeds if not full; fails if full
- */
- public void testOffer() {
- LinkedBlockingQueue q = new LinkedBlockingQueue(1);
- assertTrue(q.offer(zero));
- assertFalse(q.offer(one));
- }
-
- /**
- * add succeeds if not full; throws ISE if full
- */
- public void testAdd() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.add(new Integer(i)));
- }
- assertEquals(0, q.remainingCapacity());
- q.add(new Integer(SIZE));
- } catch (IllegalStateException success){
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(1);
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * addAll(this) throws IAE
- */
- public void testAddAllSelf() {
- try {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- q.addAll(q);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * addAll of a collection with null elements throws NPE
- */
- public void testAddAll2() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll of a collection with any null elements throws NPE after
- * possibly adding some elements
- */
- public void testAddAll3() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll throws ISE if not enough room
- */
- public void testAddAll4() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(1);
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (IllegalStateException success) {}
- }
- /**
- * Queue contains all elements, in traversal order, of successful addAll
- */
- public void testAddAll5() {
- try {
- Integer[] empty = new Integer[0];
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE);
- assertFalse(q.addAll(Arrays.asList(empty)));
- assertTrue(q.addAll(Arrays.asList(ints)));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * put(null) throws NPE
- */
- public void testPutNull() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE);
- q.put(null);
- shouldThrow();
- }
- catch (NullPointerException success){
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * all elements successfully put are contained
- */
- public void testPut() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- Integer I = new Integer(i);
- q.put(I);
- assertTrue(q.contains(I));
- }
- assertEquals(0, q.remainingCapacity());
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * put blocks interruptibly if full
- */
- public void testBlockingPut() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- int added = 0;
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- q.put(new Integer(i));
- ++added;
- }
- q.put(new Integer(SIZE));
- threadShouldThrow();
- } catch (InterruptedException ie){
- threadAssertEquals(added, SIZE);
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * put blocks waiting for take when full
- */
- public void testPutWithTake() {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- int added = 0;
- try {
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- threadShouldThrow();
- } catch (InterruptedException e){
- threadAssertTrue(added >= 2);
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- q.take();
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * timed offer times out if full and elements not taken
- */
- public void testTimedOffer() {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(new Object());
- q.put(new Object());
- threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success){}
- }
- });
-
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * take retrieves elements in FIFO order
- */
- public void testTake() {
- try {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.take()).intValue());
- }
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * take blocks interruptibly when empty
- */
- public void testTakeFromEmpty() {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){ }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Take removes existing elements until empty, then blocks interruptibly
- */
- public void testBlockingTake() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.take()).intValue());
- }
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
-
- /**
- * poll succeeds unless empty
- */
- public void testPoll() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll()).intValue());
- }
- assertNull(q.poll());
- }
-
- /**
- * timed pool with zero timeout succeeds when non-empty, else times out
- */
- public void testTimedPoll0() {
- try {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue());
- }
- assertNull(q.poll(0, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * timed pool with nonzero timeout succeeds when non-empty, else times out
- */
- public void testTimedPoll() {
- try {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
- }
- assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * Interrupted timed poll throws InterruptedException instead of
- * returning timeout status
- */
- public void testInterruptedTimedPoll() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
- }
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException success){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * timed poll before a delayed offer fails; after offer succeeds;
- * on interruption throws
- */
- public void testTimedPollWithOffer() {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success) { }
- }
- });
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * peek returns next element, or null if empty
- */
- public void testPeek() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.peek()).intValue());
- q.poll();
- assertTrue(q.peek() == null ||
- i != ((Integer)q.peek()).intValue());
- }
- assertNull(q.peek());
- }
-
- /**
- * element returns next element, or throws NSEE if empty
- */
- public void testElement() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.element()).intValue());
- q.poll();
- }
- try {
- q.element();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * remove removes next element, or throws NSEE if empty
- */
- public void testRemove() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.remove()).intValue());
- }
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success){
- }
- }
-
- /**
- * remove(x) removes x and returns true if present
- */
- public void testRemoveElement() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 1; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- }
- for (int i = 0; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- assertFalse(q.remove(new Integer(i+1)));
- }
- assertTrue(q.isEmpty());
- }
-
- /**
- * An add following remove(x) succeeds
- */
- public void testRemoveElementAndAdd() {
- try {
- LinkedBlockingQueue q = new LinkedBlockingQueue();
- assertTrue(q.add(new Integer(1)));
- assertTrue(q.add(new Integer(2)));
- assertTrue(q.remove(new Integer(1)));
- assertTrue(q.remove(new Integer(2)));
- assertTrue(q.add(new Integer(3)));
- assertTrue(q.take() != null);
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * contains(x) reports true when elements added but not yet removed
- */
- public void testContains() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.contains(new Integer(i)));
- q.poll();
- assertFalse(q.contains(new Integer(i)));
- }
- }
-
- /**
- * clear removes all elements
- */
- public void testClear() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- q.clear();
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- assertEquals(SIZE, q.remainingCapacity());
- q.add(one);
- assertFalse(q.isEmpty());
- assertTrue(q.contains(one));
- q.clear();
- assertTrue(q.isEmpty());
- }
-
- /**
- * containsAll(c) is true when c contains a subset of elements
- */
- public void testContainsAll() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- LinkedBlockingQueue p = new LinkedBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.containsAll(p));
- assertFalse(p.containsAll(q));
- p.add(new Integer(i));
- }
- assertTrue(p.containsAll(q));
- }
-
- /**
- * retainAll(c) retains only those elements of c and reports true if changed
- */
- public void testRetainAll() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- LinkedBlockingQueue p = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- boolean changed = q.retainAll(p);
- if (i == 0)
- assertFalse(changed);
- else
- assertTrue(changed);
-
- assertTrue(q.containsAll(p));
- assertEquals(SIZE-i, q.size());
- p.remove();
- }
- }
-
- /**
- * removeAll(c) removes only those elements of c and reports true if changed
- */
- public void testRemoveAll() {
- for (int i = 1; i < SIZE; ++i) {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- LinkedBlockingQueue p = populatedQueue(i);
- assertTrue(q.removeAll(p));
- assertEquals(SIZE-i, q.size());
- for (int j = 0; j < i; ++j) {
- Integer I = (Integer)(p.remove());
- assertFalse(q.contains(I));
- }
- }
- }
-
- /**
- * toArray contains all elements
- */
- public void testToArray() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- Object[] o = q.toArray();
- try {
- for(int i = 0; i < o.length; i++)
- assertEquals(o[i], q.take());
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * toArray(a) contains all elements
- */
- public void testToArray2() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- ints = (Integer[])q.toArray(ints);
- try {
- for(int i = 0; i < ints.length; i++)
- assertEquals(ints[i], q.take());
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * toArray(null) throws NPE
- */
- public void testToArray_BadArg() {
- try {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(null);
- shouldThrow();
- } catch(NullPointerException success){}
- }
-
- /**
- * toArray with incompatible array type throws CCE
- */
- public void testToArray1_BadArg() {
- try {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(new String[10] );
- shouldThrow();
- } catch(ArrayStoreException success){}
- }
-
-
- /**
- * iterator iterates through all elements
- */
- public void testIterator() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- Iterator it = q.iterator();
- try {
- while(it.hasNext()){
- assertEquals(it.next(), q.take());
- }
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * iterator.remove removes current element
- */
- public void testIteratorRemove () {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(3);
- q.add(two);
- q.add(one);
- q.add(three);
-
- Iterator it = q.iterator();
- it.next();
- it.remove();
-
- it = q.iterator();
- assertEquals(it.next(), one);
- assertEquals(it.next(), three);
- assertFalse(it.hasNext());
- }
-
-
- /**
- * iterator ordering is FIFO
- */
- public void testIteratorOrdering() {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(3);
- q.add(one);
- q.add(two);
- q.add(three);
- assertEquals(0, q.remainingCapacity());
- int k = 0;
- for (Iterator it = q.iterator(); it.hasNext();) {
- int i = ((Integer)(it.next())).intValue();
- assertEquals(++k, i);
- }
- assertEquals(3, k);
- }
-
- /**
- * Modifications do not cause iterators to fail
- */
- public void testWeaklyConsistentIteration () {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(3);
- q.add(one);
- q.add(two);
- q.add(three);
- try {
- for (Iterator it = q.iterator(); it.hasNext();) {
- q.remove();
- it.next();
- }
- }
- catch (ConcurrentModificationException e) {
- unexpectedException();
- }
- assertEquals(0, q.size());
- }
-
-
- /**
- * toString contains toStrings of elements
- */
- public void testToString() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- String s = q.toString();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
-
- /**
- * offer transfers elements across Executor tasks
- */
- public void testOfferInExecutor() {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(2);
- q.add(one);
- q.add(two);
- ExecutorService executor = Executors.newFixedThreadPool(2);
- executor.execute(new Runnable() {
- public void run() {
- threadAssertFalse(q.offer(three));
- try {
- threadAssertTrue(q.offer(three, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertEquals(0, q.remainingCapacity());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- executor.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- threadAssertEquals(one, q.take());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- joinPool(executor);
- }
-
- /**
- * poll retrieves elements across Executor threads
- */
- public void testPollInExecutor() {
- final LinkedBlockingQueue q = new LinkedBlockingQueue(2);
- ExecutorService executor = Executors.newFixedThreadPool(2);
- executor.execute(new Runnable() {
- public void run() {
- threadAssertNull(q.poll());
- try {
- threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(q.isEmpty());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- executor.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- q.put(one);
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- joinPool(executor);
- }
-
- /**
- * A deserialized serialized queue has same elements in same order
- */
- public void testSerialization() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- LinkedBlockingQueue r = (LinkedBlockingQueue)in.readObject();
- assertEquals(q.size(), r.size());
- while (!q.isEmpty())
- assertEquals(q.remove(), r.remove());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null) throws NPE
- */
- public void testDrainToNull() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(null);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this) throws IAE
- */
- public void testDrainToSelf() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(q);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c) empties queue into another collection c
- */
- public void testDrainTo() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- assertEquals(l.size(), SIZE);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(l.get(i), new Integer(i));
- q.add(zero);
- q.add(one);
- assertFalse(q.isEmpty());
- assertTrue(q.contains(zero));
- assertTrue(q.contains(one));
- l.clear();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- assertEquals(l.size(), 2);
- for (int i = 0; i < 2; ++i)
- assertEquals(l.get(i), new Integer(i));
- }
-
- /**
- * drainTo empties full queue, unblocking a waiting put.
- */
- public void testDrainToWithActivePut() {
- final LinkedBlockingQueue q = populatedQueue(SIZE);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(new Integer(SIZE+1));
- } catch (InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertTrue(l.size() >= SIZE);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(l.get(i), new Integer(i));
- t.join();
- assertTrue(q.size() + l.size() >= SIZE);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null, n) throws NPE
- */
- public void testDrainToNullN() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(null, 0);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this, n) throws IAE
- */
- public void testDrainToSelfN() {
- LinkedBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(q, 0);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c, n) empties first max {n, size} elements of queue into c
- */
- public void testDrainToN() {
- LinkedBlockingQueue q = new LinkedBlockingQueue();
- for (int i = 0; i < SIZE + 2; ++i) {
- for(int j = 0; j < SIZE; j++)
- assertTrue(q.offer(new Integer(j)));
- ArrayList l = new ArrayList();
- q.drainTo(l, i);
- int k = (i < SIZE)? i : SIZE;
- assertEquals(l.size(), k);
- assertEquals(q.size(), SIZE-k);
- for (int j = 0; j < k; ++j)
- assertEquals(l.get(j), new Integer(j));
- while (q.poll() != null) ;
- }
- }
-
-}
diff --git a/concurrent/src/test/java/LinkedListTest.java b/concurrent/src/test/java/LinkedListTest.java
deleted file mode 100644
index 8d8643f..0000000
--- a/concurrent/src/test/java/LinkedListTest.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-public class LinkedListTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
-
- public static Test suite() {
- return new TestSuite(LinkedListTest.class);
- }
-
- /**
- * Create a queue of given size containing consecutive
- * Integers 0 ... n.
- */
- private LinkedList populatedQueue(int n) {
- LinkedList q = new LinkedList();
- assertTrue(q.isEmpty());
- for(int i = 0; i < n; ++i)
- assertTrue(q.offer(new Integer(i)));
- assertFalse(q.isEmpty());
- assertEquals(n, q.size());
- return q;
- }
-
- /**
- * new queue is empty
- */
- public void testConstructor1() {
- assertEquals(0, new LinkedList().size());
- }
-
- /**
- * Initializing from null Collection throws NPE
- */
- public void testConstructor3() {
- try {
- LinkedList q = new LinkedList((Collection)null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of collection used to initialize
-
- */
- public void testConstructor6() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- LinkedList q = new LinkedList(Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * isEmpty is true before add, false after
- */
- public void testEmpty() {
- LinkedList q = new LinkedList();
- assertTrue(q.isEmpty());
- q.add(new Integer(1));
- assertFalse(q.isEmpty());
- q.add(new Integer(2));
- q.remove();
- q.remove();
- assertTrue(q.isEmpty());
- }
-
- /**
- * size changes when elements added and removed
- */
- public void testSize() {
- LinkedList q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(SIZE-i, q.size());
- q.remove();
- }
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.size());
- q.add(new Integer(i));
- }
- }
-
- /**
- * offer(null) succeeds
- */
- public void testOfferNull() {
- try {
- LinkedList q = new LinkedList();
- q.offer(null);
- } catch (NullPointerException ie) {
- unexpectedException();
- }
- }
-
- /**
- * Offer succeeds
- */
- public void testOffer() {
- LinkedList q = new LinkedList();
- assertTrue(q.offer(new Integer(0)));
- assertTrue(q.offer(new Integer(1)));
- }
-
- /**
- * add succeeds
- */
- public void testAdd() {
- LinkedList q = new LinkedList();
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.size());
- assertTrue(q.add(new Integer(i)));
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- LinkedList q = new LinkedList();
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements, in traversal order, of successful addAll
- */
- public void testAddAll5() {
- try {
- Integer[] empty = new Integer[0];
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- LinkedList q = new LinkedList();
- assertFalse(q.addAll(Arrays.asList(empty)));
- assertTrue(q.addAll(Arrays.asList(ints)));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * addAll with too large an index throws IOOBE
- */
- public void testAddAll2_IndexOutOfBoundsException() {
- try {
- LinkedList l = new LinkedList();
- l.add(new Object());
- LinkedList m = new LinkedList();
- m.add(new Object());
- l.addAll(4,m);
- shouldThrow();
- } catch(IndexOutOfBoundsException success) {}
- }
-
- /**
- * addAll with negative index throws IOOBE
- */
- public void testAddAll4_BadIndex() {
- try {
- LinkedList l = new LinkedList();
- l.add(new Object());
- LinkedList m = new LinkedList();
- m.add(new Object());
- l.addAll(-1,m);
- shouldThrow();
- } catch(IndexOutOfBoundsException success){}
- }
-
- /**
- * poll succeeds unless empty
- */
- public void testPoll() {
- LinkedList q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll()).intValue());
- }
- assertNull(q.poll());
- }
-
- /**
- * peek returns next element, or null if empty
- */
- public void testPeek() {
- LinkedList q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.peek()).intValue());
- q.poll();
- assertTrue(q.peek() == null ||
- i != ((Integer)q.peek()).intValue());
- }
- assertNull(q.peek());
- }
-
- /**
- * element returns next element, or throws NSEE if empty
- */
- public void testElement() {
- LinkedList q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.element()).intValue());
- q.poll();
- }
- try {
- q.element();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * remove removes next element, or throws NSEE if empty
- */
- public void testRemove() {
- LinkedList q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.remove()).intValue());
- }
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success){
- }
- }
-
- /**
- * remove(x) removes x and returns true if present
- */
- public void testRemoveElement() {
- LinkedList q = populatedQueue(SIZE);
- for (int i = 1; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- }
- for (int i = 0; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- assertFalse(q.remove(new Integer(i+1)));
- }
- assertTrue(q.isEmpty());
- }
-
- /**
- * contains(x) reports true when elements added but not yet removed
- */
- public void testContains() {
- LinkedList q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.contains(new Integer(i)));
- q.poll();
- assertFalse(q.contains(new Integer(i)));
- }
- }
-
- /**
- * clear removes all elements
- */
- public void testClear() {
- LinkedList q = populatedQueue(SIZE);
- q.clear();
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- q.add(new Integer(1));
- assertFalse(q.isEmpty());
- q.clear();
- assertTrue(q.isEmpty());
- }
-
- /**
- * containsAll(c) is true when c contains a subset of elements
- */
- public void testContainsAll() {
- LinkedList q = populatedQueue(SIZE);
- LinkedList p = new LinkedList();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.containsAll(p));
- assertFalse(p.containsAll(q));
- p.add(new Integer(i));
- }
- assertTrue(p.containsAll(q));
- }
-
- /**
- * retainAll(c) retains only those elements of c and reports true if changed
- */
- public void testRetainAll() {
- LinkedList q = populatedQueue(SIZE);
- LinkedList p = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- boolean changed = q.retainAll(p);
- if (i == 0)
- assertFalse(changed);
- else
- assertTrue(changed);
-
- assertTrue(q.containsAll(p));
- assertEquals(SIZE-i, q.size());
- p.remove();
- }
- }
-
- /**
- * removeAll(c) removes only those elements of c and reports true if changed
- */
- public void testRemoveAll() {
- for (int i = 1; i < SIZE; ++i) {
- LinkedList q = populatedQueue(SIZE);
- LinkedList p = populatedQueue(i);
- assertTrue(q.removeAll(p));
- assertEquals(SIZE-i, q.size());
- for (int j = 0; j < i; ++j) {
- Integer I = (Integer)(p.remove());
- assertFalse(q.contains(I));
- }
- }
- }
-
- /**
- * toArray contains all elements
- */
- public void testToArray() {
- LinkedList q = populatedQueue(SIZE);
- Object[] o = q.toArray();
- Arrays.sort(o);
- for(int i = 0; i < o.length; i++)
- assertEquals(o[i], q.poll());
- }
-
- /**
- * toArray(a) contains all elements
- */
- public void testToArray2() {
- LinkedList q = populatedQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- ints = (Integer[])q.toArray(ints);
- Arrays.sort(ints);
- for(int i = 0; i < ints.length; i++)
- assertEquals(ints[i], q.poll());
- }
-
- /**
- * toArray(null) throws NPE
- */
- public void testToArray_BadArg() {
- try {
- LinkedList l = new LinkedList();
- l.add(new Object());
- Object o[] = l.toArray(null);
- shouldThrow();
- } catch(NullPointerException success){}
- }
-
- /**
- * toArray with incompatable aray type throws CCE
- */
- public void testToArray1_BadArg() {
- try {
- LinkedList l = new LinkedList();
- l.add(new Integer(5));
- Object o[] = l.toArray(new String[10] );
- shouldThrow();
- } catch(ArrayStoreException success){}
- }
-
- /**
- * iterator iterates through all elements
- */
- public void testIterator() {
- LinkedList q = populatedQueue(SIZE);
- int i = 0;
- Iterator it = q.iterator();
- while(it.hasNext()) {
- assertTrue(q.contains(it.next()));
- ++i;
- }
- assertEquals(i, SIZE);
- }
-
- /**
- * iterator ordering is FIFO
- */
- public void testIteratorOrdering() {
- final LinkedList q = new LinkedList();
- q.add(new Integer(1));
- q.add(new Integer(2));
- q.add(new Integer(3));
- int k = 0;
- for (Iterator it = q.iterator(); it.hasNext();) {
- int i = ((Integer)(it.next())).intValue();
- assertEquals(++k, i);
- }
-
- assertEquals(3, k);
- }
-
- /**
- * iterator.remove removes current element
- */
- public void testIteratorRemove () {
- final LinkedList q = new LinkedList();
- q.add(new Integer(1));
- q.add(new Integer(2));
- q.add(new Integer(3));
- Iterator it = q.iterator();
- it.next();
- it.remove();
- it = q.iterator();
- assertEquals(it.next(), new Integer(2));
- assertEquals(it.next(), new Integer(3));
- assertFalse(it.hasNext());
- }
-
-
- /**
- * toString contains toStrings of elements
- */
- public void testToString() {
- LinkedList q = populatedQueue(SIZE);
- String s = q.toString();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
- /**
- * peek returns element inserted with addFirst
- */
- public void testAddFirst() {
- LinkedList q = populatedQueue(3);
- q.addFirst(four);
- assertEquals(four,q.peek());
- }
-
-}
diff --git a/concurrent/src/test/java/LockSupportTest.java b/concurrent/src/test/java/LockSupportTest.java
deleted file mode 100644
index b074a20..0000000
--- a/concurrent/src/test/java/LockSupportTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.locks.*;
-
-public class LockSupportTest extends JSR166TestCase{
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(LockSupportTest.class);
- }
-
- /**
- * park is released by unpark occurring after park
- */
- public void testPark() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- LockSupport.park();
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- LockSupport.unpark(t);
- t.join();
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * park is released by unpark occurring before park
- */
- public void testPark2() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SHORT_DELAY_MS);
- LockSupport.park();
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- LockSupport.unpark(t);
- t.join();
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * park is released by interrupt
- */
- public void testPark3() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- LockSupport.park();
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * park returns if interrupted before park
- */
- public void testPark4() {
- final ReentrantLock lock = new ReentrantLock();
- lock.lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- LockSupport.park();
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- t.interrupt();
- lock.unlock();
- t.join();
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * parkNanos times out if not unparked
- */
- public void testParkNanos() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- LockSupport.parkNanos(1000);
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- t.join();
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-
-
- /**
- * parkUntil times out if not unparked
- */
- public void testParkUntil() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- long d = new Date().getTime() + 100;
- LockSupport.parkUntil(d);
- } catch(Exception e){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- t.join();
- }
- catch(Exception e) {
- unexpectedException();
- }
- }
-}
diff --git a/concurrent/src/test/java/PriorityBlockingQueueTest.java b/concurrent/src/test/java/PriorityBlockingQueueTest.java
deleted file mode 100644
index 97ca3f8..0000000
--- a/concurrent/src/test/java/PriorityBlockingQueueTest.java
+++ /dev/null
@@ -1,955 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class PriorityBlockingQueueTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(PriorityBlockingQueueTest.class);
- }
-
- private static final int NOCAP = Integer.MAX_VALUE;
-
- /** Sample Comparator */
- static class MyReverseComparator implements Comparator {
- public int compare(Object x, Object y) {
- int i = ((Integer)x).intValue();
- int j = ((Integer)y).intValue();
- if (i < j) return 1;
- if (i > j) return -1;
- return 0;
- }
- }
-
- /**
- * Create a queue of given size containing consecutive
- * Integers 0 ... n.
- */
- private PriorityBlockingQueue populatedQueue(int n) {
- PriorityBlockingQueue q = new PriorityBlockingQueue(n);
- assertTrue(q.isEmpty());
- for(int i = n-1; i >= 0; i-=2)
- assertTrue(q.offer(new Integer(i)));
- for(int i = (n & 1); i < n; i+=2)
- assertTrue(q.offer(new Integer(i)));
- assertFalse(q.isEmpty());
- assertEquals(NOCAP, q.remainingCapacity());
- assertEquals(n, q.size());
- return q;
- }
-
- /**
- * A new queue has unbounded capacity
- */
- public void testConstructor1() {
- assertEquals(NOCAP, new PriorityBlockingQueue(SIZE).remainingCapacity());
- }
-
- /**
- * Constructor throws IAE if capacity argument nonpositive
- */
- public void testConstructor2() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(0);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * Initializing from null Collection throws NPE
- */
- public void testConstructor3() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection of null elements throws NPE
- */
- public void testConstructor4() {
- try {
- Integer[] ints = new Integer[SIZE];
- PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection with some null elements throws NPE
- */
- public void testConstructor5() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of collection used to initialize
- */
- public void testConstructor6() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- PriorityBlockingQueue q = new PriorityBlockingQueue(Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * The comparator used in constructor is used
- */
- public void testConstructor7() {
- try {
- MyReverseComparator cmp = new MyReverseComparator();
- PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE, cmp);
- assertEquals(cmp, q.comparator());
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- for (int i = SIZE-1; i >= 0; --i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * isEmpty is true before add, false after
- */
- public void testEmpty() {
- PriorityBlockingQueue q = new PriorityBlockingQueue(2);
- assertTrue(q.isEmpty());
- assertEquals(NOCAP, q.remainingCapacity());
- q.add(one);
- assertFalse(q.isEmpty());
- q.add(two);
- q.remove();
- q.remove();
- assertTrue(q.isEmpty());
- }
-
- /**
- * remainingCapacity does not change when elements added or removed,
- * but size does
- */
- public void testRemainingCapacity() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(NOCAP, q.remainingCapacity());
- assertEquals(SIZE-i, q.size());
- q.remove();
- }
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(NOCAP, q.remainingCapacity());
- assertEquals(i, q.size());
- q.add(new Integer(i));
- }
- }
-
- /**
- * offer(null) throws NPE
- */
- public void testOfferNull() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(1);
- q.offer(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * add(null) throws NPE
- */
- public void testAddNull() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(1);
- q.add(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * Offer of comparable element succeeds
- */
- public void testOffer() {
- PriorityBlockingQueue q = new PriorityBlockingQueue(1);
- assertTrue(q.offer(zero));
- assertTrue(q.offer(one));
- }
-
- /**
- * Offer of non-Comparable throws CCE
- */
- public void testOfferNonComparable() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(1);
- q.offer(new Object());
- q.offer(new Object());
- q.offer(new Object());
- shouldThrow();
- }
- catch(ClassCastException success) {}
- }
-
- /**
- * add of comparable succeeds
- */
- public void testAdd() {
- PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.size());
- assertTrue(q.add(new Integer(i)));
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(1);
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * addAll(this) throws IAE
- */
- public void testAddAllSelf() {
- try {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- q.addAll(q);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * addAll of a collection with null elements throws NPE
- */
- public void testAddAll2() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll of a collection with any null elements throws NPE after
- * possibly adding some elements
- */
- public void testAddAll3() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of successful addAll
- */
- public void testAddAll5() {
- try {
- Integer[] empty = new Integer[0];
- Integer[] ints = new Integer[SIZE];
- for (int i = SIZE-1; i >= 0; --i)
- ints[i] = new Integer(i);
- PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE);
- assertFalse(q.addAll(Arrays.asList(empty)));
- assertTrue(q.addAll(Arrays.asList(ints)));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * put(null) throws NPE
- */
- public void testPutNull() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE);
- q.put(null);
- shouldThrow();
- }
- catch (NullPointerException success){
- }
- }
-
- /**
- * all elements successfully put are contained
- */
- public void testPut() {
- try {
- PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- Integer I = new Integer(i);
- q.put(I);
- assertTrue(q.contains(I));
- }
- assertEquals(SIZE, q.size());
- }
- finally {
- }
- }
-
- /**
- * put doesn't block waiting for take
- */
- public void testPutWithTake() {
- final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- int added = 0;
- try {
- q.put(new Integer(0));
- ++added;
- q.put(new Integer(0));
- ++added;
- q.put(new Integer(0));
- ++added;
- q.put(new Integer(0));
- ++added;
- threadAssertTrue(added == 4);
- } finally {
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- q.take();
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * timed offer does not time out
- */
- public void testTimedOffer() {
- final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(new Integer(0));
- q.put(new Integer(0));
- threadAssertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(q.offer(new Integer(0), LONG_DELAY_MS, TimeUnit.MILLISECONDS));
- } finally { }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * take retrieves elements in priority order
- */
- public void testTake() {
- try {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.take()).intValue());
- }
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * take blocks interruptibly when empty
- */
- public void testTakeFromEmpty() {
- final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){ }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Take removes existing elements until empty, then blocks interruptibly
- */
- public void testBlockingTake() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- threadAssertEquals(i, ((Integer)q.take()).intValue());
- }
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
-
- /**
- * poll succeeds unless empty
- */
- public void testPoll() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll()).intValue());
- }
- assertNull(q.poll());
- }
-
- /**
- * timed pool with zero timeout succeeds when non-empty, else times out
- */
- public void testTimedPoll0() {
- try {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll(0, TimeUnit.MILLISECONDS)).intValue());
- }
- assertNull(q.poll(0, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * timed pool with nonzero timeout succeeds when non-empty, else times out
- */
- public void testTimedPoll() {
- try {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
- }
- assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * Interrupted timed poll throws InterruptedException instead of
- * returning timeout status
- */
- public void testInterruptedTimedPoll() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- threadAssertEquals(i, ((Integer)q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS)).intValue());
- }
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException success){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * timed poll before a delayed offer fails; after offer succeeds;
- * on interruption throws
- */
- public void testTimedPollWithOffer() {
- final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success) { }
- }
- });
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * peek returns next element, or null if empty
- */
- public void testPeek() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.peek()).intValue());
- q.poll();
- assertTrue(q.peek() == null ||
- i != ((Integer)q.peek()).intValue());
- }
- assertNull(q.peek());
- }
-
- /**
- * element returns next element, or throws NSEE if empty
- */
- public void testElement() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.element()).intValue());
- q.poll();
- }
- try {
- q.element();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * remove removes next element, or throws NSEE if empty
- */
- public void testRemove() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.remove()).intValue());
- }
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success){
- }
- }
-
- /**
- * remove(x) removes x and returns true if present
- */
- public void testRemoveElement() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 1; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- }
- for (int i = 0; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- assertFalse(q.remove(new Integer(i+1)));
- }
- assertTrue(q.isEmpty());
- }
-
- /**
- * contains(x) reports true when elements added but not yet removed
- */
- public void testContains() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.contains(new Integer(i)));
- q.poll();
- assertFalse(q.contains(new Integer(i)));
- }
- }
-
- /**
- * clear removes all elements
- */
- public void testClear() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- q.clear();
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- q.add(one);
- assertFalse(q.isEmpty());
- assertTrue(q.contains(one));
- q.clear();
- assertTrue(q.isEmpty());
- }
-
- /**
- * containsAll(c) is true when c contains a subset of elements
- */
- public void testContainsAll() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- PriorityBlockingQueue p = new PriorityBlockingQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.containsAll(p));
- assertFalse(p.containsAll(q));
- p.add(new Integer(i));
- }
- assertTrue(p.containsAll(q));
- }
-
- /**
- * retainAll(c) retains only those elements of c and reports true if changed
- */
- public void testRetainAll() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- PriorityBlockingQueue p = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- boolean changed = q.retainAll(p);
- if (i == 0)
- assertFalse(changed);
- else
- assertTrue(changed);
-
- assertTrue(q.containsAll(p));
- assertEquals(SIZE-i, q.size());
- p.remove();
- }
- }
-
- /**
- * removeAll(c) removes only those elements of c and reports true if changed
- */
- public void testRemoveAll() {
- for (int i = 1; i < SIZE; ++i) {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- PriorityBlockingQueue p = populatedQueue(i);
- assertTrue(q.removeAll(p));
- assertEquals(SIZE-i, q.size());
- for (int j = 0; j < i; ++j) {
- Integer I = (Integer)(p.remove());
- assertFalse(q.contains(I));
- }
- }
- }
-
- /**
- * toArray contains all elements
- */
- public void testToArray() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- Object[] o = q.toArray();
- Arrays.sort(o);
- try {
- for(int i = 0; i < o.length; i++)
- assertEquals(o[i], q.take());
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * toArray(a) contains all elements
- */
- public void testToArray2() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- ints = (Integer[])q.toArray(ints);
- Arrays.sort(ints);
- try {
- for(int i = 0; i < ints.length; i++)
- assertEquals(ints[i], q.take());
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * toArray(null) throws NPE
- */
- public void testToArray_BadArg() {
- try {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(null);
- shouldThrow();
- } catch(NullPointerException success){}
- }
-
- /**
- * toArray with incompatible array type throws CCE
- */
- public void testToArray1_BadArg() {
- try {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- Object o[] = q.toArray(new String[10] );
- shouldThrow();
- } catch(ArrayStoreException success){}
- }
-
- /**
- * iterator iterates through all elements
- */
- public void testIterator() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- int i = 0;
- Iterator it = q.iterator();
- while(it.hasNext()) {
- assertTrue(q.contains(it.next()));
- ++i;
- }
- assertEquals(i, SIZE);
- }
-
- /**
- * iterator.remove removes current element
- */
- public void testIteratorRemove () {
- final PriorityBlockingQueue q = new PriorityBlockingQueue(3);
- q.add(new Integer(2));
- q.add(new Integer(1));
- q.add(new Integer(3));
-
- Iterator it = q.iterator();
- it.next();
- it.remove();
-
- it = q.iterator();
- assertEquals(it.next(), new Integer(2));
- assertEquals(it.next(), new Integer(3));
- assertFalse(it.hasNext());
- }
-
-
- /**
- * toString contains toStrings of elements
- */
- public void testToString() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- String s = q.toString();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
- /**
- * offer transfers elements across Executor tasks
- */
- public void testPollInExecutor() {
- final PriorityBlockingQueue q = new PriorityBlockingQueue(2);
- ExecutorService executor = Executors.newFixedThreadPool(2);
- executor.execute(new Runnable() {
- public void run() {
- threadAssertNull(q.poll());
- try {
- threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(q.isEmpty());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- executor.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- q.put(new Integer(1));
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- joinPool(executor);
- }
-
- /**
- * A deserialized serialized queue has same elements
- */
- public void testSerialization() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- PriorityBlockingQueue r = (PriorityBlockingQueue)in.readObject();
- assertEquals(q.size(), r.size());
- while (!q.isEmpty())
- assertEquals(q.remove(), r.remove());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null) throws NPE
- */
- public void testDrainToNull() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(null);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this) throws IAE
- */
- public void testDrainToSelf() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(q);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c) empties queue into another collection c
- */
- public void testDrainTo() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- assertEquals(l.size(), SIZE);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(l.get(i), new Integer(i));
- q.add(zero);
- q.add(one);
- assertFalse(q.isEmpty());
- assertTrue(q.contains(zero));
- assertTrue(q.contains(one));
- l.clear();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- assertEquals(l.size(), 2);
- for (int i = 0; i < 2; ++i)
- assertEquals(l.get(i), new Integer(i));
- }
-
- /**
- * drainTo empties queue
- */
- public void testDrainToWithActivePut() {
- final PriorityBlockingQueue q = populatedQueue(SIZE);
- Thread t = new Thread(new Runnable() {
- public void run() {
- q.put(new Integer(SIZE+1));
- }
- });
- try {
- t.start();
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertTrue(l.size() >= SIZE);
- for (int i = 0; i < SIZE; ++i)
- assertEquals(l.get(i), new Integer(i));
- t.join();
- assertTrue(q.size() + l.size() >= SIZE);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null, n) throws NPE
- */
- public void testDrainToNullN() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(null, 0);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this, n) throws IAE
- */
- public void testDrainToSelfN() {
- PriorityBlockingQueue q = populatedQueue(SIZE);
- try {
- q.drainTo(q, 0);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c, n) empties first max {n, size} elements of queue into c
- */
- public void testDrainToN() {
- PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE*2);
- for (int i = 0; i < SIZE + 2; ++i) {
- for(int j = 0; j < SIZE; j++)
- assertTrue(q.offer(new Integer(j)));
- ArrayList l = new ArrayList();
- q.drainTo(l, i);
- int k = (i < SIZE)? i : SIZE;
- assertEquals(l.size(), k);
- assertEquals(q.size(), SIZE-k);
- for (int j = 0; j < k; ++j)
- assertEquals(l.get(j), new Integer(j));
- while (q.poll() != null) ;
- }
- }
-
-
-}
diff --git a/concurrent/src/test/java/PriorityQueueTest.java b/concurrent/src/test/java/PriorityQueueTest.java
deleted file mode 100644
index 898e193..0000000
--- a/concurrent/src/test/java/PriorityQueueTest.java
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class PriorityQueueTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(PriorityQueueTest.class);
- }
-
- static class MyReverseComparator implements Comparator {
- public int compare(Object x, Object y) {
- int i = ((Integer)x).intValue();
- int j = ((Integer)y).intValue();
- if (i < j) return 1;
- if (i > j) return -1;
- return 0;
- }
- }
-
- /**
- * Create a queue of given size containing consecutive
- * Integers 0 ... n.
- */
- private PriorityQueue populatedQueue(int n) {
- PriorityQueue q = new PriorityQueue(n);
- assertTrue(q.isEmpty());
- for(int i = n-1; i >= 0; i-=2)
- assertTrue(q.offer(new Integer(i)));
- for(int i = (n & 1); i < n; i+=2)
- assertTrue(q.offer(new Integer(i)));
- assertFalse(q.isEmpty());
- assertEquals(n, q.size());
- return q;
- }
-
- /**
- * A new queue has unbounded capacity
- */
- public void testConstructor1() {
- assertEquals(0, new PriorityQueue(SIZE).size());
- }
-
- /**
- * Constructor throws IAE if capacity argument nonpositive
- */
- public void testConstructor2() {
- try {
- PriorityQueue q = new PriorityQueue(0);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * Initializing from null Collection throws NPE
- */
- public void testConstructor3() {
- try {
- PriorityQueue q = new PriorityQueue((Collection)null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection of null elements throws NPE
- */
- public void testConstructor4() {
- try {
- Integer[] ints = new Integer[SIZE];
- PriorityQueue q = new PriorityQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Initializing from Collection with some null elements throws NPE
- */
- public void testConstructor5() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- PriorityQueue q = new PriorityQueue(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of collection used to initialize
- */
- public void testConstructor6() {
- try {
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- PriorityQueue q = new PriorityQueue(Arrays.asList(ints));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * The comparator used in constructor is used
- */
- public void testConstructor7() {
- try {
- MyReverseComparator cmp = new MyReverseComparator();
- PriorityQueue q = new PriorityQueue(SIZE, cmp);
- assertEquals(cmp, q.comparator());
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- for (int i = SIZE-1; i >= 0; --i)
- assertEquals(ints[i], q.poll());
- }
- finally {}
- }
-
- /**
- * isEmpty is true before add, false after
- */
- public void testEmpty() {
- PriorityQueue q = new PriorityQueue(2);
- assertTrue(q.isEmpty());
- q.add(new Integer(1));
- assertFalse(q.isEmpty());
- q.add(new Integer(2));
- q.remove();
- q.remove();
- assertTrue(q.isEmpty());
- }
-
- /**
- * size changes when elements added and removed
- */
- public void testSize() {
- PriorityQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(SIZE-i, q.size());
- q.remove();
- }
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.size());
- q.add(new Integer(i));
- }
- }
-
- /**
- * offer(null) throws NPE
- */
- public void testOfferNull() {
- try {
- PriorityQueue q = new PriorityQueue(1);
- q.offer(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * add(null) throws NPE
- */
- public void testAddNull() {
- try {
- PriorityQueue q = new PriorityQueue(1);
- q.add(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * Offer of comparable element succeeds
- */
- public void testOffer() {
- PriorityQueue q = new PriorityQueue(1);
- assertTrue(q.offer(zero));
- assertTrue(q.offer(one));
- }
-
- /**
- * Offer of non-Comparable throws CCE
- */
- public void testOfferNonComparable() {
- try {
- PriorityQueue q = new PriorityQueue(1);
- q.offer(new Object());
- q.offer(new Object());
- q.offer(new Object());
- shouldThrow();
- }
- catch(ClassCastException success) {}
- }
-
- /**
- * add of comparable succeeds
- */
- public void testAdd() {
- PriorityQueue q = new PriorityQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, q.size());
- assertTrue(q.add(new Integer(i)));
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- PriorityQueue q = new PriorityQueue(1);
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll of a collection with null elements throws NPE
- */
- public void testAddAll2() {
- try {
- PriorityQueue q = new PriorityQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll of a collection with any null elements throws NPE after
- * possibly adding some elements
- */
- public void testAddAll3() {
- try {
- PriorityQueue q = new PriorityQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE-1; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * Queue contains all elements of successful addAll
- */
- public void testAddAll5() {
- try {
- Integer[] empty = new Integer[0];
- Integer[] ints = new Integer[SIZE];
- for (int i = 0; i < SIZE; ++i)
- ints[i] = new Integer(SIZE-1-i);
- PriorityQueue q = new PriorityQueue(SIZE);
- assertFalse(q.addAll(Arrays.asList(empty)));
- assertTrue(q.addAll(Arrays.asList(ints)));
- for (int i = 0; i < SIZE; ++i)
- assertEquals(new Integer(i), q.poll());
- }
- finally {}
- }
-
- /**
- * poll succeeds unless empty
- */
- public void testPoll() {
- PriorityQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.poll()).intValue());
- }
- assertNull(q.poll());
- }
-
- /**
- * peek returns next element, or null if empty
- */
- public void testPeek() {
- PriorityQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.peek()).intValue());
- q.poll();
- assertTrue(q.peek() == null ||
- i != ((Integer)q.peek()).intValue());
- }
- assertNull(q.peek());
- }
-
- /**
- * element returns next element, or throws NSEE if empty
- */
- public void testElement() {
- PriorityQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.element()).intValue());
- q.poll();
- }
- try {
- q.element();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * remove removes next element, or throws NSEE if empty
- */
- public void testRemove() {
- PriorityQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertEquals(i, ((Integer)q.remove()).intValue());
- }
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success){
- }
- }
-
- /**
- * remove(x) removes x and returns true if present
- */
- public void testRemoveElement() {
- PriorityQueue q = populatedQueue(SIZE);
- for (int i = 1; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- }
- for (int i = 0; i < SIZE; i+=2) {
- assertTrue(q.remove(new Integer(i)));
- assertFalse(q.remove(new Integer(i+1)));
- }
- assertTrue(q.isEmpty());
- }
-
- /**
- * contains(x) reports true when elements added but not yet removed
- */
- public void testContains() {
- PriorityQueue q = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.contains(new Integer(i)));
- q.poll();
- assertFalse(q.contains(new Integer(i)));
- }
- }
-
- /**
- * clear removes all elements
- */
- public void testClear() {
- PriorityQueue q = populatedQueue(SIZE);
- q.clear();
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- q.add(new Integer(1));
- assertFalse(q.isEmpty());
- q.clear();
- assertTrue(q.isEmpty());
- }
-
- /**
- * containsAll(c) is true when c contains a subset of elements
- */
- public void testContainsAll() {
- PriorityQueue q = populatedQueue(SIZE);
- PriorityQueue p = new PriorityQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(q.containsAll(p));
- assertFalse(p.containsAll(q));
- p.add(new Integer(i));
- }
- assertTrue(p.containsAll(q));
- }
-
- /**
- * retainAll(c) retains only those elements of c and reports true if changed
- */
- public void testRetainAll() {
- PriorityQueue q = populatedQueue(SIZE);
- PriorityQueue p = populatedQueue(SIZE);
- for (int i = 0; i < SIZE; ++i) {
- boolean changed = q.retainAll(p);
- if (i == 0)
- assertFalse(changed);
- else
- assertTrue(changed);
-
- assertTrue(q.containsAll(p));
- assertEquals(SIZE-i, q.size());
- p.remove();
- }
- }
-
- /**
- * removeAll(c) removes only those elements of c and reports true if changed
- */
- public void testRemoveAll() {
- for (int i = 1; i < SIZE; ++i) {
- PriorityQueue q = populatedQueue(SIZE);
- PriorityQueue p = populatedQueue(i);
- assertTrue(q.removeAll(p));
- assertEquals(SIZE-i, q.size());
- for (int j = 0; j < i; ++j) {
- Integer I = (Integer)(p.remove());
- assertFalse(q.contains(I));
- }
- }
- }
-
- /**
- * toArray contains all elements
- */
- public void testToArray() {
- PriorityQueue q = populatedQueue(SIZE);
- Object[] o = q.toArray();
- Arrays.sort(o);
- for(int i = 0; i < o.length; i++)
- assertEquals(o[i], q.poll());
- }
-
- /**
- * toArray(a) contains all elements
- */
- public void testToArray2() {
- PriorityQueue q = populatedQueue(SIZE);
- Integer[] ints = new Integer[SIZE];
- ints = (Integer[])q.toArray(ints);
- Arrays.sort(ints);
- for(int i = 0; i < ints.length; i++)
- assertEquals(ints[i], q.poll());
- }
-
- /**
- * iterator iterates through all elements
- */
- public void testIterator() {
- PriorityQueue q = populatedQueue(SIZE);
- int i = 0;
- Iterator it = q.iterator();
- while(it.hasNext()) {
- assertTrue(q.contains(it.next()));
- ++i;
- }
- assertEquals(i, SIZE);
- }
-
- /**
- * iterator.remove removes current element
- */
- public void testIteratorRemove () {
- final PriorityQueue q = new PriorityQueue(3);
- q.add(new Integer(2));
- q.add(new Integer(1));
- q.add(new Integer(3));
-
- Iterator it = q.iterator();
- it.next();
- it.remove();
-
- it = q.iterator();
- assertEquals(it.next(), new Integer(2));
- assertEquals(it.next(), new Integer(3));
- assertFalse(it.hasNext());
- }
-
-
- /**
- * toString contains toStrings of elements
- */
- public void testToString() {
- PriorityQueue q = populatedQueue(SIZE);
- String s = q.toString();
- for (int i = 0; i < SIZE; ++i) {
- assertTrue(s.indexOf(String.valueOf(i)) >= 0);
- }
- }
-
- /**
- * A deserialized serialized queue has same elements
- */
- public void testSerialization() {
- PriorityQueue q = populatedQueue(SIZE);
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- PriorityQueue r = (PriorityQueue)in.readObject();
- assertEquals(q.size(), r.size());
- while (!q.isEmpty())
- assertEquals(q.remove(), r.remove());
- } catch(Exception e){
- unexpectedException();
- }
- }
-}
diff --git a/concurrent/src/test/java/ReentrantLockTest.java b/concurrent/src/test/java/ReentrantLockTest.java
deleted file mode 100644
index b2e4619..0000000
--- a/concurrent/src/test/java/ReentrantLockTest.java
+++ /dev/null
@@ -1,1162 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.locks.*;
-import java.util.concurrent.*;
-import java.util.*;
-import java.io.*;
-
-public class ReentrantLockTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ReentrantLockTest.class);
- }
-
- /**
- * A runnable calling lockInterruptibly
- */
- class InterruptibleLockRunnable implements Runnable {
- final ReentrantLock lock;
- InterruptibleLockRunnable(ReentrantLock l) { lock = l; }
- public void run() {
- try {
- lock.lockInterruptibly();
- } catch(InterruptedException success){}
- }
- }
-
-
- /**
- * A runnable calling lockInterruptibly that expects to be
- * interrupted
- */
- class InterruptedLockRunnable implements Runnable {
- final ReentrantLock lock;
- InterruptedLockRunnable(ReentrantLock l) { lock = l; }
- public void run() {
- try {
- lock.lockInterruptibly();
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- }
-
- /**
- * Subclass to expose protected methods
- */
- static class PublicReentrantLock extends ReentrantLock {
- PublicReentrantLock() { super(); }
- public Collection<Thread> getQueuedThreads() {
- return super.getQueuedThreads();
- }
- public Collection<Thread> getWaitingThreads(Condition c) {
- return super.getWaitingThreads(c);
- }
-
-
- }
-
- /**
- * Constructor sets given fairness
- */
- public void testConstructor() {
- ReentrantLock rl = new ReentrantLock();
- assertFalse(rl.isFair());
- ReentrantLock r2 = new ReentrantLock(true);
- assertTrue(r2.isFair());
- }
-
- /**
- * locking an unlocked lock succeeds
- */
- public void testLock() {
- ReentrantLock rl = new ReentrantLock();
- rl.lock();
- assertTrue(rl.isLocked());
- rl.unlock();
- }
-
- /**
- * locking an unlocked fair lock succeeds
- */
- public void testFairLock() {
- ReentrantLock rl = new ReentrantLock(true);
- rl.lock();
- assertTrue(rl.isLocked());
- rl.unlock();
- }
-
- /**
- * Unlocking an unlocked lock throws IllegalMonitorStateException
- */
- public void testUnlock_IllegalMonitorStateException() {
- ReentrantLock rl = new ReentrantLock();
- try {
- rl.unlock();
- shouldThrow();
-
- } catch(IllegalMonitorStateException success){}
- }
-
- /**
- * tryLock on an unlocked lock succeeds
- */
- public void testTryLock() {
- ReentrantLock rl = new ReentrantLock();
- assertTrue(rl.tryLock());
- assertTrue(rl.isLocked());
- rl.unlock();
- }
-
-
- /**
- * hasQueuedThreads reports whether there are waiting threads
- */
- public void testhasQueuedThreads() {
- final ReentrantLock lock = new ReentrantLock();
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertFalse(lock.hasQueuedThreads());
- lock.lock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- lock.unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(lock.hasQueuedThreads());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getQueueLength reports number of waiting threads
- */
- public void testGetQueueLength() {
- final ReentrantLock lock = new ReentrantLock();
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertEquals(0, lock.getQueueLength());
- lock.lock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(2, lock.getQueueLength());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- lock.unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(0, lock.getQueueLength());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getQueueLength reports number of waiting threads
- */
- public void testGetQueueLength_fair() {
- final ReentrantLock lock = new ReentrantLock(true);
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertEquals(0, lock.getQueueLength());
- lock.lock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(2, lock.getQueueLength());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- lock.unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(0, lock.getQueueLength());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * hasQueuedThread(null) throws NPE
- */
- public void testHasQueuedThreadNPE() {
- final ReentrantLock sync = new ReentrantLock();
- try {
- sync.hasQueuedThread(null);
- shouldThrow();
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * hasQueuedThread reports whether a thread is queued.
- */
- public void testHasQueuedThread() {
- final ReentrantLock sync = new ReentrantLock();
- Thread t1 = new Thread(new InterruptedLockRunnable(sync));
- Thread t2 = new Thread(new InterruptibleLockRunnable(sync));
- try {
- assertFalse(sync.hasQueuedThread(t1));
- assertFalse(sync.hasQueuedThread(t2));
- sync.lock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasQueuedThread(t1));
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasQueuedThread(t1));
- assertTrue(sync.hasQueuedThread(t2));
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.hasQueuedThread(t1));
- assertTrue(sync.hasQueuedThread(t2));
- sync.unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.hasQueuedThread(t1));
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.hasQueuedThread(t2));
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * getQueuedThreads includes waiting threads
- */
- public void testGetQueuedThreads() {
- final PublicReentrantLock lock = new PublicReentrantLock();
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertTrue(lock.getQueuedThreads().isEmpty());
- lock.lock();
- assertTrue(lock.getQueuedThreads().isEmpty());
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().contains(t1));
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().contains(t1));
- assertTrue(lock.getQueuedThreads().contains(t2));
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(lock.getQueuedThreads().contains(t1));
- assertTrue(lock.getQueuedThreads().contains(t2));
- lock.unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().isEmpty());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * timed tryLock is interruptible.
- */
- public void testInterruptedException2() {
- final ReentrantLock lock = new ReentrantLock();
- lock.lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.tryLock(MEDIUM_DELAY_MS,TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- try {
- t.start();
- t.interrupt();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * TryLock on a locked lock fails
- */
- public void testTryLockWhenLocked() {
- final ReentrantLock lock = new ReentrantLock();
- lock.lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertFalse(lock.tryLock());
- }
- });
- try {
- t.start();
- t.join();
- lock.unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Timed tryLock on a locked lock times out
- */
- public void testTryLock_Timeout() {
- final ReentrantLock lock = new ReentrantLock();
- lock.lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(lock.tryLock(1, TimeUnit.MILLISECONDS));
- } catch (Exception ex) {
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- t.join();
- lock.unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getHoldCount returns number of recursive holds
- */
- public void testGetHoldCount() {
- ReentrantLock lock = new ReentrantLock();
- for(int i = 1; i <= SIZE; i++) {
- lock.lock();
- assertEquals(i,lock.getHoldCount());
- }
- for(int i = SIZE; i > 0; i--) {
- lock.unlock();
- assertEquals(i-1,lock.getHoldCount());
- }
- }
-
-
- /**
- * isLocked is true when locked and false when not
- */
- public void testIsLocked() {
- final ReentrantLock lock = new ReentrantLock();
- lock.lock();
- assertTrue(lock.isLocked());
- lock.unlock();
- assertFalse(lock.isLocked());
- Thread t = new Thread(new Runnable() {
- public void run() {
- lock.lock();
- try {
- Thread.sleep(SMALL_DELAY_MS);
- }
- catch(Exception e) {
- threadUnexpectedException();
- }
- lock.unlock();
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.isLocked());
- t.join();
- assertFalse(lock.isLocked());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * lockInterruptibly is interruptible.
- */
- public void testLockInterruptibly1() {
- final ReentrantLock lock = new ReentrantLock();
- lock.lock();
- Thread t = new Thread(new InterruptedLockRunnable(lock));
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- lock.unlock();
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * lockInterruptibly succeeds when unlocked, else is interruptible
- */
- public void testLockInterruptibly2() {
- final ReentrantLock lock = new ReentrantLock();
- try {
- lock.lockInterruptibly();
- } catch(Exception e) {
- unexpectedException();
- }
- Thread t = new Thread(new InterruptedLockRunnable(lock));
- try {
- t.start();
- t.interrupt();
- assertTrue(lock.isLocked());
- assertTrue(lock.isHeldByCurrentThread());
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Calling await without holding lock throws IllegalMonitorStateException
- */
- public void testAwait_IllegalMonitor() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- try {
- c.await();
- shouldThrow();
- }
- catch (IllegalMonitorStateException success) {
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * Calling signal without holding lock throws IllegalMonitorStateException
- */
- public void testSignal_IllegalMonitor() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- try {
- c.signal();
- shouldThrow();
- }
- catch (IllegalMonitorStateException success) {
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitNanos without a signal times out
- */
- public void testAwaitNanos_Timeout() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- try {
- lock.lock();
- long t = c.awaitNanos(100);
- assertTrue(t <= 0);
- lock.unlock();
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * timed await without a signal times out
- */
- public void testAwait_Timeout() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- try {
- lock.lock();
- c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- lock.unlock();
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitUntil without a signal times out
- */
- public void testAwaitUntil_Timeout() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- try {
- lock.lock();
- java.util.Date d = new java.util.Date();
- c.awaitUntil(new java.util.Date(d.getTime() + 10));
- lock.unlock();
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * await returns when signalled
- */
- public void testAwait() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- c.await();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- c.signal();
- lock.unlock();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * hasWaiters throws NPE if null
- */
- public void testHasWaitersNPE() {
- final ReentrantLock lock = new ReentrantLock();
- try {
- lock.hasWaiters(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength throws NPE if null
- */
- public void testGetWaitQueueLengthNPE() {
- final ReentrantLock lock = new ReentrantLock();
- try {
- lock.getWaitQueueLength(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitingThreads throws NPE if null
- */
- public void testGetWaitingThreadsNPE() {
- final PublicReentrantLock lock = new PublicReentrantLock();
- try {
- lock.getWaitingThreads(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * hasWaiters throws IAE if not owned
- */
- public void testHasWaitersIAE() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = (lock.newCondition());
- final ReentrantLock lock2 = new ReentrantLock();
- try {
- lock2.hasWaiters(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * hasWaiters throws IMSE if not locked
- */
- public void testHasWaitersIMSE() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = (lock.newCondition());
- try {
- lock.hasWaiters(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitQueueLength throws IAE if not owned
- */
- public void testGetWaitQueueLengthIAE() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = (lock.newCondition());
- final ReentrantLock lock2 = new ReentrantLock();
- try {
- lock2.getWaitQueueLength(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength throws IMSE if not locked
- */
- public void testGetWaitQueueLengthIMSE() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = (lock.newCondition());
- try {
- lock.getWaitQueueLength(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitingThreads throws IAE if not owned
- */
- public void testGetWaitingThreadsIAE() {
- final PublicReentrantLock lock = new PublicReentrantLock();
- final Condition c = (lock.newCondition());
- final PublicReentrantLock lock2 = new PublicReentrantLock();
- try {
- lock2.getWaitingThreads(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitingThreads throws IMSE if not locked
- */
- public void testGetWaitingThreadsIMSE() {
- final PublicReentrantLock lock = new PublicReentrantLock();
- final Condition c = (lock.newCondition());
- try {
- lock.getWaitingThreads(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
-
- /**
- * hasWaiters returns true when a thread is waiting, else false
- */
- public void testHasWaiters() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- threadAssertFalse(lock.hasWaiters(c));
- threadAssertEquals(0, lock.getWaitQueueLength(c));
- c.await();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- assertTrue(lock.hasWaiters(c));
- assertEquals(1, lock.getWaitQueueLength(c));
- c.signal();
- lock.unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- assertFalse(lock.hasWaiters(c));
- assertEquals(0, lock.getWaitQueueLength(c));
- lock.unlock();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength returns number of waiting threads
- */
- public void testGetWaitQueueLength() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- threadAssertFalse(lock.hasWaiters(c));
- threadAssertEquals(0, lock.getWaitQueueLength(c));
- c.await();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- threadAssertTrue(lock.hasWaiters(c));
- threadAssertEquals(1, lock.getWaitQueueLength(c));
- c.await();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- assertTrue(lock.hasWaiters(c));
- assertEquals(2, lock.getWaitQueueLength(c));
- c.signalAll();
- lock.unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- assertFalse(lock.hasWaiters(c));
- assertEquals(0, lock.getWaitQueueLength(c));
- lock.unlock();
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitingThreads returns only and all waiting threads
- */
- public void testGetWaitingThreads() {
- final PublicReentrantLock lock = new PublicReentrantLock();
- final Condition c = lock.newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- threadAssertTrue(lock.getWaitingThreads(c).isEmpty());
- c.await();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- threadAssertFalse(lock.getWaitingThreads(c).isEmpty());
- c.await();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- lock.lock();
- assertTrue(lock.getWaitingThreads(c).isEmpty());
- lock.unlock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- assertTrue(lock.hasWaiters(c));
- assertTrue(lock.getWaitingThreads(c).contains(t1));
- assertTrue(lock.getWaitingThreads(c).contains(t2));
- c.signalAll();
- lock.unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- assertFalse(lock.hasWaiters(c));
- assertTrue(lock.getWaitingThreads(c).isEmpty());
- lock.unlock();
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /** A helper class for uninterruptible wait tests */
- class UninterruptableThread extends Thread {
- private ReentrantLock lock;
- private Condition c;
-
- public volatile boolean canAwake = false;
- public volatile boolean interrupted = false;
- public volatile boolean lockStarted = false;
-
- public UninterruptableThread(ReentrantLock lock, Condition c) {
- this.lock = lock;
- this.c = c;
- }
-
- public synchronized void run() {
- lock.lock();
- lockStarted = true;
-
- while (!canAwake) {
- c.awaitUninterruptibly();
- }
-
- interrupted = isInterrupted();
- lock.unlock();
- }
- }
-
- /**
- * awaitUninterruptibly doesn't abort on interrupt
- */
- public void testAwaitUninterruptibly() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- UninterruptableThread thread = new UninterruptableThread(lock, c);
-
- try {
- thread.start();
-
- while (!thread.lockStarted) {
- Thread.sleep(100);
- }
-
- lock.lock();
- try {
- thread.interrupt();
- thread.canAwake = true;
- c.signal();
- } finally {
- lock.unlock();
- }
-
- thread.join();
- assertTrue(thread.interrupted);
- assertFalse(thread.isAlive());
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * await is interruptible
- */
- public void testAwait_Interrupt() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- c.await();
- lock.unlock();
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitNanos is interruptible
- */
- public void testAwaitNanos_Interrupt() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- c.awaitNanos(1000 * 1000 * 1000); // 1 sec
- lock.unlock();
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitUntil is interruptible
- */
- public void testAwaitUntil_Interrupt() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- java.util.Date d = new java.util.Date();
- c.awaitUntil(new java.util.Date(d.getTime() + 10000));
- lock.unlock();
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * signalAll wakes up all threads
- */
- public void testSignalAll() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- c.await();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- c.await();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- c.signalAll();
- lock.unlock();
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * await after multiple reentrant locking preserves lock count
- */
- public void testAwaitLockCount() {
- final ReentrantLock lock = new ReentrantLock();
- final Condition c = lock.newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- threadAssertEquals(1, lock.getHoldCount());
- c.await();
- threadAssertEquals(1, lock.getHoldCount());
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.lock();
- lock.lock();
- threadAssertEquals(2, lock.getHoldCount());
- c.await();
- threadAssertEquals(2, lock.getHoldCount());
- lock.unlock();
- lock.unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.lock();
- c.signalAll();
- lock.unlock();
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * A serialized lock deserializes as unlocked
- */
- public void testSerialization() {
- ReentrantLock l = new ReentrantLock();
- l.lock();
- l.unlock();
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- ReentrantLock r = (ReentrantLock) in.readObject();
- r.lock();
- r.unlock();
- } catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
- /**
- * toString indicates current lock state
- */
- public void testToString() {
- ReentrantLock lock = new ReentrantLock();
- String us = lock.toString();
- assertTrue(us.indexOf("Unlocked") >= 0);
- lock.lock();
- String ls = lock.toString();
- assertTrue(ls.indexOf("Locked") >= 0);
- }
-
-}
diff --git a/concurrent/src/test/java/ReentrantReadWriteLockTest.java b/concurrent/src/test/java/ReentrantReadWriteLockTest.java
deleted file mode 100644
index dfd4126..0000000
--- a/concurrent/src/test/java/ReentrantReadWriteLockTest.java
+++ /dev/null
@@ -1,1660 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.locks.*;
-import java.util.concurrent.*;
-import java.io.*;
-import java.util.*;
-
-public class ReentrantReadWriteLockTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ReentrantReadWriteLockTest.class);
- }
-
- /**
- * A runnable calling lockInterruptibly
- */
- class InterruptibleLockRunnable implements Runnable {
- final ReentrantReadWriteLock lock;
- InterruptibleLockRunnable(ReentrantReadWriteLock l) { lock = l; }
- public void run() {
- try {
- lock.writeLock().lockInterruptibly();
- } catch(InterruptedException success){}
- }
- }
-
-
- /**
- * A runnable calling lockInterruptibly that expects to be
- * interrupted
- */
- class InterruptedLockRunnable implements Runnable {
- final ReentrantReadWriteLock lock;
- InterruptedLockRunnable(ReentrantReadWriteLock l) { lock = l; }
- public void run() {
- try {
- lock.writeLock().lockInterruptibly();
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- }
-
- /**
- * Subclass to expose protected methods
- */
- static class PublicReentrantReadWriteLock extends ReentrantReadWriteLock {
- PublicReentrantReadWriteLock() { super(); }
- public Collection<Thread> getQueuedThreads() {
- return super.getQueuedThreads();
- }
- public Collection<Thread> getWaitingThreads(Condition c) {
- return super.getWaitingThreads(c);
- }
- }
-
- /**
- * Constructor sets given fairness, and is in unlocked state
- */
- public void testConstructor() {
- ReentrantReadWriteLock rl = new ReentrantReadWriteLock();
- assertFalse(rl.isFair());
- assertFalse(rl.isWriteLocked());
- assertEquals(0, rl.getReadLockCount());
- ReentrantReadWriteLock r2 = new ReentrantReadWriteLock(true);
- assertTrue(r2.isFair());
- assertFalse(r2.isWriteLocked());
- assertEquals(0, r2.getReadLockCount());
- }
-
- /**
- * write-locking and read-locking an unlocked lock succeed
- */
- public void testLock() {
- ReentrantReadWriteLock rl = new ReentrantReadWriteLock();
- rl.writeLock().lock();
- assertTrue(rl.isWriteLocked());
- assertTrue(rl.isWriteLockedByCurrentThread());
- assertEquals(0, rl.getReadLockCount());
- rl.writeLock().unlock();
- assertFalse(rl.isWriteLocked());
- assertFalse(rl.isWriteLockedByCurrentThread());
- assertEquals(0, rl.getReadLockCount());
- rl.readLock().lock();
- assertFalse(rl.isWriteLocked());
- assertFalse(rl.isWriteLockedByCurrentThread());
- assertEquals(1, rl.getReadLockCount());
- rl.readLock().unlock();
- assertFalse(rl.isWriteLocked());
- assertFalse(rl.isWriteLockedByCurrentThread());
- assertEquals(0, rl.getReadLockCount());
- }
-
-
- /**
- * locking an unlocked fair lock succeeds
- */
- public void testFairLock() {
- ReentrantReadWriteLock rl = new ReentrantReadWriteLock(true);
- rl.writeLock().lock();
- assertTrue(rl.isWriteLocked());
- assertTrue(rl.isWriteLockedByCurrentThread());
- assertEquals(0, rl.getReadLockCount());
- rl.writeLock().unlock();
- assertFalse(rl.isWriteLocked());
- assertFalse(rl.isWriteLockedByCurrentThread());
- assertEquals(0, rl.getReadLockCount());
- rl.readLock().lock();
- assertFalse(rl.isWriteLocked());
- assertFalse(rl.isWriteLockedByCurrentThread());
- assertEquals(1, rl.getReadLockCount());
- rl.readLock().unlock();
- assertFalse(rl.isWriteLocked());
- assertFalse(rl.isWriteLockedByCurrentThread());
- assertEquals(0, rl.getReadLockCount());
- }
-
- /**
- * getWriteHoldCount returns number of recursive holds
- */
- public void testGetWriteHoldCount() {
- ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- for(int i = 1; i <= SIZE; i++) {
- lock.writeLock().lock();
- assertEquals(i,lock.getWriteHoldCount());
- }
- for(int i = SIZE; i > 0; i--) {
- lock.writeLock().unlock();
- assertEquals(i-1,lock.getWriteHoldCount());
- }
- }
-
-
- /**
- * write-unlocking an unlocked lock throws IllegalMonitorStateException
- */
- public void testUnlock_IllegalMonitorStateException() {
- ReentrantReadWriteLock rl = new ReentrantReadWriteLock();
- try {
- rl.writeLock().unlock();
- shouldThrow();
- } catch(IllegalMonitorStateException success){}
- }
-
-
- /**
- * write-lockInterruptibly is interruptible
- */
- public void testWriteLockInterruptibly_Interrupted() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lockInterruptibly();
- lock.writeLock().unlock();
- lock.writeLock().lockInterruptibly();
- lock.writeLock().unlock();
- } catch(InterruptedException success){}
- }
- });
- try {
- lock.writeLock().lock();
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().unlock();
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * timed write-tryLock is interruptible
- */
- public void testWriteTryLock_Interrupted() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().tryLock(1000,TimeUnit.MILLISECONDS);
- } catch(InterruptedException success){}
- }
- });
- try {
- t.start();
- t.interrupt();
- lock.writeLock().unlock();
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * read-lockInterruptibly is interruptible
- */
- public void testReadLockInterruptibly_Interrupted() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.readLock().lockInterruptibly();
- } catch(InterruptedException success){}
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().unlock();
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * timed read-tryLock is interruptible
- */
- public void testReadTryLock_Interrupted() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.readLock().tryLock(1000,TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- try {
- t.start();
- t.interrupt();
- t.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * write-tryLock fails if locked
- */
- public void testWriteTryLockWhenLocked() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertFalse(lock.writeLock().tryLock());
- }
- });
- try {
- t.start();
- t.join();
- lock.writeLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * read-tryLock fails if locked
- */
- public void testReadTryLockWhenLocked() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertFalse(lock.readLock().tryLock());
- }
- });
- try {
- t.start();
- t.join();
- lock.writeLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Multiple threads can hold a read lock when not write-locked
- */
- public void testMultipleReadLocks() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.readLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertTrue(lock.readLock().tryLock());
- lock.readLock().unlock();
- }
- });
- try {
- t.start();
- t.join();
- lock.readLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * A writelock succeeds after reading threads unlock
- */
- public void testWriteAfterMultipleReadLocks() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.readLock().lock();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- lock.readLock().lock();
- lock.readLock().unlock();
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
-
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.readLock().unlock();
- t1.join(MEDIUM_DELAY_MS);
- t2.join(MEDIUM_DELAY_MS);
- assertTrue(!t1.isAlive());
- assertTrue(!t2.isAlive());
-
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Readlocks succeed after a writing thread unlocks
- */
- public void testReadAfterWriteLock() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- lock.readLock().lock();
- lock.readLock().unlock();
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- lock.readLock().lock();
- lock.readLock().unlock();
- }
- });
-
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().unlock();
- t1.join(MEDIUM_DELAY_MS);
- t2.join(MEDIUM_DELAY_MS);
- assertTrue(!t1.isAlive());
- assertTrue(!t2.isAlive());
-
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Read trylock succeeds if write locked by current thread
- */
- public void testReadHoldingWriteLock() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- assertTrue(lock.readLock().tryLock());
- lock.readLock().unlock();
- lock.writeLock().unlock();
- }
-
- /**
- * Read lock succeeds if write locked by current thread even if
- * other threads are waiting for readlock
- */
- public void testReadHoldingWriteLock2() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- lock.readLock().lock();
- lock.readLock().unlock();
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- lock.readLock().lock();
- lock.readLock().unlock();
- }
- });
-
- try {
- t1.start();
- t2.start();
- lock.readLock().lock();
- lock.readLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.readLock().lock();
- lock.readLock().unlock();
- lock.writeLock().unlock();
- t1.join(MEDIUM_DELAY_MS);
- t2.join(MEDIUM_DELAY_MS);
- assertTrue(!t1.isAlive());
- assertTrue(!t2.isAlive());
-
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Read lock succeeds if write locked by current thread even if
- * other threads are waiting for writelock
- */
- public void testReadHoldingWriteLock3() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
-
- try {
- t1.start();
- t2.start();
- lock.readLock().lock();
- lock.readLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.readLock().lock();
- lock.readLock().unlock();
- lock.writeLock().unlock();
- t1.join(MEDIUM_DELAY_MS);
- t2.join(MEDIUM_DELAY_MS);
- assertTrue(!t1.isAlive());
- assertTrue(!t2.isAlive());
-
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * Write lock succeeds if write locked by current thread even if
- * other threads are waiting for writelock
- */
- public void testWriteHoldingWriteLock4() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
-
- try {
- t1.start();
- t2.start();
- lock.writeLock().lock();
- lock.writeLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- lock.writeLock().unlock();
- lock.writeLock().unlock();
- t1.join(MEDIUM_DELAY_MS);
- t2.join(MEDIUM_DELAY_MS);
- assertTrue(!t1.isAlive());
- assertTrue(!t2.isAlive());
-
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * Fair Read trylock succeeds if write locked by current thread
- */
- public void testReadHoldingWriteLockFair() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
- lock.writeLock().lock();
- assertTrue(lock.readLock().tryLock());
- lock.readLock().unlock();
- lock.writeLock().unlock();
- }
-
- /**
- * Fair Read lock succeeds if write locked by current thread even if
- * other threads are waiting for readlock
- */
- public void testReadHoldingWriteLockFair2() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
- lock.writeLock().lock();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- lock.readLock().lock();
- lock.readLock().unlock();
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- lock.readLock().lock();
- lock.readLock().unlock();
- }
- });
-
- try {
- t1.start();
- t2.start();
- lock.readLock().lock();
- lock.readLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.readLock().lock();
- lock.readLock().unlock();
- lock.writeLock().unlock();
- t1.join(MEDIUM_DELAY_MS);
- t2.join(MEDIUM_DELAY_MS);
- assertTrue(!t1.isAlive());
- assertTrue(!t2.isAlive());
-
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * Fair Read lock succeeds if write locked by current thread even if
- * other threads are waiting for writelock
- */
- public void testReadHoldingWriteLockFair3() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
- lock.writeLock().lock();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
-
- try {
- t1.start();
- t2.start();
- lock.readLock().lock();
- lock.readLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.readLock().lock();
- lock.readLock().unlock();
- lock.writeLock().unlock();
- t1.join(MEDIUM_DELAY_MS);
- t2.join(MEDIUM_DELAY_MS);
- assertTrue(!t1.isAlive());
- assertTrue(!t2.isAlive());
-
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * Fair Write lock succeeds if write locked by current thread even if
- * other threads are waiting for writelock
- */
- public void testWriteHoldingWriteLockFair4() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
- lock.writeLock().lock();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- });
-
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.isWriteLockedByCurrentThread());
- assertTrue(lock.getWriteHoldCount() == 1);
- lock.writeLock().lock();
- assertTrue(lock.getWriteHoldCount() == 2);
- lock.writeLock().unlock();
- lock.writeLock().lock();
- lock.writeLock().unlock();
- lock.writeLock().unlock();
- t1.join(MEDIUM_DELAY_MS);
- t2.join(MEDIUM_DELAY_MS);
- assertTrue(!t1.isAlive());
- assertTrue(!t2.isAlive());
-
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * Read tryLock succeeds if readlocked but not writelocked
- */
- public void testTryLockWhenReadLocked() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.readLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertTrue(lock.readLock().tryLock());
- lock.readLock().unlock();
- }
- });
- try {
- t.start();
- t.join();
- lock.readLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
-
- /**
- * write tryLock fails when readlocked
- */
- public void testWriteTryLockWhenReadLocked() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.readLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertFalse(lock.writeLock().tryLock());
- }
- });
- try {
- t.start();
- t.join();
- lock.readLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * Fair Read tryLock succeeds if readlocked but not writelocked
- */
- public void testTryLockWhenReadLockedFair() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
- lock.readLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertTrue(lock.readLock().tryLock());
- lock.readLock().unlock();
- }
- });
- try {
- t.start();
- t.join();
- lock.readLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
-
- /**
- * Fair write tryLock fails when readlocked
- */
- public void testWriteTryLockWhenReadLockedFair() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
- lock.readLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- threadAssertFalse(lock.writeLock().tryLock());
- }
- });
- try {
- t.start();
- t.join();
- lock.readLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
-
- /**
- * write timed tryLock times out if locked
- */
- public void testWriteTryLock_Timeout() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(lock.writeLock().tryLock(1, TimeUnit.MILLISECONDS));
- } catch (Exception ex) {
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- t.join();
- lock.writeLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * read timed tryLock times out if write-locked
- */
- public void testReadTryLock_Timeout() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- lock.writeLock().lock();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertFalse(lock.readLock().tryLock(1, TimeUnit.MILLISECONDS));
- } catch (Exception ex) {
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- t.join();
- lock.writeLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * write lockInterruptibly succeeds if lock free else is interruptible
- */
- public void testWriteLockInterruptibly() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- try {
- lock.writeLock().lockInterruptibly();
- } catch(Exception e) {
- unexpectedException();
- }
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lockInterruptibly();
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- t.join();
- lock.writeLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * read lockInterruptibly succeeds if lock free else is interruptible
- */
- public void testReadLockInterruptibly() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- try {
- lock.writeLock().lockInterruptibly();
- } catch(Exception e) {
- unexpectedException();
- }
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.readLock().lockInterruptibly();
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- lock.writeLock().unlock();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Calling await without holding lock throws IllegalMonitorStateException
- */
- public void testAwait_IllegalMonitor() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- try {
- c.await();
- shouldThrow();
- }
- catch (IllegalMonitorStateException success) {
- }
- catch (Exception ex) {
- shouldThrow();
- }
- }
-
- /**
- * Calling signal without holding lock throws IllegalMonitorStateException
- */
- public void testSignal_IllegalMonitor() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- try {
- c.signal();
- shouldThrow();
- }
- catch (IllegalMonitorStateException success) {
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitNanos without a signal times out
- */
- public void testAwaitNanos_Timeout() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- try {
- lock.writeLock().lock();
- long t = c.awaitNanos(100);
- assertTrue(t <= 0);
- lock.writeLock().unlock();
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * timed await without a signal times out
- */
- public void testAwait_Timeout() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- try {
- lock.writeLock().lock();
- lock.writeLock().unlock();
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitUntil without a signal times out
- */
- public void testAwaitUntil_Timeout() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- try {
- lock.writeLock().lock();
- java.util.Date d = new java.util.Date();
- lock.writeLock().unlock();
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * await returns when signalled
- */
- public void testAwait() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- c.await();
- lock.writeLock().unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- c.signal();
- lock.writeLock().unlock();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /** A helper class for uninterruptible wait tests */
- class UninterruptableThread extends Thread {
- private Lock lock;
- private Condition c;
-
- public volatile boolean canAwake = false;
- public volatile boolean interrupted = false;
- public volatile boolean lockStarted = false;
-
- public UninterruptableThread(Lock lock, Condition c) {
- this.lock = lock;
- this.c = c;
- }
-
- public synchronized void run() {
- lock.lock();
- lockStarted = true;
-
- while (!canAwake) {
- c.awaitUninterruptibly();
- }
-
- interrupted = isInterrupted();
- lock.unlock();
- }
- }
-
- /**
- * awaitUninterruptibly doesn't abort on interrupt
- */
- public void testAwaitUninterruptibly() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- UninterruptableThread thread = new UninterruptableThread(lock.writeLock(), c);
-
- try {
- thread.start();
-
- while (!thread.lockStarted) {
- Thread.sleep(100);
- }
-
- lock.writeLock().lock();
- try {
- thread.interrupt();
- thread.canAwake = true;
- c.signal();
- } finally {
- lock.writeLock().unlock();
- }
-
- thread.join();
- assertTrue(thread.interrupted);
- assertFalse(thread.isAlive());
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * await is interruptible
- */
- public void testAwait_Interrupt() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- c.await();
- lock.writeLock().unlock();
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitNanos is interruptible
- */
- public void testAwaitNanos_Interrupt() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- c.awaitNanos(SHORT_DELAY_MS * 2 * 1000000);
- lock.writeLock().unlock();
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * awaitUntil is interruptible
- */
- public void testAwaitUntil_Interrupt() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- java.util.Date d = new java.util.Date();
- c.awaitUntil(new java.util.Date(d.getTime() + 10000));
- lock.writeLock().unlock();
- threadShouldThrow();
- }
- catch(InterruptedException success) {
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * signalAll wakes up all threads
- */
- public void testSignalAll() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- c.await();
- lock.writeLock().unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- c.await();
- lock.writeLock().unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t1.start();
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- c.signalAll();
- lock.writeLock().unlock();
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * A serialized lock deserializes as unlocked
- */
- public void testSerialization() {
- ReentrantReadWriteLock l = new ReentrantReadWriteLock();
- l.readLock().lock();
- l.readLock().unlock();
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- ReentrantReadWriteLock r = (ReentrantReadWriteLock) in.readObject();
- r.readLock().lock();
- r.readLock().unlock();
- } catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
- /**
- * hasQueuedThreads reports whether there are waiting threads
- */
- public void testhasQueuedThreads() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertFalse(lock.hasQueuedThreads());
- lock.writeLock().lock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- lock.writeLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(lock.hasQueuedThreads());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * hasQueuedThread(null) throws NPE
- */
- public void testHasQueuedThreadNPE() {
- final ReentrantReadWriteLock sync = new ReentrantReadWriteLock();
- try {
- sync.hasQueuedThread(null);
- shouldThrow();
- } catch (NullPointerException success) {
- }
- }
-
- /**
- * hasQueuedThread reports whether a thread is queued.
- */
- public void testHasQueuedThread() {
- final ReentrantReadWriteLock sync = new ReentrantReadWriteLock();
- Thread t1 = new Thread(new InterruptedLockRunnable(sync));
- Thread t2 = new Thread(new InterruptibleLockRunnable(sync));
- try {
- assertFalse(sync.hasQueuedThread(t1));
- assertFalse(sync.hasQueuedThread(t2));
- sync.writeLock().lock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasQueuedThread(t1));
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(sync.hasQueuedThread(t1));
- assertTrue(sync.hasQueuedThread(t2));
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.hasQueuedThread(t1));
- assertTrue(sync.hasQueuedThread(t2));
- sync.writeLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.hasQueuedThread(t1));
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(sync.hasQueuedThread(t2));
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * getQueueLength reports number of waiting threads
- */
- public void testGetQueueLength() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertEquals(0, lock.getQueueLength());
- lock.writeLock().lock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(2, lock.getQueueLength());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- lock.writeLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(0, lock.getQueueLength());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getQueuedThreads includes waiting threads
- */
- public void testGetQueuedThreads() {
- final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertTrue(lock.getQueuedThreads().isEmpty());
- lock.writeLock().lock();
- assertTrue(lock.getQueuedThreads().isEmpty());
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().contains(t1));
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().contains(t1));
- assertTrue(lock.getQueuedThreads().contains(t2));
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(lock.getQueuedThreads().contains(t1));
- assertTrue(lock.getQueuedThreads().contains(t2));
- lock.writeLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().isEmpty());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * hasWaiters throws NPE if null
- */
- public void testHasWaitersNPE() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- try {
- lock.hasWaiters(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength throws NPE if null
- */
- public void testGetWaitQueueLengthNPE() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- try {
- lock.getWaitQueueLength(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitingThreads throws NPE if null
- */
- public void testGetWaitingThreadsNPE() {
- final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
- try {
- lock.getWaitingThreads(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * hasWaiters throws IAE if not owned
- */
- public void testHasWaitersIAE() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = (lock.writeLock().newCondition());
- final ReentrantReadWriteLock lock2 = new ReentrantReadWriteLock();
- try {
- lock2.hasWaiters(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * hasWaiters throws IMSE if not locked
- */
- public void testHasWaitersIMSE() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = (lock.writeLock().newCondition());
- try {
- lock.hasWaiters(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitQueueLength throws IAE if not owned
- */
- public void testGetWaitQueueLengthIAE() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = (lock.writeLock().newCondition());
- final ReentrantReadWriteLock lock2 = new ReentrantReadWriteLock();
- try {
- lock2.getWaitQueueLength(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength throws IMSE if not locked
- */
- public void testGetWaitQueueLengthIMSE() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = (lock.writeLock().newCondition());
- try {
- lock.getWaitQueueLength(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitingThreads throws IAE if not owned
- */
- public void testGetWaitingThreadsIAE() {
- final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
- final Condition c = (lock.writeLock().newCondition());
- final PublicReentrantReadWriteLock lock2 = new PublicReentrantReadWriteLock();
- try {
- lock2.getWaitingThreads(c);
- shouldThrow();
- } catch (IllegalArgumentException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitingThreads throws IMSE if not locked
- */
- public void testGetWaitingThreadsIMSE() {
- final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
- final Condition c = (lock.writeLock().newCondition());
- try {
- lock.getWaitingThreads(c);
- shouldThrow();
- } catch (IllegalMonitorStateException success) {
- } catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * hasWaiters returns true when a thread is waiting, else false
- */
- public void testHasWaiters() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = (lock.writeLock().newCondition());
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- threadAssertFalse(lock.hasWaiters(c));
- threadAssertEquals(0, lock.getWaitQueueLength(c));
- c.await();
- lock.writeLock().unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- assertTrue(lock.hasWaiters(c));
- assertEquals(1, lock.getWaitQueueLength(c));
- c.signal();
- lock.writeLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- assertFalse(lock.hasWaiters(c));
- assertEquals(0, lock.getWaitQueueLength(c));
- lock.writeLock().unlock();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * getWaitQueueLength returns number of waiting threads
- */
- public void testGetWaitQueueLength() {
- final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- final Condition c = (lock.writeLock().newCondition());
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- threadAssertFalse(lock.hasWaiters(c));
- threadAssertEquals(0, lock.getWaitQueueLength(c));
- c.await();
- lock.writeLock().unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- assertTrue(lock.hasWaiters(c));
- assertEquals(1, lock.getWaitQueueLength(c));
- c.signal();
- lock.writeLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- assertFalse(lock.hasWaiters(c));
- assertEquals(0, lock.getWaitQueueLength(c));
- lock.writeLock().unlock();
- t.join(SHORT_DELAY_MS);
- assertFalse(t.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * getWaitingThreads returns only and all waiting threads
- */
- public void testGetWaitingThreads() {
- final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
- final Condition c = lock.writeLock().newCondition();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- threadAssertTrue(lock.getWaitingThreads(c).isEmpty());
- c.await();
- lock.writeLock().unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- lock.writeLock().lock();
- threadAssertFalse(lock.getWaitingThreads(c).isEmpty());
- c.await();
- lock.writeLock().unlock();
- }
- catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- try {
- lock.writeLock().lock();
- assertTrue(lock.getWaitingThreads(c).isEmpty());
- lock.writeLock().unlock();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- assertTrue(lock.hasWaiters(c));
- assertTrue(lock.getWaitingThreads(c).contains(t1));
- assertTrue(lock.getWaitingThreads(c).contains(t2));
- c.signalAll();
- lock.writeLock().unlock();
- Thread.sleep(SHORT_DELAY_MS);
- lock.writeLock().lock();
- assertFalse(lock.hasWaiters(c));
- assertTrue(lock.getWaitingThreads(c).isEmpty());
- lock.writeLock().unlock();
- t1.join(SHORT_DELAY_MS);
- t2.join(SHORT_DELAY_MS);
- assertFalse(t1.isAlive());
- assertFalse(t2.isAlive());
- }
- catch (Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * toString indicates current lock state
- */
- public void testToString() {
- ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- String us = lock.toString();
- assertTrue(us.indexOf("Write locks = 0") >= 0);
- assertTrue(us.indexOf("Read locks = 0") >= 0);
- lock.writeLock().lock();
- String ws = lock.toString();
- assertTrue(ws.indexOf("Write locks = 1") >= 0);
- assertTrue(ws.indexOf("Read locks = 0") >= 0);
- lock.writeLock().unlock();
- lock.readLock().lock();
- lock.readLock().lock();
- String rs = lock.toString();
- assertTrue(rs.indexOf("Write locks = 0") >= 0);
- assertTrue(rs.indexOf("Read locks = 2") >= 0);
- }
-
- /**
- * readLock.toString indicates current lock state
- */
- public void testReadLockToString() {
- ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- String us = lock.readLock().toString();
- assertTrue(us.indexOf("Read locks = 0") >= 0);
- lock.readLock().lock();
- lock.readLock().lock();
- String rs = lock.readLock().toString();
- assertTrue(rs.indexOf("Read locks = 2") >= 0);
- }
-
- /**
- * writeLock.toString indicates current lock state
- */
- public void testWriteLockToString() {
- ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
- String us = lock.writeLock().toString();
- assertTrue(us.indexOf("Unlocked") >= 0);
- lock.writeLock().lock();
- String ls = lock.writeLock().toString();
- assertTrue(ls.indexOf("Locked") >= 0);
- }
-
-}
diff --git a/concurrent/src/test/java/ScheduledExecutorTest.java b/concurrent/src/test/java/ScheduledExecutorTest.java
deleted file mode 100644
index 85ade46..0000000
--- a/concurrent/src/test/java/ScheduledExecutorTest.java
+++ /dev/null
@@ -1,1147 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-public class ScheduledExecutorTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ScheduledExecutorTest.class);
- }
-
-
- /**
- * execute successfully executes a runnable
- */
- public void testExecute() {
- try {
- TrackedShortRunnable runnable =new TrackedShortRunnable();
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- p1.execute(runnable);
- assertFalse(runnable.done);
- Thread.sleep(SHORT_DELAY_MS);
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- } catch(InterruptedException e){
- unexpectedException();
- }
- assertTrue(runnable.done);
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- joinPool(p1);
- }
- catch(Exception e){
- unexpectedException();
- }
-
- }
-
-
- /**
- * delayed schedule of callable successfully executes after delay
- */
- public void testSchedule1() {
- try {
- TrackedCallable callable = new TrackedCallable();
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- assertFalse(callable.done);
- Thread.sleep(MEDIUM_DELAY_MS);
- assertTrue(callable.done);
- assertEquals(Boolean.TRUE, f.get());
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- joinPool(p1);
- } catch(RejectedExecutionException e){}
- catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
- /**
- * delayed schedule of runnable successfully executes after delay
- */
- public void testSchedule3() {
- try {
- TrackedShortRunnable runnable = new TrackedShortRunnable();
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- p1.schedule(runnable, SMALL_DELAY_MS, TimeUnit.MILLISECONDS);
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(runnable.done);
- Thread.sleep(MEDIUM_DELAY_MS);
- assertTrue(runnable.done);
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- joinPool(p1);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * scheduleAtFixedRate executes runnable after given initial delay
- */
- public void testSchedule4() {
- try {
- TrackedShortRunnable runnable = new TrackedShortRunnable();
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- ScheduledFuture h = p1.scheduleAtFixedRate(runnable, SHORT_DELAY_MS, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- assertFalse(runnable.done);
- Thread.sleep(MEDIUM_DELAY_MS);
- assertTrue(runnable.done);
- h.cancel(true);
- joinPool(p1);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- static class RunnableCounter implements Runnable {
- AtomicInteger count = new AtomicInteger(0);
- public void run() { count.getAndIncrement(); }
- }
-
- /**
- * scheduleWithFixedDelay executes runnable after given initial delay
- */
- public void testSchedule5() {
- try {
- TrackedShortRunnable runnable = new TrackedShortRunnable();
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- ScheduledFuture h = p1.scheduleWithFixedDelay(runnable, SHORT_DELAY_MS, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- assertFalse(runnable.done);
- Thread.sleep(MEDIUM_DELAY_MS);
- assertTrue(runnable.done);
- h.cancel(true);
- joinPool(p1);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * scheduleAtFixedRate executes series of tasks at given rate
- */
- public void testFixedRateSequence() {
- try {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- RunnableCounter counter = new RunnableCounter();
- ScheduledFuture h =
- p1.scheduleAtFixedRate(counter, 0, 1, TimeUnit.MILLISECONDS);
- Thread.sleep(SMALL_DELAY_MS);
- h.cancel(true);
- int c = counter.count.get();
- // By time scaling conventions, we must have at least
- // an execution per SHORT delay, but no more than one SHORT more
- assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS);
- assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS);
- joinPool(p1);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * scheduleWithFixedDelay executes series of tasks with given period
- */
- public void testFixedDelaySequence() {
- try {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- RunnableCounter counter = new RunnableCounter();
- ScheduledFuture h =
- p1.scheduleWithFixedDelay(counter, 0, 1, TimeUnit.MILLISECONDS);
- Thread.sleep(SMALL_DELAY_MS);
- h.cancel(true);
- int c = counter.count.get();
- assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS);
- assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS);
- joinPool(p1);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * execute (null) throws NPE
- */
- public void testExecuteNull() {
- ScheduledThreadPoolExecutor se = null;
- try {
- se = new ScheduledThreadPoolExecutor(1);
- se.execute(null);
- shouldThrow();
- } catch(NullPointerException success){}
- catch(Exception e){
- unexpectedException();
- }
-
- joinPool(se);
- }
-
- /**
- * schedule (null) throws NPE
- */
- public void testScheduleNull() {
- ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
- try {
- TrackedCallable callable = null;
- Future f = se.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(NullPointerException success){}
- catch(Exception e){
- unexpectedException();
- }
- joinPool(se);
- }
-
- /**
- * execute throws RejectedExecutionException if shutdown
- */
- public void testSchedule1_RejectedExecutionException() {
- ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
- try {
- se.shutdown();
- se.schedule(new NoOpRunnable(),
- MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(RejectedExecutionException success){
- } catch (SecurityException ok) {
- }
-
- joinPool(se);
-
- }
-
- /**
- * schedule throws RejectedExecutionException if shutdown
- */
- public void testSchedule2_RejectedExecutionException() {
- ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
- try {
- se.shutdown();
- se.schedule(new NoOpCallable(),
- MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(RejectedExecutionException success){
- } catch (SecurityException ok) {
- }
- joinPool(se);
- }
-
- /**
- * schedule callable throws RejectedExecutionException if shutdown
- */
- public void testSchedule3_RejectedExecutionException() {
- ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
- try {
- se.shutdown();
- se.schedule(new NoOpCallable(),
- MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(RejectedExecutionException success){
- } catch (SecurityException ok) {
- }
- joinPool(se);
- }
-
- /**
- * scheduleAtFixedRate throws RejectedExecutionException if shutdown
- */
- public void testScheduleAtFixedRate1_RejectedExecutionException() {
- ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
- try {
- se.shutdown();
- se.scheduleAtFixedRate(new NoOpRunnable(),
- MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(RejectedExecutionException success){
- } catch (SecurityException ok) {
- }
- joinPool(se);
- }
-
- /**
- * scheduleWithFixedDelay throws RejectedExecutionException if shutdown
- */
- public void testScheduleWithFixedDelay1_RejectedExecutionException() {
- ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
- try {
- se.shutdown();
- se.scheduleWithFixedDelay(new NoOpRunnable(),
- MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(RejectedExecutionException success){
- } catch (SecurityException ok) {
- }
- joinPool(se);
- }
-
- /**
- * getActiveCount increases but doesn't overestimate, when a
- * thread becomes active
- */
- public void testGetActiveCount() {
- ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2);
- assertEquals(0, p2.getActiveCount());
- p2.execute(new SmallRunnable());
- try {
- Thread.sleep(SHORT_DELAY_MS);
- } catch(Exception e){
- unexpectedException();
- }
- assertEquals(1, p2.getActiveCount());
- joinPool(p2);
- }
-
- /**
- * getCompletedTaskCount increases, but doesn't overestimate,
- * when tasks complete
- */
- public void testGetCompletedTaskCount() {
- ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2);
- assertEquals(0, p2.getCompletedTaskCount());
- p2.execute(new SmallRunnable());
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- } catch(Exception e){
- unexpectedException();
- }
- assertEquals(1, p2.getCompletedTaskCount());
- joinPool(p2);
- }
-
- /**
- * getCorePoolSize returns size given in constructor if not otherwise set
- */
- public void testGetCorePoolSize() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- assertEquals(1, p1.getCorePoolSize());
- joinPool(p1);
- }
-
- /**
- * getLargestPoolSize increases, but doesn't overestimate, when
- * multiple threads active
- */
- public void testGetLargestPoolSize() {
- ScheduledThreadPoolExecutor p2 = new ScheduledThreadPoolExecutor(2);
- assertEquals(0, p2.getLargestPoolSize());
- p2.execute(new SmallRunnable());
- p2.execute(new SmallRunnable());
- try {
- Thread.sleep(SHORT_DELAY_MS);
- } catch(Exception e){
- unexpectedException();
- }
- assertEquals(2, p2.getLargestPoolSize());
- joinPool(p2);
- }
-
- /**
- * getPoolSize increases, but doesn't overestimate, when threads
- * become active
- */
- public void testGetPoolSize() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- assertEquals(0, p1.getPoolSize());
- p1.execute(new SmallRunnable());
- assertEquals(1, p1.getPoolSize());
- joinPool(p1);
- }
-
- /**
- * getTaskCount increases, but doesn't overestimate, when tasks
- * submitted
- */
- public void testGetTaskCount() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- assertEquals(0, p1.getTaskCount());
- for(int i = 0; i < 5; i++)
- p1.execute(new SmallRunnable());
- try {
- Thread.sleep(SHORT_DELAY_MS);
- } catch(Exception e){
- unexpectedException();
- }
- assertEquals(5, p1.getTaskCount());
- joinPool(p1);
- }
-
- /**
- * getThreadFactory returns factory in constructor if not set
- */
- public void testGetThreadFactory() {
- ThreadFactory tf = new SimpleThreadFactory();
- ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf);
- assertSame(tf, p.getThreadFactory());
- joinPool(p);
- }
-
- /**
- * setThreadFactory sets the thread factory returned by getThreadFactory
- */
- public void testSetThreadFactory() {
- ThreadFactory tf = new SimpleThreadFactory();
- ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
- p.setThreadFactory(tf);
- assertSame(tf, p.getThreadFactory());
- joinPool(p);
- }
-
- /**
- * setThreadFactory(null) throws NPE
- */
- public void testSetThreadFactoryNull() {
- ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
- try {
- p.setThreadFactory(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } finally {
- joinPool(p);
- }
- }
-
- /**
- * is isShutDown is false before shutdown, true after
- */
- public void testIsShutdown() {
-
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- try {
- assertFalse(p1.isShutdown());
- }
- finally {
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- }
- assertTrue(p1.isShutdown());
- }
-
-
- /**
- * isTerminated is false before termination, true after
- */
- public void testIsTerminated() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- try {
- p1.execute(new SmallRunnable());
- } finally {
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- }
- try {
- assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
- assertTrue(p1.isTerminated());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * isTerminating is not true when running or when terminated
- */
- public void testIsTerminating() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- assertFalse(p1.isTerminating());
- try {
- p1.execute(new SmallRunnable());
- assertFalse(p1.isTerminating());
- } finally {
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- }
- try {
- assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
- assertTrue(p1.isTerminated());
- assertFalse(p1.isTerminating());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getQueue returns the work queue, which contains queued tasks
- */
- public void testGetQueue() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- ScheduledFuture[] tasks = new ScheduledFuture[5];
- for(int i = 0; i < 5; i++){
- tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
- }
- try {
- Thread.sleep(SHORT_DELAY_MS);
- BlockingQueue<Runnable> q = p1.getQueue();
- assertTrue(q.contains(tasks[4]));
- assertFalse(q.contains(tasks[0]));
- } catch(Exception e) {
- unexpectedException();
- } finally {
- joinPool(p1);
- }
- }
-
- /**
- * remove(task) removes queued task, and fails to remove active task
- */
- public void testRemove() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- ScheduledFuture[] tasks = new ScheduledFuture[5];
- for(int i = 0; i < 5; i++){
- tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
- }
- try {
- Thread.sleep(SHORT_DELAY_MS);
- BlockingQueue<Runnable> q = p1.getQueue();
- assertFalse(p1.remove((Runnable)tasks[0]));
- assertTrue(q.contains((Runnable)tasks[4]));
- assertTrue(q.contains((Runnable)tasks[3]));
- assertTrue(p1.remove((Runnable)tasks[4]));
- assertFalse(p1.remove((Runnable)tasks[4]));
- assertFalse(q.contains((Runnable)tasks[4]));
- assertTrue(q.contains((Runnable)tasks[3]));
- assertTrue(p1.remove((Runnable)tasks[3]));
- assertFalse(q.contains((Runnable)tasks[3]));
- } catch(Exception e) {
- unexpectedException();
- } finally {
- joinPool(p1);
- }
- }
-
- /**
- * purge removes cancelled tasks from the queue
- */
- public void testPurge() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- ScheduledFuture[] tasks = new ScheduledFuture[5];
- for(int i = 0; i < 5; i++){
- tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- }
- try {
- int max = 5;
- if (tasks[4].cancel(true)) --max;
- if (tasks[3].cancel(true)) --max;
- // There must eventually be an interference-free point at
- // which purge will not fail. (At worst, when queue is empty.)
- int k;
- for (k = 0; k < SMALL_DELAY_MS; ++k) {
- p1.purge();
- long count = p1.getTaskCount();
- if (count >= 0 && count <= max)
- break;
- Thread.sleep(1);
- }
- assertTrue(k < SMALL_DELAY_MS);
- } catch(Exception e) {
- unexpectedException();
- } finally {
- joinPool(p1);
- }
- }
-
- /**
- * shutDownNow returns a list containing tasks that were not run
- */
- public void testShutDownNow() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- for(int i = 0; i < 5; i++)
- p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- List l;
- try {
- l = p1.shutdownNow();
- } catch (SecurityException ok) {
- return;
- }
- assertTrue(p1.isShutdown());
- assertTrue(l.size() > 0 && l.size() <= 5);
- joinPool(p1);
- }
-
- /**
- * In default setting, shutdown cancels periodic but not delayed
- * tasks at shutdown
- */
- public void testShutDown1() {
- try {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- assertTrue(p1.getExecuteExistingDelayedTasksAfterShutdownPolicy());
- assertFalse(p1.getContinueExistingPeriodicTasksAfterShutdownPolicy());
-
- ScheduledFuture[] tasks = new ScheduledFuture[5];
- for(int i = 0; i < 5; i++)
- tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- BlockingQueue q = p1.getQueue();
- for (Iterator it = q.iterator(); it.hasNext();) {
- ScheduledFuture t = (ScheduledFuture)it.next();
- assertFalse(t.isCancelled());
- }
- assertTrue(p1.isShutdown());
- Thread.sleep(SMALL_DELAY_MS);
- for (int i = 0; i < 5; ++i) {
- assertTrue(tasks[i].isDone());
- assertFalse(tasks[i].isCancelled());
- }
-
- }
- catch(Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * If setExecuteExistingDelayedTasksAfterShutdownPolicy is false,
- * delayed tasks are cancelled at shutdown
- */
- public void testShutDown2() {
- try {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- p1.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
- ScheduledFuture[] tasks = new ScheduledFuture[5];
- for(int i = 0; i < 5; i++)
- tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- assertTrue(p1.isShutdown());
- BlockingQueue q = p1.getQueue();
- assertTrue(q.isEmpty());
- Thread.sleep(SMALL_DELAY_MS);
- assertTrue(p1.isTerminated());
- }
- catch(Exception ex) {
- unexpectedException();
- }
- }
-
-
- /**
- * If setContinueExistingPeriodicTasksAfterShutdownPolicy is set false,
- * periodic tasks are not cancelled at shutdown
- */
- public void testShutDown3() {
- try {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
- ScheduledFuture task =
- p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS);
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- assertTrue(p1.isShutdown());
- BlockingQueue q = p1.getQueue();
- assertTrue(q.isEmpty());
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(p1.isTerminated());
- }
- catch(Exception ex) {
- unexpectedException();
- }
- }
-
- /**
- * if setContinueExistingPeriodicTasksAfterShutdownPolicy is true,
- * periodic tasks are cancelled at shutdown
- */
- public void testShutDown4() {
- ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
- try {
- p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
- ScheduledFuture task =
- p1.scheduleAtFixedRate(new NoOpRunnable(), 1, 1, TimeUnit.MILLISECONDS);
- assertFalse(task.isCancelled());
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- assertFalse(task.isCancelled());
- assertFalse(p1.isTerminated());
- assertTrue(p1.isShutdown());
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(task.isCancelled());
- assertTrue(task.cancel(true));
- assertTrue(task.isDone());
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(p1.isTerminated());
- }
- catch(Exception ex) {
- unexpectedException();
- }
- finally {
- joinPool(p1);
- }
- }
-
- /**
- * completed submit of callable returns result
- */
- public void testSubmitCallable() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- Future<String> future = e.submit(new StringTask());
- String result = future.get();
- assertSame(TEST_STRING, result);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * completed submit of runnable returns successfully
- */
- public void testSubmitRunnable() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- Future<?> future = e.submit(new NoOpRunnable());
- future.get();
- assertTrue(future.isDone());
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * completed submit of (runnable, result) returns result
- */
- public void testSubmitRunnable2() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
- String result = future.get();
- assertSame(TEST_STRING, result);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(null) throws NPE
- */
- public void testInvokeAny1() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- e.invokeAny(null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(empty collection) throws IAE
- */
- public void testInvokeAny2() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- e.invokeAny(new ArrayList<Callable<String>>());
- } catch (IllegalArgumentException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) throws NPE if c has null elements
- */
- public void testInvokeAny3() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAny(l);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) throws ExecutionException if no task completes
- */
- public void testInvokeAny4() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- e.invokeAny(l);
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) returns result of some task
- */
- public void testInvokeAny5() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- String result = e.invokeAny(l);
- assertSame(TEST_STRING, result);
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(null) throws NPE
- */
- public void testInvokeAll1() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- e.invokeAll(null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(empty collection) returns empty collection
- */
- public void testInvokeAll2() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
- assertTrue(r.isEmpty());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(c) throws NPE if c has null elements
- */
- public void testInvokeAll3() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAll(l);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * get of invokeAll(c) throws exception on failed task
- */
- public void testInvokeAll4() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- List<Future<String>> result = e.invokeAll(l);
- assertEquals(1, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- it.next().get();
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(c) returns results of all completed tasks
- */
- public void testInvokeAll5() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l);
- assertEquals(2, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- assertSame(TEST_STRING, it.next().get());
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(null) throws NPE
- */
- public void testTimedInvokeAny1() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(,,null) throws NPE
- */
- public void testTimedInvokeAnyNullTimeUnit() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- e.invokeAny(l, MEDIUM_DELAY_MS, null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(empty collection) throws IAE
- */
- public void testTimedInvokeAny2() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (IllegalArgumentException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) throws NPE if c has null elements
- */
- public void testTimedInvokeAny3() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- ex.printStackTrace();
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) throws ExecutionException if no task completes
- */
- public void testTimedInvokeAny4() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) returns result of some task
- */
- public void testTimedInvokeAny5() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertSame(TEST_STRING, result);
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(null) throws NPE
- */
- public void testTimedInvokeAll1() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(,,null) throws NPE
- */
- public void testTimedInvokeAllNullTimeUnit() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- e.invokeAll(l, MEDIUM_DELAY_MS, null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(empty collection) returns empty collection
- */
- public void testTimedInvokeAll2() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertTrue(r.isEmpty());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(c) throws NPE if c has null elements
- */
- public void testTimedInvokeAll3() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * get of element of invokeAll(c) throws exception on failed task
- */
- public void testTimedInvokeAll4() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(1, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- it.next().get();
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(c) returns results of all completed tasks
- */
- public void testTimedInvokeAll5() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(2, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- assertSame(TEST_STRING, it.next().get());
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(c) cancels tasks not completed by timeout
- */
- public void testTimedInvokeAll6() {
- ExecutorService e = new ScheduledThreadPoolExecutor(2);
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(3, result.size());
- Iterator<Future<String>> it = result.iterator();
- Future<String> f1 = it.next();
- Future<String> f2 = it.next();
- Future<String> f3 = it.next();
- assertTrue(f1.isDone());
- assertTrue(f2.isDone());
- assertTrue(f3.isDone());
- assertFalse(f1.isCancelled());
- assertTrue(f2.isCancelled());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
-
-}
diff --git a/concurrent/src/test/java/SemaphoreTest.java b/concurrent/src/test/java/SemaphoreTest.java
deleted file mode 100644
index 88b1d28..0000000
--- a/concurrent/src/test/java/SemaphoreTest.java
+++ /dev/null
@@ -1,917 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class SemaphoreTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(SemaphoreTest.class);
- }
-
- /**
- * Subclass to expose protected methods
- */
- static class PublicSemaphore extends Semaphore {
- PublicSemaphore(int p, boolean f) { super(p, f); }
- public Collection<Thread> getQueuedThreads() {
- return super.getQueuedThreads();
- }
- public void reducePermits(int p) {
- super.reducePermits(p);
- }
- }
-
- /**
- * A runnable calling acquire
- */
- class InterruptibleLockRunnable implements Runnable {
- final Semaphore lock;
- InterruptibleLockRunnable(Semaphore l) { lock = l; }
- public void run() {
- try {
- lock.acquire();
- } catch(InterruptedException success){}
- }
- }
-
-
- /**
- * A runnable calling acquire that expects to be
- * interrupted
- */
- class InterruptedLockRunnable implements Runnable {
- final Semaphore lock;
- InterruptedLockRunnable(Semaphore l) { lock = l; }
- public void run() {
- try {
- lock.acquire();
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- }
-
- /**
- * Zero, negative, and positive initial values are allowed in constructor
- */
- public void testConstructor() {
- Semaphore s0 = new Semaphore(0, false);
- assertEquals(0, s0.availablePermits());
- assertFalse(s0.isFair());
- Semaphore s1 = new Semaphore(-1, false);
- assertEquals(-1, s1.availablePermits());
- assertFalse(s1.isFair());
- Semaphore s2 = new Semaphore(-1, false);
- assertEquals(-1, s2.availablePermits());
- assertFalse(s2.isFair());
- }
-
- /**
- * Constructor without fairness argument behaves as nonfair
- */
- public void testConstructor2() {
- Semaphore s0 = new Semaphore(0);
- assertEquals(0, s0.availablePermits());
- assertFalse(s0.isFair());
- Semaphore s1 = new Semaphore(-1);
- assertEquals(-1, s1.availablePermits());
- assertFalse(s1.isFair());
- Semaphore s2 = new Semaphore(-1);
- assertEquals(-1, s2.availablePermits());
- assertFalse(s2.isFair());
- }
-
- /**
- * tryAcquire succeeds when sufficient permits, else fails
- */
- public void testTryAcquireInSameThread() {
- Semaphore s = new Semaphore(2, false);
- assertEquals(2, s.availablePermits());
- assertTrue(s.tryAcquire());
- assertTrue(s.tryAcquire());
- assertEquals(0, s.availablePermits());
- assertFalse(s.tryAcquire());
- }
-
- /**
- * Acquire and release of semaphore succeed if initially available
- */
- public void testAcquireReleaseInSameThread() {
- Semaphore s = new Semaphore(1, false);
- try {
- s.acquire();
- s.release();
- s.acquire();
- s.release();
- s.acquire();
- s.release();
- s.acquire();
- s.release();
- s.acquire();
- s.release();
- assertEquals(1, s.availablePermits());
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * Uninterruptible acquire and release of semaphore succeed if
- * initially available
- */
- public void testAcquireUninterruptiblyReleaseInSameThread() {
- Semaphore s = new Semaphore(1, false);
- try {
- s.acquireUninterruptibly();
- s.release();
- s.acquireUninterruptibly();
- s.release();
- s.acquireUninterruptibly();
- s.release();
- s.acquireUninterruptibly();
- s.release();
- s.acquireUninterruptibly();
- s.release();
- assertEquals(1, s.availablePermits());
- } finally {
- }
- }
-
- /**
- * Timed Acquire and release of semaphore succeed if
- * initially available
- */
- public void testTimedAcquireReleaseInSameThread() {
- Semaphore s = new Semaphore(1, false);
- try {
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertEquals(1, s.availablePermits());
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A release in one thread enables an acquire in another thread
- */
- public void testAcquireReleaseInDifferentThreads() {
- final Semaphore s = new Semaphore(0, false);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.acquire();
- s.release();
- s.release();
- s.acquire();
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- s.release();
- s.release();
- s.acquire();
- s.acquire();
- s.release();
- t.join();
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A release in one thread enables an uninterruptible acquire in another thread
- */
- public void testUninterruptibleAcquireReleaseInDifferentThreads() {
- final Semaphore s = new Semaphore(0, false);
- Thread t = new Thread(new Runnable() {
- public void run() {
- s.acquireUninterruptibly();
- s.release();
- s.release();
- s.acquireUninterruptibly();
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- s.release();
- s.release();
- s.acquireUninterruptibly();
- s.acquireUninterruptibly();
- s.release();
- t.join();
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
-
- /**
- * A release in one thread enables a timed acquire in another thread
- */
- public void testTimedAcquireReleaseInDifferentThreads() {
- final Semaphore s = new Semaphore(1, false);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.release();
- threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
-
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- s.release();
- t.join();
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A waiting acquire blocks interruptibly
- */
- public void testAcquire_InterruptedException() {
- final Semaphore s = new Semaphore(0, false);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.acquire();
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A waiting timed acquire blocks interruptibly
- */
- public void testTryAcquire_InterruptedException() {
- final Semaphore s = new Semaphore(0, false);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.tryAcquire(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){
- }
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * hasQueuedThreads reports whether there are waiting threads
- */
- public void testHasQueuedThreads() {
- final Semaphore lock = new Semaphore(1, false);
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertFalse(lock.hasQueuedThreads());
- lock.acquireUninterruptibly();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.hasQueuedThreads());
- lock.release();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(lock.hasQueuedThreads());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getQueueLength reports number of waiting threads
- */
- public void testGetQueueLength() {
- final Semaphore lock = new Semaphore(1, false);
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertEquals(0, lock.getQueueLength());
- lock.acquireUninterruptibly();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(2, lock.getQueueLength());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- lock.release();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(0, lock.getQueueLength());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getQueuedThreads includes waiting threads
- */
- public void testGetQueuedThreads() {
- final PublicSemaphore lock = new PublicSemaphore(1, false);
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertTrue(lock.getQueuedThreads().isEmpty());
- lock.acquireUninterruptibly();
- assertTrue(lock.getQueuedThreads().isEmpty());
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().contains(t1));
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().contains(t1));
- assertTrue(lock.getQueuedThreads().contains(t2));
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(lock.getQueuedThreads().contains(t1));
- assertTrue(lock.getQueuedThreads().contains(t2));
- lock.release();
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(lock.getQueuedThreads().isEmpty());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainPermits reports and removes given number of permits
- */
- public void testDrainPermits() {
- Semaphore s = new Semaphore(0, false);
- assertEquals(0, s.availablePermits());
- assertEquals(0, s.drainPermits());
- s.release(10);
- assertEquals(10, s.availablePermits());
- assertEquals(10, s.drainPermits());
- assertEquals(0, s.availablePermits());
- assertEquals(0, s.drainPermits());
- }
-
- /**
- * reducePermits reduces number of permits
- */
- public void testReducePermits() {
- PublicSemaphore s = new PublicSemaphore(10, false);
- assertEquals(10, s.availablePermits());
- s.reducePermits(1);
- assertEquals(9, s.availablePermits());
- s.reducePermits(10);
- assertEquals(-1, s.availablePermits());
- }
-
- /**
- * a deserialized serialized semaphore has same number of permits
- */
- public void testSerialization() {
- Semaphore l = new Semaphore(3, false);
- try {
- l.acquire();
- l.release();
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- Semaphore r = (Semaphore) in.readObject();
- assertEquals(3, r.availablePermits());
- assertFalse(r.isFair());
- r.acquire();
- r.release();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * Zero, negative, and positive initial values are allowed in constructor
- */
- public void testConstructor_fair() {
- Semaphore s0 = new Semaphore(0, true);
- assertEquals(0, s0.availablePermits());
- assertTrue(s0.isFair());
- Semaphore s1 = new Semaphore(-1, true);
- assertEquals(-1, s1.availablePermits());
- Semaphore s2 = new Semaphore(-1, true);
- assertEquals(-1, s2.availablePermits());
- }
-
- /**
- * tryAcquire succeeds when sufficient permits, else fails
- */
- public void testTryAcquireInSameThread_fair() {
- Semaphore s = new Semaphore(2, true);
- assertEquals(2, s.availablePermits());
- assertTrue(s.tryAcquire());
- assertTrue(s.tryAcquire());
- assertEquals(0, s.availablePermits());
- assertFalse(s.tryAcquire());
- }
-
- /**
- * tryAcquire(n) succeeds when sufficient permits, else fails
- */
- public void testTryAcquireNInSameThread_fair() {
- Semaphore s = new Semaphore(2, true);
- assertEquals(2, s.availablePermits());
- assertTrue(s.tryAcquire(2));
- assertEquals(0, s.availablePermits());
- assertFalse(s.tryAcquire());
- }
-
- /**
- * Acquire and release of semaphore succeed if initially available
- */
- public void testAcquireReleaseInSameThread_fair() {
- Semaphore s = new Semaphore(1, true);
- try {
- s.acquire();
- s.release();
- s.acquire();
- s.release();
- s.acquire();
- s.release();
- s.acquire();
- s.release();
- s.acquire();
- s.release();
- assertEquals(1, s.availablePermits());
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * Acquire(n) and release(n) of semaphore succeed if initially available
- */
- public void testAcquireReleaseNInSameThread_fair() {
- Semaphore s = new Semaphore(1, true);
- try {
- s.release(1);
- s.acquire(1);
- s.release(2);
- s.acquire(2);
- s.release(3);
- s.acquire(3);
- s.release(4);
- s.acquire(4);
- s.release(5);
- s.acquire(5);
- assertEquals(1, s.availablePermits());
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * Acquire(n) and release(n) of semaphore succeed if initially available
- */
- public void testAcquireUninterruptiblyReleaseNInSameThread_fair() {
- Semaphore s = new Semaphore(1, true);
- try {
- s.release(1);
- s.acquireUninterruptibly(1);
- s.release(2);
- s.acquireUninterruptibly(2);
- s.release(3);
- s.acquireUninterruptibly(3);
- s.release(4);
- s.acquireUninterruptibly(4);
- s.release(5);
- s.acquireUninterruptibly(5);
- assertEquals(1, s.availablePermits());
- } finally {
- }
- }
-
- /**
- * release(n) in one thread enables timed acquire(n) in another thread
- */
- public void testTimedAcquireReleaseNInSameThread_fair() {
- Semaphore s = new Semaphore(1, true);
- try {
- s.release(1);
- assertTrue(s.tryAcquire(1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release(2);
- assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release(3);
- assertTrue(s.tryAcquire(3, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release(4);
- assertTrue(s.tryAcquire(4, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release(5);
- assertTrue(s.tryAcquire(5, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- assertEquals(1, s.availablePermits());
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * release in one thread enables timed acquire in another thread
- */
- public void testTimedAcquireReleaseInSameThread_fair() {
- Semaphore s = new Semaphore(1, true);
- try {
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release();
- assertEquals(1, s.availablePermits());
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A release in one thread enables an acquire in another thread
- */
- public void testAcquireReleaseInDifferentThreads_fair() {
- final Semaphore s = new Semaphore(0, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.acquire();
- s.acquire();
- s.acquire();
- s.acquire();
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- s.release();
- s.release();
- s.release();
- s.release();
- s.release();
- s.release();
- t.join();
- assertEquals(2, s.availablePermits());
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * release(n) in one thread enables acquire(n) in another thread
- */
- public void testAcquireReleaseNInDifferentThreads_fair() {
- final Semaphore s = new Semaphore(0, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.acquire();
- s.release(2);
- s.acquire();
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- s.release(2);
- s.acquire(2);
- s.release(1);
- t.join();
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * release(n) in one thread enables acquire(n) in another thread
- */
- public void testAcquireReleaseNInDifferentThreads_fair2() {
- final Semaphore s = new Semaphore(0, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.acquire(2);
- s.acquire(2);
- s.release(4);
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- s.release(6);
- s.acquire(2);
- s.acquire(2);
- s.release(2);
- t.join();
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
-
-
-
-
- /**
- * release in one thread enables timed acquire in another thread
- */
- public void testTimedAcquireReleaseInDifferentThreads_fair() {
- final Semaphore s = new Semaphore(1, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(s.tryAcquire(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
-
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- t.start();
- try {
- s.release();
- s.release();
- s.release();
- s.release();
- s.release();
- t.join();
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * release(n) in one thread enables timed acquire(n) in another thread
- */
- public void testTimedAcquireReleaseNInDifferentThreads_fair() {
- final Semaphore s = new Semaphore(2, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release(2);
- threadAssertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release(2);
- } catch(InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- t.start();
- try {
- assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release(2);
- assertTrue(s.tryAcquire(2, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- s.release(2);
- t.join();
- } catch( InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A waiting acquire blocks interruptibly
- */
- public void testAcquire_InterruptedException_fair() {
- final Semaphore s = new Semaphore(0, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.acquire();
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A waiting acquire(n) blocks interruptibly
- */
- public void testAcquireN_InterruptedException_fair() {
- final Semaphore s = new Semaphore(2, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.acquire(3);
- threadShouldThrow();
- } catch(InterruptedException success){}
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A waiting tryAcquire blocks interruptibly
- */
- public void testTryAcquire_InterruptedException_fair() {
- final Semaphore s = new Semaphore(0, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.tryAcquire(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){
- }
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * A waiting tryAcquire(n) blocks interruptibly
- */
- public void testTryAcquireN_InterruptedException_fair() {
- final Semaphore s = new Semaphore(1, true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- s.tryAcquire(4, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch(InterruptedException success){
- }
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * getQueueLength reports number of waiting threads
- */
- public void testGetQueueLength_fair() {
- final Semaphore lock = new Semaphore(1, true);
- Thread t1 = new Thread(new InterruptedLockRunnable(lock));
- Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
- try {
- assertEquals(0, lock.getQueueLength());
- lock.acquireUninterruptibly();
- t1.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- t2.start();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(2, lock.getQueueLength());
- t1.interrupt();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, lock.getQueueLength());
- lock.release();
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(0, lock.getQueueLength());
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * a deserialized serialized semaphore has same number of permits
- */
- public void testSerialization_fair() {
- Semaphore l = new Semaphore(3, true);
-
- try {
- l.acquire();
- l.release();
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(l);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- Semaphore r = (Semaphore) in.readObject();
- assertEquals(3, r.availablePermits());
- assertTrue(r.isFair());
- r.acquire();
- r.release();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * toString indicates current number of permits
- */
- public void testToString() {
- Semaphore s = new Semaphore(0);
- String us = s.toString();
- assertTrue(us.indexOf("Permits = 0") >= 0);
- s.release();
- String s1 = s.toString();
- assertTrue(s1.indexOf("Permits = 1") >= 0);
- s.release();
- String s2 = s.toString();
- assertTrue(s2.indexOf("Permits = 2") >= 0);
- }
-
-}
diff --git a/concurrent/src/test/java/SynchronousQueueTest.java b/concurrent/src/test/java/SynchronousQueueTest.java
deleted file mode 100644
index e06b20f..0000000
--- a/concurrent/src/test/java/SynchronousQueueTest.java
+++ /dev/null
@@ -1,894 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class SynchronousQueueTest extends JSR166TestCase {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
-
- public static Test suite() {
- return new TestSuite(SynchronousQueueTest.class);
- }
-
- /**
- * A SynchronousQueue is both empty and full
- */
- public void testEmptyFull() {
- SynchronousQueue q = new SynchronousQueue();
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- assertEquals(0, q.remainingCapacity());
- assertFalse(q.offer(zero));
- }
-
- /**
- * A fair SynchronousQueue is both empty and full
- */
- public void testFairEmptyFull() {
- SynchronousQueue q = new SynchronousQueue(true);
- assertTrue(q.isEmpty());
- assertEquals(0, q.size());
- assertEquals(0, q.remainingCapacity());
- assertFalse(q.offer(zero));
- }
-
- /**
- * offer(null) throws NPE
- */
- public void testOfferNull() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- q.offer(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * add(null) throws NPE
- */
- public void testAddNull() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- q.add(null);
- shouldThrow();
- } catch (NullPointerException success) { }
- }
-
- /**
- * offer fails if no active taker
- */
- public void testOffer() {
- SynchronousQueue q = new SynchronousQueue();
- assertFalse(q.offer(one));
- }
-
- /**
- * add throws ISE if no active taker
- */
- public void testAdd() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- assertEquals(0, q.remainingCapacity());
- q.add(one);
- shouldThrow();
- } catch (IllegalStateException success){
- }
- }
-
- /**
- * addAll(null) throws NPE
- */
- public void testAddAll1() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- q.addAll(null);
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
-
- /**
- * addAll(this) throws IAE
- */
- public void testAddAllSelf() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- q.addAll(q);
- shouldThrow();
- }
- catch (IllegalArgumentException success) {}
- }
-
- /**
- * addAll of a collection with null elements throws NPE
- */
- public void testAddAll2() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- Integer[] ints = new Integer[1];
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (NullPointerException success) {}
- }
- /**
- * addAll throws ISE if no active taker
- */
- public void testAddAll4() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- Integer[] ints = new Integer[1];
- for (int i = 0; i < 1; ++i)
- ints[i] = new Integer(i);
- q.addAll(Arrays.asList(ints));
- shouldThrow();
- }
- catch (IllegalStateException success) {}
- }
-
- /**
- * put(null) throws NPE
- */
- public void testPutNull() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- q.put(null);
- shouldThrow();
- }
- catch (NullPointerException success){
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * put blocks interruptibly if no active taker
- */
- public void testBlockingPut() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- q.put(zero);
- threadShouldThrow();
- } catch (InterruptedException ie){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * put blocks waiting for take
- */
- public void testPutWithTake() {
- final SynchronousQueue q = new SynchronousQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- int added = 0;
- try {
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- threadShouldThrow();
- } catch (InterruptedException e){
- assertTrue(added >= 1);
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- q.take();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * timed offer times out if elements not taken
- */
- public void testTimedOffer() {
- final SynchronousQueue q = new SynchronousQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
-
- threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success){}
- }
- });
-
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * take blocks interruptibly when empty
- */
- public void testTakeFromEmpty() {
- final SynchronousQueue q = new SynchronousQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){ }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * put blocks interruptibly if no active taker
- */
- public void testFairBlockingPut() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- SynchronousQueue q = new SynchronousQueue(true);
- q.put(zero);
- threadShouldThrow();
- } catch (InterruptedException ie){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * put blocks waiting for take
- */
- public void testFairPutWithTake() {
- final SynchronousQueue q = new SynchronousQueue(true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- int added = 0;
- try {
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- q.put(new Object());
- ++added;
- threadShouldThrow();
- } catch (InterruptedException e){
- assertTrue(added >= 1);
- }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- q.take();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * timed offer times out if elements not taken
- */
- public void testFairTimedOffer() {
- final SynchronousQueue q = new SynchronousQueue(true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
-
- threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.offer(new Object(), LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success){}
- }
- });
-
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * take blocks interruptibly when empty
- */
- public void testFairTakeFromEmpty() {
- final SynchronousQueue q = new SynchronousQueue(true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.take();
- threadShouldThrow();
- } catch (InterruptedException success){ }
- }
- });
- try {
- t.start();
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * poll fails unless active taker
- */
- public void testPoll() {
- SynchronousQueue q = new SynchronousQueue();
- assertNull(q.poll());
- }
-
- /**
- * timed pool with zero timeout times out if no active taker
- */
- public void testTimedPoll0() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- assertNull(q.poll(0, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * timed pool with nonzero timeout times out if no active taker
- */
- public void testTimedPoll() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException e){
- unexpectedException();
- }
- }
-
- /**
- * Interrupted timed poll throws InterruptedException instead of
- * returning timeout status
- */
- public void testInterruptedTimedPoll() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException success){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * timed poll before a delayed offer fails; after offer succeeds;
- * on interruption throws
- */
- public void testTimedPollWithOffer() {
- final SynchronousQueue q = new SynchronousQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success) { }
- }
- });
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
- /**
- * Interrupted timed poll throws InterruptedException instead of
- * returning timeout status
- */
- public void testFairInterruptedTimedPoll() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- SynchronousQueue q = new SynchronousQueue(true);
- assertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- } catch (InterruptedException success){
- }
- }});
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- }
- catch (InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * timed poll before a delayed offer fails; after offer succeeds;
- * on interruption throws
- */
- public void testFairTimedPollWithOffer() {
- final SynchronousQueue q = new SynchronousQueue(true);
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- threadAssertNull(q.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- q.poll(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
- threadShouldThrow();
- } catch (InterruptedException success) { }
- }
- });
- try {
- t.start();
- Thread.sleep(SMALL_DELAY_MS);
- assertTrue(q.offer(zero, SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
- t.interrupt();
- t.join();
- } catch (Exception e){
- unexpectedException();
- }
- }
-
-
- /**
- * peek returns null
- */
- public void testPeek() {
- SynchronousQueue q = new SynchronousQueue();
- assertNull(q.peek());
- }
-
- /**
- * element throws NSEE
- */
- public void testElement() {
- SynchronousQueue q = new SynchronousQueue();
- try {
- q.element();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * remove throws NSEE if no active taker
- */
- public void testRemove() {
- SynchronousQueue q = new SynchronousQueue();
- try {
- q.remove();
- shouldThrow();
- } catch (NoSuchElementException success){
- }
- }
-
- /**
- * remove(x) returns false
- */
- public void testRemoveElement() {
- SynchronousQueue q = new SynchronousQueue();
- assertFalse(q.remove(zero));
- assertTrue(q.isEmpty());
- }
-
- /**
- * contains returns false
- */
- public void testContains() {
- SynchronousQueue q = new SynchronousQueue();
- assertFalse(q.contains(zero));
- }
-
- /**
- * clear ensures isEmpty
- */
- public void testClear() {
- SynchronousQueue q = new SynchronousQueue();
- q.clear();
- assertTrue(q.isEmpty());
- }
-
- /**
- * containsAll returns false unless empty
- */
- public void testContainsAll() {
- SynchronousQueue q = new SynchronousQueue();
- Integer[] empty = new Integer[0];
- assertTrue(q.containsAll(Arrays.asList(empty)));
- Integer[] ints = new Integer[1]; ints[0] = zero;
- assertFalse(q.containsAll(Arrays.asList(ints)));
- }
-
- /**
- * retainAll returns false
- */
- public void testRetainAll() {
- SynchronousQueue q = new SynchronousQueue();
- Integer[] empty = new Integer[0];
- assertFalse(q.retainAll(Arrays.asList(empty)));
- Integer[] ints = new Integer[1]; ints[0] = zero;
- assertFalse(q.retainAll(Arrays.asList(ints)));
- }
-
- /**
- * removeAll returns false
- */
- public void testRemoveAll() {
- SynchronousQueue q = new SynchronousQueue();
- Integer[] empty = new Integer[0];
- assertFalse(q.removeAll(Arrays.asList(empty)));
- Integer[] ints = new Integer[1]; ints[0] = zero;
- assertFalse(q.containsAll(Arrays.asList(ints)));
- }
-
-
- /**
- * toArray is empty
- */
- public void testToArray() {
- SynchronousQueue q = new SynchronousQueue();
- Object[] o = q.toArray();
- assertEquals(o.length, 0);
- }
-
- /**
- * toArray(a) is nulled at position 0
- */
- public void testToArray2() {
- SynchronousQueue q = new SynchronousQueue();
- Integer[] ints = new Integer[1];
- assertNull(ints[0]);
- }
-
- /**
- * toArray(null) throws NPE
- */
- public void testToArray_BadArg() {
- try {
- SynchronousQueue q = new SynchronousQueue();
- Object o[] = q.toArray(null);
- shouldThrow();
- } catch(NullPointerException success){}
- }
-
-
- /**
- * iterator does not traverse any elements
- */
- public void testIterator() {
- SynchronousQueue q = new SynchronousQueue();
- Iterator it = q.iterator();
- assertFalse(it.hasNext());
- try {
- Object x = it.next();
- shouldThrow();
- }
- catch (NoSuchElementException success) {}
- }
-
- /**
- * iterator remove throws ISE
- */
- public void testIteratorRemove() {
- SynchronousQueue q = new SynchronousQueue();
- Iterator it = q.iterator();
- try {
- it.remove();
- shouldThrow();
- }
- catch (IllegalStateException success) {}
- }
-
- /**
- * toString returns a non-null string
- */
- public void testToString() {
- SynchronousQueue q = new SynchronousQueue();
- String s = q.toString();
- assertNotNull(s);
- }
-
-
- /**
- * offer transfers elements across Executor tasks
- */
- public void testOfferInExecutor() {
- final SynchronousQueue q = new SynchronousQueue();
- ExecutorService executor = Executors.newFixedThreadPool(2);
- final Integer one = new Integer(1);
-
- executor.execute(new Runnable() {
- public void run() {
- threadAssertFalse(q.offer(one));
- try {
- threadAssertTrue(q.offer(one, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertEquals(0, q.remainingCapacity());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- executor.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- threadAssertEquals(one, q.take());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- joinPool(executor);
-
- }
-
- /**
- * poll retrieves elements across Executor threads
- */
- public void testPollInExecutor() {
- final SynchronousQueue q = new SynchronousQueue();
- ExecutorService executor = Executors.newFixedThreadPool(2);
- executor.execute(new Runnable() {
- public void run() {
- threadAssertNull(q.poll());
- try {
- threadAssertTrue(null != q.poll(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS));
- threadAssertTrue(q.isEmpty());
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- executor.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SMALL_DELAY_MS);
- q.put(new Integer(1));
- }
- catch (InterruptedException e) {
- threadUnexpectedException();
- }
- }
- });
-
- joinPool(executor);
- }
-
- /**
- * a deserialized serialized queue is usable
- */
- public void testSerialization() {
- SynchronousQueue q = new SynchronousQueue();
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- SynchronousQueue r = (SynchronousQueue)in.readObject();
- assertEquals(q.size(), r.size());
- while (!q.isEmpty())
- assertEquals(q.remove(), r.remove());
- } catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null) throws NPE
- */
- public void testDrainToNull() {
- SynchronousQueue q = new SynchronousQueue();
- try {
- q.drainTo(null);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this) throws IAE
- */
- public void testDrainToSelf() {
- SynchronousQueue q = new SynchronousQueue();
- try {
- q.drainTo(q);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c) of empty queue doesn't transfer elements
- */
- public void testDrainTo() {
- SynchronousQueue q = new SynchronousQueue();
- ArrayList l = new ArrayList();
- q.drainTo(l);
- assertEquals(q.size(), 0);
- assertEquals(l.size(), 0);
- }
-
- /**
- * drainTo empties queue, unblocking a waiting put.
- */
- public void testDrainToWithActivePut() {
- final SynchronousQueue q = new SynchronousQueue();
- Thread t = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(new Integer(1));
- } catch (InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- try {
- t.start();
- ArrayList l = new ArrayList();
- Thread.sleep(SHORT_DELAY_MS);
- q.drainTo(l);
- assertTrue(l.size() <= 1);
- if (l.size() > 0)
- assertEquals(l.get(0), new Integer(1));
- t.join();
- assertTrue(l.size() <= 1);
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * drainTo(null, n) throws NPE
- */
- public void testDrainToNullN() {
- SynchronousQueue q = new SynchronousQueue();
- try {
- q.drainTo(null, 0);
- shouldThrow();
- } catch(NullPointerException success) {
- }
- }
-
- /**
- * drainTo(this, n) throws IAE
- */
- public void testDrainToSelfN() {
- SynchronousQueue q = new SynchronousQueue();
- try {
- q.drainTo(q, 0);
- shouldThrow();
- } catch(IllegalArgumentException success) {
- }
- }
-
- /**
- * drainTo(c, n) empties up to n elements of queue into c
- */
- public void testDrainToN() {
- final SynchronousQueue q = new SynchronousQueue();
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(one);
- } catch (InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- try {
- q.put(two);
- } catch (InterruptedException ie){
- threadUnexpectedException();
- }
- }
- });
-
- try {
- t1.start();
- t2.start();
- ArrayList l = new ArrayList();
- Thread.sleep(SHORT_DELAY_MS);
- q.drainTo(l, 1);
- assertTrue(l.size() == 1);
- q.drainTo(l, 1);
- assertTrue(l.size() == 2);
- assertTrue(l.contains(one));
- assertTrue(l.contains(two));
- t1.join();
- t2.join();
- } catch(Exception e){
- unexpectedException();
- }
- }
-
-
-}
diff --git a/concurrent/src/test/java/SystemTest.java b/concurrent/src/test/java/SystemTest.java
deleted file mode 100644
index f8713d1..0000000
--- a/concurrent/src/test/java/SystemTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-
-public class SystemTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new TestSuite(SystemTest.class);
- }
-
- /**
- * Worst case rounding for millisecs; set for 60 cycle millis clock.
- * This value might need to be changed os JVMs with coarser
- * System.currentTimeMillis clocks.
- */
- static final long MILLIS_ROUND = 17;
-
- /**
- * Nanos between readings of millis is no longer than millis (plus
- * possible rounding).
- * This shows only that nano timing not (much) worse than milli.
- */
- public void testNanoTime1() {
- try {
- long m1 = System.currentTimeMillis();
- Thread.sleep(1);
- long n1 = System.nanoTime();
- Thread.sleep(SHORT_DELAY_MS);
- long n2 = System.nanoTime();
- Thread.sleep(1);
- long m2 = System.currentTimeMillis();
- long millis = m2 - m1;
- long nanos = n2 - n1;
- assertTrue(nanos >= 0);
- long nanosAsMillis = nanos / 1000000;
- assertTrue(nanosAsMillis <= millis + MILLIS_ROUND);
- }
- catch(InterruptedException ie) {
- unexpectedException();
- }
- }
-
- /**
- * Millis between readings of nanos is less than nanos, adjusting
- * for rounding.
- * This shows only that nano timing not (much) worse than milli.
- */
- public void testNanoTime2() {
- try {
- long n1 = System.nanoTime();
- Thread.sleep(1);
- long m1 = System.currentTimeMillis();
- Thread.sleep(SHORT_DELAY_MS);
- long m2 = System.currentTimeMillis();
- Thread.sleep(1);
- long n2 = System.nanoTime();
- long millis = m2 - m1;
- long nanos = n2 - n1;
-
- assertTrue(nanos >= 0);
- long nanosAsMillis = nanos / 1000000;
- assertTrue(millis <= nanosAsMillis + MILLIS_ROUND);
- }
- catch(InterruptedException ie) {
- unexpectedException();
- }
- }
-
-}
-
diff --git a/concurrent/src/test/java/ThreadLocalTest.java b/concurrent/src/test/java/ThreadLocalTest.java
deleted file mode 100644
index 71149c9..0000000
--- a/concurrent/src/test/java/ThreadLocalTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-import java.util.concurrent.Semaphore;
-
-public class ThreadLocalTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new TestSuite(ThreadLocalTest.class);
- }
-
- static ThreadLocal<Integer> tl = new ThreadLocal<Integer>() {
- public Integer initialValue() {
- return one;
- }
- };
-
- static InheritableThreadLocal<Integer> itl =
- new InheritableThreadLocal<Integer>() {
- protected Integer initialValue() {
- return zero;
- }
-
- protected Integer childValue(Integer parentValue) {
- return new Integer(parentValue.intValue() + 1);
- }
- };
-
- /**
- * remove causes next access to return initial value
- */
- public void testRemove() {
- assertEquals(tl.get(), one);
- tl.set(two);
- assertEquals(tl.get(), two);
- tl.remove();
- assertEquals(tl.get(), one);
- }
-
- /**
- * remove in InheritableThreadLocal causes next access to return
- * initial value
- */
- public void testRemoveITL() {
- assertEquals(itl.get(), zero);
- itl.set(two);
- assertEquals(itl.get(), two);
- itl.remove();
- assertEquals(itl.get(), zero);
- }
-
- private class ITLThread extends Thread {
- final int[] x;
- ITLThread(int[] array) { x = array; }
- public void run() {
- Thread child = null;
- if (itl.get().intValue() < x.length - 1) {
- child = new ITLThread(x);
- child.start();
- }
- Thread.currentThread().yield();
-
- int threadId = itl.get().intValue();
- for (int j = 0; j < threadId; j++) {
- x[threadId]++;
- Thread.currentThread().yield();
- }
-
- if (child != null) { // Wait for child (if any)
- try {
- child.join();
- } catch(InterruptedException e) {
- threadUnexpectedException();
- }
- }
- }
- }
-
- /**
- * InheritableThreadLocal propagates generic values.
- */
- public void testGenericITL() {
- final int threadCount = 10;
- final int x[] = new int[threadCount];
- Thread progenitor = new ITLThread(x);
- try {
- progenitor.start();
- progenitor.join();
- for(int i = 0; i < threadCount; i++) {
- assertEquals(i, x[i]);
- }
- } catch(InterruptedException e) {
- unexpectedException();
- }
- }
-}
-
diff --git a/concurrent/src/test/java/ThreadPoolExecutorTest.java b/concurrent/src/test/java/ThreadPoolExecutorTest.java
deleted file mode 100644
index fd9f69e..0000000
--- a/concurrent/src/test/java/ThreadPoolExecutorTest.java
+++ /dev/null
@@ -1,1568 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-import junit.framework.*;
-import java.util.*;
-
-public class ThreadPoolExecutorTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run (suite());
- }
- public static Test suite() {
- return new TestSuite(ThreadPoolExecutorTest.class);
- }
-
- static class ExtendedTPE extends ThreadPoolExecutor {
- volatile boolean beforeCalled = false;
- volatile boolean afterCalled = false;
- volatile boolean terminatedCalled = false;
- public ExtendedTPE() {
- super(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>());
- }
- protected void beforeExecute(Thread t, Runnable r) {
- beforeCalled = true;
- }
- protected void afterExecute(Runnable r, Throwable t) {
- afterCalled = true;
- }
- protected void terminated() {
- terminatedCalled = true;
- }
- }
-
- static class FailingThreadFactory implements ThreadFactory{
- int calls = 0;
- public Thread newThread(Runnable r){
- if (++calls > 1) return null;
- return new Thread(r);
- }
- }
-
-
- /**
- * execute successfully executes a runnable
- */
- public void testExecute() {
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- p1.execute(new Runnable() {
- public void run() {
- try {
- Thread.sleep(SHORT_DELAY_MS);
- } catch(InterruptedException e){
- threadUnexpectedException();
- }
- }
- });
- Thread.sleep(SMALL_DELAY_MS);
- } catch(InterruptedException e){
- unexpectedException();
- }
- joinPool(p1);
- }
-
- /**
- * getActiveCount increases but doesn't overestimate, when a
- * thread becomes active
- */
- public void testGetActiveCount() {
- ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertEquals(0, p2.getActiveCount());
- p2.execute(new MediumRunnable());
- try {
- Thread.sleep(SHORT_DELAY_MS);
- } catch(Exception e){
- unexpectedException();
- }
- assertEquals(1, p2.getActiveCount());
- joinPool(p2);
- }
-
- /**
- * prestartCoreThread starts a thread if under corePoolSize, else doesn't
- */
- public void testPrestartCoreThread() {
- ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertEquals(0, p2.getPoolSize());
- assertTrue(p2.prestartCoreThread());
- assertEquals(1, p2.getPoolSize());
- assertTrue(p2.prestartCoreThread());
- assertEquals(2, p2.getPoolSize());
- assertFalse(p2.prestartCoreThread());
- assertEquals(2, p2.getPoolSize());
- joinPool(p2);
- }
-
- /**
- * prestartAllCoreThreads starts all corePoolSize threads
- */
- public void testPrestartAllCoreThreads() {
- ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertEquals(0, p2.getPoolSize());
- p2.prestartAllCoreThreads();
- assertEquals(2, p2.getPoolSize());
- p2.prestartAllCoreThreads();
- assertEquals(2, p2.getPoolSize());
- joinPool(p2);
- }
-
- /**
- * getCompletedTaskCount increases, but doesn't overestimate,
- * when tasks complete
- */
- public void testGetCompletedTaskCount() {
- ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertEquals(0, p2.getCompletedTaskCount());
- p2.execute(new ShortRunnable());
- try {
- Thread.sleep(SMALL_DELAY_MS);
- } catch(Exception e){
- unexpectedException();
- }
- assertEquals(1, p2.getCompletedTaskCount());
- try { p2.shutdown(); } catch(SecurityException ok) { return; }
- joinPool(p2);
- }
-
- /**
- * getCorePoolSize returns size given in constructor if not otherwise set
- */
- public void testGetCorePoolSize() {
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertEquals(1, p1.getCorePoolSize());
- joinPool(p1);
- }
-
- /**
- * getKeepAliveTime returns value given in constructor if not otherwise set
- */
- public void testGetKeepAliveTime() {
- ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertEquals(1, p2.getKeepAliveTime(TimeUnit.SECONDS));
- joinPool(p2);
- }
-
-
- /**
- * getThreadFactory returns factory in constructor if not set
- */
- public void testGetThreadFactory() {
- ThreadFactory tf = new SimpleThreadFactory();
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), tf, new NoOpREHandler());
- assertSame(tf, p.getThreadFactory());
- joinPool(p);
- }
-
- /**
- * setThreadFactory sets the thread factory returned by getThreadFactory
- */
- public void testSetThreadFactory() {
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- ThreadFactory tf = new SimpleThreadFactory();
- p.setThreadFactory(tf);
- assertSame(tf, p.getThreadFactory());
- joinPool(p);
- }
-
-
- /**
- * setThreadFactory(null) throws NPE
- */
- public void testSetThreadFactoryNull() {
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- p.setThreadFactory(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } finally {
- joinPool(p);
- }
- }
-
- /**
- * getRejectedExecutionHandler returns handler in constructor if not set
- */
- public void testGetRejectedExecutionHandler() {
- RejectedExecutionHandler h = new NoOpREHandler();
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), h);
- assertSame(h, p.getRejectedExecutionHandler());
- joinPool(p);
- }
-
- /**
- * setRejectedExecutionHandler sets the handler returned by
- * getRejectedExecutionHandler
- */
- public void testSetRejectedExecutionHandler() {
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- RejectedExecutionHandler h = new NoOpREHandler();
- p.setRejectedExecutionHandler(h);
- assertSame(h, p.getRejectedExecutionHandler());
- joinPool(p);
- }
-
-
- /**
- * setRejectedExecutionHandler(null) throws NPE
- */
- public void testSetRejectedExecutionHandlerNull() {
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- p.setRejectedExecutionHandler(null);
- shouldThrow();
- } catch (NullPointerException success) {
- } finally {
- joinPool(p);
- }
- }
-
-
- /**
- * getLargestPoolSize increases, but doesn't overestimate, when
- * multiple threads active
- */
- public void testGetLargestPoolSize() {
- ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- assertEquals(0, p2.getLargestPoolSize());
- p2.execute(new MediumRunnable());
- p2.execute(new MediumRunnable());
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(2, p2.getLargestPoolSize());
- } catch(Exception e){
- unexpectedException();
- }
- joinPool(p2);
- }
-
- /**
- * getMaximumPoolSize returns value given in constructor if not
- * otherwise set
- */
- public void testGetMaximumPoolSize() {
- ThreadPoolExecutor p2 = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertEquals(2, p2.getMaximumPoolSize());
- joinPool(p2);
- }
-
- /**
- * getPoolSize increases, but doesn't overestimate, when threads
- * become active
- */
- public void testGetPoolSize() {
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertEquals(0, p1.getPoolSize());
- p1.execute(new MediumRunnable());
- assertEquals(1, p1.getPoolSize());
- joinPool(p1);
- }
-
- /**
- * getTaskCount increases, but doesn't overestimate, when tasks submitted
- */
- public void testGetTaskCount() {
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- assertEquals(0, p1.getTaskCount());
- p1.execute(new MediumRunnable());
- Thread.sleep(SHORT_DELAY_MS);
- assertEquals(1, p1.getTaskCount());
- } catch(Exception e){
- unexpectedException();
- }
- joinPool(p1);
- }
-
- /**
- * isShutDown is false before shutdown, true after
- */
- public void testIsShutdown() {
-
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertFalse(p1.isShutdown());
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- assertTrue(p1.isShutdown());
- joinPool(p1);
- }
-
-
- /**
- * isTerminated is false before termination, true after
- */
- public void testIsTerminated() {
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertFalse(p1.isTerminated());
- try {
- p1.execute(new MediumRunnable());
- } finally {
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- }
- try {
- assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
- assertTrue(p1.isTerminated());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * isTerminating is not true when running or when terminated
- */
- public void testIsTerminating() {
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- assertFalse(p1.isTerminating());
- try {
- p1.execute(new SmallRunnable());
- assertFalse(p1.isTerminating());
- } finally {
- try { p1.shutdown(); } catch(SecurityException ok) { return; }
- }
- try {
- assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
- assertTrue(p1.isTerminated());
- assertFalse(p1.isTerminating());
- } catch(Exception e){
- unexpectedException();
- }
- }
-
- /**
- * getQueue returns the work queue, which contains queued tasks
- */
- public void testGetQueue() {
- BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q);
- FutureTask[] tasks = new FutureTask[5];
- for(int i = 0; i < 5; i++){
- tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
- p1.execute(tasks[i]);
- }
- try {
- Thread.sleep(SHORT_DELAY_MS);
- BlockingQueue<Runnable> wq = p1.getQueue();
- assertSame(q, wq);
- assertFalse(wq.contains(tasks[0]));
- assertTrue(wq.contains(tasks[4]));
- for (int i = 1; i < 5; ++i)
- tasks[i].cancel(true);
- p1.shutdownNow();
- } catch(Exception e) {
- unexpectedException();
- } finally {
- joinPool(p1);
- }
- }
-
- /**
- * remove(task) removes queued task, and fails to remove active task
- */
- public void testRemove() {
- BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q);
- FutureTask[] tasks = new FutureTask[5];
- for(int i = 0; i < 5; i++){
- tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
- p1.execute(tasks[i]);
- }
- try {
- Thread.sleep(SHORT_DELAY_MS);
- assertFalse(p1.remove(tasks[0]));
- assertTrue(q.contains(tasks[4]));
- assertTrue(q.contains(tasks[3]));
- assertTrue(p1.remove(tasks[4]));
- assertFalse(p1.remove(tasks[4]));
- assertFalse(q.contains(tasks[4]));
- assertTrue(q.contains(tasks[3]));
- assertTrue(p1.remove(tasks[3]));
- assertFalse(q.contains(tasks[3]));
- } catch(Exception e) {
- unexpectedException();
- } finally {
- joinPool(p1);
- }
- }
-
- /**
- * purge removes cancelled tasks from the queue
- */
- public void testPurge() {
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- FutureTask[] tasks = new FutureTask[5];
- for(int i = 0; i < 5; i++){
- tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
- p1.execute(tasks[i]);
- }
- tasks[4].cancel(true);
- tasks[3].cancel(true);
- p1.purge();
- long count = p1.getTaskCount();
- assertTrue(count >= 2 && count < 5);
- joinPool(p1);
- }
-
- /**
- * shutDownNow returns a list containing tasks that were not run
- */
- public void testShutDownNow() {
- ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- List l;
- try {
- for(int i = 0; i < 5; i++)
- p1.execute(new MediumPossiblyInterruptedRunnable());
- }
- finally {
- try {
- l = p1.shutdownNow();
- } catch (SecurityException ok) { return; }
-
- }
- assertTrue(p1.isShutdown());
- assertTrue(l.size() <= 4);
- }
-
- // Exception Tests
-
-
- /**
- * Constructor throws if corePoolSize argument is less than zero
- */
- public void testConstructor1() {
- try {
- new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if maximumPoolSize is less than zero
- */
- public void testConstructor2() {
- try {
- new ThreadPoolExecutor(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if maximumPoolSize is equal to zero
- */
- public void testConstructor3() {
- try {
- new ThreadPoolExecutor(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if keepAliveTime is less than zero
- */
- public void testConstructor4() {
- try {
- new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if corePoolSize is greater than the maximumPoolSize
- */
- public void testConstructor5() {
- try {
- new ThreadPoolExecutor(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if workQueue is set to null
- */
- public void testConstructorNullPointerException() {
- try {
- new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null);
- shouldThrow();
- }
- catch (NullPointerException success){}
- }
-
-
-
- /**
- * Constructor throws if corePoolSize argument is less than zero
- */
- public void testConstructor6() {
- try {
- new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
- shouldThrow();
- } catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if maximumPoolSize is less than zero
- */
- public void testConstructor7() {
- try {
- new ThreadPoolExecutor(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if maximumPoolSize is equal to zero
- */
- public void testConstructor8() {
- try {
- new ThreadPoolExecutor(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if keepAliveTime is less than zero
- */
- public void testConstructor9() {
- try {
- new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if corePoolSize is greater than the maximumPoolSize
- */
- public void testConstructor10() {
- try {
- new ThreadPoolExecutor(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if workQueue is set to null
- */
- public void testConstructorNullPointerException2() {
- try {
- new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory());
- shouldThrow();
- }
- catch (NullPointerException success){}
- }
-
- /**
- * Constructor throws if threadFactory is set to null
- */
- public void testConstructorNullPointerException3() {
- try {
- ThreadFactory f = null;
- new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f);
- shouldThrow();
- }
- catch (NullPointerException success){}
- }
-
-
- /**
- * Constructor throws if corePoolSize argument is less than zero
- */
- public void testConstructor11() {
- try {
- new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if maximumPoolSize is less than zero
- */
- public void testConstructor12() {
- try {
- new ThreadPoolExecutor(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if maximumPoolSize is equal to zero
- */
- public void testConstructor13() {
- try {
- new ThreadPoolExecutor(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if keepAliveTime is less than zero
- */
- public void testConstructor14() {
- try {
- new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if corePoolSize is greater than the maximumPoolSize
- */
- public void testConstructor15() {
- try {
- new ThreadPoolExecutor(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if workQueue is set to null
- */
- public void testConstructorNullPointerException4() {
- try {
- new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new NoOpREHandler());
- shouldThrow();
- }
- catch (NullPointerException success){}
- }
-
- /**
- * Constructor throws if handler is set to null
- */
- public void testConstructorNullPointerException5() {
- try {
- RejectedExecutionHandler r = null;
- new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),r);
- shouldThrow();
- }
- catch (NullPointerException success){}
- }
-
-
- /**
- * Constructor throws if corePoolSize argument is less than zero
- */
- public void testConstructor16() {
- try {
- new ThreadPoolExecutor(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if maximumPoolSize is less than zero
- */
- public void testConstructor17() {
- try {
- new ThreadPoolExecutor(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if maximumPoolSize is equal to zero
- */
- public void testConstructor18() {
- try {
- new ThreadPoolExecutor(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if keepAliveTime is less than zero
- */
- public void testConstructor19() {
- try {
- new ThreadPoolExecutor(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if corePoolSize is greater than the maximumPoolSize
- */
- public void testConstructor20() {
- try {
- new ThreadPoolExecutor(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
- shouldThrow();
- }
- catch (IllegalArgumentException success){}
- }
-
- /**
- * Constructor throws if workQueue is set to null
- */
- public void testConstructorNullPointerException6() {
- try {
- new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler());
- shouldThrow();
- }
- catch (NullPointerException success){}
- }
-
- /**
- * Constructor throws if handler is set to null
- */
- public void testConstructorNullPointerException7() {
- try {
- RejectedExecutionHandler r = null;
- new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),r);
- shouldThrow();
- }
- catch (NullPointerException success){}
- }
-
- /**
- * Constructor throws if ThreadFactory is set top null
- */
- public void testConstructorNullPointerException8() {
- try {
- ThreadFactory f = null;
- new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f,new NoOpREHandler());
- shouldThrow();
- }
- catch (NullPointerException successdn8){}
- }
-
-
- /**
- * execute throws RejectedExecutionException
- * if saturated.
- */
- public void testSaturatedExecute() {
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));
- try {
-
- for(int i = 0; i < 5; ++i){
- p.execute(new MediumRunnable());
- }
- shouldThrow();
- } catch(RejectedExecutionException success){}
- joinPool(p);
- }
-
- /**
- * executor using CallerRunsPolicy runs task if saturated.
- */
- public void testSaturatedExecute2() {
- RejectedExecutionHandler h = new ThreadPoolExecutor.CallerRunsPolicy();
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
- try {
-
- TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
- for(int i = 0; i < 5; ++i){
- tasks[i] = new TrackedNoOpRunnable();
- }
- TrackedLongRunnable mr = new TrackedLongRunnable();
- p.execute(mr);
- for(int i = 0; i < 5; ++i){
- p.execute(tasks[i]);
- }
- for(int i = 1; i < 5; ++i) {
- assertTrue(tasks[i].done);
- }
- try { p.shutdownNow(); } catch(SecurityException ok) { return; }
- } catch(RejectedExecutionException ex){
- unexpectedException();
- } finally {
- joinPool(p);
- }
- }
-
- /**
- * executor using DiscardPolicy drops task if saturated.
- */
- public void testSaturatedExecute3() {
- RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardPolicy();
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
- try {
-
- TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
- for(int i = 0; i < 5; ++i){
- tasks[i] = new TrackedNoOpRunnable();
- }
- p.execute(new TrackedLongRunnable());
- for(int i = 0; i < 5; ++i){
- p.execute(tasks[i]);
- }
- for(int i = 0; i < 5; ++i){
- assertFalse(tasks[i].done);
- }
- try { p.shutdownNow(); } catch(SecurityException ok) { return; }
- } catch(RejectedExecutionException ex){
- unexpectedException();
- } finally {
- joinPool(p);
- }
- }
-
- /**
- * executor using DiscardOldestPolicy drops oldest task if saturated.
- */
- public void testSaturatedExecute4() {
- RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardOldestPolicy();
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
- try {
- p.execute(new TrackedLongRunnable());
- TrackedLongRunnable r2 = new TrackedLongRunnable();
- p.execute(r2);
- assertTrue(p.getQueue().contains(r2));
- TrackedNoOpRunnable r3 = new TrackedNoOpRunnable();
- p.execute(r3);
- assertFalse(p.getQueue().contains(r2));
- assertTrue(p.getQueue().contains(r3));
- try { p.shutdownNow(); } catch(SecurityException ok) { return; }
- } catch(RejectedExecutionException ex){
- unexpectedException();
- } finally {
- joinPool(p);
- }
- }
-
- /**
- * execute throws RejectedExecutionException if shutdown
- */
- public void testRejectedExecutionExceptionOnShutdown() {
- ThreadPoolExecutor tpe =
- new ThreadPoolExecutor(1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
- try { tpe.shutdown(); } catch(SecurityException ok) { return; }
- try {
- tpe.execute(new NoOpRunnable());
- shouldThrow();
- } catch(RejectedExecutionException success){}
-
- joinPool(tpe);
- }
-
- /**
- * execute using CallerRunsPolicy drops task on shutdown
- */
- public void testCallerRunsOnShutdown() {
- RejectedExecutionHandler h = new ThreadPoolExecutor.CallerRunsPolicy();
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
-
- try { p.shutdown(); } catch(SecurityException ok) { return; }
- try {
- TrackedNoOpRunnable r = new TrackedNoOpRunnable();
- p.execute(r);
- assertFalse(r.done);
- } catch(RejectedExecutionException success){
- unexpectedException();
- } finally {
- joinPool(p);
- }
- }
-
- /**
- * execute using DiscardPolicy drops task on shutdown
- */
- public void testDiscardOnShutdown() {
- RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardPolicy();
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
-
- try { p.shutdown(); } catch(SecurityException ok) { return; }
- try {
- TrackedNoOpRunnable r = new TrackedNoOpRunnable();
- p.execute(r);
- assertFalse(r.done);
- } catch(RejectedExecutionException success){
- unexpectedException();
- } finally {
- joinPool(p);
- }
- }
-
-
- /**
- * execute using DiscardOldestPolicy drops task on shutdown
- */
- public void testDiscardOldestOnShutdown() {
- RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardOldestPolicy();
- ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
-
- try { p.shutdown(); } catch(SecurityException ok) { return; }
- try {
- TrackedNoOpRunnable r = new TrackedNoOpRunnable();
- p.execute(r);
- assertFalse(r.done);
- } catch(RejectedExecutionException success){
- unexpectedException();
- } finally {
- joinPool(p);
- }
- }
-
-
- /**
- * execute (null) throws NPE
- */
- public void testExecuteNull() {
- ThreadPoolExecutor tpe = null;
- try {
- tpe = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
- tpe.execute(null);
- shouldThrow();
- } catch(NullPointerException success){}
-
- joinPool(tpe);
- }
-
- /**
- * setCorePoolSize of negative value throws IllegalArgumentException
- */
- public void testCorePoolSizeIllegalArgumentException() {
- ThreadPoolExecutor tpe = null;
- try {
- tpe = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
- } catch(Exception e){}
- try {
- tpe.setCorePoolSize(-1);
- shouldThrow();
- } catch(IllegalArgumentException success){
- } finally {
- try { tpe.shutdown(); } catch(SecurityException ok) { return; }
- }
- joinPool(tpe);
- }
-
- /**
- * setMaximumPoolSize(int) throws IllegalArgumentException if
- * given a value less the core pool size
- */
- public void testMaximumPoolSizeIllegalArgumentException() {
- ThreadPoolExecutor tpe = null;
- try {
- tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
- } catch(Exception e){}
- try {
- tpe.setMaximumPoolSize(1);
- shouldThrow();
- } catch(IllegalArgumentException success){
- } finally {
- try { tpe.shutdown(); } catch(SecurityException ok) { return; }
- }
- joinPool(tpe);
- }
-
- /**
- * setMaximumPoolSize throws IllegalArgumentException
- * if given a negative value
- */
- public void testMaximumPoolSizeIllegalArgumentException2() {
- ThreadPoolExecutor tpe = null;
- try {
- tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
- } catch(Exception e){}
- try {
- tpe.setMaximumPoolSize(-1);
- shouldThrow();
- } catch(IllegalArgumentException success){
- } finally {
- try { tpe.shutdown(); } catch(SecurityException ok) { return; }
- }
- joinPool(tpe);
- }
-
-
- /**
- * setKeepAliveTime throws IllegalArgumentException
- * when given a negative value
- */
- public void testKeepAliveTimeIllegalArgumentException() {
- ThreadPoolExecutor tpe = null;
- try {
- tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
- } catch(Exception e){}
-
- try {
- tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS);
- shouldThrow();
- } catch(IllegalArgumentException success){
- } finally {
- try { tpe.shutdown(); } catch(SecurityException ok) { return; }
- }
- joinPool(tpe);
- }
-
- /**
- * terminated() is called on termination
- */
- public void testTerminated() {
- ExtendedTPE tpe = new ExtendedTPE();
- try { tpe.shutdown(); } catch(SecurityException ok) { return; }
- assertTrue(tpe.terminatedCalled);
- joinPool(tpe);
- }
-
- /**
- * beforeExecute and afterExecute are called when executing task
- */
- public void testBeforeAfter() {
- ExtendedTPE tpe = new ExtendedTPE();
- try {
- TrackedNoOpRunnable r = new TrackedNoOpRunnable();
- tpe.execute(r);
- Thread.sleep(SHORT_DELAY_MS);
- assertTrue(r.done);
- assertTrue(tpe.beforeCalled);
- assertTrue(tpe.afterCalled);
- try { tpe.shutdown(); } catch(SecurityException ok) { return; }
- }
- catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(tpe);
- }
- }
-
- /**
- * completed submit of callable returns result
- */
- public void testSubmitCallable() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- Future<String> future = e.submit(new StringTask());
- String result = future.get();
- assertSame(TEST_STRING, result);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * completed submit of runnable returns successfully
- */
- public void testSubmitRunnable() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- Future<?> future = e.submit(new NoOpRunnable());
- future.get();
- assertTrue(future.isDone());
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * completed submit of (runnable, result) returns result
- */
- public void testSubmitRunnable2() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
- String result = future.get();
- assertSame(TEST_STRING, result);
- }
- catch (ExecutionException ex) {
- unexpectedException();
- }
- catch (InterruptedException ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
-
-
-
-
- /**
- * invokeAny(null) throws NPE
- */
- public void testInvokeAny1() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- e.invokeAny(null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(empty collection) throws IAE
- */
- public void testInvokeAny2() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- e.invokeAny(new ArrayList<Callable<String>>());
- } catch (IllegalArgumentException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) throws NPE if c has null elements
- */
- public void testInvokeAny3() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAny(l);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) throws ExecutionException if no task completes
- */
- public void testInvokeAny4() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- e.invokeAny(l);
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAny(c) returns result of some task
- */
- public void testInvokeAny5() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- String result = e.invokeAny(l);
- assertSame(TEST_STRING, result);
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(null) throws NPE
- */
- public void testInvokeAll1() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- e.invokeAll(null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(empty collection) returns empty collection
- */
- public void testInvokeAll2() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
- assertTrue(r.isEmpty());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(c) throws NPE if c has null elements
- */
- public void testInvokeAll3() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAll(l);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * get of element of invokeAll(c) throws exception on failed task
- */
- public void testInvokeAll4() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- List<Future<String>> result = e.invokeAll(l);
- assertEquals(1, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- it.next().get();
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * invokeAll(c) returns results of all completed tasks
- */
- public void testInvokeAll5() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l);
- assertEquals(2, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- assertSame(TEST_STRING, it.next().get());
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
-
-
- /**
- * timed invokeAny(null) throws NPE
- */
- public void testTimedInvokeAny1() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(,,null) throws NPE
- */
- public void testTimedInvokeAnyNullTimeUnit() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- e.invokeAny(l, MEDIUM_DELAY_MS, null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(empty collection) throws IAE
- */
- public void testTimedInvokeAny2() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (IllegalArgumentException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) throws NPE if c has null elements
- */
- public void testTimedInvokeAny3() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- ex.printStackTrace();
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) throws ExecutionException if no task completes
- */
- public void testTimedInvokeAny4() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAny(c) returns result of some task
- */
- public void testTimedInvokeAny5() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertSame(TEST_STRING, result);
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(null) throws NPE
- */
- public void testTimedInvokeAll1() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(,,null) throws NPE
- */
- public void testTimedInvokeAllNullTimeUnit() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- e.invokeAll(l, MEDIUM_DELAY_MS, null);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(empty collection) returns empty collection
- */
- public void testTimedInvokeAll2() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertTrue(r.isEmpty());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(c) throws NPE if c has null elements
- */
- public void testTimedInvokeAll3() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(null);
- e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- } catch (NullPointerException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * get of element of invokeAll(c) throws exception on failed task
- */
- public void testTimedInvokeAll4() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new NPETask());
- List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(1, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- it.next().get();
- } catch(ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(c) returns results of all completed tasks
- */
- public void testTimedInvokeAll5() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(2, result.size());
- for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
- assertSame(TEST_STRING, it.next().get());
- } catch (ExecutionException success) {
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * timed invokeAll(c) cancels tasks not completed by timeout
- */
- public void testTimedInvokeAll6() {
- ExecutorService e = new ThreadPoolExecutor(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- l.add(new StringTask());
- l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
- l.add(new StringTask());
- List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
- assertEquals(3, result.size());
- Iterator<Future<String>> it = result.iterator();
- Future<String> f1 = it.next();
- Future<String> f2 = it.next();
- Future<String> f3 = it.next();
- assertTrue(f1.isDone());
- assertTrue(f2.isDone());
- assertTrue(f3.isDone());
- assertFalse(f1.isCancelled());
- assertTrue(f2.isCancelled());
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * Execution continues if there is at least one thread even if
- * thread factory fails to create more
- */
- public void testFailingThreadFactory() {
- ExecutorService e = new ThreadPoolExecutor(100, 100, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new FailingThreadFactory());
- try {
- ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
- for (int k = 0; k < 100; ++k) {
- e.execute(new NoOpRunnable());
- }
- Thread.sleep(LONG_DELAY_MS);
- } catch(Exception ex) {
- unexpectedException();
- } finally {
- joinPool(e);
- }
- }
-
- /**
- * execute allows the same task to be submitted multiple times, even
- * if rejected
- */
- public void testRejectedRecycledTask() {
- final int nTasks = 1000;
- final AtomicInteger nRun = new AtomicInteger(0);
- final Runnable recycledTask = new Runnable() {
- public void run() {
- nRun.getAndIncrement();
- } };
- final ThreadPoolExecutor p =
- new ThreadPoolExecutor(1, 30, 60, TimeUnit.SECONDS,
- new ArrayBlockingQueue(30));
- try {
- for (int i = 0; i < nTasks; ++i) {
- for (;;) {
- try {
- p.execute(recycledTask);
- break;
- }
- catch (RejectedExecutionException ignore) {
- }
- }
- }
- Thread.sleep(5000); // enough time to run all tasks
- assertEquals(nRun.get(), nTasks);
- } catch(Exception ex) {
- ex.printStackTrace();
- unexpectedException();
- } finally {
- p.shutdown();
- }
- }
-
-}
diff --git a/concurrent/src/test/java/ThreadTest.java b/concurrent/src/test/java/ThreadTest.java
deleted file mode 100644
index 892ca69..0000000
--- a/concurrent/src/test/java/ThreadTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-import junit.framework.*;
-
-public class ThreadTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new TestSuite(ThreadTest.class);
- }
-
- static class MyHandler implements Thread.UncaughtExceptionHandler {
- public void uncaughtException(Thread t, Throwable e) {
- e.printStackTrace();
- }
- }
-
- /**
- * getUncaughtExceptionHandler returns ThreadGroup unless set,
- * otherwise returning value of last setUncaughtExceptionHandler.
- */
- public void testGetAndSetUncaughtExceptionHandler() {
- // these must be done all at once to avoid state
- // dependencies across tests
- Thread current = Thread.currentThread();
- ThreadGroup tg = current.getThreadGroup();
- MyHandler eh = new MyHandler();
- assertEquals(tg, current.getUncaughtExceptionHandler());
- current.setUncaughtExceptionHandler(eh);
- assertEquals(eh, current.getUncaughtExceptionHandler());
- current.setUncaughtExceptionHandler(null);
- assertEquals(tg, current.getUncaughtExceptionHandler());
- }
-
- /**
- * getDefaultUncaughtExceptionHandler returns value of last
- * setDefaultUncaughtExceptionHandler.
- */
- public void testGetAndSetDefaultUncaughtExceptionHandler() {
- assertEquals(null, Thread.getDefaultUncaughtExceptionHandler());
- // failure due to securityException is OK.
- // Would be nice to explicitly test both ways, but cannot yet.
- try {
- Thread current = Thread.currentThread();
- ThreadGroup tg = current.getThreadGroup();
- MyHandler eh = new MyHandler();
- Thread.setDefaultUncaughtExceptionHandler(eh);
- assertEquals(eh, Thread.getDefaultUncaughtExceptionHandler());
- Thread.setDefaultUncaughtExceptionHandler(null);
- }
- catch(SecurityException ok) {
- }
- assertEquals(null, Thread.getDefaultUncaughtExceptionHandler());
- }
-
-
- // How to test actually using UEH within junit?
-
-}
-
diff --git a/concurrent/src/test/java/TimeUnitTest.java b/concurrent/src/test/java/TimeUnitTest.java
deleted file mode 100644
index afb8c7d..0000000
--- a/concurrent/src/test/java/TimeUnitTest.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- * Other contributors include Andrew Wright, Jeffrey Hayes,
- * Pat Fisher, Mike Judd.
- */
-
-
-import junit.framework.*;
-import java.util.concurrent.*;
-import java.io.*;
-
-public class TimeUnitTest extends JSR166TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new TestSuite(TimeUnitTest.class);
- }
-
- // (loops to 88888 check increments at all time divisions.)
-
- /**
- * convert correctly converts sample values across the units
- */
- public void testConvert() {
- for (long t = 0; t < 88888; ++t) {
- assertEquals(t,
- TimeUnit.SECONDS.convert(t,
- TimeUnit.SECONDS));
- assertEquals(t,
- TimeUnit.SECONDS.convert(1000L*t,
- TimeUnit.MILLISECONDS));
- assertEquals(t,
- TimeUnit.SECONDS.convert(1000000L*t,
- TimeUnit.MICROSECONDS));
- assertEquals(t,
- TimeUnit.SECONDS.convert(1000000000L*t,
- TimeUnit.NANOSECONDS));
-
-
- assertEquals(1000L*t,
- TimeUnit.MILLISECONDS.convert(t,
- TimeUnit.SECONDS));
- assertEquals(t,
- TimeUnit.MILLISECONDS.convert(t,
- TimeUnit.MILLISECONDS));
- assertEquals(t,
- TimeUnit.MILLISECONDS.convert(1000L*t,
- TimeUnit.MICROSECONDS));
- assertEquals(t,
- TimeUnit.MILLISECONDS.convert(1000000L*t,
- TimeUnit.NANOSECONDS));
-
- assertEquals(1000000L*t,
- TimeUnit.MICROSECONDS.convert(t,
- TimeUnit.SECONDS));
- assertEquals(1000L*t,
- TimeUnit.MICROSECONDS.convert(t,
- TimeUnit.MILLISECONDS));
- assertEquals(t,
- TimeUnit.MICROSECONDS.convert(t,
- TimeUnit.MICROSECONDS));
- assertEquals(t,
- TimeUnit.MICROSECONDS.convert(1000L*t,
- TimeUnit.NANOSECONDS));
-
- assertEquals(1000000000L*t,
- TimeUnit.NANOSECONDS.convert(t,
- TimeUnit.SECONDS));
- assertEquals(1000000L*t,
- TimeUnit.NANOSECONDS.convert(t,
- TimeUnit.MILLISECONDS));
- assertEquals(1000L*t,
- TimeUnit.NANOSECONDS.convert(t,
- TimeUnit.MICROSECONDS));
- assertEquals(t,
- TimeUnit.NANOSECONDS.convert(t,
- TimeUnit.NANOSECONDS));
- }
- }
-
- /**
- * toNanos correctly converts sample values in different units to
- * nanoseconds
- */
- public void testToNanos() {
- for (long t = 0; t < 88888; ++t) {
- assertEquals(1000000000L*t,
- TimeUnit.SECONDS.toNanos(t));
- assertEquals(1000000L*t,
- TimeUnit.MILLISECONDS.toNanos(t));
- assertEquals(1000L*t,
- TimeUnit.MICROSECONDS.toNanos(t));
- assertEquals(t,
- TimeUnit.NANOSECONDS.toNanos(t));
- }
- }
-
- /**
- * toMicros correctly converts sample values in different units to
- * microseconds
- */
- public void testToMicros() {
- for (long t = 0; t < 88888; ++t) {
- assertEquals(1000000L*t,
- TimeUnit.SECONDS.toMicros(t));
- assertEquals(1000L*t,
- TimeUnit.MILLISECONDS.toMicros(t));
- assertEquals(t,
- TimeUnit.MICROSECONDS.toMicros(t));
- assertEquals(t,
- TimeUnit.NANOSECONDS.toMicros(t*1000L));
- }
- }
-
- /**
- * toMillis correctly converts sample values in different units to
- * milliseconds
- */
- public void testToMillis() {
- for (long t = 0; t < 88888; ++t) {
- assertEquals(1000L*t,
- TimeUnit.SECONDS.toMillis(t));
- assertEquals(t,
- TimeUnit.MILLISECONDS.toMillis(t));
- assertEquals(t,
- TimeUnit.MICROSECONDS.toMillis(t*1000L));
- assertEquals(t,
- TimeUnit.NANOSECONDS.toMillis(t*1000000L));
- }
- }
-
- /**
- * toSeconds correctly converts sample values in different units to
- * seconds
- */
- public void testToSeconds() {
- for (long t = 0; t < 88888; ++t) {
- assertEquals(t,
- TimeUnit.SECONDS.toSeconds(t));
- assertEquals(t,
- TimeUnit.MILLISECONDS.toSeconds(t*1000L));
- assertEquals(t,
- TimeUnit.MICROSECONDS.toSeconds(t*1000000L));
- assertEquals(t,
- TimeUnit.NANOSECONDS.toSeconds(t*1000000000L));
- }
- }
-
- /**
- * convert saturates positive too-large values to Long.MAX_VALUE
- * and negative to LONG.MIN_VALUE
- */
- public void testConvertSaturate() {
- assertEquals(Long.MAX_VALUE,
- TimeUnit.NANOSECONDS.convert(Long.MAX_VALUE / 2,
- TimeUnit.SECONDS));
- assertEquals(Long.MIN_VALUE,
- TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4,
- TimeUnit.SECONDS));
- }
-
- /**
- * toNanos saturates positive too-large values to Long.MAX_VALUE
- * and negative to LONG.MIN_VALUE
- */
- public void testToNanosSaturate() {
- assertEquals(Long.MAX_VALUE,
- TimeUnit.MILLISECONDS.toNanos(Long.MAX_VALUE / 2));
- assertEquals(Long.MIN_VALUE,
- TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3));
- }
-
-
- /**
- * toString returns string containing common name of unit
- */
- public void testToString() {
- String s = TimeUnit.SECONDS.toString();
- assertTrue(s.indexOf("ECOND") >= 0);
- }
-
-
- /**
- * Timed wait without holding lock throws
- * IllegalMonitorStateException
- */
- public void testTimedWait_IllegalMonitorException() {
- //created a new thread with anonymous runnable
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- Object o = new Object();
- TimeUnit tu = TimeUnit.MILLISECONDS;
- try {
- tu.timedWait(o,LONG_DELAY_MS);
- threadShouldThrow();
- }
- catch (InterruptedException ie) {
- threadUnexpectedException();
- }
- catch(IllegalMonitorStateException success) {
- }
-
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * timedWait throws InterruptedException when interrupted
- */
- public void testTimedWait() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- Object o = new Object();
-
- TimeUnit tu = TimeUnit.MILLISECONDS;
- try {
- synchronized(o) {
- tu.timedWait(o,MEDIUM_DELAY_MS);
- }
- threadShouldThrow();
- }
- catch(InterruptedException success) {}
- catch(IllegalMonitorStateException failure) {
- threadUnexpectedException();
- }
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(Exception e) {
- unexpectedException();
- }
- }
-
-
- /**
- * timedJoin throws InterruptedException when interrupted
- */
- public void testTimedJoin() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- TimeUnit tu = TimeUnit.MILLISECONDS;
- try {
- Thread s = new Thread(new Runnable() {
- public void run() {
- try {
- Thread.sleep(MEDIUM_DELAY_MS);
- } catch(InterruptedException success){}
- }
- });
- s.start();
- tu.timedJoin(s,MEDIUM_DELAY_MS);
- threadShouldThrow();
- }
- catch(Exception e) {}
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * timedSleep throws InterruptedException when interrupted
- */
- public void testTimedSleep() {
- //created a new thread with anonymous runnable
-
- Thread t = new Thread(new Runnable() {
- public void run() {
- TimeUnit tu = TimeUnit.MILLISECONDS;
- try {
- tu.sleep(MEDIUM_DELAY_MS);
- threadShouldThrow();
- }
- catch(InterruptedException success) {}
- }
- });
- t.start();
- try {
- Thread.sleep(SHORT_DELAY_MS);
- t.interrupt();
- t.join();
- } catch(Exception e) {
- unexpectedException();
- }
- }
-
- /**
- * a deserialized serialized unit is equal
- */
- public void testSerialization() {
- TimeUnit q = TimeUnit.MILLISECONDS;
-
- try {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
- out.writeObject(q);
- out.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
- TimeUnit r = (TimeUnit)in.readObject();
-
- assertEquals(q.toString(), r.toString());
- } catch(Exception e){
- e.printStackTrace();
- unexpectedException();
- }
- }
-
-}
diff --git a/crypto/src/test/api/java.injected/javax/crypto/spec/PSourceTest.java b/crypto/src/test/api/java.injected/javax/crypto/spec/PSourceTest.java
index ec53c98..d405978 100644
--- a/crypto/src/test/api/java.injected/javax/crypto/spec/PSourceTest.java
+++ b/crypto/src/test/api/java.injected/javax/crypto/spec/PSourceTest.java
@@ -106,8 +106,4 @@
return new TestSuite(PSourceTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java
index 6ba083b..4fd2830 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java
@@ -45,7 +45,7 @@
/**
* Tests for Mac class constructors and methods
- *
+ *
*/
public class MacTest extends TestCase {
@@ -53,7 +53,7 @@
public static final String srvMac = "Mac";
private static String defaultAlgorithm = null;
-
+
private static String defaultProviderName = null;
private static Provider defaultProvider = null;
@@ -65,11 +65,11 @@
private static final String[] invalidValues = SpiEngUtils.invalidValues;
private static String[] validValues = new String[3];
-
- public static final String validAlgorithmsMac [] =
+
+ public static final String validAlgorithmsMac [] =
{"HmacSHA1", "HmacMD5", "HmacSHA256", "HmacSHA384", "HmacSHA512"};
-
+
static {
for (int i = 0; i < validAlgorithmsMac.length; i++) {
defaultProvider = SpiEngUtils.isSupport(validAlgorithmsMac[i],
@@ -104,7 +104,7 @@
/**
* Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
+ * Assertion:
* throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not available
*/
@@ -121,10 +121,10 @@
fail("NoSuchAlgorithmException must be thrown when algorithm is not available: "
.concat(invalidValues[i]));
} catch (NoSuchAlgorithmException e) {
- }
+ }
}
}
-
+
/**
* Test for <code>getInstance(String algorithm)</code> method
* Assertion: returns Mac object
@@ -142,7 +142,7 @@
}
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
+ * Assertion:
* throws IllegalArgumentException when provider is null or empty
* throws NoSuchProviderException when provider is not available
*/
@@ -174,14 +174,14 @@
}
}
}
-
+
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
+ * Assertion:
* throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not available
*/
- public void testMac04() throws NoSuchAlgorithmException,
+ public void testMac04() throws NoSuchAlgorithmException,
IllegalArgumentException, NoSuchProviderException {
if (!DEFSupported) {
fail(NotSupportedMsg);
@@ -216,7 +216,7 @@
for (int i = 0; i < validValues.length; i++) {
mac = Mac.getInstance(validValues[i], defaultProviderName);
assertEquals("Incorrect algorithm", mac.getAlgorithm(), validValues[i]);
- assertEquals("Incorrect provider", mac.getProvider().getName(),
+ assertEquals("Incorrect provider", mac.getProvider().getName(),
defaultProviderName);
}
}
@@ -241,11 +241,11 @@
}
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code> method
- * Assertion:
+ * Assertion:
* throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not available
*/
- public void testMac07() throws NoSuchAlgorithmException,
+ public void testMac07() throws NoSuchAlgorithmException,
NoSuchProviderException, IllegalArgumentException {
if (!DEFSupported) {
fail(NotSupportedMsg);
@@ -266,7 +266,7 @@
}
}
}
-
+
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code> method
* Assertion: returns Mac object
@@ -317,7 +317,7 @@
macs[i].update(bBuf);
fail("IllegalStateException must be thrown");
} catch (IllegalStateException e) {
- }
+ }
try {
macs[i].doFinal();
fail("IllegalStateException must be thrown");
@@ -337,8 +337,8 @@
}
/**
* Test for <code>doFinal(byte[] output, int outOffset)</code> method
- * Assertion:
- * throws ShotBufferException when outOffset is negative or
+ * Assertion:
+ * throws ShotBufferException when outOffset is negative or
* outOffset >= output.length or when given buffer is small
*/
public void testMac10() throws NoSuchAlgorithmException,
@@ -374,7 +374,7 @@
macs[i].doFinal(new byte[1], 0);
fail("ShortBufferException must be thrown");
} catch (ShortBufferException e) {
- }
+ }
byte[] res = macs[i].doFinal();
try {
macs[i].doFinal(new byte[res.length - 1], 0);
@@ -383,7 +383,7 @@
}
}
}
-
+
/**
* Test for <code>doFinal(byte[] output, int outOffset)</code> and
* <code>doFinal()</code> methods Assertion: Mac result is stored in
@@ -430,7 +430,7 @@
for (int i = 0; i < macs.length; i++) {
macs[i].init(scs);
byte [] res1 = macs[i].doFinal();
- byte [] res2 = macs[i].doFinal();
+ byte [] res2 = macs[i].doFinal();
assertEquals("Results are not the same", res1.length, res2.length);
for(int t = 0; t < res1.length; t++) {
assertEquals("Results are not the same", res1[t], res2[t]);
@@ -444,13 +444,13 @@
}
}
}
-
+
/**
* Test for <code>update(byte[] input, int outset, int len)</code> method
* Assertion: throws IllegalArgumentException when offset or len is negative,
* offset + len >= input.length
*/
- public void testMac13() throws NoSuchAlgorithmException,
+ public void testMac13() throws NoSuchAlgorithmException,
NoSuchProviderException, IllegalArgumentException, IllegalStateException,
InvalidKeyException {
if (!DEFSupported) {
@@ -482,16 +482,16 @@
macs[i].update(b, b.length - 1, 2);
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e) {
- }
+ }
}
- }
+ }
/**
* Test for <code>update(byte[] input, int outset, int len)</code> and
- * <code>update(byte[] input</code>
+ * <code>update(byte[] input</code>
* methods
* Assertion: updates Mac
*/
- public void testMac14() throws NoSuchAlgorithmException,
+ public void testMac14() throws NoSuchAlgorithmException,
NoSuchProviderException, IllegalArgumentException, IllegalStateException,
InvalidKeyException {
if (!DEFSupported) {
@@ -528,11 +528,11 @@
assertEquals("Results are not the same", res1[t], res2[t]);
}
}
- }
+ }
/**
* Test for <code>clone()</code> method
* Assertion: returns Mac object or throws CloneNotSupportedException
- */
+ */
public void testMacClone() throws NoSuchAlgorithmException, CloneNotSupportedException {
if (!DEFSupported) {
fail(NotSupportedMsg);
@@ -551,13 +551,13 @@
}
}
/**
- * Test for
- * <code>init(Key key, AlgorithmParameterSpec params)</code>
- * <code>init(Key key)</code>
+ * Test for
+ * <code>init(Key key, AlgorithmParameterSpec params)</code>
+ * <code>init(Key key)</code>
* methods
* Assertion: throws InvalidKeyException and InvalidAlgorithmParameterException
- * when parameters are not appropriate
- */
+ * when parameters are not appropriate
+ */
public void testInit() throws NoSuchAlgorithmException, NoSuchProviderException,
IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException,
InvalidKeyException {
@@ -581,23 +581,23 @@
try {
macs[i].init(null, null);
fail("InvalidKeyException must be thrown");
- } catch (InvalidKeyException e) {
+ } catch (InvalidKeyException e) {
}
try {
macs[i].init(null);
fail("InvalidKeyException must be thrown");
- } catch (InvalidKeyException e) {
- }
+ } catch (InvalidKeyException e) {
+ }
}
}
-
+
/**
* Test for <code>update(ByteBuffer input)</code>
* <code>update(byte[] input, int offset, int len)</code>
* methods
- * Assertion: processes Mac; if input is null then do nothing
- */
+ * Assertion: processes Mac; if input is null then do nothing
+ */
public void testUpdateByteBuffer01() throws NoSuchAlgorithmException, NoSuchProviderException,
IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException,
InvalidKeyException {
@@ -632,15 +632,15 @@
bb2 = macs[i].doFinal();
for (int t = 0; t < bb1.length; t++) {
assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
- }
+ }
}
}
/**
* Test for <code>update(ByteBuffer input)</code>
* <code>update(byte[] input, int offset, int len)</code>
* methods
- * Assertion: processes Mac
- */
+ * Assertion: processes Mac
+ */
public void testUpdateByteBuffer02() throws NoSuchAlgorithmException, NoSuchProviderException,
IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException,
InvalidKeyException {
@@ -657,13 +657,13 @@
byte [] bb1;
byte [] bb2;
for (int i = 0; i < macs.length; i++) {
- byteBuf = ByteBuffer.allocate(5);
+ byteBuf = ByteBuffer.allocate(5);
byteBuf.put(bbuf);
- byteBuf.position(2);
- macs[i].init(sks);
- macs[i].update(byteBuf);
+ byteBuf.position(2);
+ macs[i].init(sks);
+ macs[i].update(byteBuf);
bb1 = macs[i].doFinal();
-
+
macs[i].init(sks);
macs[i].update(bbuf, 2, 3);
bb2 = macs[i].doFinal();
@@ -674,8 +674,8 @@
}
/**
* Test for <code>clone()</code> method
- * Assertion: clone if provider is clo
- */
+ * Assertion: clone if provider is clo
+ */
public void testClone() {
if (!DEFSupported) {
fail(NotSupportedMsg);
@@ -708,11 +708,11 @@
assertTrue("Length should be positive", (macs[i].getMacLength() >= 0));
}
}
-
+
/**
* Test for <code>reset()</code> method
* Assertion: return Mac length
- */
+ */
public void testReset() throws InvalidKeyException {
if (!DEFSupported) {
fail(NotSupportedMsg);
@@ -728,26 +728,26 @@
for (int i = 0; i < macs.length; i++) {
macs[i].init(sks);
bb1 = macs[i].doFinal();
- macs[i].reset();
+ macs[i].reset();
bb2 = macs[i].doFinal();
assertEquals("incorrect result",bb1.length, bb2.length);
for (int t = 0; t < bb1.length; t++) {
- assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
+ assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
}
macs[i].reset();
macs[i].update(bbuf);
bb1 = macs[i].doFinal();
- macs[i].reset();
+ macs[i].reset();
macs[i].update(bbuf, 0, bbuf.length);
bb2 = macs[i].doFinal();
assertEquals("incorrect result",bb1.length, bb2.length);
for (int t = 0; t < bb1.length; t++) {
- assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
- }
+ assertEquals("Incorrect doFinal result", bb1[t], bb2[t]);
+ }
}
}
/**
- * Test for <code>Mac</code> constructor
+ * Test for <code>Mac</code> constructor
* Assertion: returns Mac object
*/
public void testMacConstructor() throws NoSuchAlgorithmException,
@@ -767,7 +767,7 @@
} catch (Exception e) {
}
assertEquals("Invalid mac length", mac.getMacLength(), 0);
-
+
mac = new myMac(null, null, null);
assertNull("Algorithm must be null", mac.getAlgorithm());
assertNull("Provider must be null", mac.getProvider());
@@ -782,15 +782,11 @@
} catch (NullPointerException e) {
}
}
-
+
public static Test suite() {
return new TestSuite(MacTest.class);
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
-
- }
}
/**
* Additional class for Mac constructor verification
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java
index 42d6102..a1ab0bc 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/BadPaddingExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for BadPaddingException serialization
- *
+ *
*/
public class BadPaddingExceptionTest extends SerializationTest {
@@ -42,7 +42,4 @@
new BadPaddingException(null), new BadPaddingException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BadPaddingExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java
index 17bd8ef..ca0ecf7 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ExemptionMechanismExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for ExemptionMechanismException serialization
- *
+ *
*/
public class ExemptionMechanismExceptionTest extends SerializationTest {
@@ -42,7 +42,4 @@
new ExemptionMechanismException(null), new ExemptionMechanismException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(ExemptionMechanismExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java
index eb9bc19..27eb229 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/IllegalBlockSizeExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for IllegalBlockSizeException serialization
- *
+ *
*/
public class IllegalBlockSizeExceptionTest extends SerializationTest {
@@ -42,7 +42,4 @@
new IllegalBlockSizeException(null), new IllegalBlockSizeException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(IllegalBlockSizeExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java
index 34072bd..7d10dfe 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/NoSuchPaddingExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for NuSuchPaddingException serialization
- *
+ *
*/
public class NoSuchPaddingExceptionTest extends SerializationTest {
@@ -42,7 +42,4 @@
new NoSuchPaddingException(null), new NoSuchPaddingException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(NoSuchPaddingExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java
index 21d510b..0a2b169 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/serialization/ShortBufferExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for ShortBufferException serialization
- *
+ *
*/
public class ShortBufferExceptionTest extends SerializationTest {
@@ -42,7 +42,4 @@
new ShortBufferException(null), new ShortBufferException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(ShortBufferExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java
index ddedfcc..1ca8674 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java
@@ -39,7 +39,7 @@
// Got from:
// FIP PUB 74
// FEDERAL INFORMATION PROCESSING STANDARDS PUBLICATION 1981
- // GUIDELINES FOR IMPLEMENTING AND USING THE NBS DATA ENCRYPTION STANDARD
+ // GUIDELINES FOR IMPLEMENTING AND USING THE NBS DATA ENCRYPTION STANDARD
// http://www.dice.ucl.ac.be/crypto/standards/fips/fip74/fip74-1.pdf
private static final byte[][] semiweaks = {
{(byte) 0xE0, (byte) 0x01, (byte) 0xE0, (byte) 0x01,
@@ -78,7 +78,7 @@
{(byte) 0xFE, (byte) 0xE0, (byte) 0xFE, (byte) 0xE0,
(byte) 0xFE, (byte) 0xF1, (byte) 0xFE, (byte) 0xF1},
- {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
+ {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01},
{(byte) 0xFE, (byte) 0xFE, (byte) 0xFE, (byte) 0xFE,
@@ -155,7 +155,7 @@
/**
* getKey() method testing. Checks that modification of returned key
* does not affect the internal key. Also test check an equality of
- * the key with the key specified in the constructor. The object under
+ * the key with the key specified in the constructor. The object under
* the test is created by different constructors.
*/
public void testGetKey() {
@@ -241,7 +241,7 @@
/**
* isWeak(byte[] key, int offset) method testing. Tests if the
* method throws appropriate exceptions on incorrect byte array, if
- * it returns true on weak or semi-weak keys, and if it returns
+ * it returns true on weak or semi-weak keys, and if it returns
* false on other keys.
*/
public void testIsWeak() {
@@ -286,8 +286,4 @@
return new TestSuite(DESKeySpecTest.class);
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java
index 6f99ada..a1fd0ce 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESedeKeySpecTest.java
@@ -98,7 +98,7 @@
/**
* getKey() method testing. Checks that modification of returned key
* does not affect the internal key. Also test check an equality of
- * the key with the key specified in the constructor. The object under
+ * the key with the key specified in the constructor. The object under
* the test is created by different constructors.
*/
public void testGetKey() {
@@ -194,8 +194,4 @@
return new TestSuite(DESedeKeySpecTest.class);
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java
index 903df61..76befd9 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHGenParameterSpecTest.java
@@ -58,8 +58,4 @@
return new TestSuite(DHGenParameterSpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java
index 9b51047..a921b2a 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHParameterSpecTest.java
@@ -73,8 +73,4 @@
return new TestSuite(DHParameterSpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java
index 009b8af..6c9b557 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPrivateKeySpecTest.java
@@ -63,8 +63,4 @@
return new TestSuite(DHPrivateKeySpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java
index c7fb962..8b9b81e 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DHPublicKeySpecTest.java
@@ -63,8 +63,4 @@
return new TestSuite(DHPublicKeySpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java
index 911c92a..b1dce3b 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/IvParameterSpecTest.java
@@ -136,8 +136,4 @@
return new TestSuite(IvParameterSpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java
index 4e94392..58e2293 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/OAEPParameterSpecTest.java
@@ -158,8 +158,4 @@
return new TestSuite(OAEPParameterSpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java
index 0f4d04d..36c9a8a 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEKeySpecTest.java
@@ -302,8 +302,4 @@
return new TestSuite(PBEKeySpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java
index b0d9af3..b1eeaa3 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/PBEParameterSpecTest.java
@@ -94,8 +94,4 @@
return new TestSuite(PBEParameterSpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java
index b157c12..8522880 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC2ParameterSpecTest.java
@@ -197,8 +197,4 @@
return new TestSuite(RC2ParameterSpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
index b4160d2..ac5ff3d 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
@@ -279,8 +279,4 @@
return new TestSuite(RC5ParameterSpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
index ba9f752..c90346d 100644
--- a/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
+++ b/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
@@ -263,8 +263,4 @@
return new TestSuite(SecretKeySpecTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
index 86f1e19..2a8496c 100644
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
+++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
@@ -1,13 +1,13 @@
-/*
+/*
* 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.
@@ -30,7 +30,6 @@
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import java.util.logging.LoggerExtension;
import java.util.logging.LoggingPermission;
import junit.framework.TestCase;
@@ -41,7 +40,7 @@
/**
* Test suite for the class java.util.logging.Logger.
- *
+ *
*/
public class LoggerTest extends TestCase {
@@ -52,7 +51,7 @@
private final static String VALID_RESOURCE_BUNDLE3 = "bundles/java/util/logging/res3";
private final static String INVALID_RESOURCE_BUNDLE = "impossible_not_existing";
-
+
private final static String LOGGING_CONFIG_FILE= "resources/config/java/util/logging/logging.config";
private final static String VALID_KEY = "LOGGERTEST";
@@ -64,7 +63,7 @@
private Logger sharedLogger = null;
private Locale oldLocale = null;
-
+
/*
* @see TestCase#setUp()
*/
@@ -87,7 +86,7 @@
/**
* Constructor for LoggerTest.
- *
+ *
* @param arg0
*/
public LoggerTest(String arg0) {
@@ -113,7 +112,7 @@
/*
* Test constructor under normal conditions.
- *
+ *
* TODO: using a series of class loaders to load resource bundles
*/
public void testConstructor_Normal() {
@@ -322,7 +321,7 @@
}
Logger logger = Logger.getLogger("", null);
assertNull(logger.getResourceBundleName());
- assertNull(logger.getResourceBundle());
+ assertNull(logger.getResourceBundle());
}
/*
@@ -2726,7 +2725,7 @@
assertNull(r.getParameters()[0]);
assertSame(r.getThrown(), null);
}
-
+
/**
* @tests java.util.logging.Logger#logrb(Level, String, String, String,
* String, Object)
@@ -3400,7 +3399,7 @@
* Test whether privileged code is used to load resource bundles.
*/
public void testLoadResourceBundle() {
- //
+ //
SecurityManager oldMan = System.getSecurityManager();
System.setSecurityManager(new MockNoLoadingClassSecurityManager());
try {
@@ -3409,18 +3408,20 @@
System.setSecurityManager(oldMan);
}
}
-
- public void testLoadResourceBundleNonExistent() {
- try {
- // Try a load a non-existent resource bundle.
- LoggerExtension.loadResourceBundle("missinglogger.properties");
- fail("Expected an exception.");
- } catch (MissingResourceException ex) {
- // Expected exception is precisely a MissingResourceException
- assertTrue(ex.getClass() == MissingResourceException.class);
+
+ /* Logger.loadResourceBundle is not publicly accessible in Android
+ public void testLoadResourceBundleNonExistent() {
+ try {
+ // Try a load a non-existent resource bundle.
+ LoggerExtension.loadResourceBundle("missinglogger.properties");
+ fail("Expected an exception.");
+ } catch (MissingResourceException ex) {
+ // Expected exception is precisely a MissingResourceException
+ assertTrue(ex.getClass() == MissingResourceException.class);
+ }
}
- }
-
+ */
+
/**
* @tests java.util.logging.Logger#logrb(Level, String, String, String,
* String, Object)
@@ -3456,7 +3457,7 @@
System.setSecurityManager(originalSecurityManager);
}
}
-
+
/*
* test initHandler
*/
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java
index e47b188..1f2e261 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java
@@ -821,7 +821,7 @@
* Returns the file name of the key/trust store. The key store file (named
* as "key_store." + extension equals to the default KeyStore type installed
* in the system in lower case) is searched in classpath.
- *
+ *
* @throws AssertionFailedError
* if property was not set or file does not exist.
*/
@@ -984,7 +984,7 @@
/**
* Performs interaction between client's HttpURLConnection and servers side
* (ServerSocket). Server will response with specified response code.
- *
+ *
* @param doAuthentication
* specifies if the server needs client authentication.
*/
@@ -1177,7 +1177,7 @@
/**
* Creates the thread acting as a server side.
- *
+ *
* @param serverSocket
* the server socket to be used during connection
* @param responseCode
@@ -1395,7 +1395,7 @@
/**
* Creates the thread acting as a client side.
- *
+ *
* @param connection
* connection to be used to contact the server side
*/
@@ -1452,7 +1452,4 @@
return new TestSuite(HttpsURLConnectionTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/Character_SubsetTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/Character_SubsetTest.java
index bce4a3c..0a715d1 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/Character_SubsetTest.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/Character_SubsetTest.java
@@ -46,7 +46,4 @@
assertSame(name, subset.toString());
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(Character_SubsetTest.class);
- }
}
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/util/Base64Test.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/util/Base64Test.java
index cb4f398..ca92d8a 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/util/Base64Test.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/util/Base64Test.java
@@ -42,8 +42,4 @@
return new TestSuite(Base64Test.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/io/FileCanonPathCacheTest.java b/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/io/FileCanonPathCacheTest.java
deleted file mode 100644
index 150d469..0000000
--- a/luni/src/test/impl/common/org/apache/harmony/luni/tests/java/io/FileCanonPathCacheTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.harmony.luni.tests.java.io;
-
-import java.io.File;
-
-import org.apache.harmony.luni.internal.io.FileCanonPathCache;
-
-import junit.framework.TestCase;
-
-public class FileCanonPathCacheTest extends TestCase {
-
- private static int DEFAULT_TIMEOUT = 600000;
-
- @Override
- public void setUp() throws Exception {
- FileCanonPathCache.clear();
- FileCanonPathCache.setTimeout(DEFAULT_TIMEOUT);
- }
-
- public void testGetSet() throws Exception {
- File file1 = new File("test/hello~1");
- assertNull(FileCanonPathCache.get(file1.getAbsolutePath()));
- FileCanonPathCache.put(file1.getAbsolutePath(), file1
- .getCanonicalPath());
- assertEquals(file1.getCanonicalPath(), FileCanonPathCache.get(file1
- .getAbsolutePath()));
-
- File file2 = new File("test/world~1");
- assertNull(FileCanonPathCache.get(file2.getAbsolutePath()));
- FileCanonPathCache.put(file2.getAbsolutePath(), file2
- .getCanonicalPath());
- assertEquals(file2.getCanonicalPath(), FileCanonPathCache.get(file2
- .getAbsolutePath()));
-
- assertNull(FileCanonPathCache.get("notexist"));
- }
-
- public void testGetTimeout01() throws Exception {
- FileCanonPathCache.setTimeout(10);
-
- File file1 = new File("test/hello~1");
- assertNull(FileCanonPathCache.get(file1.getAbsolutePath()));
- FileCanonPathCache.put(file1.getAbsolutePath(), file1
- .getCanonicalPath());
- Thread.sleep(50);
- assertNull(FileCanonPathCache.get(file1.getAbsolutePath()));
- }
-
- public void testGetTimeout02() throws Exception {
- FileCanonPathCache.setTimeout(10);
-
- File file1 = new File("test/hello~1");
- assertNull(FileCanonPathCache.get(file1.getAbsolutePath()));
- FileCanonPathCache.put(file1.getAbsolutePath(), file1
- .getCanonicalPath());
- File file2 = new File("test/hello~2");
- assertNull(FileCanonPathCache.get(file2.getAbsolutePath()));
- FileCanonPathCache.put(file2.getAbsolutePath(), file2
- .getCanonicalPath());
- File file3 = new File("test/hello~3");
- assertNull(FileCanonPathCache.get(file3.getAbsolutePath()));
- FileCanonPathCache.put(file3.getAbsolutePath(), file3
- .getCanonicalPath());
- File file4 = new File("test/hello~4");
- assertNull(FileCanonPathCache.get(file4.getAbsolutePath()));
- FileCanonPathCache.put(file4.getAbsolutePath(), file4
- .getCanonicalPath());
- File file5 = new File("test/hello~5");
- assertNull(FileCanonPathCache.get(file5.getAbsolutePath()));
- FileCanonPathCache.put(file5.getAbsolutePath(), file5
- .getCanonicalPath());
-
- Thread.sleep(50);
-
- assertNull(FileCanonPathCache.get(file1.getAbsolutePath()));
- assertNull(FileCanonPathCache.get(file2.getAbsolutePath()));
- assertNull(FileCanonPathCache.get(file3.getAbsolutePath()));
- assertNull(FileCanonPathCache.get(file4.getAbsolutePath()));
- assertNull(FileCanonPathCache.get(file5.getAbsolutePath()));
- }
-
- public void testTimeout03() throws Exception {
- FileCanonPathCache.setTimeout(10);
- File file = new File("1");
- FileCanonPathCache.put(file.getAbsolutePath(), file.getAbsolutePath());
- file = new File("2");
- FileCanonPathCache.put(file.getAbsolutePath(), file.getAbsolutePath());
- file = new File("3");
- FileCanonPathCache.put(file.getAbsolutePath(), file.getAbsolutePath());
- Thread.sleep(100);
- FileCanonPathCache.get(file.getAbsolutePath());
- assertNull(FileCanonPathCache.get(new File("1").getAbsolutePath()));
- assertNull(FileCanonPathCache.get(new File("2").getAbsolutePath()));
- }
-
- public void testCacheFull() throws Exception {
- int cacheSize = FileCanonPathCache.CACHE_SIZE;
- File[] files = new File[cacheSize];
- for (int i = 0; i < cacheSize; ++i) {
- files[i] = new File("test/world" + i);
- FileCanonPathCache.put(files[i].getAbsolutePath(), files[i]
- .getCanonicalPath());
- }
-
- for (int i = cacheSize; i < files.length; ++i) {
- assertEquals(files[i - cacheSize].getCanonicalPath(),
- FileCanonPathCache.get(files[i - cacheSize]
- .getAbsolutePath()));
- files[i] = new File("test/world" + i);
- FileCanonPathCache.put(files[i].getAbsolutePath(), files[i]
- .getCanonicalPath());
- assertEquals(files[i].getCanonicalPath(), FileCanonPathCache
- .get(files[i].getAbsolutePath()));
- assertNull(FileCanonPathCache.get(files[i - cacheSize]
- .getAbsolutePath()));
- }
- }
-}
diff --git a/nio/src/test/java/common/org/apache/harmony/nio/tests/AddressUtilTest.java b/nio/src/test/java/common/org/apache/harmony/nio/tests/AddressUtilTest.java
deleted file mode 100644
index cb2c673..0000000
--- a/nio/src/test/java/common/org/apache/harmony/nio/tests/AddressUtilTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/* 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.
- */
-
-package org.apache.harmony.nio.tests;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channel;
-import java.nio.channels.DatagramChannel;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.nio.AddressUtil;
-
-public class AddressUtilTest extends TestCase {
-
- /**
- * @tests AddressUtil#getDirectBufferAddress
- */
- public void test_getDirectBufferAddress() throws Exception {
- ByteBuffer buf = ByteBuffer.allocateDirect(10);
- assertTrue(AddressUtil.getDirectBufferAddress(buf) != 0);
- }
-
- /**
- * @tests AddressUtil#getChannelAddress
- */
- public void test_getFileChannelAddress() throws Exception {
-// FileChannel fc = new FileInputStream("src/main/java/org/apache/harmony/nio/AddressUtil.java").getChannel();
-// assertTrue(AddressUtil.getChannelAddress(fc) > 0);
- }
-
- /**
- * @tests AddressUtil#getChannelAddress
- */
- public void test_getSocketChannelAddress() throws Exception {
- SocketChannel sc = SocketChannel.open();
- assertTrue(AddressUtil.getChannelAddress(sc)>0);
- }
-
- /**
- * @tests AddressUtil#getChannelAddress
- */
- public void test_getDatagramChannelAddress() throws Exception {
- DatagramChannel dc = DatagramChannel.open();
- assertTrue(AddressUtil.getChannelAddress(dc)>0);
- }
-
- /**
- * @tests AddressUtil#getChannelAddress
- */
- public void test_getServerSocketChannelAddress() throws Exception {
- ServerSocketChannel ssc = ServerSocketChannel.open();
- assertTrue(AddressUtil.getChannelAddress(ssc)>0);
- }
-
- /**
- * @tests AddressUtil#getChannelAddress
- */
- public void test_getNonNativeChannelAddress() throws Exception{
- Channel channel = new MockChannel();
- assertEquals(0, AddressUtil.getChannelAddress(channel));
- }
-
- private static class MockChannel implements Channel{
- public boolean isOpen() {
- return false;
- }
- public void close() throws IOException {
- }
- }
-}
-
diff --git a/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java b/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
index 3a0907c..8f41904 100644
--- a/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
+++ b/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
@@ -27,10 +27,6 @@
*/
public class ByteOrderTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(ByteOrderTest.class);
- }
-
public void testToString() {
assertEquals(ByteOrder.BIG_ENDIAN.toString(), "BIG_ENDIAN");
assertEquals(ByteOrder.LITTLE_ENDIAN.toString(), "LITTLE_ENDIAN");
diff --git a/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java b/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
index 91d7eff..9e27cc5 100644
--- a/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
+++ b/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
@@ -40,7 +40,7 @@
/**
* Test for DatagramChannel
- *
+ *
*/
public class DatagramChannelTest extends TestCase {
@@ -281,7 +281,7 @@
/**
* Test method for 'DatagramChannelImpl.socket()'
- *
+ *
* @throws SocketException
*/
public void testSocket_BasicStatusBeforeConnect() throws SocketException {
@@ -295,7 +295,7 @@
/**
* Test method for 'DatagramChannelImpl.socket()'
- *
+ *
* @throws IOException
*/
public void testSocket_Block_BasicStatusAfterConnect() throws IOException {
@@ -308,7 +308,7 @@
}
public void testSocket_NonBlock_BasicStatusAfterConnect()
- throws IOException {
+ throws IOException {
this.channel1.connect(localAddr1);
this.channel1.configureBlocking(false);
DatagramSocket s1 = this.channel1.socket();
@@ -320,7 +320,7 @@
/**
* Test method for 'DatagramChannelImpl.socket()'
- *
+ *
* @throws IOException
*/
public void testSocket_ActionsBeforeConnect() throws IOException {
@@ -331,7 +331,7 @@
/**
* Test method for 'DatagramChannelImpl.socket()'
- *
+ *
* @throws IOException
*/
public void testSocket_Block_ActionsAfterConnect() throws IOException {
@@ -356,7 +356,7 @@
assertFalse(s.getBroadcast());
assertFalse(s.getReuseAddress());
assertNull(s.getInetAddress());
- assertEquals(s.getLocalAddress().isAnyLocalAddress());
+ assertTrue(s.getLocalAddress().isAnyLocalAddress());
assertEquals(s.getLocalPort(), 0);
assertNull(s.getLocalSocketAddress());
assertEquals(s.getPort(), -1);
@@ -451,7 +451,7 @@
/**
* Test method for 'DatagramChannelImpl.isConnected()'
- *
+ *
* @throws IOException
*/
public void testIsConnected_WithServer() throws IOException {
@@ -476,7 +476,7 @@
datagramSocket1.close();
disconnectAfterConnected();
}
-
+
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
*/
@@ -487,7 +487,7 @@
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
*/
public void testConnect_NonBlockWithServer() throws IOException {
@@ -500,7 +500,7 @@
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
*/
public void testConnect_Null() throws IOException {
@@ -515,7 +515,7 @@
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
*/
public void testConnect_UnsupportedType() throws IOException {
@@ -538,7 +538,7 @@
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
*/
public void testConnect_Unresolved() throws IOException {
@@ -563,9 +563,9 @@
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
- *
+ *
*/
public void testConnect_ClosedChannelException() throws IOException {
assertFalse(this.channel1.isConnected());
@@ -581,9 +581,9 @@
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
- *
+ *
*/
public void testConnect_IllegalStateException() throws IOException {
assertFalse(this.channel1.isConnected());
@@ -600,9 +600,9 @@
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
- *
+ *
*/
public void testConnect_CheckOpenBeforeStatus() throws IOException {
assertFalse(this.channel1.isConnected());
@@ -654,7 +654,7 @@
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
public void testDisconnect_BeforeConnect() throws IOException {
@@ -665,7 +665,7 @@
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
public void testDisconnect_UnconnectedClosed() throws IOException {
@@ -678,7 +678,7 @@
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
public void testDisconnect_BlockWithServerChannelClosed()
@@ -692,7 +692,7 @@
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
public void testDisconnect_NonBlockWithServerChannelClosed()
@@ -706,7 +706,7 @@
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
public void testDisconnect_BlockWithServerServerClosed() throws IOException {
@@ -721,7 +721,7 @@
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
public void testDisconnect_NonBlockWithServerServerClosed()
@@ -742,7 +742,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedNull() throws Exception {
@@ -757,7 +757,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedReadonly() throws Exception {
@@ -775,7 +775,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedBufEmpty() throws Exception {
@@ -787,7 +787,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedBufZero() throws Exception {
@@ -798,7 +798,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedBufNotEmpty() throws Exception {
@@ -812,7 +812,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedBufFull() throws Exception {
@@ -826,7 +826,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedClose() throws Exception {
@@ -844,7 +844,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedCloseNull() throws Exception {
@@ -862,7 +862,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_UnconnectedCloseReadonly() throws Exception {
@@ -882,7 +882,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerBufEmpty() throws Exception {
@@ -892,7 +892,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_BlockNoServerNull() throws Exception {
@@ -902,7 +902,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerNull() throws Exception {
@@ -912,7 +912,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_BlockNoServerReadonly() throws Exception {
@@ -922,7 +922,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerReadonly() throws Exception {
@@ -932,7 +932,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerBufZero() throws Exception {
@@ -942,7 +942,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerBufNotEmpty() throws Exception {
@@ -955,7 +955,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerBufFull() throws Exception {
@@ -967,7 +967,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_BlockNoServerChannelClose() throws Exception {
@@ -977,7 +977,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerChannelClose() throws Exception {
@@ -987,7 +987,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_BlockNoServerCloseNull() throws Exception {
@@ -997,7 +997,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerCloseNull() throws Exception {
@@ -1007,7 +1007,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_NonBlockNoServerCloseReadonly() throws Exception {
@@ -1017,7 +1017,7 @@
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
public void testReceive_BlockNoServerCloseReadonly() throws Exception {
@@ -1117,22 +1117,22 @@
private void sendDataBlocking(InetSocketAddress addr, ByteBuffer writeBuf)
throws IOException {
- InetSocketAddress ipAddr = addr;
+ InetSocketAddress ipAddr = addr;
assertEquals(CAPACITY_NORMAL, this.channel1.send(writeBuf, ipAddr));
assertTrue(this.channel1.isOpen());
assertTrue(this.channel1.isBlocking());
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
}
private void sendDataNonBlocking(InetSocketAddress addr, ByteBuffer writeBuf)
throws IOException {
- InetSocketAddress ipAddr = addr;
+ InetSocketAddress ipAddr = addr;
this.channel1.configureBlocking(false);
assertEquals(CAPACITY_NORMAL, this.channel1.send(writeBuf, ipAddr));
assertTrue(this.channel1.isOpen());
assertFalse(this.channel1.isBlocking());
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
}
@@ -1452,7 +1452,7 @@
this.channel1.close();
}
}
-
+
/*
* Fails if the difference between current time and start time is greater
* than timeout.
@@ -1506,7 +1506,7 @@
}
}
- public void testRead_Security() throws Exception {
+ public void testRead_Security() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
String strHello = "hello";
localAddr1 = new InetSocketAddress("127.0.0.1", testPort);
@@ -1525,7 +1525,7 @@
}
}
- public void testReceive_Peek_Security_Nonblocking() throws Exception {
+ public void testReceive_Peek_Security_Nonblocking() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
String strHello = "hello";
localAddr1 = new InetSocketAddress("127.0.0.1", testPort);
@@ -1548,7 +1548,7 @@
private void connectWriteBuf(InetSocketAddress ipAddr, ByteBuffer buf)
throws IOException {
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
assertEquals(CAPACITY_NORMAL, this.channel1.write(buf));
assertEquals(0, this.channel1.write(buf));
@@ -1579,9 +1579,9 @@
public void testWriteByteBuffer_Block_closed() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
noconnectWrite(writeBuf);
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
this.channel1.close();
try {
@@ -1594,11 +1594,11 @@
public void testWriteByteBuffer_NonBlock_closed() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
// non block mode
this.channel1.configureBlocking(false);
noconnectWrite(writeBuf);
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
this.channel1.close();
try {
@@ -1611,14 +1611,14 @@
public void testWriteByteBuffer_Block_BufNull() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(0);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.write((ByteBuffer) null);
fail("Should throw NPE.");
} catch (NullPointerException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
this.channel1.write((ByteBuffer) null);
@@ -1638,7 +1638,7 @@
public void testWriteByteBuffer_NonBlock_BufNull() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(0);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
// non block mode
this.channel1.configureBlocking(false);
@@ -1649,7 +1649,7 @@
} catch (NullPointerException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
this.channel1.write((ByteBuffer) null);
@@ -1674,14 +1674,14 @@
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.write(writeBuf, 0, 2);
fail("Should throw NotYetConnectedException.");
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf, 0, 2));
// cannot be buffered again!
@@ -1693,7 +1693,7 @@
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
// non-block mode
this.channel1.configureBlocking(false);
try {
@@ -1702,7 +1702,7 @@
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf, 0, 2));
// cannot be buffered again!
@@ -1715,7 +1715,7 @@
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.write(writeBuf, -1, 2);
fail("should throw IndexOutOfBoundsException");
@@ -1728,7 +1728,7 @@
} catch (IndexOutOfBoundsException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf, 0, 2));
// cannot be buffered again!
@@ -1740,8 +1740,8 @@
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
- this.channel1.connect(ipAddr);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
this.channel1.write(writeBuf, -1, 2);
@@ -1785,8 +1785,8 @@
throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
- this.channel1.connect(ipAddr);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
this.channel1.write(null, 0, 2);
@@ -1824,7 +1824,7 @@
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(localAddr1);
+ this.channel1.connect(localAddr1);
assertTrue(this.channel1.isConnected());
this.channel1.configureBlocking(false);
// note : blocking-mode will make the read process endless!
@@ -1840,14 +1840,14 @@
public void testReadByteBuffer_bufNull() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocateDirect(0);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.read(readBuf);
fail("should throw NotYetConnectedException");
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
channel1.read((ByteBuffer) null);
@@ -1868,14 +1868,14 @@
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.read(readBuf, 0, 2);
fail("should throw NotYetConnectedException");
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
this.channel1.configureBlocking(false);
// note : blocking-mode will make the read process endless!
@@ -1906,14 +1906,14 @@
public void testReadByteBufferArrayIntInt_BufNull() throws IOException {
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.read(null, 0, 0);
fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
this.channel1.configureBlocking(false);
// note : blocking-mode will make the read process endless!
@@ -2400,12 +2400,12 @@
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
assertEquals(0, this.channel2.read(targetBuf));
}
-
+
public void test_write_LBuffer_positioned() throws Exception {
// Regression test for Harmony-683
int position = 16;
DatagramChannel dc = DatagramChannel.open();
- byte[] sourceArray = new byte[CAPACITY_NORMAL];
+ byte[] sourceArray = new byte[CAPACITY_NORMAL];
dc.connect(localAddr1);
// write
ByteBuffer sourceBuf = ByteBuffer.wrap(sourceArray);
@@ -2424,12 +2424,12 @@
ByteBuffer sourceBuf = ByteBuffer.wrap(sourceArray);
sourceBuf.position(position);
int ret = dc.send(sourceBuf, localAddr1);
- // assert send (256 - 16) bytes
+ // assert send (256 - 16) bytes
assertEquals(CAPACITY_NORMAL - position, ret);
// assert the position of ByteBuffer has been set
assertEquals(CAPACITY_NORMAL, sourceBuf.position());
}
-
+
/**
* @tests DatagramChannel#read(ByteBuffer[])
*/
@@ -2437,14 +2437,14 @@
// regression test for Harmony-754
channel2.socket().bind(localAddr1);
channel1.socket().bind(localAddr2);
- channel1.connect(localAddr1);
+ channel1.connect(localAddr1);
channel2.connect(localAddr2);
channel2.write(ByteBuffer.allocate(CAPACITY_NORMAL));
-
+
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
-
+ readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+
channel1.configureBlocking(true);
assertEquals(CAPACITY_NORMAL, channel1.read(readBuf));
}
@@ -2456,18 +2456,18 @@
// regression test for Harmony-754
channel2.socket().bind(localAddr1);
channel1.socket().bind(localAddr2);
- channel1.connect(localAddr1);
+ channel1.connect(localAddr1);
channel2.connect(localAddr2);
channel2.write(ByteBuffer.allocate(CAPACITY_NORMAL));
-
+
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
-
+ readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+
channel1.configureBlocking(true);
assertEquals(CAPACITY_NORMAL, channel1.read(readBuf,0,2));
}
-
+
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
@@ -2483,7 +2483,7 @@
// expected
}
}
-
+
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
@@ -2498,7 +2498,7 @@
// expected
}
}
-
+
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
@@ -2520,7 +2520,7 @@
// expected
}
}
-
+
/**
* @tests DatagramChannel#send(ByteBuffer, SocketAddress)
*/
@@ -2553,7 +2553,7 @@
//pass
}
}
-
+
/**
* @tests DatagramChannel#socket()
*/
@@ -2575,7 +2575,7 @@
// expected
}
}
-
+
public void test_bounded_harmony6493() throws IOException {
DatagramChannel server = DatagramChannel.open();
InetSocketAddress addr = new InetSocketAddress("localhost", 0);
@@ -2588,11 +2588,11 @@
sent.flip();
client.send(sent, boundedAddress);
assertTrue(client.socket().isBound());
-
+
server.close();
client.close();
}
-
+
// -------------------------------------------------------------------
// Mock class for security test.
// -------------------------------------------------------------------
diff --git a/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/UnixSelectorTest.java b/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/UnixSelectorTest.java
index cb3513f..95fbbd6 100644
--- a/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/UnixSelectorTest.java
+++ b/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/UnixSelectorTest.java
@@ -16,9 +16,6 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.nio.channels.SelectableChannel;
@@ -82,11 +79,11 @@
serverChannel.register(sel1, SelectionKey.OP_ACCEPT);
// HUP is treating as acceptable
- assertThat(sel0.select(100), is(1));
- assertThat(sel0.selectedKeys().contains(mkey0), is(true));
+ assertEquals(1, sel0.select(100));
+ assertEquals(true, sel0.selectedKeys().contains(mkey0));
server.initialize();
// after bind can not accept
- assertThat(sel1.select(100), is(0));
+ assertEquals(0, sel1.select(100));
server.accept();
Thread.sleep(1000);
int port = server.getPort();
@@ -99,11 +96,11 @@
socketChannel.finishConnect();
}
- assertThat(socketChannel.isConnected(), is(true));
+ assertEquals(true, socketChannel.isConnected());
server.close();
Thread.sleep(3000);
- assertThat(socketChannel.isConnected(), is(true));
- assertThat(sel2.select(100), is(1));
+ assertEquals(true, socketChannel.isConnected());
+ assertEquals(1, sel2.select(100));
}
public void testSelectUnConnectedChannel() throws Exception {
@@ -112,22 +109,22 @@
Selector sel3 = Selector.open();
SelectionKey mkey3 = socketChannel2.register(sel3, SelectionKey.OP_WRITE);
// HUP is also treating as writable
- assertThat(sel3.select(100), is(1));
- assertThat(mkey3.isConnectable(), is(false));
+ assertEquals(1, sel3.select(100));
+ assertEquals(false, mkey3.isConnectable());
// even the channel is not connected, the selector could be writable
- assertThat(socketChannel2.isConnected(), is(false));
- assertThat(mkey3.isWritable(), is(true));
+ assertEquals(false, socketChannel2.isConnected());
+ assertEquals(true, mkey3.isWritable());
Selector sel4 = Selector.open();
SelectionKey mkey4 = socketChannel2.register(sel4, SelectionKey.OP_CONNECT);
- assertThat(sel4.select(100), is(1));
- assertThat(mkey4.isWritable(), is(false));
- assertThat(mkey4.isConnectable(), is(true));
+ assertEquals(1, sel4.select(100));
+ assertEquals(false, mkey4.isWritable());
+ assertEquals(true, mkey4.isConnectable());
Selector sel5 = Selector.open();
SelectionKey mkey5 = socketChannel2.register(sel5, SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE);
- assertThat(sel5.select(100), is(1));
- assertThat(mkey5.isWritable(), is(true));
- assertThat(mkey5.isConnectable(), is(true));
+ assertEquals(1, sel5.select(100));
+ assertEquals(true, mkey5.isWritable());
+ assertEquals(true, mkey5.isConnectable());
}
}
diff --git a/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java b/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
index 115588b..afd8c22 100644
--- a/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
+++ b/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
@@ -39,14 +39,14 @@
import junit.framework.TestCase;
-import org.apache.xpath.XPathAPI;
+//import org.apache.xpath.XPathAPI;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
/**
* TODO: refine this test to adapt all implementations
- *
+ *
*/
public class AbstractPreferencesTest extends TestCase {
@@ -1093,6 +1093,7 @@
Document doc = parseXmlStream(in, false);
// only output this node without parent and children
+ /* Android doesn't have XPathAPI
String rootpath = "/preferences[@EXTERNAL_XML_VERSION='1.0']/root[@type='user']/node[@name='java']/node[@name='util']/node[@name='prefs']";
Node node = XPathAPI
.selectSingleNode(
@@ -1109,6 +1110,7 @@
node = XPathAPI.selectSingleNode(doc, rootpath
+ "/node[@name='mock']/node[@name='child']/node");
assertNull(node);
+ */
}
private static Document parseXmlStream(InputStream input, boolean validating)
@@ -1147,6 +1149,7 @@
ByteArrayInputStream in = new ByteArrayInputStream(result);
Document doc = parseXmlStream(in, false);
+ /* Android doesn't have XPathAPI
// only output this node and subtree without parent
String rootpath = "/preferences[@EXTERNAL_XML_VERSION='1.0']/root[@type='user']/node[@name='java']/node[@name='util']/node[@name='prefs']";
Node node = XPathAPI
@@ -1179,6 +1182,7 @@
rootpath
+ "/node[@name='mock']/node[@name='child']/node[@name='grandson2']/map");
assertNotNull(node);
+ */
}
public void testCachedChildren() throws Exception {
@@ -1914,9 +1918,9 @@
/**
* Regression for HARMONY-828
*/
- public void testLongPath() throws Exception {
+ public void testLongPath() throws Exception {
assertFalse(pref.nodeExists("ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"));
- }
+ }
public static class MockPreferenceChangeListener implements
PreferenceChangeListener {
diff --git a/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java b/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java
index db5c384..33da926 100644
--- a/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java
+++ b/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java
@@ -41,7 +41,7 @@
"x(?c)y", "x(?cc)y", "x(?:c)y"
};
-
+
public PatternTest(String name) {
super(name);
}
@@ -518,7 +518,7 @@
Pattern
.compile("|(?idmsux-idmsux)|(?idmsux-idmsux)|[^|\\[-\\0274|\\,-\\\\[^|W\\}\\nq\\x65\\002\\xFE\\05\\06\\00\\x66\\x47i\\,\\xF2\\=\\06\\u0EA4\\x9B\\x3C\\f\\|\\{\\xE5\\05\\r\\u944A\\xCA\\e|\\x19\\04\\x07\\04\\u607B\\023\\0073\\x91Tr\\0150\\x83]]?(?idmsux-idmsux:\\p{Alpha}{7}?)||(?<=[^\\uEC47\\01\\02\\u3421\\a\\f\\a\\013q\\035w\\e])(?<=\\p{Punct}{0,}?)(?=^\\p{Lower})(?!\\b{8,14})(?<![|\\00-\\0146[^|\\04\\01\\04\\060\\f\\u224DO\\x1A\\xC4\\00\\02\\0315\\0351\\u84A8\\xCBt\\xCC\\06|\\0141\\00\\=\\e\\f\\x6B\\0026Tb\\040\\x76xJ&&[\\\\-\\]\\05\\07\\02\\u2DAF\\t\\x9C\\e\\0023\\02\\,X\\e|\\u6058flY\\u954C]]]{5}?)(?<=\\p{Sc}{8}+)[^|\\026-\\u89BA|o\\u6277\\t\\07\\x50&&\\p{Punct}]{8,14}+((?<=^\\p{Punct})|(?idmsux-idmsux)||(?>[\\x3E-\\]])|(?idmsux-idmsux:\\p{Punct})|(?<![\\0111\\0371\\xDF\\u6A49\\07\\u2A4D\\00\\0212\\02Xd-\\xED[^\\a-\\0061|\\0257\\04\\f\\[\\0266\\043\\03\\x2D\\042&&[^\\f-\\]&&\\s]]])|(?>[|\\n\\042\\uB09F\\06\\u0F2B\\uC96D\\x89\\uC166\\xAA|\\04-\\][^|\\a\\|\\rx\\04\\uA770\\n\\02\\t\\052\\056\\0274\\|\\=\\07\\e|\\00-\\x1D&&[^\\005\\uB15B\\uCDAC\\n\\x74\\0103\\0147\\uD91B\\n\\062G\\u9B4B\\077\\}\\0324&&[^\\0302\\,\\0221\\04\\u6D16\\04xy\\uD193\\[\\061\\06\\045\\x0F|\\e\\xBB\\f\\u1B52\\023\\u3AD2\\033\\007\\022\\}\\x66\\uA63FJ-\\0304]]]]{0,0})||(?<![^|\\0154U\\u0877\\03\\fy\\n\\|\\0147\\07-\\=[|q\\u69BE\\0243\\rp\\053\\02\\x33I\\u5E39\\u9C40\\052-\\xBC[|\\0064-\\?|\\uFC0C\\x30\\0060\\x45\\\\\\02\\?p\\xD8\\0155\\07\\0367\\04\\uF07B\\000J[^|\\0051-\\{|\\u9E4E\\u7328\\]\\u6AB8\\06\\x71\\a\\]\\e\\|KN\\u06AA\\0000\\063\\u2523&&[\\005\\0277\\x41U\\034\\}R\\u14C7\\u4767\\x09\\n\\054Ev\\0144\\<\\f\\,Q-\\xE4]]]]]{3}+)|(?>^+)|(?![^|\\|\\nJ\\t\\<\\04E\\\\\\t\\01\\\\\\02\\|\\=\\}\\xF3\\uBEC2\\032K\\014\\uCC5F\\072q\\|\\0153\\xD9\\0322\\uC6C8[^\\t\\0342\\x34\\x91\\06\\{\\xF1\\a\\u1710\\?\\xE7\\uC106\\02pF\\<&&[^|\\]\\064\\u381D\\u50CF\\eO&&[^|\\06\\x2F\\04\\045\\032\\u8536W\\0377\\0017|\\x06\\uE5FA\\05\\xD4\\020\\04c\\xFC\\02H\\x0A\\r]]]]+?)(?idmsux-idmsux)|(?<![|\\r-\\,&&[I\\t\\r\\0201\\xDB\\e&&[^|\\02\\06\\00\\<\\a\\u7952\\064\\051\\073\\x41\\?n\\040\\0053\\031&&[\\x15-\\|]]]]{8,11}?)(?![^|\\<-\\uA74B\\xFA\\u7CD2\\024\\07n\\<\\x6A\\0042\\uE4FF\\r\\u896B\\[\\=\\042Y&&^\\p{ASCII}]++)|(?<![R-\\|&&[\\a\\0120A\\u6145\\<\\050-d[|\\e-\\uA07C|\\016-\\u80D9]]]{1,}+)|(?idmsux-idmsux)|(?idmsux-idmsux)|(?idmsux-idmsux:\\B{6,}?)|(?<=\\D{5,8}?)|(?>[\\{-\\0207|\\06-\\0276\\p{XDigit}])(?idmsux-idmsux:[^|\\x52\\0012\\]u\\xAD\\0051f\\0142\\\\l\\|\\050\\05\\f\\t\\u7B91\\r\\u7763\\{|h\\0104\\a\\f\\0234\\u2D4F&&^\\P{InGreek}]))");
// HARMONY-5858
- Pattern.compile("\\u6211", Pattern.LITERAL);
+ Pattern.compile("\\u6211", Pattern.LITERAL);
}
public void testOrphanQuantifiers() {
@@ -1621,7 +1621,4 @@
assertTrue(matcher.find());
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(PatternTest.class);
- }
}
diff --git a/security/src/test/api/java.injected/java/security/AllPermissionTest.java b/security/src/test/api/java.injected/java/security/AllPermissionTest.java
index 3b63a2d..f3a6fa3 100644
--- a/security/src/test/api/java.injected/java/security/AllPermissionTest.java
+++ b/security/src/test/api/java.injected/java/security/AllPermissionTest.java
@@ -25,14 +25,10 @@
/**
* Tests for <code>AllPermission</code>
- *
+ *
*/
public class AllPermissionTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(AllPermissionTest.class);
- }
-
/**
* Constructor for AllPermissionsTest.
* @param arg0
@@ -40,7 +36,7 @@
public AllPermissionTest(String arg0) {
super(arg0);
}
-
+
/**
* Test all constructors: an object is created, name and actions are ignored
*/
@@ -49,11 +45,11 @@
AllPermission a1 = new AllPermission();
assertEquals("<all permissions>", a1.getName());
assertEquals("<all actions>", a1.getActions());
-
+
a1 = new AllPermission("sdfsdfwe&^$", "*&IUGJKHVB764");
assertEquals("<all permissions>", a1.getName());
assertEquals("<all actions>", a1.getActions());
-
+
a1 = new AllPermission(null, "");
assertEquals("<all permissions>", a1.getName());
assertEquals("<all actions>", a1.getActions());
@@ -69,7 +65,7 @@
assertFalse(a1.equals(null));
assertFalse(a1.equals(new BasicPermission("hgf"){}));
}
-
+
/** AllPermission implies any other permission */
public void testImplies()
{
@@ -78,7 +74,7 @@
assertTrue(a1.implies(new BasicPermission("2323"){}));
assertTrue(a1.implies(new UnresolvedPermission("2323", "", "", null)));
}
-
+
/** newPermissionCollection() returns a new AllPermissionCollection on every invocation. */
public void testCollection()
{
diff --git a/security/src/test/api/java.injected/java/security/BasicPermissionTest.java b/security/src/test/api/java.injected/java/security/BasicPermissionTest.java
index 3e57249..3fbe894 100644
--- a/security/src/test/api/java.injected/java/security/BasicPermissionTest.java
+++ b/security/src/test/api/java.injected/java/security/BasicPermissionTest.java
@@ -25,15 +25,11 @@
/**
* Tests for <code>BasicPermission</code>
- *
+ *
*/
public class BasicPermissionTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BasicPermissionTest.class);
- }
-
/**
* Constructor for BasicPermissionTest.
* @param arg0
@@ -43,9 +39,9 @@
}
/**
- * Check all constructors: an object is created with the specified valid name.
- * If name equal null then NPE should be thrown.
- * If name is empty then IAE should be thrown.
+ * Check all constructors: an object is created with the specified valid name.
+ * If name equal null then NPE should be thrown.
+ * If name is empty then IAE should be thrown.
* Action is ignored.
*/
public void testCtor()
@@ -62,13 +58,13 @@
fail("NPE is not thrown");
}
catch (NullPointerException ok){}
-
+
try{
new BasicPermission(null, "ds235"){};
fail("NPE is not thrown");
}
catch (NullPointerException ok){}
-
+
try{
new BasicPermission(""){};
fail("IAE is not thrown");
@@ -80,7 +76,7 @@
}
catch (IllegalArgumentException ok){}
}
-
+
private final class BasicPermissionImpl extends BasicPermission
{
public BasicPermissionImpl(String name)
@@ -88,16 +84,16 @@
super(name);
}
}
-
+
/**
- * two BasicPermissions are equal if name and class are equal;
+ * two BasicPermissions are equal if name and class are equal;
* equal permissions should have the same hash code
*/
public void testEquals()
{
BasicPermission b1 = new BasicPermissionImpl("abc");
BasicPermission b2 = null;
- assertTrue(b1.equals(b1));
+ assertTrue(b1.equals(b1));
assertFalse(b1.equals(null));
assertFalse(b1.equals(new Object()));
assertFalse(b1.equals("abc"));
@@ -107,8 +103,8 @@
assertFalse(b1.equals(new BasicPermissionImpl("abc.*")));
}
- /**
- * implies() should return true if a permission is equal to or is implied
+ /**
+ * implies() should return true if a permission is equal to or is implied
* by wildcarded permission, false otherwise.
*/
public void testImplies()
@@ -126,7 +122,7 @@
assertTrue(new BasicPermissionImpl("1.*").implies(new BasicPermissionImpl("1.234.*")));
assertTrue(new BasicPermissionImpl("*").implies(new BasicPermissionImpl("*")));
}
-
+
/**
* newPermissionCollection() should return new BasicPermissionCollection on every invocation
*/
diff --git a/security/src/test/api/java.injected/java/security/IdentityTest.java b/security/src/test/api/java.injected/java/security/IdentityTest.java
index af1d41b..af98bdc 100644
--- a/security/src/test/api/java.injected/java/security/IdentityTest.java
+++ b/security/src/test/api/java.injected/java/security/IdentityTest.java
@@ -31,21 +31,17 @@
/**
* Tests for class Identity
- *
+ *
*/
public class IdentityTest extends TestCase {
public static class MySecurityManager extends SecurityManager {
- public Permissions denied = new Permissions();
+ public Permissions denied = new Permissions();
public void checkPermission(Permission permission){
if (denied!=null && denied.implies(permission)) throw new SecurityException();
}
}
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(IdentityTest.class);
- }
/**
* Constructor for IdentityTest.
@@ -67,7 +63,7 @@
i1, Boolean.TRUE,
new IdentityStub(i1.getName()), Boolean.TRUE
};
-
+
for (int k=0; k<value.length; k+=2) {
assertEquals(value[k+1], new Boolean(i1.equals(value[k])));
if (Boolean.TRUE.equals(value[k+1])) assertEquals(i1.hashCode(), value[k].hashCode());
@@ -77,7 +73,7 @@
assertEquals(i1.identityEquals(i2), i1.equals(i2));
Identity i3 = new IdentityStub("testEquals3");
assertEquals(i1.identityEquals(i3), i1.equals(i3));
-
+
}
/**
@@ -93,12 +89,12 @@
} catch (SecurityException ok) {
} finally {
System.setSecurityManager(null);
- }
+ }
}
/**
- * verify Identity.toString()
+ * verify Identity.toString()
*/
- public void testToString2() {
+ public void testToString2() {
assertNotNull(new IdentityStub("testToString2").toString());
}
@@ -125,18 +121,18 @@
* verify Identity(String, IdentityScope) creates instance with given name and in give scope
*/
public void testIdentityStringIdentityScope() throws Exception {
- IdentityScope s = IdentityScope.getSystemScope();
+ IdentityScope s = IdentityScope.getSystemScope();
Identity i = new IdentityStub("iii2", s);
assertNotNull(i);
assertEquals("iii2", i.getName());
assertSame(s, i.getScope());
- assertSame(i, s.getIdentity(i.getName()));
+ assertSame(i, s.getIdentity(i.getName()));
}
/**
* verify addCertificate(Certificate certificate) adds a certificate for this identity.
* If the identity has a public key, the public key in the certificate must be the same
- *
+ *
*/
public void testAddCertificate1() throws Exception {
Identity i = new IdentityStub("iii");
@@ -150,7 +146,7 @@
try {
i.addCertificate(new CertificateStub("ccc", null, null, new PublicKeyStub("k2", "fff", new byte[]{6,7,8,9,0})));
fail("KeyManagementException should be thrown");
- } catch (KeyManagementException ok) {}
+ } catch (KeyManagementException ok) {}
}
/**
@@ -159,14 +155,14 @@
*/
public void testAddCertificate2() throws Exception {
Identity i = new IdentityStub("iii");
- PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
+ PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
i.addCertificate(c1);
assertSame(c1, i.certificates()[0]);
assertSame(pk1, i.getPublicKey());
-
+
}
-
+
/**
* verify addCertificate(Certificate certificate) throws SecurityException is permission is denied
*/
@@ -180,9 +176,9 @@
} catch (SecurityException ok) {
} finally {
System.setSecurityManager(null);
- }
+ }
}
-
+
/**
* verify addCertificate(Certificate certificate) throws KeyManagementException if certificate is null
*/
@@ -192,16 +188,16 @@
fail("KeyManagementException should be thrown");
} catch (KeyManagementException ok) {
} catch (NullPointerException ok) {}
-
+
}
//
-// Commented out since there will no be fix for the test failure
+// Commented out since there will no be fix for the test failure
// /**
// * verify removeCertificate(Certificate certificate) removes certificate
// */
// public void testRemoveCertificate1() throws Exception{
// Identity i = new IdentityStub("iii");
-// PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
+// PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
// CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
// i.addCertificate(c1);
// assertSame(c1, i.certificates()[0]);
@@ -211,13 +207,13 @@
// try {
// i.removeCertificate(c1);
// fail("KeyManagementException should be thrown");
-// } catch (KeyManagementException ok) {
+// } catch (KeyManagementException ok) {
// }
// try {
// i.removeCertificate(null);
// fail("KeyManagementException should be thrown");
// } catch (KeyManagementException ok) {
-//
+//
// }
// }
/**
@@ -236,7 +232,7 @@
} finally {
System.setSecurityManager(null);
}
-
+
}
/**
@@ -244,7 +240,7 @@
*/
public void testCertificates() throws Exception {
Identity i = new IdentityStub("iii");
- PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
+ PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
i.addCertificate(c1);
@@ -263,9 +259,9 @@
}
/**
- * verify Identity.identityEquals(Identity) return true, only if names and public keys are equal
+ * verify Identity.identityEquals(Identity) return true, only if names and public keys are equal
*/
-
+
public void testIdentityEquals() throws Exception {
String name = "nnn";
PublicKey pk = new PublicKeyStub("aaa", "fff", new byte[]{1,2,3,4,5});
@@ -278,14 +274,14 @@
new IdentityStub(name), Boolean.FALSE,
new IdentityStub(name, IdentityScope.getSystemScope()), Boolean.FALSE,
i, Boolean.TRUE,
- new IdentityStub(name, pk), Boolean.TRUE
+ new IdentityStub(name, pk), Boolean.TRUE
};
for (int k=0; k<value.length; k+=2){
assertEquals(value[k+1], new Boolean(i.identityEquals((Identity)value[k])));
if (Boolean.TRUE.equals(value[k+1])) assertEquals(i.hashCode(), value[k].hashCode());
}
- Identity i2 = IdentityScope.getSystemScope().getIdentity(name);
- i2.setPublicKey(pk);
+ Identity i2 = IdentityScope.getSystemScope().getIdentity(name);
+ i2.setPublicKey(pk);
assertTrue(i.identityEquals(i2));
}
@@ -301,18 +297,18 @@
/**
* verify Identity.getScope() returns identity's scope
- */
+ */
public void testGetScope() throws Exception {
Identity i = new IdentityStub("testGetScope");
assertNull(i.getScope());
IdentityScope s = IdentityScope.getSystemScope();
-
+
Identity i2 = new IdentityStub("testGetScope2", s);
assertSame(s, i2.getScope());
-
+
}
/**
- *
+ *
* verify Identity.setPublicKey() throws SecurityException if permission is denied
*
*/
@@ -326,12 +322,12 @@
} catch (SecurityException ok) {
} finally {
System.setSecurityManager(null);
- }
-
+ }
+
}
/**
- *
- * verify Identity.setPublicKey() throws KeyManagementException if key is invalid
+ *
+ * verify Identity.setPublicKey() throws KeyManagementException if key is invalid
*
*/
public void testSetPublicKey2() throws Exception {
@@ -339,15 +335,15 @@
new PublicKeyStub("kkk", "testSetPublicKey2", new byte[]{1,2,3,4,5});
try {
i2.setPublicKey(null);
- //fail("KeyManagementException should be thrown - key is null");
+ //fail("KeyManagementException should be thrown - key is null");
} catch (KeyManagementException ok) {}
}
-
+
//
-// Commented out since there will no be fix for the test failure
+// Commented out since there will no be fix for the test failure
// /**
-// *
-// * verify Identity.setPublicKey() throws KeyManagementException if key is already used
+// *
+// * verify Identity.setPublicKey() throws KeyManagementException if key is already used
// *
// */
// public void testSetPublicKey3() throws Exception {
@@ -357,44 +353,44 @@
// i1.setPublicKey(pk);
// try {
// i2.setPublicKey(pk);
-// fail("KeyManagementException should be thrown - key already used");
+// fail("KeyManagementException should be thrown - key already used");
// } catch (KeyManagementException ok) {};
// }
/**
- *
+ *
* verify Identity.setPublicKey() removes old key and all identity's certificates
*
*/
public void testSetPublicKey4() throws Exception {
Identity i = new IdentityStub("testSetPublicKey4");
- PublicKeyStub pk1 = new PublicKeyStub("kkk", "Identity.testSetPublicKey4", null);
+ PublicKeyStub pk1 = new PublicKeyStub("kkk", "Identity.testSetPublicKey4", null);
CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
i.addCertificate(c1);
i.addCertificate(c2);
assertEquals(2, i.certificates().length);
assertSame(pk1, i.getPublicKey());
-
- PublicKeyStub pk2 = new PublicKeyStub("zzz", "Identity.testSetPublicKey4", null);
+
+ PublicKeyStub pk2 = new PublicKeyStub("zzz", "Identity.testSetPublicKey4", null);
i.setPublicKey(pk2);
assertSame(pk2, i.getPublicKey());
assertEquals(0, i.certificates().length);
}
-
+
/**
* verify Identity.getPublicKey() returns public key
*/
-
+
public void testGetPublicKey() throws Exception {
Identity i = new IdentityStub("testGetPublicKey");
assertNull(i.getPublicKey());
PublicKey pk = new PublicKeyStub("kkk", "Identity.testGetPublicKey", null);
i.setPublicKey(pk);
- assertSame(pk, i.getPublicKey());
+ assertSame(pk, i.getPublicKey());
}
/**
- *
+ *
* verify Identity.setInfo() throws SecurityException if permission is denied
*
*
@@ -409,16 +405,16 @@
} catch (SecurityException ok) {
} finally {
System.setSecurityManager(null);
- }
+ }
}
public void testGetInfo() {
-
+
Identity i = new IdentityStub("testGetInfo");
i.setInfo("some info");
assertEquals("some info", i.getInfo());
}
-
+
public void testGetName() {
Identity i = new IdentityStub("testGetName");
assertEquals ("testGetName", i.getName());
diff --git a/security/src/test/api/java.injected/java/security/SecureClassLoaderTest.java b/security/src/test/api/java.injected/java/security/SecureClassLoaderTest.java
index 3b4db67..f372497 100644
--- a/security/src/test/api/java.injected/java/security/SecureClassLoaderTest.java
+++ b/security/src/test/api/java.injected/java/security/SecureClassLoaderTest.java
@@ -31,21 +31,13 @@
/**
* Unit test for SecureClassLoader.
- *
+ *
*/
public class SecureClassLoaderTest extends TestCase {
- /**
- * Entry point for stand alone runs.
- *
- * @param args command line parameters
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SecureClassLoaderTest.class);
- }
/**
- * A class name for the class presented as {@link klassData bytecode below}
+ * A class name for the class presented as {@link klassData bytecode below}
*/
private static final String klassName = "HiWorld";
@@ -54,8 +46,8 @@
* Class src:<br>
* <p>
* <code>public class HiWorld {
- * public static void main(String[] args)
- * {System.out.println("Hi, world!"); }
+ * public static void main(String[] args)
+ * {System.out.println("Hi, world!"); }
* }
* </code>
*/
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java
index 51928db..fdb31c5 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AccessControlExceptionTest.java
@@ -32,14 +32,6 @@
public class AccessControlExceptionTest extends TestCase {
/**
- * Entry point for standalone run.
- * @param args command line arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(AccessControlExceptionTest.class);
- }
-
- /**
* Tests AccessControlException(String)
*/
public void testAccessControlExceptionString() {
@@ -56,7 +48,7 @@
}
/**
- *
+ *
* Tests AccessControlException.getPermission()
*/
public void testGetPermission() {
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java
index 9b881d6..32ffbca 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameterGenerator1Test.java
@@ -32,13 +32,13 @@
/**
* Tests for <code>AlgorithmParameterGenerator</code> class constructors and
* methods.
- *
+ *
*/
public class AlgorithmParameterGenerator1Test extends TestCase {
/**
* Constructor for AlgorithmParameterGeneratorTests.
- *
+ *
* @param arg0
*/
public AlgorithmParameterGenerator1Test(String arg0) {
@@ -48,8 +48,8 @@
private static String[] invalidValues = SpiEngUtils.invalidValues;
private static String validAlgName = "DSA";
private static String[] algs = {
- "DSA", "dsa", "Dsa", "DsA", "dsA" };
-
+ "DSA", "dsa", "Dsa", "DsA", "dsA" };
+
public static final String srvAlgorithmParameterGenerator = "AlgorithmParameterGenerator";
@@ -88,10 +88,10 @@
/**
* Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
+ * Assertion:
* throws NullPointerException must be thrown is null
* throws NoSuchAlgorithmException must be thrown if algorithm is not available
- *
+ *
*/
public void testAlgorithmParameterGenerator01()
throws NoSuchAlgorithmException {
@@ -112,7 +112,7 @@
/**
* Test for <code>getInstance(String algorithm)</code> method
- * Assertion: returns AlgorithmParameterGenerator instance
+ * Assertion: returns AlgorithmParameterGenerator instance
* when algorithm is DSA
*/
public void testAlgorithmParameterGenerator02()
@@ -130,8 +130,8 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
+ * method
+ * Assertion:
* throws IllegalArgumentException if provider is null or empty
*/
public void testAlgorithmParameterGenerator03()
@@ -157,7 +157,7 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
+ * method
* Assertion: throws NoSuchProviderException if provider is not
* available
*/
@@ -182,8 +182,8 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertion:
+ * method
+ * Assertion:
* throws NullPointerException must be thrown is null
* throws NoSuchAlgorithmException must be thrown if algorithm is not available
*/
@@ -212,7 +212,7 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
+ * method
* Assertion: return AlgorithmParameterGenerator
*/
public void testAlgorithmParameterGenerator06()
@@ -233,7 +233,7 @@
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
+ * method
* Assertion: throws IllegalArgumentException when provider is null
*/
public void testAlgorithmParameterGenerator07()
@@ -254,8 +254,8 @@
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion:
+ * method
+ * Assertion:
* throws NullPointerException must be thrown is null
* throws NoSuchAlgorithmException must be thrown if algorithm is not available
*/
@@ -283,7 +283,7 @@
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
+ * method
* Assertion: returns AlgorithmParameterGenerator object
*/
public void testAlgorithmParameterGenerator09()
@@ -304,7 +304,7 @@
/**
* Test for <code>generateParameters()</code> method
* Assertion: returns AlgorithmParameters object
- */
+ */
public void testAlgorithmParameterGenerator10()
throws NoSuchAlgorithmException {
if (!DSASupported) {
@@ -318,10 +318,10 @@
assertEquals("Incorrect algorithm", ap.getAlgorithm().toUpperCase(),
apg.getAlgorithm().toUpperCase());
}
-
+
/**
- * Test for <code>init(AlgorithmParameterSpec param)</code> and
- * <code>init(AlgorithmParameterSpec param, SecureRandom random<code>
+ * Test for <code>init(AlgorithmParameterSpec param)</code> and
+ * <code>init(AlgorithmParameterSpec param, SecureRandom random<code>
* methods
* Assertion: throws InvalidAlgorithmParameterException when param is null
*/
@@ -339,13 +339,13 @@
try {
apgs[i].init(aps, random);
fail("InvalidAlgorithmParameterException must be throws when param is null");
- } catch (InvalidAlgorithmParameterException e) {
+ } catch (InvalidAlgorithmParameterException e) {
}
- }
+ }
}
-
+
/**
- * Test for <code>AlgorithmParameterGenerator</code> constructor
+ * Test for <code>AlgorithmParameterGenerator</code> constructor
* Assertion: returns AlgorithmParameterGenerator object
*/
public void testAlgorithmParameterGeneratorConstr() throws NoSuchAlgorithmException {
@@ -354,7 +354,7 @@
return;
}
AlgorithmParameterGeneratorSpi spi = new MyAlgorithmParameterGeneratorSpi();
- AlgorithmParameterGenerator apg =
+ AlgorithmParameterGenerator apg =
new myAlgPG(spi, validProvider, validAlgName);
assertEquals("Incorrect algorithm", apg.getAlgorithm(), validAlgName);
assertEquals("Incorrect provider",apg.getProvider(),validProvider);
@@ -363,7 +363,7 @@
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e) {
}
-
+
apg = new myAlgPG(null, null, null);
assertNull("Incorrect algorithm", apg.getAlgorithm());
assertNull("Incorrect provider", apg.getProvider());
@@ -374,9 +374,6 @@
}
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(AlgorithmParameterGenerator1Test.class);
- }
}
/**
* Additional class to verify AlgorithmParameterGenerator constructor
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java
index a4aa4cb..310b889 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSignerTest.java
@@ -30,19 +30,11 @@
/**
- * Unit test for CodeSigner.
+ * Unit test for CodeSigner.
*/
public class CodeSignerTest extends TestCase {
- /**
- * Entry point for standalone runs.
- * @param args command line arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CodeSignerTest.class);
- }
-
private CertPath cpath = TestCertUtils.genCertPath(3, 0);
private Date now = new Date();
@@ -71,11 +63,11 @@
* Test various assertions about equals()
*/
public final void testEqualsObject() {
-
+
CodeSigner one = new CodeSigner(cpath, ts);
CodeSigner two = new CodeSigner(cpath, ts);
CodeSigner three = new CodeSigner(cpath, null);
-
+
CertPath cpath2 = TestCertUtils.genCertPath(5, 3);
CodeSigner four = new CodeSigner(cpath2, null);
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
index 1fc3504..8bcd58c 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
@@ -36,19 +36,10 @@
/**
* Unit test for CodeSource.
- *
+ *
*/
public class CodeSourceTest extends TestCase {
- /**
- *
- * Entry point for standalone runs.
- *
- * @param args command line arguments
- */
- public static void main(String[] args) throws Exception {
- junit.textui.TestRunner.run(CodeSourceTest.class);
- }
private java.security.cert.Certificate[] chain = null;
@@ -120,10 +111,10 @@
/**
* Tests hashCode().<br>
- * javadoc says nothing, so test DRL-specific implementation.
+ * javadoc says nothing, so test DRL-specific implementation.
*/
public void testHashCode() {
- // when nothing is specified, then hashCode obviously must be 0.
+ // when nothing is specified, then hashCode obviously must be 0.
assertTrue(new CodeSource(null, (Certificate[]) null).hashCode() == 0);
// only URL.hashCode is taken into account...
assertTrue(new CodeSource(urlSite, (Certificate[]) null).hashCode() == urlSite
@@ -173,7 +164,7 @@
/**
* Test for equals(Object)<br>
- * The signer certificate chain must contain the same set of certificates, but
+ * The signer certificate chain must contain the same set of certificates, but
* the order of the certificates is not taken into account.
*/
public void testEqualsObject_02() {
@@ -188,7 +179,7 @@
/**
* Test for equals(Object)<br>
- * Checks that both 'null' and not-null URLs are taken into account - properly.
+ * Checks that both 'null' and not-null URLs are taken into account - properly.
*/
public void testEqualsObject_04() {
CodeSource thiz = new CodeSource(urlSite, (Certificate[]) null);
@@ -215,7 +206,7 @@
}
/**
- * Tests whether the getCertificates() returns certificates obtained from
+ * Tests whether the getCertificates() returns certificates obtained from
* the signers.
*/
public void testGetCertificates_01() {
@@ -227,19 +218,19 @@
CodeSigner[] signers = { new CodeSigner(cpath, null) };
CodeSource cs = new CodeSource(null, signers);
Certificate[] got = cs.getCertificates();
- // The set of certificates must be exactly the same,
+ // The set of certificates must be exactly the same,
// but the order is not specified
assertTrue(presented(certs, got));
assertTrue(presented(got, certs));
}
/**
- * Checks whether two arrays of certificates represent the same same set of
+ * Checks whether two arrays of certificates represent the same same set of
* certificates - in the same order.
- * @param one first array
+ * @param one first array
* @param two second array
- * @return <code>true</code> if both arrays represent the same set of
- * certificates,
+ * @return <code>true</code> if both arrays represent the same set of
+ * certificates,
* <code>false</code> otherwise.
*/
private static boolean checkEqual(java.security.cert.Certificate[] one,
@@ -274,10 +265,10 @@
/**
* Performs a test whether the <code>what</code> certificates are all
* presented in <code>where</code> certificates.
- *
+ *
* @param what - first array of Certificates
* @param where - second array of Certificates
- * @return <code>true</code> if each and every certificate from 'what'
+ * @return <code>true</code> if each and every certificate from 'what'
* (including null) is presented in 'where' <code>false</code> otherwise
*/
private static boolean presented(Certificate[] what, Certificate[] where) {
@@ -339,7 +330,7 @@
assertTrue(found);
}
}
-
+
public void testGetCoderSignersNull() throws Exception{
assertNull(new CodeSource(new URL("http://url"), (Certificate[])null).getCodeSigners()); //$NON-NLS-1$
}
@@ -358,7 +349,7 @@
* Tests CodeSource.toString()
*/
public void testToString() {
- // Javadoc keeps silence about String's format,
+ // Javadoc keeps silence about String's format,
// just make sure it can be invoked.
new CodeSource(urlSite, chain).toString();
new CodeSource(null, chain).toString();
@@ -367,9 +358,9 @@
/**
* Tests whether we are running with the 1.5 features.<br>
- * The test is preformed by looking for (via reflection) the CodeSource's
+ * The test is preformed by looking for (via reflection) the CodeSource's
* constructor {@link CodeSource#CodeSource(URL, CodeSigner[])}.
- * @return <code>true</code> if 1.5 feature is presented, <code>false</code>
+ * @return <code>true</code> if 1.5 feature is presented, <code>false</code>
* otherwise.
*/
private static boolean has_15_features() {
@@ -378,7 +369,7 @@
try {
klass.getConstructor(ctorArgs);
} catch (NoSuchMethodException ex) {
- // NoSuchMethod == Not RI.v1.5 and not DRL
+ // NoSuchMethod == Not RI.v1.5 and not DRL
return false;
}
return true;
@@ -453,7 +444,7 @@
assertTrue(thizCS.implies(thatCS));
assertTrue(thatCS.implies(thizCS));
- //
+ //
// Check for another site - force to create SocketPermission
//
thatCS = new CodeSource(urlDirOtherSite, (Certificate[]) null);
@@ -588,7 +579,7 @@
//
that = new CodeSource(urlSite, (Certificate[]) null);
- // 'thiz' has set of certs, while 'that' has no certs. URL-s are the
+ // 'thiz' has set of certs, while 'that' has no certs. URL-s are the
// same.
assertFalse(thiz.implies(that));
assertTrue(that.implies(thiz));
@@ -596,8 +587,8 @@
/**
* Testing with special URLs like 'localhost', 'file://' scheme ...
- * These special URLs have a special processing in implies(),
- * so they need to be covered and performance need to be checked
+ * These special URLs have a special processing in implies(),
+ * so they need to be covered and performance need to be checked
*/
public void testImplies_0C() throws Exception {
URL url0 = new URL("http://localhost/someDir");
@@ -611,8 +602,8 @@
/**
* Testing with special URLs like 'localhost', 'file://' scheme ...
- * These special URLs have a special processing in implies(),
- * so they need to be covered and performance need to be checked
+ * These special URLs have a special processing in implies(),
+ * so they need to be covered and performance need to be checked
*/
public void testImplies_0D() throws Exception {
URL url0 = new URL("file:///" + System.getProperty("user.home")
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java
index e4b2aa8..53dabe2 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/GuardedObjectTest.java
@@ -25,15 +25,11 @@
/**
* Tests for <code>GuardedObject</code>
- *
+ *
*/
public class GuardedObjectTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(GuardedObjectTest.class);
- }
-
/** Null guard imposes no restriction. */
public void testNoGuard() {
Object obj = null;
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java
index 61f3a88..989e8a0 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/IdentityScopeTest.java
@@ -28,22 +28,18 @@
/**
* Tests for <code>IdentityScope</code>
- *
+ *
*/
public class IdentityScopeTest extends TestCase {
public static class MySecurityManager extends SecurityManager {
- public Permissions denied = new Permissions();
+ public Permissions denied = new Permissions();
public void checkPermission(Permission permission){
if (denied!=null && denied.implies(permission)) throw new SecurityException();
}
}
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(IdentityScopeTest.class);
- }
-
+
IdentityScope is;
/**
@@ -94,7 +90,7 @@
public final void testGetSystemScope() {
String name = Security.getProperty("system.scope");
assertNotNull(name);
- IdentityScope scope = IdentityScope.getSystemScope();
+ IdentityScope scope = IdentityScope.getSystemScope();
assertNotNull(scope);
assertEquals(name, scope.getClass().getName());
}
@@ -104,11 +100,11 @@
* if permission is denied than SecurityException is thrown
*
*/
-
+
public final void testSetSystemScope() {
// default implementation is specified by security property system.scope
IdentityScope systemScope = IdentityScope.getSystemScope();
-
+
try {
// all permissions are granted - sm is not installed
is = new IdentityScopeStub("Aleksei Semenov");
@@ -120,12 +116,12 @@
try {
is = new IdentityScopeStub("aaa");
IdentityScopeStub.mySetSystemScope(is);
- assertSame(is, IdentityScope.getSystemScope());
+ assertSame(is, IdentityScope.getSystemScope());
// permission is denied
sm.denied.add(new SecurityPermission("setSystemScope"));
IdentityScope is2 = new IdentityScopeStub("bbb");
try{
- IdentityScopeStub.mySetSystemScope(is2);
+ IdentityScopeStub.mySetSystemScope(is2);
fail("SecurityException should be thrown");
} catch (SecurityException e){
assertSame(is, IdentityScope.getSystemScope());
@@ -138,7 +134,7 @@
IdentityScopeStub.mySetSystemScope(systemScope);
}
}
-
+
/**
* Class under test for Identity getIdentity(Principal)
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java
index 1298ee4..b3627a4 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KSPrivateKeyEntryTest.java
@@ -32,8 +32,8 @@
import junit.framework.TestSuite;
/**
- * Tests for <code>KeyStore.PrivateKeyEntry</code> class constructor and methods
- *
+ * Tests for <code>KeyStore.PrivateKeyEntry</code> class constructor and methods
+ *
*/
public class KSPrivateKeyEntryTest extends TestCase {
@@ -47,7 +47,7 @@
}
private PrivateKey testPrivateKey;
private Certificate [] testChain;
-
+
private void createParams(boolean diffCerts, boolean diffKeys) {
byte[] encoded = {(byte)0, (byte)1, (byte)2, (byte)3};
testChain = new Certificate[5];
@@ -56,10 +56,10 @@
testChain[i] = new MyCertificate("MY_TEST_CERTIFICATE_"
.concat(s), encoded);
}
- testPrivateKey = (diffKeys ? (PrivateKey)new tmpPrivateKey() :
+ testPrivateKey = (diffKeys ? (PrivateKey)new tmpPrivateKey() :
(PrivateKey)new tmpPrivateKey(testChain[0].getPublicKey().getAlgorithm()));
}
-
+
/**
* Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
* constructor
@@ -99,7 +99,7 @@
/**
* Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
* constructor
- * Assertion: throws IllegalArgumentException when chain contains certificates
+ * Assertion: throws IllegalArgumentException when chain contains certificates
* of different types
*/
public void testPrivateKeyEntry03() {
@@ -110,19 +110,19 @@
} catch (IllegalArgumentException e) {
}
}
-
+
/**
* Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
* constructor
- * Assertion: throws IllegalArgumentException when algorithm of privateKey
+ * Assertion: throws IllegalArgumentException when algorithm of privateKey
* does not match the algorithm of PublicKey in the end certificate (with 0 index)
*/
public void testPrivateKeyEntry04() {
- createParams(false, true);
+ createParams(false, true);
try {
new KeyStore.PrivateKeyEntry(testPrivateKey, testChain);
fail("IllegalArgumentException must be thrown when key algorithms do not match");
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
}
}
@@ -137,7 +137,7 @@
assertEquals("Incorrect PrivateKey", testPrivateKey, ksPKE
.getPrivateKey());
}
-
+
/**
* Test for <code>getCertificateChain()</code> method Assertion: returns
* array of the Certificates corresponding to chain
@@ -153,7 +153,7 @@
.concat(Integer.toString(i)), testChain[i], res[i]);
}
}
-
+
/**
* Test for <code>getCertificate()</code> method
* Assertion: returns end Certificate (with 0 index in chain)
@@ -182,10 +182,6 @@
return new TestSuite(KSPrivateKeyEntryTest.class);
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
- }
-
private static class tmpPrivateKey implements PrivateKey {
private String alg = "My algorithm";
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java
index c451d6b..41f8b07 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator1Test.java
@@ -33,14 +33,14 @@
/**
* Tests for <code>KeyPairGenerator</code> class constructors and methods.
- *
+ *
*/
public class KeyPairGenerator1Test extends TestCase {
/**
* Constructor for KayPairGeneratorTest.
- *
+ *
* @param arg0
*/
public KeyPairGenerator1Test(String arg0) {
@@ -48,7 +48,7 @@
}
private static String[] invalidValues = SpiEngUtils.invalidValues;
-
+
public static final String srvKeyPairGenerator = "KeyPairGenerator";
public static String[] algs = {
@@ -61,7 +61,7 @@
public static Provider validProvider = null;
private static boolean DSASupported = false;
-
+
public static String NotSupportMsg = "";
static {
@@ -71,10 +71,10 @@
DSASupported = (validProvider != null);
if (!DSASupported) {
NotSupportMsg = validAlgName + " algorithm is not supported" ;
- }
+ }
validProviderName = (DSASupported ? validProvider.getName() : null);
}
-
+
protected KeyPairGenerator [] createKPGen() {
if (!DSASupported) {
fail(NotSupportMsg);
@@ -93,10 +93,10 @@
}
/**
- * Test for <code>getInstance(String algorithm)</code> method
+ * Test for <code>getInstance(String algorithm)</code> method
* Assertion:
* throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
+ * throws NoSuchAlgorithmException when algorithm is incorrect;
*/
public void testKeyPairGenerator01() throws NoSuchAlgorithmException {
try {
@@ -116,7 +116,7 @@
}
/**
- * Test for <code>getInstance(String algorithm)</code> method
+ * Test for <code>getInstance(String algorithm)</code> method
* Assertion: returns KeyPairGenerator object
*/
public void testKeyPairGenerator02() throws NoSuchAlgorithmException {
@@ -134,7 +134,7 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
+ * method
* Assertion: throws IllegalArgumentException when provider is null or empty
*/
public void testKeyPairGenerator03() throws NoSuchAlgorithmException,
@@ -160,10 +160,10 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
+ * method
* Assertion:
* throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
+ * throws NoSuchAlgorithmException when algorithm is incorrect;
*/
public void testKeyPairGenerator04() throws NoSuchAlgorithmException,
IllegalArgumentException {
@@ -186,7 +186,7 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
+ * method
* Assertion: throws NoSuchAlgorithmException when algorithm is not
* available oe null
*/
@@ -216,7 +216,7 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
+ * method
* Assertion: returns KeyPairGenerator object
*/
public void testKeyPairGenerator06() throws NoSuchProviderException,
@@ -237,7 +237,7 @@
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
+ * method
* Assertion: throws IllegalArgumentException when provider is null
*/
public void testKeyPairGenerator07() throws NoSuchAlgorithmException {
@@ -257,10 +257,10 @@
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertion:
+ * method
+ * Assertion:
* throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
+ * throws NoSuchAlgorithmException when algorithm is incorrect;
*/
public void testKeyPairGenerator08() throws IllegalArgumentException {
if (!DSASupported) {
@@ -286,7 +286,7 @@
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
+ * method
* Assertion: returns KeyPairGenerator object
*/
public void testKeyPairGenerator09() throws NoSuchAlgorithmException,
@@ -303,11 +303,11 @@
assertEquals("Incorrect provider", kpg.getProvider(), validProvider);
}
}
-
+
/**
* Test for <code>generateKeyPair()</code> and <code>genKeyPair()</code>
* methods
- * Assertion: KeyPairGenerator was initialized before the invocation
+ * Assertion: KeyPairGenerator was initialized before the invocation
* of these methods
*/
public void testKeyPairGenerator10() throws NoSuchAlgorithmException,
@@ -330,9 +330,9 @@
kp1.getPublic()));
}
}
-
+
/**
- * Test for methods:
+ * Test for methods:
* <code>initialize(int keysize)</code>
* <code>initialize(int keysize, SecureRandom random)</code>
* <code>initialize(AlgorithmParameterSpec param)</code>
@@ -340,7 +340,7 @@
* Assertion: throws InvalidParameterException or
* InvalidAlgorithmParameterException when parameters keysize or param are
* incorrect
- */
+ */
public void testKeyPairGenerator11() throws NoSuchAlgorithmException,
NoSuchProviderException {
if (!DSASupported) {
@@ -354,14 +354,14 @@
AlgorithmParameterSpec aps = null;
for (int i = 0; i < kpg.length; i++) {
-
- for (int j = 0; j < keys.length; j++) {
+
+ for (int j = 0; j < keys.length; j++) {
try {
kpg[i].initialize(keys[j]);
kpg[i].initialize(keys[j], random);
} catch (InvalidParameterException e) {
}
- }
+ }
try {
kpg[i].initialize(aps);
@@ -370,7 +370,7 @@
}
}
}
-
+
/**
* Test for methods: <code>initialize(int keysize)</code>
* <code>initialize(int keysize, SecureRandom random)</code>
@@ -445,7 +445,7 @@
}
}
}
-
+
/**
* Test for methods: <code>initialize(int keysize)</code>
* <code>initialize(int keysize, SecureRandom random)</code>
@@ -500,7 +500,4 @@
}
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(KeyPairGenerator1Test.class);
- }
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java
index 7921958..3e859c7 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator2Test.java
@@ -32,7 +32,7 @@
/**
* Tests for <code>KeyPairGenerator</code> class constructors and methods.
- *
+ *
*/
public class KeyPairGenerator2Test extends TestCase {
@@ -42,7 +42,7 @@
private static final String KeyPairGeneratorProviderClass2 = "org.apache.harmony.security.tests.support.MyKeyPairGenerator2";
private static final String KeyPairGeneratorProviderClass3 = "org.apache.harmony.security.tests.support.MyKeyPairGenerator3";
private static final String KeyPairGeneratorProviderClass4 = "org.apache.harmony.security.tests.support.MyKeyPairGeneratorSpi";
-
+
private static final String defaultAlg = "KPGen";
private static final String[] invalidValues = SpiEngUtils.invalidValues;
@@ -50,7 +50,7 @@
private static final String[] validValues;
String post;
-
+
static {
validValues = new String[4];
validValues[0] = defaultAlg;
@@ -59,7 +59,7 @@
validValues[3] = "kPGEn";
}
- Provider mProv;
+ Provider mProv;
String resAlg;
/*
@@ -80,7 +80,7 @@
/**
* Constructor for SecurityManagerFactoryTest2.
- *
+ *
* @param arg0
*/
public KeyPairGenerator2Test(String arg0) {
@@ -181,7 +181,7 @@
* throws NullPointerException when algorithm is null throws
* NoSuchAlgorithmException when algorithm is incorrect; returns
* KeyPairGenerator object
- *
+ *
*/
private void GetInstance01(int mode) throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException {
@@ -212,12 +212,12 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
- * method
- * Assertions:
+ * method
+ * Assertions:
* throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
+ * throws NoSuchAlgorithmException when algorithm is incorrect;
* throws IllegalArgumentException when provider is null;
- * throws NoSuchProviderException when provider is available;
+ * throws NoSuchProviderException when provider is available;
* returns
* KeyPairGenerator object
*/
@@ -274,10 +274,10 @@
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
+ * method
+ * Assertions:
* throws NullPointerException when algorithm is null
- * throws NoSuchAlgorithmException when algorithm is incorrect;
+ * throws NoSuchAlgorithmException when algorithm is incorrect;
* throws IllegalArgumentException when provider is null;
* returns KeyPairGenerator object
*/
@@ -429,7 +429,4 @@
setProv();
GetInstance03(4);
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(KeyPairGenerator2Test.class);
- }
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java
index 0496425..aac8cbb 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator3Test.java
@@ -28,14 +28,14 @@
/**
* Tests for KeyPairGenerator class
- *
+ *
*/
public class KeyPairGenerator3Test extends TestCase {
/**
* Constructor for KeyPairGenerator3Test.
- *
+ *
* @param arg0
*/
public KeyPairGenerator3Test(String arg0) {
@@ -47,7 +47,7 @@
public static Provider validProvider = null;
private static boolean DSASupported = false;
-
+
private static String NotSupportMsg = KeyPairGenerator1Test.NotSupportMsg;
static {
@@ -79,11 +79,11 @@
}
}
-
+
/**
* Test for <code>generateKeyPair()</code> and <code>genKeyPair()</code>
* methods
- * Assertion: KeyPairGenerator was initialized before the invocation
+ * Assertion: KeyPairGenerator was initialized before the invocation
* of these methods
*/
public void testGenKeyPair01() throws NoSuchAlgorithmException,
@@ -106,7 +106,7 @@
kp1.getPublic()));
}
}
-
+
/**
* Test for <code>generateKeyPair()</code> and <code>genKeyPair()</code>
* methods
@@ -120,7 +120,7 @@
}
KeyPairGenerator[] kpg = createKPGen();
assertNotNull("KeyPairGenerator objects were not created", kpg);
- KeyPair kp, kp1;
+ KeyPair kp, kp1;
for (int i = 0; i < kpg.length; i++) {
kp = kpg[i].generateKeyPair();
kp1 = kpg[i].genKeyPair();
@@ -131,8 +131,4 @@
}
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(KeyPairGenerator3Test.class);
- }
-
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java
index d98040b..e909c01 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGeneratorSpiTest.java
@@ -30,14 +30,14 @@
/**
* Tests for <code>KeyPairGeneratorSpi</code> class constructors and methods.
- *
+ *
*/
public class KeyPairGeneratorSpiTest extends TestCase {
/**
* Constructor for KeyPairGeneratorSpiTest.
- *
+ *
* @param arg0
*/
public KeyPairGeneratorSpiTest(String arg0) {
@@ -45,7 +45,7 @@
}
/**
- * Test for <code>KeyPairGeneratorSpi</code> constructor
+ * Test for <code>KeyPairGeneratorSpi</code> constructor
* Assertion: constructs KeyPairGeneratorSpi
*/
public void testKeyPairGeneratorSpi01()
@@ -76,8 +76,4 @@
KeyPair kp = keyPairGen.generateKeyPair();
assertNull("Not null KeyPair", kp);
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(KeyPairGeneratorSpiTest.class);
- }
-
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java
index 4a8ced6..2acb6e9 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java
@@ -41,14 +41,14 @@
/**
* Tests for <code>KeyStoreSpi</code> constructor and methods
- *
+ *
*/
public class KeyStoreSpiTest extends TestCase {
/**
* Constructor for KeyStoreSpi.
- *
+ *
* @param arg0
*/
public KeyStoreSpiTest(String arg0) {
@@ -56,17 +56,17 @@
}
/**
- * Test for <code>KeyStoreSpi()</code> constructor
- * and the following methods:
+ * Test for <code>KeyStoreSpi()</code> constructor
+ * and the following methods:
* <code>engineLoad(KeyStore.LoadStoreParameter param)</code>
* <code>engineStore(KeyStore.LoadStoreParameter param)</code>
* <code>engineGetEntry(String alias, KeyStore.ProtectionParameter param)</code>
* <code>engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter param)</code>
- * Assertions:
+ * Assertions:
* creates new KeyStoreSpi object;
* engineGetEntry(..) returns null entry;
* engineStore(..) throws UnexpectedOperationException;
- * engineSetEntry(..) throws KeyStoreException or NullPointerException
+ * engineSetEntry(..) throws KeyStoreException or NullPointerException
*/
public void testKeyStoteSpi01() throws IOException,
NoSuchAlgorithmException, CertificateException,
@@ -95,7 +95,7 @@
ksSpi.engineSetEntry("", new KeyStore.TrustedCertificateEntry(
new MyCertificate("type", new byte[0])), null);
fail("KeyStoreException must be thrown");
- } catch (KeyStoreException e) {
+ } catch (KeyStoreException e) {
}
try {
@@ -107,7 +107,7 @@
/**
- * Test for <code>KeyStoreSpi()</code> constructor
+ * Test for <code>KeyStoreSpi()</code> constructor
* and abstract engine methods.
* Assertion: creates new KeyStoreSpi object.
*/
@@ -120,7 +120,7 @@
.engineGetCertificateChain(""));
assertNull("engineGetCertificate(..) must return null", ksSpi
.engineGetCertificate(""));
- assertEquals("engineGetCreationDate(..) must return Date(0)",
+ assertEquals("engineGetCreationDate(..) must return Date(0)",
new Date(0), ksSpi.engineGetCreationDate(""));
try {
ksSpi.engineSetKeyEntry("", null, new char[0], new Certificate[0]);
@@ -152,7 +152,7 @@
} catch (IOException e) {
}
}
-
+
/**
* @tests java.security.KeyStoreSpi#engineLoad(KeyStore.LoadStoreParameter)
*/
@@ -175,14 +175,14 @@
assertSame(msg, e.getMessage());
}
- // test: protection parameter is null
+ // test: protection parameter is null
try {
ksSpi.engineLoad(new MyLoadStoreParams(null));
fail("No expected UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
}
- // test: protection parameter is not instanceof
+ // test: protection parameter is not instanceof
// PasswordProtection or CallbackHandlerProtection
try {
ksSpi.engineLoad(new MyLoadStoreParams(new tmpProtection()));
@@ -190,15 +190,12 @@
} catch (UnsupportedOperationException e) {
}
}
-
- public static void main(String args[]) {
- junit.textui.TestRunner.run(KeyStoreSpiTest.class);
- }
+
}
/**
* Additional class implements KeyStore.Entry interface
*/
-class tmpEntry implements KeyStore.Entry {
+class tmpEntry implements KeyStore.Entry {
}
class tmpProtection implements KeyStore.ProtectionParameter {
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
index ed5e98a..2b9f552 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
@@ -28,15 +28,11 @@
/**
* Tests for <code>PermissionCollection</code>
- *
+ *
*/
public class PermissionCollectionTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(PermissionCollectionTest.class);
- }
-
/**
* Constructor for PermissionCollectionTest.
* @param arg0
@@ -44,29 +40,29 @@
public PermissionCollectionTest(String arg0) {
super(arg0);
}
-
+
// Bare extension to instantiate abstract PermissionCollection class
private static final class RealPermissionCollection extends PermissionCollection
{
- final private Collection col;
+ final private Collection col;
public RealPermissionCollection(Collection col)
{
- this.col = col;
+ this.col = col;
}
-
+
public void add(Permission permission) {}
-
- public Enumeration elements()
+
+ public Enumeration elements()
{
return col == null ? null : Collections.enumeration(col);
}
-
- public boolean implies(Permission permission)
+
+ public boolean implies(Permission permission)
{
return false;
}
}
-
+
/** Test read-only flag. Should be false by default and can be set once forever. */
public void testReadOnly()
{
@@ -77,7 +73,7 @@
pc.setReadOnly();
assertTrue("more calls to setReadOnly() should not harm", pc.isReadOnly());
}
-
+
// Regression test for "exitVM' special treatement in Java 6.
public void test_implies_exitVM() {
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java
index 96dae7e..7ceade6 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java
@@ -29,13 +29,9 @@
public class PermissionTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(PermissionTest.class);
- }
-
/**
* Constructor for PermissionTest.
- *
+ *
* @param arg0
*/
public PermissionTest(String arg0) {
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java
index 1bd6368..c29af58 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java
@@ -32,15 +32,11 @@
/**
* Tests for <code>Permissions</code>
- *
+ *
*/
public class PermissionsTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(PermissionsTest.class);
- }
-
/**
* Can add any type of permissions. Cannot add if collection is read-only.
*/
@@ -96,7 +92,7 @@
Enumeration en = ps.elements();
assertNotNull(en);
assertFalse(en.hasMoreElements());
-
+
ps.add(up1);
en = ps.elements();
assertTrue(en.hasMoreElements());
@@ -122,10 +118,10 @@
//assertEquals(5, els.size());
assertTrue(els.containsAll(Arrays.asList(arr)));
}
-
-
+
+
/**
- * input parameter is null
+ * input parameter is null
*/
public void testNull(){
Permissions ps = new Permissions();
@@ -138,14 +134,14 @@
fail("should throw NPE");
} catch (NullPointerException e){
}
-
- try {
+
+ try {
ps.add(null);
fail("should throw NullPointerException");
} catch (NullPointerException e){}
}
-
+
public void test_toString() {
Permissions ps = new Permissions();
String address = getAddress(ps.toString());
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
index 044914b..872ffc0 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
@@ -47,10 +47,6 @@
public static final String JAVA_SECURITY_POLICY = "java.security.policy";
- public static void main(String[] args) {
- junit.textui.TestRunner.run(PolicyTest.class);
- }
-
/**
* @tests java.security.Policy#setPolicy(java.security.Policy)
*/
@@ -117,8 +113,8 @@
public void refresh() {
}
}
-
- /**
+
+ /**
* Tests that getPermissions() does proper permission evaluation.
*/
public void testGetPermissions() {
@@ -130,18 +126,18 @@
ProtectionDomain pd2 = new ProtectionDomain(null, spc);
TestProvider policy = new TestProvider();
policy.pc = sp.newPermissionCollection();
-
+
//case1: empty policy, no static permissions in PD
PermissionCollection pc4pd = policy.getPermissions(pd);
assertNotNull(pc4pd);
Enumeration en = pc4pd.elements();
assertFalse(en.hasMoreElements());
-
+
//case2: empty policy, some static permissions in PD
pc4pd = policy.getPermissions(pd2);
assertNotNull(pc4pd);
//no check for static permissions
-
+
//case3: non-empty policy, no static permissions in PD
policy.pc.add(sp);
pc4pd = policy.getPermissions(pd);
@@ -151,7 +147,7 @@
}
assertTrue(c.contains(sp));
-
+
//case4: non-empty policy, some static permissions in PD
pc4pd = policy.getPermissions(pd2);
assertNotNull(pc4pd);
@@ -162,7 +158,7 @@
assertTrue(c.contains(sp));
//no check for static permissions
}
-
+
/**
* @tests java.security.Policy#getPolicy()
* @tests java.security.Policy#setPolicy()
@@ -187,9 +183,9 @@
Policy.setPolicy(oldPolicy);
}
}
-
+
/**
- * Test property expansion in policy files
+ * Test property expansion in policy files
*/
public void testPropertyExpansion() throws Exception {
@@ -225,7 +221,7 @@
/**
* Asserts codeBase property expansion in policy file
- *
+ *
* @param codeSourceURL -
* code source for policy object
* @param codeBaseURL -
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java
index 1cd371c..ce4533b 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java
@@ -25,17 +25,10 @@
/**
* Unit test for java.security.PrivilegedActionException.
- *
+ *
*/
public class PrivilegedActionExceptionTest extends TestCase {
- /**
- * Entry point for standalone runs.
- * @param args command line arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(PrivilegedActionExceptionTest.class);
- }
/**
* Tests PrivilegedActionException(Exception)
@@ -63,4 +56,4 @@
assertNotNull(new PrivilegedActionException(new Exception()).toString());
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java
index cf67483..eef72e0 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java
@@ -30,19 +30,11 @@
/**
* Unit tests for java.security.ProtectionDomain.
- *
+ *
*/
public class ProtectionDomainTest extends TestCase {
- /**
- * Entry point for standalone runs.
- * @param args command line arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(ProtectionDomainTest.class);
- }
-
private final AllPermission allperm = new AllPermission();
private URL url = null;
@@ -168,12 +160,12 @@
}
/**
- * ProtectionDomain created with a static set of permissions must not query
- * policy.
+ * ProtectionDomain created with a static set of permissions must not query
+ * policy.
*/
public void testImplies_02() {
TestPolicy policy = new TestPolicy();
- // null set of permissions [must] force the PD to use Policy - for
+ // null set of permissions [must] force the PD to use Policy - for
// dynamic permissions
ProtectionDomain pd = new ProtectionDomain(cs, null);
policy.setTrackPD(pd);
@@ -187,8 +179,8 @@
}
/**
- * ProtectionDomain created with dynamic set of permissions must query
- * policy.
+ * ProtectionDomain created with dynamic set of permissions must query
+ * policy.
*/
public void testImplies_03() {
TestPolicy policy = new TestPolicy();
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java
index 38918f7..afb3c03 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java
@@ -25,14 +25,10 @@
/**
* Tests for <code>SecurityPermission</code>
- *
+ *
*/
public class SecurityPermissionTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SecurityPermissionTest.class);
- }
-
/**
* Constructor for SecurityPermissionTest.
* @param arg0
@@ -40,11 +36,11 @@
public SecurityPermissionTest(String arg0) {
super(arg0);
}
-
+
/**
- * Check all constructors: an object is created with the specified valid name.
- * If name equal null then NPE should be thrown.
- * If name is empty then IAE should be thrown.
+ * Check all constructors: an object is created with the specified valid name.
+ * If name equal null then NPE should be thrown.
+ * If name is empty then IAE should be thrown.
* Action is ignored.
*/
public void testCtor()
@@ -61,13 +57,13 @@
fail("NPE is not thrown");
}
catch (NullPointerException ok){}
-
+
try{
new SecurityPermission(null, "ds235");
fail("NPE is not thrown");
}
catch (NullPointerException ok){}
-
+
try{
new SecurityPermission("");
fail("IAE is not thrown");
@@ -77,6 +73,6 @@
new SecurityPermission("", "ertre 3454");
fail("IAE is not thrown");
}
- catch (IllegalArgumentException ok){}
+ catch (IllegalArgumentException ok){}
}
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignerTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignerTest.java
index 6ba0a62..d933dac 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignerTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignerTest.java
@@ -31,20 +31,16 @@
/**
* tests for class Signer
- *
+ *
*/
public class SignerTest extends TestCase {
public static class MySecurityManager extends SecurityManager {
- public Permissions denied = new Permissions();
+ public Permissions denied = new Permissions();
public void checkPermission(Permission permission){
if (denied!=null && denied.implies(permission)) throw new SecurityException();
}
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SignerTest.class);
}
/**
@@ -79,7 +75,7 @@
public void testSigner() {
Signer s = new SignerStub();
assertNotNull(s);
- //assertNull(s.getName(), s.getName());
+ //assertNull(s.getName(), s.getName());
assertNull(s.getPrivateKey());
}
@@ -89,7 +85,7 @@
public void testSignerString() throws Exception {
Signer s = new SignerStub("sss3");
assertNotNull(s);
- assertEquals("sss3", s.getName());
+ assertEquals("sss3", s.getName());
assertNull(s.getPrivateKey());
}
@@ -108,19 +104,19 @@
* verify Signer.getPrivateKey() returns null or private key
*/
public void testGetPrivateKey() throws Exception {
- byte [] privateKeyData = { 1, 2, 3, 4, 5};
+ byte [] privateKeyData = { 1, 2, 3, 4, 5};
PrivateKeyStub privateKey = new PrivateKeyStub("private", "fff", privateKeyData);
PublicKeyStub publicKey = new PublicKeyStub("public", "fff", null);
KeyPair kp = new KeyPair(publicKey, privateKey);
-
+
Signer s = new SignerStub("sss5");
-
+
assertNull(s.getPrivateKey());
-
- s.setKeyPair(kp);
+
+ s.setKeyPair(kp);
assertSame(privateKey, s.getPrivateKey());
}
-
+
/**
* verify Signer.getPrivateKey() throws SecurityException if permission is denied
*/
@@ -134,18 +130,18 @@
try {
s.getPrivateKey();
fail("SecurityException should be thrown");
- } catch (SecurityException ok) {}
+ } catch (SecurityException ok) {}
} finally {
System.setSecurityManager(null);
}
-
+
}
/**
- * @tests java.security.Signer#setKeyPair(java.security.KeyPair)
+ * @tests java.security.Signer#setKeyPair(java.security.KeyPair)
*/
public void test_setKeyPairLjava_security_KeyPair() throws Exception {
-
+
// Regression for HARMONY-2408
// test: NullPointerException if pair is null
try {
@@ -153,7 +149,7 @@
fail("No expected NullPointerException");
} catch (NullPointerException e) {
}
-
+
// test: SecurityException if permission is denied
SecurityManager oldSm = System.getSecurityManager();
MySecurityManager sm = new MySecurityManager();
@@ -169,7 +165,7 @@
}
} finally {
System.setSecurityManager(oldSm);
- }
+ }
}
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/TimestampTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/TimestampTest.java
index 2bfa3e4..506d123 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/TimestampTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/TimestampTest.java
@@ -31,15 +31,11 @@
/**
* Tests for <code>Timestamp</code> class fields and methods
- *
+ *
*/
public class TimestampTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(TimestampTest.class);
- }
-
private Date now = new Date();
private static final byte[] encoding = { 1, 2, 3 };
@@ -73,12 +69,12 @@
assertTrue(two.equals(one));
assertFalse(one.equals(null));
assertFalse(one.equals(new Object()));
-
+
Timestamp two1 = new Timestamp(new Date(9999), cpath);
assertFalse(one.equals(two1));
assertTrue(two1.equals(two1));
}
-
+
public void testGetSignerCertPath() {
assertSame(new Timestamp(now, cpath).getSignerCertPath(), cpath);
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java
index d4d4ef7..da435e5 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/AclNotFoundExceptionTest.java
@@ -27,15 +27,11 @@
/**
* Unit test for AclNotFoundException.
- *
+ *
*/
public class AclNotFoundExceptionTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(AclNotFoundExceptionTest.class);
- }
-
/**
* @tests java.security.acl.AclNotFoundException#AclNotFoundException()
*/
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java
index aa92b7f..c50010a 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/LastOwnerExceptionTest.java
@@ -23,15 +23,11 @@
/**
* Unit test for LastOwnerException.
- *
+ *
*/
public class LastOwnerExceptionTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(LastOwnerExceptionTest.class);
- }
-
/**
* @tests java.security.acl.LastOwnerException#LastOwnerException()
*/
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java
index 77fef54..349acbf 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/acl/NotOwnerExceptionTest.java
@@ -23,15 +23,11 @@
/**
* Unit test for NotOwnerException.
- *
+ *
*/
public class NotOwnerExceptionTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(NotOwnerExceptionTest.class);
- }
-
/**
* @tests java.security.acl.NotOwnerException#NotOwnerException()
*/
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
index 18703cf..c836389 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder1Test.java
@@ -41,7 +41,7 @@
/**
* Tests for <code>CertPathBuilder</code> class constructors and
* methods.
- *
+ *
*/
public class CertPathBuilder1Test extends TestCase {
@@ -55,17 +55,17 @@
}
public static final String srvCertPathBuilder = "CertPathBuilder";
- public static final String defaultType = "PKIX";
+ public static final String defaultType = "PKIX";
public static final String [] validValues = {
"PKIX", "pkix", "PkiX", "pKiX" };
-
+
private static String [] invalidValues = SpiEngUtils.invalidValues;
-
+
private static boolean PKIXSupport = false;
private static Provider defaultProvider;
private static String defaultProviderName;
-
+
private static String NotSupportMsg = "";
public static final String DEFAULT_TYPE_PROPERTY = "certpathbuilder.type";
@@ -93,8 +93,8 @@
} catch (Exception e) {
return null;
}
- }
-
+ }
+
/**
* @tests java.security.cert.CertPathBuilder#getDefaultType()
*/
@@ -102,7 +102,7 @@
// Regression for HARMONY-2785
- // test: default value
+ // test: default value
assertNull(Security.getProperty(DEFAULT_TYPE_PROPERTY));
assertEquals("PKIX", CertPathBuilder.getDefaultType());
@@ -122,11 +122,11 @@
assertEquals("AnotherType", CertPathBuilder.getDefaultType());
}
}
-
+
/**
* Test for <code>getInstance(String algorithm)</code> method
* Assertion:
- * throws NullPointerException when algorithm is null
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not correct
* or it is not available
*/
@@ -144,11 +144,11 @@
}
}
}
-
+
/**
* Test for <code>getInstance(String algorithm)</code> method
* Assertion: returns CertPathBuilder object
- */
+ */
public void testCertPathBuilder03() throws NoSuchAlgorithmException {
if (!PKIXSupport) {
fail(NotSupportMsg);
@@ -162,9 +162,9 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
* Assertion: throws IllegalArgumentException when provider is null or empty
- *
+ *
* FIXME: verify what exception will be thrown if provider is empty
- */
+ */
public void testCertPathBuilder04()
throws NoSuchAlgorithmException, NoSuchProviderException {
if (!PKIXSupport) {
@@ -172,7 +172,7 @@
return;
}
String provider = null;
- for (int i = 0; i < validValues.length; i++) {
+ for (int i = 0; i < validValues.length; i++) {
try {
CertPathBuilder.getInstance(validValues[i], provider);
fail("IllegalArgumentException must be thrown thrown");
@@ -185,10 +185,10 @@
}
}
}
-
+
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
+ * Assertion:
* throws NoSuchProviderException when provider has invalid value
*/
public void testCertPathBuilder05()
@@ -205,12 +205,12 @@
} catch (NoSuchProviderException e1) {
}
}
- }
+ }
}
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
+ * Assertion:
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not correct
*/
public void testCertPathBuilder06()
@@ -230,9 +230,9 @@
fail("NoSuchAlgorithmException must be thrown");
} catch (NoSuchAlgorithmException e1) {
}
- }
+ }
}
-
+
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
* Assertion: returns CertPathBuilder object
@@ -248,7 +248,7 @@
certPB = CertPathBuilder.getInstance(validValues[i], defaultProviderName);
assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
assertEquals("Incorrect provider name", certPB.getProvider().getName(), defaultProviderName);
- }
+ }
}
/**
@@ -268,13 +268,13 @@
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e1) {
}
- }
+ }
}
-
+
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
+ * Assertion:
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not correct
*/
public void testCertPathBuilder09()
@@ -311,19 +311,19 @@
certPB = CertPathBuilder.getInstance(validValues[i], defaultProvider);
assertEquals("Incorrect algorithm", certPB.getAlgorithm(), validValues[i]);
assertEquals("Incorrect provider name", certPB.getProvider(), defaultProvider);
- }
+ }
}
/**
* Test for <code>build(CertPathParameters params)</code> method
* Assertion: throws InvalidAlgorithmParameterException params is null
*/
public void testCertPathBuilder11()
- throws NoSuchAlgorithmException, NoSuchProviderException,
+ throws NoSuchAlgorithmException, NoSuchProviderException,
CertPathBuilderException {
if (!PKIXSupport) {
fail(NotSupportMsg);
return;
- }
+ }
CertPathBuilder [] certPB = createCPBs();
assertNotNull("CertPathBuilder objects were not created", certPB);
for (int i = 0; i < certPB.length; i++ ){
@@ -335,12 +335,12 @@
}
}
/**
- * Test for
+ * Test for
* <code>CertPathBuilder</code> constructor
* Assertion: returns CertPathBuilder object
*/
public void testCertPathBuilder12()
- throws CertificateException, NoSuchProviderException,
+ throws CertificateException, NoSuchProviderException,
NoSuchAlgorithmException, InvalidAlgorithmParameterException,
CertPathBuilderException {
if (!PKIXSupport) {
@@ -348,28 +348,24 @@
return;
}
CertPathBuilderSpi spi = new MyCertPathBuilderSpi();
- CertPathBuilder certPB = new myCertPathBuilder(spi,
+ CertPathBuilder certPB = new myCertPathBuilder(spi,
defaultProvider, defaultType);
assertEquals("Incorrect algorithm", certPB.getAlgorithm(), defaultType);
assertEquals("Incorrect provider", certPB.getProvider(), defaultProvider);
try {
certPB.build(null);
fail("CertPathBuilderException must be thrown ");
- } catch (CertPathBuilderException e) {
+ } catch (CertPathBuilderException e) {
}
certPB = new myCertPathBuilder(null, null, null);
assertNull("Incorrect algorithm", certPB.getAlgorithm());
- assertNull("Incorrect provider", certPB.getProvider());
+ assertNull("Incorrect provider", certPB.getProvider());
try {
certPB.build(null);
fail("NullPointerException must be thrown ");
- } catch (NullPointerException e) {
+ } catch (NullPointerException e) {
}
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(CertPathBuilder1Test.class);
- }
-
}
/**
* Additional class to verify CertPathBuilder constructor
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
index 068f603..03a6737 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathBuilder2Test.java
@@ -37,7 +37,7 @@
/**
* Tests for CertPathBuilder class constructors and methods
- *
+ *
*/
public class CertPathBuilder2Test extends TestCase {
@@ -77,7 +77,7 @@
/**
* Constructor for CertPathBuilder2Test.
- *
+ *
* @param arg0
*/
public CertPathBuilder2Test(String arg0) {
@@ -104,16 +104,16 @@
certBuild.build(null);
fail("CertPathBuilderException must be thrown");
} catch (CertPathBuilderException e) {
- }
+ }
CertPathBuilderResult cpbResult = certBuild.build(null);
assertNull("Not null CertPathBuilderResult", cpbResult);
}
/**
- * Test for <code>getInstance(String algorithm)</code> method
+ * Test for <code>getInstance(String algorithm)</code> method
* Assertions:
- * throws
- * throws NullPointerException when algorithm is null
+ * throws
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not correct
* returns CertPathBuilder object
*/
@@ -144,11 +144,11 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertions:
- * throws NullPointerException when algorithm is null
+ * Assertions:
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not correct
- * throws IllegalArgumentException when provider is null or empty;
- * throws NoSuchProviderException when provider is available;
+ * throws IllegalArgumentException when provider is null or empty;
+ * throws NoSuchProviderException when provider is available;
* returns CertPathBuilder object
*/
public void testGetInstance02() throws NoSuchAlgorithmException,
@@ -209,9 +209,9 @@
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
- * method
- * Assertions:
- * throws NullPointerException when algorithm is null
+ * method
+ * Assertions:
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not correct
* returns CertPathBuilder object
*/
@@ -249,9 +249,5 @@
checkResult(cerPB);
}
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(CertPathBuilder2Test.class);
- }
-
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java
index e18c80f..14e24e2 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertPathValidator1Test.java
@@ -41,7 +41,7 @@
/**
* Tests for <code>CertPathValidator</code> class constructors and
* methods.
- *
+ *
*/
public class CertPathValidator1Test extends TestCase {
@@ -54,18 +54,18 @@
super(name);
}
public static final String srvCertPathValidator = "CertPathValidator";
-
- private static final String defaultType = "PKIX";
+
+ private static final String defaultType = "PKIX";
public static final String [] validValues = {
"PKIX", "pkix", "PkiX", "pKiX" };
-
+
private static String [] invalidValues = SpiEngUtils.invalidValues;
-
+
private static boolean PKIXSupport = false;
private static Provider defaultProvider;
private static String defaultProviderName;
-
+
private static String NotSupportMsg = "";
static {
@@ -74,10 +74,10 @@
PKIXSupport = (defaultProvider != null);
defaultProviderName = (PKIXSupport ? defaultProvider.getName() : null);
NotSupportMsg = defaultType.concat(" is not supported");
- }
-
-
-
+ }
+
+
+
private static CertPathValidator[] createCPVs() {
if (!PKIXSupport) {
fail(NotSupportMsg);
@@ -94,13 +94,13 @@
} catch (Exception e) {
return null;
}
- }
-
-
+ }
+
+
/**
* Test for <code>getDefaultType()</code> method
* Assertion: returns security property "certpathvalidator.type" or "PKIX"
- */
+ */
public void testCertPathValidator01() {
if (!PKIXSupport) {
fail(NotSupportMsg);
@@ -108,29 +108,29 @@
}
String propName = "certpathvalidator.type";
String defCPV = Security.getProperty(propName);
-
+
String dt = CertPathValidator.getDefaultType();
- String resType = defCPV;
+ String resType = defCPV;
if (resType == null) {
resType = defaultType;
}
assertNotNull("Default type have not be null", dt);
assertEquals("Incorrect default type", dt, resType);
-
+
if (defCPV == null) {
Security.setProperty(propName, defaultType);
dt = CertPathValidator.getDefaultType();
resType = Security.getProperty(propName);
assertNotNull("Incorrect default type", resType);
assertNotNull("Default type have not be null", dt);
- assertEquals("Incorrect default type", dt, resType);
+ assertEquals("Incorrect default type", dt, resType);
}
}
-
+
/**
* Test for <code>getInstance(String algorithm)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
+ * Assertion:
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not available
*/
public void testCertPathValidator02() {
@@ -147,11 +147,11 @@
} catch (NoSuchAlgorithmException e) {
}
}
- }
+ }
/**
* Test for <code>getInstance(String algorithm)</code> method
* Assertion: returns CertPathValidator object
- */
+ */
public void testCertPathValidator03() throws NoSuchAlgorithmException {
if (!PKIXSupport) {
fail(NotSupportMsg);
@@ -166,9 +166,9 @@
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
* Assertion: throws IllegalArgumentException when provider is null or empty
- *
+ *
* FIXME: verify what exception will be thrown if provider is empty
- */
+ */
public void testCertPathValidator04()
throws NoSuchAlgorithmException, NoSuchProviderException {
if (!PKIXSupport) {
@@ -176,7 +176,7 @@
return;
}
String provider = null;
- for (int i = 0; i < validValues.length; i++) {
+ for (int i = 0; i < validValues.length; i++) {
try {
CertPathValidator.getInstance(validValues[i], provider);
fail("IllegalArgumentException must be thrown thrown");
@@ -191,7 +191,7 @@
}
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
+ * Assertion:
* throws NoSuchProviderException when provider has invalid value
*/
public void testCertPathValidator05() throws NoSuchAlgorithmException {
@@ -210,11 +210,11 @@
}
}
}
-
+
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
+ * Assertion:
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not available
*/
public void testCertPathValidator06()
@@ -257,7 +257,7 @@
.getName(), defaultProviderName);
}
}
-
+
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code> method
* Assertion: throws IllegalArgumentException when provider is null
@@ -275,13 +275,13 @@
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e1) {
}
- }
+ }
}
-
+
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
- * Assertion:
- * throws NullPointerException when algorithm is null
+ * Assertion:
+ * throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not available
*/
public void testCertPathValidator09()
@@ -353,9 +353,9 @@
}
}
}
-
+
/**
- * Test for
+ * Test for
* <code>CertPathValidator</code> constructor
* Assertion: returns CertPathValidator object
*/
@@ -367,7 +367,7 @@
return;
}
CertPathValidatorSpi spi = new MyCertPathValidatorSpi();
- CertPathValidator certPV = new myCertPathValidator(spi,
+ CertPathValidator certPV = new myCertPathValidator(spi,
defaultProvider, defaultType);
assertEquals("Incorrect algorithm", certPV.getAlgorithm(), defaultType);
assertEquals("Incorrect provider", certPV.getProvider(), defaultProvider);
@@ -376,7 +376,7 @@
certPV.validate(null, null);
fail("CertPathValidatorException must be thrown");
} catch (CertPathValidatorException e) {
- }
+ }
certPV = new myCertPathValidator(null, null, null);
assertNull("Incorrect algorithm", certPV.getAlgorithm());
assertNull("Incorrect provider", certPV.getProvider());
@@ -386,9 +386,6 @@
} catch (NullPointerException e) {
}
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(CertPathValidator1Test.class);
- }
}
/**
* Additional class to verify CertPathValidator constructor
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java
index 968188d..697e65d 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertStoreSpiTest.java
@@ -39,14 +39,14 @@
/**
* Tests for <code>CertStoreSpi</code> class constructors and methods.
- *
+ *
*/
public class CertStoreSpiTest extends TestCase {
/**
* Constructor for CertStoreSpiTest.
- *
+ *
* @param arg0
*/
public CertStoreSpiTest(String arg0) {
@@ -74,16 +74,12 @@
assertNull("Not null collection", certStoreSpi
.engineGetCRLs(crlSelector));
}
-
+
public static Test suite() {
return new TestSuite(CertStoreSpiTest.class);
}
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
- }
-
- /**
+ /**
* Additional classes for verification CertStoreSpi class
*/
public static class tmpCRLSelector implements CRLSelector {
@@ -102,5 +98,5 @@
return true;
}
}
-
+
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java
index 8a311bb..7f756ae 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory1Test.java
@@ -49,14 +49,14 @@
/**
* Tests for <code>CertificateFactory</code> class methods and constructor
- *
+ *
*/
public class CertificateFactory1Test extends TestCase {
/**
* Constructor for CertificateFactoryTests.
- *
+ *
* @param arg0
*/
public CertificateFactory1Test(String arg0) {
@@ -64,7 +64,7 @@
}
public static final String srvCertificateFactory = "CertificateFactory";
-
+
private static String defaultProviderName = null;
private static Provider defaultProvider = null;
@@ -73,7 +73,7 @@
public static String defaultType = "X.509";
- public static final String[] validValues = {
+ public static final String[] validValues = {
"X.509", "x.509" };
private final static String[] invalidValues = SpiEngUtils.invalidValues;
@@ -111,14 +111,14 @@
}
/**
- * Test for <code>getInstance(String type)</code> method
+ * Test for <code>getInstance(String type)</code> method
* Assertion: returns CertificateFactory if type is X.509
*/
public void testCertificateFactory01() throws CertificateException {
if (!X509Support) {
fail(NotSupportMsg);
return;
- }
+ }
for (int i = 0; i < validValues.length; i++) {
CertificateFactory certF = CertificateFactory
.getInstance(validValues[i]);
@@ -127,9 +127,9 @@
}
/**
- * Test for <code>getInstance(String type)</code> method
+ * Test for <code>getInstance(String type)</code> method
* Assertion:
- * throws NullPointerException when type is null
+ * throws NullPointerException when type is null
* throws CertificateException when type is not available
*/
public void testCertificateFactory02() {
@@ -176,8 +176,8 @@
/**
* Test for <code>getInstance(String type, String provider)</code> method
- * Assertion:
- * throws NullPointerException when type is null
+ * Assertion:
+ * throws NullPointerException when type is null
* throws CertificateException when type is not available
*/
public void testCertificateFactory04() throws CertificateException,
@@ -227,7 +227,7 @@
/**
* Test for <code>getInstance(String type, Provider provider)</code>
- * method
+ * method
* Assertion: throws IllegalArgumentException when provider is null
*/
public void testCertificateFactory06() throws CertificateException {
@@ -247,9 +247,9 @@
/**
* Test for <code>getInstance(String type, Provider provider)</code>
- * method
- * Assertion:
- * throws NullPointerException when type is null
+ * method
+ * Assertion:
+ * throws NullPointerException when type is null
* throws CertificateException when type is not available
*/
public void testCertificateFactory07() throws CertificateException {
@@ -277,7 +277,7 @@
/**
* Test for <code>getInstance(String type, Provider provider)</code>
- * method
+ * method
* Assertion: returns CertificateFactorythrows when type and provider
* have valid values
*/
@@ -297,7 +297,7 @@
}
/**
- * Test for <code>getCertPathEncodings()</code> method
+ * Test for <code>getCertPathEncodings()</code> method
* Assertion: returns encodings
*/
public void testCertificateFactory09() throws CertificateException,
@@ -347,7 +347,7 @@
* <code>generateCertificates(InputStream inStream)</code>
* <code>generateCRL(InputStream inStream)</code>
* <code>generateCRLs(InputStream inStream)</code>
- * methods
+ * methods
* Assertion: throw CertificateException and CRLException when
* inStream is null or empty
*/
@@ -425,10 +425,10 @@
/*
* Test for <code> generateCertificate(InputStream inStream) </code><code>
* generateCertificates(InputStream inStream) </code><code>
- * generateCRL(InputStream inStream) </code><code>
- * generateCRLs(InputStream inStream) </code>
- * methods
- * Assertion: throw CertificateException and CRLException when inStream
+ * generateCRL(InputStream inStream) </code><code>
+ * generateCRLs(InputStream inStream) </code>
+ * methods
+ * Assertion: throw CertificateException and CRLException when inStream
* contains incompatible datas
*/
public void testCertificateFactory11() throws CertificateException,
@@ -488,7 +488,7 @@
/**
* Test for <code>generateCertPath(InputStream inStream)</code>
* <code>generateCertPath(InputStream inStream, String encoding)</code>
- * methods
+ * methods
* Assertion: throws CertificateException when inStream is null or
* when isStream contains invalid datas
*/
@@ -538,7 +538,7 @@
/**
* Test for <code>generateCertPath(InputStream inStream)</code>
* <code>generateCertPath(InputStream inStream, String encoding)</code>
- * methods
+ * methods
* Assertion: throw CertificateException when isStream contains invalid datas
*/
public void testCertificateFactory13() throws IOException,
@@ -569,7 +569,7 @@
}
Iterator it = certFs[i].getCertPathEncodings();
while (it.hasNext()) {
- try {
+ try {
certFs[i].generateCertPath(is, (String) it.next());
fail("CertificateException must be thrown because input stream contains incorrect datas");
} catch (CertificateException e) {
@@ -613,13 +613,13 @@
return;
}
CertificateFactory[] certFs = initCertFs();
- assertNotNull("CertificateFactory objects were not created", certFs);
+ assertNotNull("CertificateFactory objects were not created", certFs);
List list = new Vector();
for (int i = 0; i < certFs.length; i++) {
CertPath cp = certFs[i].generateCertPath(list);
List list1 = cp.getCertificates();
assertTrue("List should be empty", list1.isEmpty());
- }
+ }
}
/**
@@ -648,7 +648,7 @@
}
/**
- * Test for <code>CertificateFactory</code> constructor
+ * Test for <code>CertificateFactory</code> constructor
* Assertion: returns CertificateFactory object
*/
public void testCertificateFactory17() throws CertificateException,
@@ -657,7 +657,7 @@
fail(NotSupportMsg);
return;
}
- CertificateFactorySpi spi = new MyCertificateFactorySpi();
+ CertificateFactorySpi spi = new MyCertificateFactorySpi();
CertificateFactory cf = new myCertificateFactory(spi, defaultProvider,
defaultType);
assertEquals("Incorrect type", cf.getType(), defaultType);
@@ -667,7 +667,7 @@
fail("CRLException must be thrown");
} catch (CRLException e) {
}
-
+
cf = new myCertificateFactory(null, null, null);
assertNull("Incorrect type", cf.getType());
assertNull("Incorrect provider", cf.getProvider());
@@ -677,10 +677,7 @@
} catch (NullPointerException e) {
}
}
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateFactory1Test.class);
- }
+
}
/**
* Additional class to verify CertificateFactory constructor
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java
index 42c9070..127c40d 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLEntryTest.java
@@ -157,7 +157,7 @@
* appropriate exception.
*/
public void testGetCertificateIssuer() {
- assertNull("The default implementation should return null.",
+ assertNull("The default implementation should return null.",
tbt_crlentry.getCertificateIssuer());
}
@@ -165,8 +165,4 @@
return new TestSuite(X509CRLEntryTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java
index 83e01b2..8c2a0e0 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CRLTest.java
@@ -255,8 +255,4 @@
return new TestSuite(X509CRLTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.java
index 92c4655..79dc841 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CRLExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CRLException serialization
- *
+ * Test for CRLException serialization
+ *
*/
public class CRLExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new CRLException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CRLExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.java
index 5a113ce..fb5da26 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathBuilderExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CertPathBuilderException serialization
- *
+ * Test for CertPathBuilderException serialization
+ *
*/
public class CertPathBuilderExceptionTest extends SerializationTest {
@@ -47,8 +47,4 @@
new CertPathBuilderException(new Throwable()), new CertPathBuilderException(th),
new CertPathBuilderException(msgs[1], dExc) };
}
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertPathBuilderExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.java
index 80acd0f..81bc4a9 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertPathValidatorExceptionTest.java
@@ -30,7 +30,7 @@
/**
* Test for CertPathValidatorException serialization
- *
+ *
*/
public class CertPathValidatorExceptionTest extends SerializationTest implements
@@ -56,10 +56,10 @@
}
public void assertDeserialized(Serializable oref, Serializable otest) {
-
+
// common checks
THROWABLE_COMPARATOR.assertDeserialized(oref, otest);
-
+
// class specific checks
CertPathValidatorException ref = (CertPathValidatorException) oref;
CertPathValidatorException test = (CertPathValidatorException) otest;
@@ -74,7 +74,4 @@
}
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertPathValidatorExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.java
index d93a465..cd039f2 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertStoreExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CertStoreException serialization
- *
+ * Test for CertStoreException serialization
+ *
*/
public class CertStoreExceptionTest extends SerializationTest {
@@ -47,8 +47,4 @@
new CertStoreException(new Throwable()), new CertStoreException(th),
new CertStoreException(msgs[1], dExc) };
}
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertStoreExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.java
index 3c1d652..e50de73 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateEncodingExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CertificateEncodingException serialization
- *
+ * Test for CertificateEncodingException serialization
+ *
*/
public class CertificateEncodingExceptionTest extends SerializationTest {
@@ -47,8 +47,4 @@
new CertificateEncodingException(new Throwable()), new CertificateEncodingException(th),
new CertificateEncodingException(msgs[1], dExc) };
}
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateEncodingExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.java
index 9c78039..6a39b6d 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CertificateException serialization
- *
+ * Test for CertificateException serialization
+ *
*/
public class CertificateExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new CertificateException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.java
index 2550db5..65b354c 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateExpiredExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for CertificateExpiredException serialization
- *
+ *
*/
public class CertificateExpiredExceptionTest extends SerializationTest {
@@ -44,7 +44,4 @@
new CertificateExpiredException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateExpiredExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.java
index f16ce52..00f7296 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateNotYetValidExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CertificateNotYetValidException serialization
- *
+ * Test for CertificateNotYetValidException serialization
+ *
*/
public class CertificateNotYetValidExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new CertificateNotYetValidException(msgs[1])};
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateNotYetValidExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.java
index 7964745..8eeed05 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/serialization/CertificateParsingExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CertificateParsingException serialization
- *
+ * Test for CertificateParsingException serialization
+ *
*/
public class CertificateParsingExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new CertificateParsingException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateParsingExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.java
index 3ba94fb..474ebe6 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AccessControlExceptionTest.java
@@ -31,16 +31,12 @@
/**
* Serialization tests for <code>AccessControlException</code>
- *
+ *
*/
public class AccessControlExceptionTest extends SerializationTest implements
SerializationTest.SerializableAssert {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(AccessControlExceptionTest.class);
- }
-
protected Object[] getData() {
AllPermission allperms = new AllPermission();
return new Object[] { new AccessControlException(null),
@@ -50,7 +46,7 @@
}
public void assertDeserialized(Serializable oref, Serializable otest) {
-
+
// common checks
THROWABLE_COMPARATOR.assertDeserialized(oref, otest);
@@ -64,4 +60,4 @@
assertEquals(p, test.getPermission());
}
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.java
index 6143a91..8f003a7 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSignerTest.java
@@ -32,15 +32,11 @@
/**
* Serialization tests for <code>CodeSigner</code>
- *
+ *
*/
public class CodeSignerTest extends SerializationTest {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CodeSignerTest.class);
- }
-
/**
* @see com.intel.drl.test.SerializationTest#getData()
*/
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.java
index d2df92d..d46e837 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.java
@@ -42,15 +42,11 @@
/**
* Serialization test for CodeSource.
- *
+ *
*/
public class CodeSourceTest extends SerializationTest {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CodeSourceTest.class);
- }
-
protected void setUp() throws Exception {
super.setUp();
TestCertUtils.install_test_x509_factory();
@@ -64,13 +60,13 @@
public void testGolden() throws Throwable {
super.testGolden();
// do special testing to cover Exceptions in the {read/write}Data
-
+
//
// test writeObject()
//
-
+
{//~
-
+
Certificate[] certs = new Certificate[] { new InvalidX509Certificate_00() };
CodeSource cs = new CodeSource(null, certs);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -84,7 +80,7 @@
}
}//~
-
+
//
// test readObject
//
@@ -93,12 +89,12 @@
CodeSource cs = new CodeSource(null, certs);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
-
+
oos.writeObject(cs);
-
+
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
-
+
try {
ois.readObject();
fail("must not pass here");
@@ -107,21 +103,21 @@
// ok
}
}//~
-
- // test readObject, force the CertFactory to throw an Exception from
+
+ // test readObject, force the CertFactory to throw an Exception from
// inside the generateCertificate
-
+
{//~
Certificate[] certs = new Certificate[] { new InvalidX509Certificate_01() };
CodeSource cs = new CodeSource(null, certs);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
-
+
oos.writeObject(cs);
-
+
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
-
+
try {
ois.readObject();
fail("must not pass here");
@@ -131,7 +127,7 @@
}
}//~
}
-
+
private class InvalidX509Certificate_00 extends TestCertUtils.TestX509Certificate {
InvalidX509Certificate_00() {
super(TestCertUtils.rootPrincipal, TestCertUtils.rootPrincipal);
@@ -141,24 +137,24 @@
throw new CertificateEncodingException("CEE");
}
}
-
+
private class InvalidX509Certificate_01 extends TestCertUtils.TestX509Certificate {
InvalidX509Certificate_01() {
super(TestCertUtils.rootPrincipal, TestCertUtils.rootPrincipal);
}
public byte[] getEncoded() throws CertificateEncodingException {
// this is invalid encoding for TestX509Certificate
- return new byte[] {1,2,3,4,5};
+ return new byte[] {1,2,3,4,5};
}
}
-
+
private class CertificateOfUnsupportedType extends TestCertUtils.TestCertificate {
CertificateOfUnsupportedType() {
super(null, "this is indeed unsupported type of certificates. I do believe so.");
}
}
-
+
protected Object[] getData() {
URL url;
CodeSigner[] signers = null;
@@ -175,7 +171,7 @@
Certificate[] x509chain = new Certificate[] {
TestCertUtils.rootCA
};
-
+
Object[] data = new Object[] {
new CodeSource(url, (Certificate[])null),
new CodeSource(url, new Certificate[0]),
@@ -194,4 +190,4 @@
.getField("location");
assertEquals("Ljava/net/URL;", objectStreamField.getTypeString());
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.java
index 6213bba..8b39a77 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/DigestExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Tests for DigestException serialization
- *
+ *
*/
public class DigestExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new DigestException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(DigestExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.java
index 9054f8c..b1ae9b5 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/GeneralSecurityExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for GeneralSecurityException serialization
- *
+ * Test for GeneralSecurityException serialization
+ *
*/
public class GeneralSecurityExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new GeneralSecurityException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(GeneralSecurityExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.java
index d051bfb..edf702a 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidAlgorithmParameterExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for InvalidAlgorithmParameterException serialization
- *
+ * Test for InvalidAlgorithmParameterException serialization
+ *
*/
public class InvalidAlgorithmParameterExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new InvalidAlgorithmParameterException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(InvalidAlgorithmParameterExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.java
index 60fbec8..b3e706c 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidKeyExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for InvalidKeyException serialization
- *
+ * Test for InvalidKeyException serialization
+ *
*/
public class InvalidKeyExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new InvalidKeyException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(InvalidKeyExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.java
index 466f0fd..4cade57 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/InvalidParameterExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for InvalidParameterException serialization
- *
+ * Test for InvalidParameterException serialization
+ *
*/
public class InvalidParameterExceptionTest extends SerializationTest {
@@ -38,14 +38,11 @@
"Long message for Exception. Long message for Exception. Long message for Exception." };
protected Object[] getData() {
- return new Object[] {
+ return new Object[] {
new InvalidParameterException(),
new InvalidParameterException(null),
new InvalidParameterException(msgs[1])
};
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(InvalidParameterExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.java
index a170a8d..36eb47e 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for KeyException serialization
- *
+ * Test for KeyException serialization
+ *
*/
public class KeyExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new KeyException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(KeyExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.java
index cf4060e..527b9d3 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyManagementExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for KeyManagementException serialization
- *
+ * Test for KeyManagementException serialization
+ *
*/
public class KeyManagementExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new KeyManagementException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(KeyManagementExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.java
index 44b60be..324351c 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/KeyStoreExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for KeyStoreException serialization
- *
+ * Test for KeyStoreException serialization
+ *
*/
public class KeyStoreExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new KeyStoreException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(KeyStoreExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.java
index b20595c..4ca46dd 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchAlgorithmExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for NoSuchAlgorithmException serialization
- *
+ * Test for NoSuchAlgorithmException serialization
+ *
*/
public class NoSuchAlgorithmExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new NoSuchAlgorithmException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(NoSuchAlgorithmExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.java
index 679dc66..ad1a5e3 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/NoSuchProviderExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for NoSuchProviderException serialization
- *
+ *
*/
public class NoSuchProviderExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new NoSuchProviderException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(NoSuchProviderExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.java
index f6d6c6c..ceda16a 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PrivilegedActionExceptionTest.java
@@ -33,10 +33,6 @@
public class PrivilegedActionExceptionTest extends SerializationTest implements
SerializationTest.SerializableAssert {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(PrivilegedActionExceptionTest.class);
- }
protected Object[] getData() {
Exception ex = new Exception();
@@ -47,12 +43,12 @@
new PrivilegedActionException(ex1)
};
}
-
+
public void assertDeserialized(Serializable reference, Serializable otest) {
-
+
// common checks
THROWABLE_COMPARATOR.assertDeserialized(reference, otest);
-
+
// class specific checks
PrivilegedActionException ref = (PrivilegedActionException)reference;
PrivilegedActionException test = (PrivilegedActionException)otest;
@@ -63,6 +59,6 @@
.getException());
}
}
-
+
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.java
index f4a4f74..0e1357b 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/ProviderExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for ProviderException serialization
- *
+ * Test for ProviderException serialization
+ *
*/
public class ProviderExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new ProviderException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(ProviderExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.java
index 7b715b2..26ca9ef 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignatureExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for SignatureException serialization
- *
+ * Test for SignatureException serialization
+ *
*/
public class SignatureExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new SignatureException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SignatureExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.java
index 993416a..5a40a6c 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SignedObjectTest.java
@@ -37,7 +37,7 @@
/**
* Tests for SignedObject serialization
- *
+ *
*/
public class SignedObjectTest extends SerializationTest implements
SerializationTest.SerializableAssert {
@@ -45,10 +45,10 @@
private Signature sig;
private TestKeyPair tkp = null;
private Properties prop;
-
+
protected Object[] getData() {
try {
- sig = Signature.getInstance("SHA1withDSA");
+ sig = Signature.getInstance("SHA1withDSA");
} catch (NoSuchAlgorithmException e) {
fail(e.toString());
}
@@ -63,11 +63,11 @@
try {
o = new SignedObject(prop, tkp.getPrivate(), sig);
} catch (IOException e) {
- fail(e.toString());
- } catch (SignatureException e) {
- fail(e.toString());
+ fail(e.toString());
+ } catch (SignatureException e) {
+ fail(e.toString());
} catch (InvalidKeyException e) {
- fail(e.toString());
+ fail(e.toString());
} catch (InvalidKeySpecException e) {
fail(e.toString());
}
@@ -79,28 +79,25 @@
SignedObject test = (SignedObject) otest;
assertEquals(test.getAlgorithm(), ref.getAlgorithm());
-
+
try {
- assertEquals(test.getObject(), prop);
+ assertEquals(test.getObject(), prop);
} catch (ClassNotFoundException e) {
- fail(e.toString());
+ fail(e.toString());
} catch (IOException e) {
- fail(e.toString());
+ fail(e.toString());
}
try {
if (!test.verify(tkp.getPublic(), sig)) {
fail("verify() failed");
- }
+ }
} catch (SignatureException e) {
- fail(e.toString());
+ fail(e.toString());
} catch (InvalidKeyException e) {
- fail(e.toString());
+ fail(e.toString());
} catch (InvalidKeySpecException e) {
- fail(e.toString());
- }
+ fail(e.toString());
+ }
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(DigestExceptionTest.class);
- }
}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.java
index 5c25fde..ea8b711 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/TimestampTest.java
@@ -31,15 +31,11 @@
/**
* Serialization tests for <code>Timestamp</code>
- *
+ *
*/
public class TimestampTest extends SerializationTest {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(TimestampTest.class);
- }
-
/**
* @see com.intel.drl.test.SerializationTest#getData()
*/
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.java
index 863ab72..f19e757 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableEntryExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for UnrecoverableEntryException serialization
- *
+ *
*/
public class UnrecoverableEntryExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new UnrecoverableEntryException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(UnrecoverableEntryExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.java
index dddef8c..0bca49a 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnrecoverableKeyExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for UnrecoverableKeyException serialization
- *
+ *
*/
public class UnrecoverableKeyExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new UnrecoverableKeyException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(UnrecoverableKeyExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.java
index bfb7ba3..31e9694 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidKeySpecExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for InvalidKeySpecException serialization
- *
+ * Test for InvalidKeySpecException serialization
+ *
*/
public class InvalidKeySpecExceptionTest extends SerializationTest {
@@ -48,7 +48,4 @@
new InvalidKeySpecException(msgs[1], dExc) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(InvalidKeySpecExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.java
index 9b42f10..0380a9c 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/serialization/InvalidParameterSpecExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for InvalidParameterSpecException serialization
- *
+ * Test for InvalidParameterSpecException serialization
+ *
*/
public class InvalidParameterSpecExceptionTest extends SerializationTest {
@@ -38,12 +38,9 @@
"Long message for Exception. Long message for Exception. Long message for Exception." };
protected Object[] getData() {
- return new Object[] { new InvalidParameterSpecException(),
+ return new Object[] { new InvalidParameterSpecException(),
new InvalidParameterSpecException(null),
new InvalidParameterSpecException(msgs[1])};
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(InvalidParameterSpecExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java
index 5be7081..e4451c7 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/CertificateTest.java
@@ -47,7 +47,7 @@
public byte[] getEncoded()
throws CertificateEncodingException {
return null;
- }
+ }
public void verify(PublicKey key)
throws CertificateException, NoSuchAlgorithmException,
@@ -56,7 +56,7 @@
}
public void verify(PublicKey key, String sigProvider)
- throws CertificateException, NoSuchAlgorithmException,
+ throws CertificateException, NoSuchAlgorithmException,
InvalidKeyException, NoSuchProviderException,
SignatureException {
}
@@ -122,7 +122,7 @@
assertFalse("The Certificates with differing encoded form "
+ "should not be equal", tbt_cert.equals(tbt_cert_3));
assertFalse("The Certificates should not be equals to the object "
- + "which is not an instance of Certificate",
+ + "which is not an instance of Certificate",
tbt_cert.equals(new Object()));
}
@@ -149,8 +149,4 @@
return new TestSuite(CertificateTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java
index a09bc59..0673547 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/X509CertificateTest.java
@@ -45,11 +45,11 @@
public class X509CertificateTest extends TestCase {
- // Testing data was generated by using of classes
+ // Testing data was generated by using of classes
// from org.apache.harmony.security.asn1 package encoded
// by org.apache.harmony.misc.Base64 class.
- private static String base64cert =
+ private static String base64cert =
"-----BEGIN CERTIFICATE-----\n" +
"MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a" +
"WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF" +
@@ -67,7 +67,7 @@
"XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1" +
"UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP" +
"7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n" +
- "-----END CERTIFICATE-----";
+ "-----END CERTIFICATE-----";
private java.security.cert.X509Certificate cert;
private javax.security.cert.X509Certificate tbt_cert;
@@ -337,8 +337,4 @@
return new TestSuite(X509CertificateTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.java
index f71436e..616f148 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateEncodingExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for CertificateEncodingException serialization
- *
+ *
*/
public class CertificateEncodingExceptionTest extends SerializationTest {
@@ -44,7 +44,4 @@
new CertificateEncodingException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateEncodingExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.java
index ad6f9f1..ad9577e 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CertificateException serialization
- *
+ * Test for CertificateException serialization
+ *
*/
public class CertificateExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new CertificateException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.java
index 7a69b3b..61052ff 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateExpiredExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for CertificateExpiredException serialization
- *
+ *
*/
public class CertificateExpiredExceptionTest extends SerializationTest {
@@ -44,7 +44,4 @@
new CertificateExpiredException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateExpiredExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.java
index df1ea9e..e6de86a 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateNotYetValidExceptionTest.java
@@ -27,8 +27,8 @@
/**
- * Test for CertificateNotYetValidException serialization
- *
+ * Test for CertificateNotYetValidException serialization
+ *
*/
public class CertificateNotYetValidExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new CertificateNotYetValidException(msgs[1])};
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateNotYetValidExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.java
index 4a6f42f..d9ae899 100644
--- a/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.java
+++ b/security/src/test/api/java/org/apache/harmony/security/tests/javax/security/cert/serialization/CertificateParsingExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for CertificateParsingException serialization
- *
+ *
*/
public class CertificateParsingExceptionTest extends SerializationTest {
@@ -44,7 +44,4 @@
new CertificateParsingException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(CertificateParsingExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java b/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java
index 972a51a..7a66ba2 100644
--- a/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java
+++ b/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java
@@ -75,7 +75,7 @@
this.thisUpdate = thisUpdate;
this.nextUpdate = nextUpdate;
}
-
+
public void setCrlNumber(BigInteger crlNumber) {
this.crlNumber = crlNumber;
}
@@ -350,7 +350,7 @@
* setMinCRLNumber(BigInteger minCRL) method testing.
* Tests if CRLs with any crl number value match the selector in the case of
* null crlNumber criteria, if specified minCRL value matches the selector,
- * and if CRL with inappropriate crlNumber value does not match the selector.
+ * and if CRL with inappropriate crlNumber value does not match the selector.
*/
public void testSetMinCRLNumber() {
X509CRLSelector selector = new X509CRLSelector();
@@ -372,7 +372,7 @@
* setMaxCRLNumber(BigInteger maxCRL) method testing.
* Tests if CRLs with any crl number value match the selector in the case of
* null crlNumber criteria, if specified maxCRL value matches the selector,
- * and if CRL with inappropriate crlNumber value does not match the selector.
+ * and if CRL with inappropriate crlNumber value does not match the selector.
*/
public void testSetMaxCRLNumber() {
X509CRLSelector selector = new X509CRLSelector();
@@ -393,7 +393,7 @@
/**
* setDateAndTime(Date dateAndTime) method testing.
* Tests if CRLs with any update dates match the selector in the case of
- * null dateAndTime criteria, if correct dates match and incorrect
+ * null dateAndTime criteria, if correct dates match and incorrect
* do not match the selector.
*/
public void testSetDateAndTime() {
@@ -440,7 +440,7 @@
selector.addIssuerName(iss_name_2);
selector.addIssuer(iss2);
selector.addIssuerName(iss_name_3);
-
+
Collection result = selector.getIssuers();
assertEquals("Size does not correspond to expected",
5, result.size());
@@ -493,7 +493,7 @@
/**
* getMinCRL() method testing.
- * Tests if the method return null in the case of not specified minCRL
+ * Tests if the method return null in the case of not specified minCRL
* criteria, and if the returned value corresponds to the specified one.
*/
public void testGetMinCRL() {
@@ -508,7 +508,7 @@
/**
* getMaxCRL() method testing.
- * Tests if the method return null in the case of not specified maxCRL
+ * Tests if the method return null in the case of not specified maxCRL
* criteria, and if the returned value corresponds to the specified one.
*/
public void testGetMaxCRL() {
@@ -523,7 +523,7 @@
/**
* getDateAndTime() method testing.
- * Tests if the method return null in the case of not specified dateAndTime
+ * Tests if the method return null in the case of not specified dateAndTime
* criteria, and if the returned value corresponds to the specified one.
*/
public void testGetDateAndTime() {
@@ -542,7 +542,7 @@
*/
public void testMatch() {
X509CRLSelector selector = new X509CRLSelector();
- assertFalse("The null object should not match",
+ assertFalse("The null object should not match",
selector.match((X509CRL) null));
}
@@ -576,7 +576,7 @@
clone.addIssuer(iss3);
assertFalse("The changes of the clone selector should not cause "
- + "the changes of initial object",
+ + "the changes of initial object",
selector.getIssuerNames().size() == 3);
}
@@ -601,8 +601,4 @@
return new TestSuite(X509CRLSelectorTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java b/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
index dfb0fb0..fa44d39 100644
--- a/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
+++ b/security/src/test/impl/java.injected/java/security/cert/X509CertSelectorTest.java
@@ -87,7 +87,7 @@
* The abstract class stub implementation.
*/
private class TestCert extends X509Certificate {
-
+
/* Stuff fields */
protected String equalCriteria = null; // to simplify method equals()
protected BigInteger serialNumber = null;
@@ -105,10 +105,10 @@
protected byte[] encoding = null;
protected String[] policies = null;
protected NameConstraints nameConstraints = null;
-
+
/* Stuff methods */
public TestCert() {}
-
+
public TestCert(GeneralNames sans) {
setSubjectAlternativeNames(sans);
}
@@ -120,129 +120,129 @@
public TestCert(String equalCriteria) {
setEqualCriteria(equalCriteria);
}
-
+
public TestCert(String[] policies) {
setPolicies(policies);
}
-
+
public TestCert(BigInteger serial) {
setSerialNumber(serial);
}
-
+
public TestCert(X500Principal principal) {
setIssuer(principal);
setSubject(principal);
}
-
+
public TestCert(byte[] array) {
setKeyIdentifier(array);
}
-
+
public TestCert(Date date) {
setDate(date);
}
-
+
public TestCert(Date notBefore, Date notAfter) {
setPeriod(notBefore, notAfter);
}
-
+
public TestCert(PublicKey key) {
setPublicKey(key);
}
-
+
public TestCert(boolean[] keyUsage) {
setKeyUsage(keyUsage);
}
-
+
public TestCert(Set extKeyUsage) {
setExtendedKeyUsage(extKeyUsage);
}
-
+
public TestCert(int pathLen) {
this.pathLen = pathLen;
}
-
+
public void setPolicies(String[] policies) {
this.policies = policies;
}
-
+
public void setSubjectAlternativeNames(GeneralNames sans) {
this.sans = sans;
}
public void setExtendedKeyUsage(Set extKeyUsage) {
- this.extKeyUsage = (extKeyUsage == null)
- ? null
+ this.extKeyUsage = (extKeyUsage == null)
+ ? null
: new ArrayList(extKeyUsage);
}
-
+
public void setKeyUsage(boolean[] keyUsage) {
this.keyUsage = (keyUsage == null) ? null
: (boolean[]) keyUsage.clone();
}
-
+
public void setPublicKey(PublicKey key) {
this.key = key;
}
-
+
public void setPeriod(Date notBefore, Date notAfter) {
this.notBefore = notBefore;
this.notAfter = notAfter;
}
-
+
public void setSerialNumber(BigInteger serial) {
this.serialNumber = serial;
}
public void setEqualCriteria(String equalCriteria) {
- this.equalCriteria = equalCriteria;
+ this.equalCriteria = equalCriteria;
}
-
+
public void setIssuer(X500Principal issuer) {
- this.issuer = issuer;
+ this.issuer = issuer;
}
-
+
public void setSubject(X500Principal subject) {
- this.subject = subject;
+ this.subject = subject;
}
-
+
public void setKeyIdentifier(byte[] subjectKeyID) {
- this.keyIdentifier = subjectKeyID.clone();
+ this.keyIdentifier = subjectKeyID.clone();
}
-
+
public void setDate(Date date) {
- this.date = new Date(date.getTime());
+ this.date = new Date(date.getTime());
}
public void setEncoding(byte[] encoding) {
this.encoding = encoding;
}
-
- /* Method implementations */
+
+ /* Method implementations */
public boolean equals(Object cert) {
if (cert == null) {
return false;
}
- if ((equalCriteria == null)
+ if ((equalCriteria == null)
|| (((TestCert)cert).equalCriteria == null)) {
return false;
} else {
return equalCriteria.equals(((TestCert)cert).equalCriteria);
}
}
-
+
public String toString() {
if (equalCriteria != null) {
return equalCriteria;
}
return "";
}
-
+
public void checkValidity() throws CertificateExpiredException,
CertificateNotYetValidException {}
- public void checkValidity(Date date)
- throws CertificateExpiredException,
+ public void checkValidity(Date date)
+ throws CertificateExpiredException,
CertificateNotYetValidException {
if (this.date == null) {
throw new CertificateExpiredException();
@@ -261,19 +261,19 @@
}
public BigInteger getSerialNumber() {
- return (serialNumber == null)
- ? new BigInteger("1111")
+ return (serialNumber == null)
+ ? new BigInteger("1111")
: serialNumber;
}
public Principal getIssuerDN() {
return issuer;
}
-
+
public X500Principal getIssuerX500Principal() {
return issuer;
}
-
+
public Principal getSubjectDN() {
return subject;
}
@@ -337,8 +337,8 @@
throws CertificateParsingException {
return sans.getPairsList();
}
-
-
+
+
public void verify(PublicKey key)
throws CertificateException, NoSuchAlgorithmException,
InvalidKeyException, NoSuchProviderException,
@@ -377,7 +377,7 @@
return ASN1OctetString.getInstance().encode(keyIdentifier);
}
if ("2.5.29.16".equals(oid)) {
- PrivateKeyUsagePeriod pkup =
+ PrivateKeyUsagePeriod pkup =
new PrivateKeyUsagePeriod(notBefore, notAfter);
byte[] encoded = pkup.getEncoded();
return ASN1OctetString.getInstance().encode(encoded);
@@ -415,10 +415,10 @@
return ASN1OctetString.getInstance().encode(
GeneralNames.ASN1.encode(sans));
}
- if ("2.5.29.32".equals(oid) && (policies != null)
+ if ("2.5.29.32".equals(oid) && (policies != null)
&& (policies.length > 0)) {
// Certificate Policies Extension (as specified in rfc 3280)
- CertificatePolicies certificatePolicies =
+ CertificatePolicies certificatePolicies =
new CertificatePolicies();
for (int i=0; i<policies.length; i++) {
PolicyInformation policyInformation =
@@ -444,7 +444,7 @@
/* ********************************************************************** */
/* ************************* Test implementation ************************ */
/* ********************************************************************** */
-
+
/**
* setCertificate(X509Certificate certificate) method testing.
* Tests if any certificates match in the case of null criteria,
@@ -472,7 +472,7 @@
/**
* getCertificate() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetCertificate() {
TestCert cert_1 = new TestCert("same certificate");
@@ -516,7 +516,7 @@
/**
* getSerialNumber() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetSerialNumber() {
BigInteger ser1 = new BigInteger("10000");
@@ -560,7 +560,7 @@
/**
* getIssuer() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetIssuer() {
X500Principal iss1 = new X500Principal("O=First Org.");
@@ -607,7 +607,7 @@
/**
* getIssuerAsString() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetIssuerAsString() {
String name1 = "O=First Org.";
@@ -619,14 +619,14 @@
assertNull("Selector should return null", selector.getIssuerAsString());
selector.setIssuer(iss1);
assertEquals("The returned issuer should be equal to specified",
- new X500Principal(name1),
+ new X500Principal(name1),
new X500Principal(selector.getIssuerAsString()));
assertFalse("The returned issuer should differ",
- new X500Principal(name2).equals(
+ new X500Principal(name2).equals(
new X500Principal(selector.getIssuerAsString())));
selector.setIssuer(iss2);
assertEquals("The returned issuer should be equal to specified",
- new X500Principal(name2),
+ new X500Principal(name2),
new X500Principal(selector.getIssuerAsString()));
}
@@ -668,7 +668,7 @@
/**
* getIssuerAsBytes() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetIssuerAsBytes() throws IOException {
byte[] name1 = new byte[]
@@ -727,7 +727,7 @@
/**
* getSubject() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetSubject() {
X500Principal sub1 = new X500Principal("O=First Org.");
@@ -775,7 +775,7 @@
/**
* getSubjectAsString() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetSubjectAsString() {
String name1 = "O=First Org.";
@@ -784,18 +784,18 @@
X500Principal sub2 = new X500Principal(name2);
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getSubjectAsString());
selector.setSubject(sub1);
assertEquals("The returned subject should be equal to specified",
- new X500Principal(name1),
+ new X500Principal(name1),
new X500Principal(selector.getSubjectAsString()));
assertFalse("The returned subject should differ",
- new X500Principal(name2).equals(
+ new X500Principal(name2).equals(
new X500Principal(selector.getSubjectAsString())));
selector.setSubject(sub2);
assertEquals("The returned subject should be equal to specified",
- new X500Principal(name2),
+ new X500Principal(name2),
new X500Principal(selector.getSubjectAsString()));
}
@@ -838,7 +838,7 @@
/**
* getSubjectAsBytes() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetSubjectAsBytes() throws IOException {
byte[] name1 = new byte[]
@@ -871,7 +871,7 @@
/**
* setSubjectKeyIdentifier(byte[] subjectKeyID) method testing.
* Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
+ * if [not]proper certificates [do not]match, and if the initialization
* object are copied during the initialization.
*/
public void testSetSubjectKeyIdentifier() {
@@ -899,7 +899,7 @@
/**
* getSubjectKeyIdentifier() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
* and its modification does not cause the modification of internal object.
*/
public void testGetSubjectKeyIdentifier() {
@@ -907,7 +907,7 @@
byte[] skid2 = new byte[] {4, 5, 5, 4, 3, 2, 1}; // random value
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getSubjectKeyIdentifier());
selector.setSubjectKeyIdentifier(skid1);
assertTrue("The returned keyID should be equal to specified",
@@ -922,7 +922,7 @@
/**
* setAuthorityKeyIdentifier(byte[] authorityKeyID) method testing.
* Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
+ * if [not]proper certificates [do not]match, and if the initialization
* object are copied during the initialization.
*/
public void testSetAuthorityKeyIdentifier() {
@@ -950,7 +950,7 @@
/**
* getAuthorityKeyIdentifier() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
* and its modification does not cause the modification of internal object.
*/
public void testGetAuthorityKeyIdentifier() {
@@ -958,7 +958,7 @@
byte[] akid2 = new byte[] {4, 5, 5, 4, 3, 2, 1}; // random value
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getAuthorityKeyIdentifier());
selector.setAuthorityKeyIdentifier(akid1);
assertTrue("The returned keyID should be equal to specified",
@@ -973,7 +973,7 @@
/**
* setCertificateValid(Date certificateValid) method testing.
* Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
+ * if [not]proper certificates [do not]match, and if the initialization
* object are copied during the initialization.
*/
public void testSetCertificateValid() {
@@ -1001,7 +1001,7 @@
/**
* getCertificateValid() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
* and its modification does not cause the modification of internal object.
*/
public void testGetCertificateValid() {
@@ -1009,7 +1009,7 @@
Date date2 = new Date(200);
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getCertificateValid());
selector.setCertificateValid(date1);
assertTrue("The returned date should be equal to specified",
@@ -1024,7 +1024,7 @@
/**
* setPrivateKeyValid(Date privateKeyValid) method testing.
* Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
+ * if [not]proper certificates [do not]match, and if the initialization
* object are copied during the initialization.
*/
public void testSetPrivateKeyValid() {
@@ -1055,7 +1055,7 @@
/**
* getPrivateKeyValid() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
* and its modification does not cause the modification of internal object.
*/
public void testGetPrivateKeyValid() {
@@ -1063,7 +1063,7 @@
Date date2 = new Date(200);
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getPrivateKeyValid());
selector.setPrivateKeyValid(date1);
assertTrue("The returned date should be equal to specified",
@@ -1124,14 +1124,14 @@
/**
* getSubjectPublicKeyAlgID() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
*/
public void testGetSubjectPublicKeyAlgID() throws IOException {
String pkaid1 = "1.2.840.113549.1.1.1"; // RSA encryption (source: http://asn1.elibel.tm.fr)
String pkaid2 = "1.2.840.113549.1.1.2"; // MD2 with RSA encryption (source: http://asn1.elibel.tm.fr)
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getSubjectPublicKeyAlgID());
selector.setSubjectPublicKeyAlgID(pkaid1);
@@ -1171,7 +1171,7 @@
/**
* getSubjectPublicKey() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value corresponds to specified
+ * if the returned value corresponds to specified
*/
public void testGetSubjectPublicKey1() throws Exception {
@@ -1179,11 +1179,11 @@
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getSubjectPublicKey());
selector.setSubjectPublicKey(pkey);
PublicKey result = selector.getSubjectPublicKey();
-
+
assertEquals("The name of algorithm should be RSA",
result.getAlgorithm(), "RSA");
}
@@ -1191,7 +1191,7 @@
/**
* setSubjectPublicKey(byte[] key) method testing.
* Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
+ * if [not]proper certificates [do not]match, and if the initialization
* object are copied during the initialization.
*/
public void testSetSubjectPublicKey2() throws Exception {
@@ -1227,7 +1227,7 @@
/**
* getSubjectPublicKey() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value corresponds to specified
+ * if the returned value corresponds to specified
*/
public void testGetSubjectPublicKey2() throws Exception {
@@ -1235,13 +1235,13 @@
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getSubjectPublicKey());
selector.setSubjectPublicKey(pkey.getEncoded());
PublicKey result = selector.getSubjectPublicKey();
-
+
assertEquals("The name of algorithm should be RSA",
result.getAlgorithm(), "RSA");
}
@@ -1249,12 +1249,12 @@
/**
* setKeyUsage(boolean[] keyUsage) method testing.
* Tests if any certificates match in the case of null criteria,
- * if [not]proper certificates [do not]match, and if the initialization
+ * if [not]proper certificates [do not]match, and if the initialization
* object are copied during the initialization. Also checks if selector
* matches the certificate which does not have a keyUsage extension.
*/
public void testSetKeyUsage() {
- boolean[] ku1 = new boolean[]
+ boolean[] ku1 = new boolean[]
{true, true, true, true, true, true, true, true, true};
// decipherOnly is disallowed
boolean[] ku2 = new boolean[]
@@ -1285,7 +1285,7 @@
/**
* getKeyUsage() method testing.
* Tests if the method return null in the case of not specified criteria,
- * if the returned value [does not]corresponds to [not]specified
+ * if the returned value [does not]corresponds to [not]specified
* and its modification does not cause the modification of internal object.
*/
public void testGetKeyUsage() {
@@ -1308,13 +1308,13 @@
*/
public void testSetExtendedKeyUsage() throws IOException {
HashSet ku1 = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
+ "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
+ "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
"1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
));
HashSet ku2 = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
+ "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
+ "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
"1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6"}));
TestCert cert_1 = new TestCert(ku1);
TestCert cert_2 = new TestCert(ku2);
@@ -1349,13 +1349,13 @@
*/
public void testGetExtendedKeyUsage() {
HashSet ku = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
+ "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
+ "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
"1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
));
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getExtendedKeyUsage());
try {
selector.setExtendedKeyUsage(ku);
@@ -1371,20 +1371,20 @@
} catch (UnsupportedOperationException e) {
}
}
-
+
/**
* setSubjectAlternativeNames(Collection<List<?>> names) method testing.
*/
public void testSetSubjectAlternativeNames() {
try {
- GeneralName san0 =
- new GeneralName(new OtherName("1.2.3.4.5",
+ GeneralName san0 =
+ new GeneralName(new OtherName("1.2.3.4.5",
new byte[] {1, 2, 0, 1}));
GeneralName san1 = new GeneralName(1, "rfc@822.Name");
GeneralName san2 = new GeneralName(2, "dNSName");
GeneralName san3 = new GeneralName(new ORAddress());
GeneralName san4 = new GeneralName(new Name("O=Organization"));
- GeneralName san5 =
+ GeneralName san5 =
new GeneralName(new EDIPartyName("assigner", "party"));
GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
GeneralName san7 = new GeneralName(7, "1.1.1.1");
@@ -1402,7 +1402,7 @@
sans_1.addName(san8);
GeneralNames sans_2 = new GeneralNames();
sans_2.addName(san0);
-
+
TestCert cert_1 = new TestCert(sans_1);
TestCert cert_2 = new TestCert(sans_2);
X509CertSelector selector = new X509CertSelector();
@@ -1412,7 +1412,7 @@
assertTrue("Any certificate should match in the case of null "
+ "subjectAlternativeNames criteria.",
selector.match(cert_1) && selector.match(cert_2));
-
+
Collection sans = sans_1.getPairsList();
selector.setSubjectAlternativeNames(sans);
assertTrue("The certificate should match the selection criteria.",
@@ -1460,7 +1460,7 @@
GeneralNames sans_2 = new GeneralNames();
sans_2.addName(san1);
sans_2.addName(san2);
-
+
TestCert cert_1 = new TestCert(sans_1);
TestCert cert_2 = new TestCert(sans_2);
X509CertSelector selector = new X509CertSelector();
@@ -1517,8 +1517,8 @@
*/
public void testAddSubjectAlternativeName2() {
try {
- GeneralName san0 =
- new GeneralName(new OtherName("1.2.3.4.5",
+ GeneralName san0 =
+ new GeneralName(new OtherName("1.2.3.4.5",
ASN1Integer.getInstance().encode(
BigInteger.valueOf(55L).toByteArray())
));
@@ -1526,7 +1526,7 @@
GeneralName san2 = new GeneralName(2, "dNSName");
GeneralName san3 = new GeneralName(new ORAddress());
GeneralName san4 = new GeneralName(new Name("O=Organization"));
- GeneralName san5 =
+ GeneralName san5 =
new GeneralName(new EDIPartyName("assigner", "party"));
GeneralName san6 = new GeneralName(6, "http://uniform.Resource.Id");
GeneralName san7 = new GeneralName(new byte[] {1, 1, 1, 1});
@@ -1546,7 +1546,7 @@
sans_2.addName(san0);
sans_2.addName(san1);
sans_2.addName(san2);
-
+
TestCert cert_1 = new TestCert(sans_1);
TestCert cert_2 = new TestCert(sans_2);
X509CertSelector selector = new X509CertSelector();
@@ -1622,7 +1622,7 @@
TestCert cert_1 = new TestCert(sans);
X509CertSelector selector = new X509CertSelector();
- assertNull("Selector should return null",
+ assertNull("Selector should return null",
selector.getSubjectAlternativeNames());
selector.setSubjectAlternativeNames(sans.getPairsList());
@@ -1677,7 +1677,7 @@
*/
public void testGetMatchAllSubjectAltNames() {
X509CertSelector selector = new X509CertSelector();
- assertTrue("The matchAllNames initially should be true",
+ assertTrue("The matchAllNames initially should be true",
selector.getMatchAllSubjectAltNames());
selector.setMatchAllSubjectAltNames(false);
assertFalse("The value should be false",
@@ -1690,10 +1690,10 @@
* GeneralNames of types: 1, 2, 6, 7 and set it as a criterion.
*/
public void testSetNameConstraints0() throws IOException {
- // Restrictions apply only when the specified name form is present.
- // If no name of the type is in the certificate,
+ // Restrictions apply only when the specified name form is present.
+ // If no name of the type is in the certificate,
// the certificate is acceptable (rfc 3280).
-
+
GeneralName [] name_constraints = new GeneralName[] {
new GeneralName(1, "822.Name"),
new GeneralName(1, "rfc@822.Name"),
@@ -1712,7 +1712,7 @@
// 3, 3, 3, 3, 3, 3, 3, 3})
};
- // names which should match divided from names which should not
+ // names which should match divided from names which should not
// match by null
GeneralName[][] alternative_names = new GeneralName[][] {
{
@@ -1734,12 +1734,12 @@
new GeneralName(2, "Name.org"),
new GeneralName(2, "dNS.OtherName.org")
}, {
-
+
// new GeneralName(4, "O=Organization"),
// null,
// new GeneralName(4, "O=OtherOrganization")
//}, {
-
+
new GeneralName(6, "http://uniform.Resource.Id/location"),
null,
//new GeneralName(6, "http://Resource.Id")
@@ -1784,7 +1784,7 @@
for (int i=0; i<name_constraints.length; i++) {
// make the subtrees (part of name constraints)
// this subtrees will be used as permited and as excluded
- GeneralSubtree subtree =
+ GeneralSubtree subtree =
new GeneralSubtree(name_constraints[i]);
GeneralSubtrees subtrees = new GeneralSubtrees();
NameConstraints constraints;
@@ -1795,46 +1795,46 @@
for (int j=0; j<alternative_names[i].length; j++) {
GeneralNames alt_names_extension = new GeneralNames();
if (alternative_names[i][j] == null) {
- // double trick: turn the switch and check that the
- // restrictions apply only when the specified name
+ // double trick: turn the switch and check that the
+ // restrictions apply only when the specified name
// form is presented. If no name of the type is in the
- // certificate, the certificate is acceptable.
+ // certificate, the certificate is acceptable.
check_matching = false;
} else {
alt_names_extension.addName(alternative_names[i][j]);
}
TestCert certificate = new TestCert(alt_names_extension);
certificate.setSubject(x500Subject);
- certificate.setEncoding(getCertEncoding(nameSubject,
+ certificate.setEncoding(getCertEncoding(nameSubject,
alt_names_extension));
// first check if permited name match
constraints = new NameConstraints(subtrees, null);
selector.setNameConstraints(constraints.getEncoded());
boolean expected = check_matching
|| (alternative_names[i][j] == null);
- assertTrue("The method match() for:\n "
- + alternative_names[i][j]
+ assertTrue("The method match() for:\n "
+ + alternative_names[i][j]
+ "\nand permited name\n "
+ name_constraints[i]
- + "\nshould return: "+expected,
+ + "\nshould return: "+expected,
selector.match(certificate) == expected);
// second check if excluded name does not match
- constraints = (check_matching)
- // check for 'Any name matching a
+ constraints = (check_matching)
+ // check for 'Any name matching a
// restriction in the excludedSubtrees
- // field is invalid regardless of
- // information appearing in the
+ // field is invalid regardless of
+ // information appearing in the
// permittedSubtrees'.
? new NameConstraints(subtrees, subtrees)
: new NameConstraints(null, subtrees);
selector.setNameConstraints(constraints.getEncoded());
expected = !check_matching
|| (alternative_names[i][j] == null);
- assertTrue("The method match() for:\n "
- + alternative_names[i][j]
+ assertTrue("The method match() for:\n "
+ + alternative_names[i][j]
+ "\nand excluded name\n "
+ name_constraints[i]
- + "\nshould return: "+expected,
+ + "\nshould return: "+expected,
selector.match(certificate) == expected);
}
}
@@ -1860,15 +1860,15 @@
new GeneralName(6, "http://uniform.Resource.Id"),
new GeneralName(7, "1.1.1.1"),
new GeneralName(7, "1.1.1.1/3.3.3.3"),
- new GeneralName(7, "0101:0101:0101:0101:0101:0101:0101:0101"),
- new GeneralName(7, "0101:0101:0101:0101:0101:0101:0101:0101"
- + "/0303:0303:0303:0303:0303:0303:0303:0303"),
+ new GeneralName(7, "0101:0101:0101:0101:0101:0101:0101:0101"),
+ new GeneralName(7, "0101:0101:0101:0101:0101:0101:0101:0101"
+ + "/0303:0303:0303:0303:0303:0303:0303:0303"),
};
- // Names which should match divided from names which should not
+ // Names which should match divided from names which should not
// match by null.
- // Restrictions apply only when the specified name form is present.
- // If no name of the type is in the certificate, the certificate
+ // Restrictions apply only when the specified name form is present.
+ // If no name of the type is in the certificate, the certificate
// is acceptable (rfc 3280). This assertion is checked during processing
// of null GeneralName object (it also serves as separator).
GeneralName[][] alternative_names = new GeneralName[][] {
@@ -1891,7 +1891,7 @@
new GeneralName(2, "Name.org"),
new GeneralName(2, "dNS.OtherName.org")
}, {
-
+
new GeneralName(6, "http://uniform.Resource.Id/location"),
null,
new GeneralName(6, "http://Resource.Id")
@@ -1936,7 +1936,7 @@
for (int i=0; i<name_constraints.length; i++) {
// make the subtrees (part of name constraints)
// this subtrees will be used as permited and as excluded
- GeneralSubtree subtree =
+ GeneralSubtree subtree =
new GeneralSubtree(name_constraints[i]);
GeneralSubtrees subtrees = new GeneralSubtrees();
NameConstraints constraints;
@@ -1947,46 +1947,46 @@
for (int j=0; j<alternative_names[i].length; j++) {
GeneralNames alt_names_extension = new GeneralNames();
if (alternative_names[i][j] == null) {
- // double trick: turn the switch and check that the
- // restrictions apply only when the specified name
+ // double trick: turn the switch and check that the
+ // restrictions apply only when the specified name
// form is presented. If no name of the type is in the
- // certificate, the certificate is acceptable.
+ // certificate, the certificate is acceptable.
check_matching = false;
} else {
alt_names_extension.addName(alternative_names[i][j]);
}
TestCert certificate = new TestCert(alt_names_extension);
certificate.setSubject(x500Subject);
- certificate.setEncoding(getCertEncoding(nameSubject,
+ certificate.setEncoding(getCertEncoding(nameSubject,
alt_names_extension));
// first check if permited name match
constraints = new NameConstraints(subtrees, null);
selector.setNameConstraints(constraints.getEncoded());
boolean expected = check_matching
|| (alternative_names[i][j] == null);
- assertTrue("The method match() for:\n "
- + alternative_names[i][j]
+ assertTrue("The method match() for:\n "
+ + alternative_names[i][j]
+ "\nand permited name\n "
+ name_constraints[i]
- + "\nshould return: "+expected,
+ + "\nshould return: "+expected,
selector.match(certificate) == expected);
// second check if excluded name does not match
- constraints = (check_matching)
- // check for 'Any name matching a
+ constraints = (check_matching)
+ // check for 'Any name matching a
// restriction in the excludedSubtrees
- // field is invalid regardless of
- // information appearing in the
+ // field is invalid regardless of
+ // information appearing in the
// permittedSubtrees'.
? new NameConstraints(subtrees, subtrees)
: new NameConstraints(null, subtrees);
selector.setNameConstraints(constraints.getEncoded());
expected = !check_matching
|| (alternative_names[i][j] == null);
- assertTrue("The method match() for:\n "
- + alternative_names[i][j]
+ assertTrue("The method match() for:\n "
+ + alternative_names[i][j]
+ "\nand excluded name\n "
+ name_constraints[i]
- + "\nshould return: "+expected,
+ + "\nshould return: "+expected,
selector.match(certificate) == expected);
}
}
@@ -2006,13 +2006,13 @@
// As specified in rfc 3280:
//
// Restrictions apply only when the specified name form is present.
- // If no name of the type is in the certificate,
+ // If no name of the type is in the certificate,
// the certificate is acceptable.
//
- // Restrictions of the form directoryName MUST be applied to the
- // subject field in the certificate and to the subjectAltName
+ // Restrictions of the form directoryName MUST be applied to the
+ // subject field in the certificate and to the subjectAltName
// extensions of type directoryName.
- //
+ //
// According to p. 4.1.2.4 comparing the encoded forms of the names.
String[][] variants = new String[][] {
@@ -2035,7 +2035,7 @@
alt_names_extension.addName(alt_name);
TestCert certificate = new TestCert(alt_names_extension);
certificate.setSubject(subject);
- certificate.setEncoding(getCertEncoding(subject_name,
+ certificate.setEncoding(getCertEncoding(subject_name,
alt_names_extension));
// make the subtrees (part of name constraints)
// this subtrees will be used as permited and as excluded
@@ -2056,51 +2056,51 @@
constraints = new NameConstraints(pos_subtrees, null);
selector.setNameConstraints(constraints.getEncoded());
assertTrue("The method match() for certificate "
- + "with subject:\n "
- + variants[i][0]
- + "\nand with alternative name:\n "
- + variants[i][1]
+ + "with subject:\n "
+ + variants[i][0]
+ + "\nand with alternative name:\n "
+ + variants[i][1]
+ "\nand permited name\n "
- + variants[i][2]
- + "\nshould return true",
+ + variants[i][2]
+ + "\nshould return true",
selector.match(certificate));
// second check if certificate with excluded name doesn't match:
constraints = new NameConstraints(pos_subtrees, pos_subtrees);
selector.setNameConstraints(constraints.getEncoded());
assertTrue("The method match() for certificate "
- + "with subject:\n "
+ + "with subject:\n "
+ variants[i][0]
- + "\nand with alternative name:\n "
+ + "\nand with alternative name:\n "
+ variants[i][1]
+ "\nand excluded name\n "
+ variants[i][2]
- + "\nshould return false",
+ + "\nshould return false",
!selector.match(certificate));
// Work with name which is not presented in certificate
- // first check if the certificate without permited name
+ // first check if the certificate without permited name
// does not match:
constraints = new NameConstraints(neg_subtrees, null);
selector.setNameConstraints(constraints.getEncoded());
assertTrue("The method match() for certificate "
- + "with subject:\n "
+ + "with subject:\n "
+ variants[i][0]
- + "\nand with alternative name:\n "
+ + "\nand with alternative name:\n "
+ variants[i][1]
+ "\nand permited name\n "
+ variants[i][3]
- + "\nshould return false",
+ + "\nshould return false",
!selector.match(certificate));
// second check if certificate without excluded name matches:
constraints = new NameConstraints(neg_subtrees, neg_subtrees);
selector.setNameConstraints(constraints.getEncoded());
assertTrue("The method match() for certificate "
- + "with subject:\n "
+ + "with subject:\n "
+ variants[i][0]
- + "\nand with alternative name:\n "
+ + "\nand with alternative name:\n "
+ variants[i][1]
+ "\nand excluded name\n "
+ variants[i][3]
- + "\nshould return false",
+ + "\nshould return false",
!selector.match(certificate));
}
} catch (IOException e) {
@@ -2117,32 +2117,32 @@
throws IOException {
// make the TBSCertificate for Certificate
int version = 2; //v3
- BigInteger serialNumber = BigInteger.valueOf(555L);
+ BigInteger serialNumber = BigInteger.valueOf(555L);
AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555");
Name issuer = new Name("O=Certificate Issuer");
- Validity validity = new Validity(new Date(100000000),
+ Validity validity = new Validity(new Date(100000000),
new Date(200000000));
- SubjectPublicKeyInfo subjectPublicKeyInfo =
+ SubjectPublicKeyInfo subjectPublicKeyInfo =
new SubjectPublicKeyInfo(
- new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
+ new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
new byte[10]);
- boolean[] issuerUniqueID = new boolean[]
+ boolean[] issuerUniqueID = new boolean[]
{true, false, true, false, true, false, true, false};
boolean[] subjectUniqueID = new boolean[]
{false, true, false, true, false, true, false, true};
- Extension extension = new Extension("2.5.29.17",
+ Extension extension = new Extension("2.5.29.17",
true, subjectAltNames.getEncoded());
Extensions extensions = new Extensions();
extensions.addExtension(extension);
-
- TBSCertificate tbsCertificate = new TBSCertificate(version,
- serialNumber, signature, issuer, validity, subject,
- subjectPublicKeyInfo, issuerUniqueID, subjectUniqueID,
+
+ TBSCertificate tbsCertificate = new TBSCertificate(version,
+ serialNumber, signature, issuer, validity, subject,
+ subjectPublicKeyInfo, issuerUniqueID, subjectUniqueID,
extensions);
// make the Certificate
- org.apache.harmony.security.x509.Certificate certificate =
+ org.apache.harmony.security.x509.Certificate certificate =
new org.apache.harmony.security.x509.Certificate
(tbsCertificate, signature, new byte[10]);
@@ -2164,7 +2164,7 @@
fail("IllegalArgumentException should be thrown.");
} catch (IllegalArgumentException e) {
}
-
+
int plen1 = 2;
int plen2 = -1;
TestCert cert_1 = new TestCert(plen1);
@@ -2193,7 +2193,7 @@
int plen2 = -1;
X509CertSelector selector = new X509CertSelector();
- assertEquals("Selector should return -1",
+ assertEquals("Selector should return -1",
selector.getBasicConstraints(), -1);
selector.setBasicConstraints(plen1);
assertEquals("The returned value should be equal to specified",
@@ -2231,17 +2231,17 @@
TestCert cert_2 = new TestCert(policies_2);
TestCert cert_3 = new TestCert(policies_3);
TestCert cert_4 = new TestCert(policies_4);
- assertTrue("The certificate should match the specified criteria",
+ assertTrue("The certificate should match the specified criteria",
selector.match(cert_1));
- assertTrue("The certificate should match the specified criteria",
+ assertTrue("The certificate should match the specified criteria",
selector.match(cert_2));
- assertFalse("The certificate should not match the specified criteria",
+ assertFalse("The certificate should not match the specified criteria",
selector.match(cert_3));
- assertFalse("The certificate should not match the specified criteria",
+ assertFalse("The certificate should not match the specified criteria",
selector.match(cert_4));
set.add("2.2.2.2.2.2");
assertFalse("The modification of the set should not cause the "
- + "modification of internal object",
+ + "modification of internal object",
selector.match(cert_3));
set = new HashSet();
try {
@@ -2250,13 +2250,13 @@
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
- assertTrue("The certificate should match the specified criteria",
+ assertTrue("The certificate should match the specified criteria",
selector.match(cert_1));
- assertTrue("The certificate should match the specified criteria",
+ assertTrue("The certificate should match the specified criteria",
selector.match(cert_2));
- assertTrue("The certificate should match the specified criteria",
+ assertTrue("The certificate should match the specified criteria",
selector.match(cert_3));
- assertFalse("The certificate should not match the specified criteria",
+ assertFalse("The certificate should not match the specified criteria",
selector.match(cert_4));
set.add("2.2.2.2.2.2");
try {
@@ -2265,13 +2265,13 @@
e.printStackTrace();
fail("Unexpected IOException was thrown.");
}
- assertFalse("The certificate should not match the specified criteria",
+ assertFalse("The certificate should not match the specified criteria",
selector.match(cert_1));
- assertTrue("The certificate should match the specified criteria",
+ assertTrue("The certificate should match the specified criteria",
selector.match(cert_2));
- assertTrue("The certificate should match the specified criteria",
+ assertTrue("The certificate should match the specified criteria",
selector.match(cert_3));
- assertFalse("The certificate should not match the specified criteria",
+ assertFalse("The certificate should not match the specified criteria",
selector.match(cert_4));
}
@@ -2330,15 +2330,15 @@
TestCert cert;
GeneralSubtrees subtrees;
- NameConstraints constraints;
+ NameConstraints constraints;
for (int i=0; i<names.length; i+=2) {
// Set up the pathToNames criterion
ArrayList pathToNames = new ArrayList();
pathToNames.add(names[i].getAsList());
selector.setPathToNames(pathToNames);
-
+
// Construct the subtrees without the current name
- subtrees = new GeneralSubtrees();
+ subtrees = new GeneralSubtrees();
for (int j=0; j<names.length; j++) {
if (i != j && i+1 != j) {
subtrees.addSubtree(new GeneralSubtree(names[j]));
@@ -2446,13 +2446,13 @@
TestCert cert;
GeneralSubtrees subtrees;
- NameConstraints constraints;
+ NameConstraints constraints;
for (int i=0; i<names.length-2; i+=2) {
// Set up the pathToNames criterion
selector.addPathToName(types[i], names[i]);
-
+
// Construct the subtrees without the current name
- subtrees = new GeneralSubtrees();
+ subtrees = new GeneralSubtrees();
for (int j=i+2; j<names.length; j++) {
if (i != j && i+1 != j) {
subtrees.addSubtree(
@@ -2563,13 +2563,13 @@
TestCert cert;
GeneralSubtrees subtrees;
- NameConstraints constraints;
+ NameConstraints constraints;
for (int i=0; i<names.length-2; i+=2) {
// Set up the pathToNames criterion
selector.addPathToName(types[i], names[i]);
-
+
// Construct the subtrees without the current name
- subtrees = new GeneralSubtrees();
+ subtrees = new GeneralSubtrees();
for (int j=i+2; j<names.length; j++) {
if (i != j && i+1 != j) {
subtrees.addSubtree(
@@ -2660,7 +2660,7 @@
*/
public void testGetPathToNames() {
try {
- byte[] encoding =
+ byte[] encoding =
new GeneralName(1, "rfc@822.Name").getEncodedName();
X509CertSelector selector = new X509CertSelector();
@@ -2671,7 +2671,7 @@
Iterator it = coll.iterator();
List list = (List) it.next();
Object result = list.get(1);
- if ((result instanceof byte[])
+ if ((result instanceof byte[])
&& (encoding[0] == ((byte[])result)[0])) {
fail("Deep copy should be performed on pathToNames.");
}
@@ -2704,8 +2704,8 @@
{true, true, true, true, true, true, true, true, false};
// OID values was taken from rfc 3280
HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
+ "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
+ "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
"1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
));
GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
@@ -2721,7 +2721,7 @@
"1.1.1.1.1.1",
};
TestCert cert = new TestCert("certificate equality criteria");
-
+
X509CertSelector selector = new X509CertSelector();
selector.setCertificate(cert);
selector.setSerialNumber(serial);
@@ -2739,13 +2739,13 @@
selector.setMatchAllSubjectAltNames(true);
selector.setPolicy(new HashSet(Arrays.asList(policies)));
- assertNotNull("The result should not be null.",
+ assertNotNull("The result should not be null.",
selector.toString());
}
/**
* match(Certificate cert) method testing.
- * Tests if the null object matches to the selector or does not,
+ * Tests if the null object matches to the selector or does not,
* and if the certificate conforming to the multiple matching criteria
* matches or does not..
*/
@@ -2769,8 +2769,8 @@
{true, true, true, true, true, true, true, true, false};
// OID values was taken from rfc 3280
HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
+ "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
+ "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
"1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
));
GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
@@ -2785,7 +2785,7 @@
"0.0.0.0.0.0",
"1.1.1.1.1.1",
};
-
+
TestCert cert = new TestCert("certificate equality criteria");
cert.setSerialNumber(serial);
cert.setIssuer(issuer);
@@ -2798,7 +2798,7 @@
cert.setExtendedKeyUsage(extKeyUsage);
cert.setSubjectAlternativeNames(subjectAltNames);
cert.setPolicies(policies);
-
+
X509CertSelector selector = new X509CertSelector();
selector.setCertificate(cert);
selector.setSerialNumber(serial);
@@ -2816,9 +2816,9 @@
selector.setMatchAllSubjectAltNames(true);
selector.setPolicy(new HashSet(Arrays.asList(policies)));
- assertFalse("The null object should not match",
+ assertFalse("The null object should not match",
selector.match((X509Certificate) null));
- assertTrue("The certificate should match the selector",
+ assertTrue("The certificate should match the selector",
selector.match(cert));
}
@@ -2864,8 +2864,8 @@
{true, true, true, true, true, true, true, true, false};
// OID values was taken from rfc 3280
HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
- "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
- "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
+ "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
+ "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
"1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
));
GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
@@ -2880,7 +2880,7 @@
"0.0.0.0.0.0",
"1.1.1.1.1.1",
};
-
+
TestCert cert = new TestCert("certificate equality criteria");
cert.setSerialNumber(serial);
cert.setIssuer(issuer);
@@ -2893,7 +2893,7 @@
cert.setExtendedKeyUsage(extKeyUsage);
cert.setSubjectAlternativeNames(subjectAltNames);
cert.setPolicies(policies);
-
+
X509CertSelector selector = new X509CertSelector();
selector.setCertificate(cert);
selector.setSerialNumber(serial);
@@ -2911,7 +2911,7 @@
selector.setMatchAllSubjectAltNames(true);
selector.setPolicy(new HashSet(Arrays.asList(policies)));
- assertTrue("The certificate should match the selector",
+ assertTrue("The certificate should match the selector",
((X509CertSelector)selector.clone()).match(cert));
}
@@ -2920,8 +2920,4 @@
return new TestSuite(X509CertSelectorTest.class);
}
- public static void main(String[] args) {
- //new X509CertSelectorTest().testSetSubjectPublicKey1();
- junit.textui.TestRunner.run(suite());
- }
}
diff --git a/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java b/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
index 97e4e09..efd910f 100644
--- a/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
+++ b/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
@@ -48,7 +48,7 @@
// Base64 encoded form of ASN.1 DER encoded X.509 Certificate
// (see RFC 3280 at http://www.ietf.org/rfc/rfc3280.txt)
- // (generated by using of classes from
+ // (generated by using of classes from
// org.apache.harmony.security.x509 package)
static String base64cert =
"MIIByzCCATagAwIBAgICAiswCwYJKoZIhvcNAQEFMB0xGzAZBgNVBAoT"
@@ -66,9 +66,9 @@
// Base64 encoded form of ASN.1 DER encoded X.509 CRL
// (see RFC 3280 at http://www.ietf.org/rfc/rfc3280.txt)
- // (generated by using of classes from
+ // (generated by using of classes from
// org.apache.harmony.security.x509 package)
- static String base64crl =
+ static String base64crl =
"MIHXMIGXAgEBMAkGByqGSM44BAMwFTETMBEGA1UEChMKQ1JMIElzc3Vl"
+ "chcNMDYwNDI3MDYxMzQ1WhcNMDYwNDI3MDYxNTI1WjBBMD8CAgIrFw0w"
+ "NjA0MjcwNjEzNDZaMCowCgYDVR0VBAMKAQEwHAYDVR0YBBUYEzIwMDYw"
@@ -271,15 +271,10 @@
X509CRL crl = (X509CRL) certFactory.generateCRL(is);
crl.getExtensionValue("1.1.1.1");
}
-
-
+
+
public static Test suite() {
return new TestSuite(X509CertificateTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
-
diff --git a/security/src/test/impl/java.injected/org/apache/harmony/security/DefaultPolicyScannerTest.java b/security/src/test/impl/java.injected/org/apache/harmony/security/DefaultPolicyScannerTest.java
index 87e8654..f11fd84 100644
--- a/security/src/test/impl/java.injected/org/apache/harmony/security/DefaultPolicyScannerTest.java
+++ b/security/src/test/impl/java.injected/org/apache/harmony/security/DefaultPolicyScannerTest.java
@@ -36,14 +36,10 @@
/**
* TODO Put your class description here
- *
+ *
*/
public class DefaultPolicyScannerTest extends TestCase {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(DefaultPolicyScannerTest.class);
- }
private static String IO_ERROR = "Failed intentionally";
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/SystemScopeTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/SystemScopeTest.java
index 1b4f7aa..6421c74 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/SystemScopeTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/SystemScopeTest.java
@@ -34,19 +34,15 @@
/**
- * Unit test for class org.apache.harmony.security.SystemScope
- *
+ * Unit test for class org.apache.harmony.security.SystemScope
+ *
*/
public class SystemScopeTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SystemScopeTest.class);
- }
-
IdentityScope ss = null;
- final static boolean mode = true;
-
+ final static boolean mode = true;
+
/*
* @see TestCase#setUp()
*/
@@ -71,7 +67,7 @@
/**
* verify SystemScope.size() returns number of Identities
*/
-
+
public void testSize() throws Exception {
//SystemScope ss = new SystemScope("SystemScope");
assertEquals(0, ss.size());
@@ -87,12 +83,12 @@
public void testGetIdentityString() throws Exception {
//SystemScope ss = new SystemScope("SystemScope");
assertNull(ss.getIdentity("aaa"));
-
+
java.security.Identity aaa = new IdentityScopeStub("aaa");
ss.addIdentity(aaa);
assertSame(aaa, ss.getIdentity(aaa.getName()));
assertNull(ss.getIdentity("bbb"));
-
+
}
/*
@@ -105,8 +101,8 @@
java.security.Identity aaa = new IdentityScopeStub("aaa");
aaa.setPublicKey(kkk);
ss.addIdentity(aaa);
-
- assertSame(aaa, ss.getIdentity(kkk));
+
+ assertSame(aaa, ss.getIdentity(kkk));
}
/**
@@ -115,35 +111,35 @@
*/
public void testAddIdentity() throws Exception {
// SystemScope ss = new SystemScope("SystemScope");
- java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);
+ java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);
java.security.Identity aaa = new IdentityScopeStub("aaa");
aaa.setPublicKey(kkk);
ss.addIdentity(aaa);
-
+
java.security.Identity bbb = new IdentityScopeStub("aaa");
try {
ss.addIdentity(bbb);
fail("KeyManagementException should be thrown for already used name");
} catch (KeyManagementException ok) {}
-
+
java.security.Identity ccc = new IdentityScopeStub("ccc");
ccc.setPublicKey(kkk);
try {
ss.addIdentity(ccc);
fail("KeyManagementException should be thrown for already used key");
- } catch (KeyManagementException ok) {}
-
-
+ } catch (KeyManagementException ok) {}
+
+
}
/**
* verify that identities are removed
* @throws Exception
*/
-
+
public void testRemoveIdentity() throws Exception{
-// SystemScope ss = new SystemScope("SystemScope");
- java.security.Identity aaa = new IdentityScopeStub("aaa");
+// SystemScope ss = new SystemScope("SystemScope");
+ java.security.Identity aaa = new IdentityScopeStub("aaa");
ss.addIdentity(aaa);
assertEquals(1, ss.size());
ss.removeIdentity(aaa);
@@ -151,12 +147,12 @@
}
public void testIdentities() throws Exception {
-// SystemScope ss = new SystemScope("SystemScope");
+// SystemScope ss = new SystemScope("SystemScope");
java.security.Identity aaa = new IdentityScopeStub("aaa");
java.security.Identity bbb = new IdentityScopeStub("bbb");
ss.addIdentity(aaa);
ss.addIdentity(bbb);
-
+
boolean hasAaa = false, hasBbb = false;
Enumeration e = ss.identities();
while (e.hasMoreElements()){
@@ -164,7 +160,7 @@
if (!hasAaa) hasAaa = (i==aaa);
if (!hasBbb) hasBbb = (i==bbb);
}
- assertTrue(hasAaa && hasBbb);
+ assertTrue(hasAaa && hasBbb);
}
/*
@@ -178,7 +174,7 @@
*/
public void testSystemScopeString() {
SystemScope ss = new SystemScope("SystemScope");
- assertEquals("SystemScope", ss.getName());
+ assertEquals("SystemScope", ss.getName());
}
/*
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/UnresolvedPrincipalTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/UnresolvedPrincipalTest.java
index a847324..bb3392f 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/UnresolvedPrincipalTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/UnresolvedPrincipalTest.java
@@ -28,15 +28,11 @@
/**
* Tests for <code>UnresolvedPrincipal</code>
- *
+ *
*/
public class UnresolvedPrincipalTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(UnresolvedPrincipalTest.class);
- }
-
public void testCtor() {
String klass = "abc";
String name = "NAME";
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/AnyTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/AnyTest.java
index 8272950..76974c4 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/AnyTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/AnyTest.java
@@ -33,16 +33,12 @@
/**
* ASN.1 DER test for ANY type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class AnyTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(AnyTest.class);
- }
-
private static byte[] encoded = new byte[] { 0x01, 0x03, 0x11, 0x13, 0x15 };
public void testDecode() throws IOException {
@@ -56,4 +52,4 @@
encoded);
assertTrue("False", Arrays.equals(encoded, out.encoded));
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BerInputStreamTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BerInputStreamTest.java
index 93d8bf4..1834f15 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BerInputStreamTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BerInputStreamTest.java
@@ -34,16 +34,12 @@
/**
* Tests BerInputStream implementation
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class BerInputStreamTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BerInputStreamTest.class);
- }
-
/**
* @tests org.apache.harmony.security.asn1.BerInputStream#BerInputStream(
* java.io.ByteArrayInputStream)
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BitStringTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BitStringTest.java
index 2d54719..c1daff7 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BitStringTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BitStringTest.java
@@ -36,23 +36,19 @@
/**
* ASN.1 DER test for Bitstring type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class BitStringTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BitStringTest.class);
- }
-
private static Object[][] validBitstring = new Object[][] {
//bitstring array format: bitstring object/ byte array
//
- { new BitString(new byte[] {}, 0), // object
+ { new BitString(new byte[] {}, 0), // object
new byte[] { 0x03, 0x01, 0x00 } },
//
- { new BitString(new byte[] { 0x05 }, 0), // object
+ { new BitString(new byte[] { 0x05 }, 0), // object
new byte[] { 0x03, 0x02, 0x00, 0x05 } },
//
{ new BitString(new byte[] { (byte) 0x80 }, 7), // object
@@ -143,7 +139,7 @@
//
{ new boolean[] { true }, // object
new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } },
- //
+ //
{ new boolean[] { true, false, true }, // object
new byte[] { 0x03, 0x02, 0x05, (byte) 0xA0 } },
//
@@ -183,7 +179,7 @@
new boolean[] { true, false, false, false, false,
false, false, false }, // object
new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } },
- //
+ //
{
new boolean[] { true, false, true, false, false, false,
false, false }, // object
@@ -224,7 +220,7 @@
//
{ new boolean[] { true }, // object
new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } },
- //
+ //
{ new boolean[] { true, false, true }, // object
new byte[] { 0x03, 0x02, 0x05, (byte) 0xA0 } },
//
@@ -247,4 +243,4 @@
(byte[]) testcaseBoolean[i][1], out.encoded));
}
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BooleanTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BooleanTest.java
index 36f7aaf..8532a60 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BooleanTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/BooleanTest.java
@@ -34,15 +34,11 @@
/**
* ASN.1 DER test for Boolean type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class BooleanTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BooleanTest.class);
- }
-
private static byte[] eFalse = new byte[] { 0x01, 0x01, 0x00 };
private static byte[] eTrue = new byte[] { 0x01, 0x01, (byte) 0xFF };
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ChoiceTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ChoiceTest.java
index af0d3ea..f5143a0 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ChoiceTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ChoiceTest.java
@@ -45,16 +45,12 @@
/**
* ASN.1 DER test for Choice type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class ChoiceTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(ChoiceTest.class);
- }
-
private static ASN1SequenceOf sequence = new ASN1SequenceOf(ASN1Boolean
.getInstance());
@@ -89,7 +85,7 @@
//
private static Object[][] testcases = {
- // format: object to encode / byte array
+ // format: object to encode / byte array
// choice = Boolean (false)
{ Boolean.FALSE, new byte[] { 0x01, 0x01, 0x00 } },
@@ -100,7 +96,7 @@
// choice = SequenceOf (empty)
{ new ArrayList(), new byte[] { 0x30, 0x00 } },
- //TODO add testcase for another ASN.1 type`
+ //TODO add testcase for another ASN.1 type`
};
@@ -164,10 +160,10 @@
assertTrue("Second: ", Arrays.equals(new byte[] { 0x09 },
(byte[]) values.get(1)));
}
-
+
//
//
- //
+ //
//
//
@@ -195,7 +191,7 @@
assertEquals("True: ", Boolean.TRUE, explicit.decode(encoded));
}
-
+
/**
* TODO Put method description here
*/
@@ -334,4 +330,4 @@
} catch (IllegalArgumentException e) {
}
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ExplicitTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ExplicitTest.java
index b87f4a9..d9a3ef8 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ExplicitTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ExplicitTest.java
@@ -38,16 +38,12 @@
/**
* ASN.1 DER test for Explicitly tagged type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class ExplicitTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(ExplicitTest.class);
- }
-
private static ASN1SequenceOf sequence = new ASN1SequenceOf(ASN1Boolean
.getInstance());
@@ -194,4 +190,4 @@
(byte[]) taggedType[i][1], out.encoded));
}
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/GeneralizedTimeTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/GeneralizedTimeTest.java
index e14153e..cedb31c 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/GeneralizedTimeTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/GeneralizedTimeTest.java
@@ -34,7 +34,7 @@
/**
* ASN.1 DER test for GeneralizedTime type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
@@ -97,8 +97,8 @@
/**
* Verifies DER decoding/encoding ASN.1 GeneralizedTime.
- * GeneralizedTime expresses Greenwich Mean Time by
- * the following pattern: YYYYMMDDHHMMSS'Z'
+ * GeneralizedTime expresses Greenwich Mean Time by
+ * the following pattern: YYYYMMDDHHMMSS'Z'
*/
public void test_Decode_Encode() throws Exception {
@@ -140,7 +140,7 @@
.getTime();
assertEquals(old_date, new_date);
}
-
+
public void test_EncodeMilliseconds() throws IOException{
//cRegression for HARMONY-2302
long old_date = 1164358741071L;
@@ -148,8 +148,5 @@
.getTime();
assertEquals(old_date, new_date);
}
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(GeneralizedTimeTest.class);
- }
+
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ImplicitTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ImplicitTest.java
index 864adf0..67db8ae 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ImplicitTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/ImplicitTest.java
@@ -40,16 +40,12 @@
/**
* ASN.1 DER test for Implicitly tagged type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class ImplicitTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(ImplicitTest.class);
- }
-
private static ASN1SequenceOf sequence = new ASN1SequenceOf(ASN1Boolean
.getInstance());
@@ -185,10 +181,10 @@
(byte[]) taggedType[i][1], out.encoded));
}
}
-
+
/**
* Tests 2 consecutive implicit string type tagging
- *
+ *
* TYPE1 = [1] IMPLICIT OCTET STRING
* TYPE2 = [2] IMPLICIT TYPE1
*/
@@ -198,7 +194,7 @@
ASN1Implicit type2 = new ASN1Implicit(2, type1);
byte[] primitiveEncoding = new byte[] {
- // tag: class(CONTEXT SPECIFIC) + number (2)
+ // tag: class(CONTEXT SPECIFIC) + number (2)
(byte) 0x82,
// length
0x03,
@@ -206,7 +202,7 @@
0x00, 0x01, 0x02 };
byte[] constructedEncoding = new byte[] {
- // tag: class(CONTEXT SPECIFIC) + constructed +number (2)
+ // tag: class(CONTEXT SPECIFIC) + constructed +number (2)
(byte) 0xA2,
// length
0x00 };
@@ -231,4 +227,4 @@
e.getMessage());
}
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/IntegerTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/IntegerTest.java
index 2a16fd7..0c208c5 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/IntegerTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/IntegerTest.java
@@ -36,16 +36,12 @@
/**
* ASN.1 DER test for INTEGER type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class IntegerTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(IntegerTest.class);
- }
-
public static final Object[][] validTestcase = {
// BigInteger / two's-complement representation / encoding
{ new BigInteger("0"), null, null },
@@ -99,7 +95,7 @@
Arrays.equals((byte[]) validTestcase[i][1], // expected
(byte[]) asn1.decode(in))); // returned
}
-
+
// decode from input stream
for (int i = 0; i < validTestcase.length; i++) {
DerInputStream in = new DerInputStream(new ByteArrayInputStream(
@@ -127,9 +123,9 @@
new byte[] { 0x01, 0x01, 0x00 },
// wrong length: length is 0
new byte[] { 0x02, 0x00 },
- // wrong content: is not encoded in minimum number of octets
+ // wrong content: is not encoded in minimum number of octets
new byte[] { 0x02, 0x02, 0x00, 0x00 },
- // wrong content: is not encoded in minimum number of octets
+ // wrong content: is not encoded in minimum number of octets
new byte[] { 0x02, 0x02, (byte) 0xFF, (byte) 0x80 } };
for (int i = 0; i < invalid.length; i++) {
@@ -151,4 +147,4 @@
.toIntValue(ASN1Integer.fromIntValue(testcase[i])));
}
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/OidTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/OidTest.java
index 5fd6b5f..5c11e0d 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/OidTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/OidTest.java
@@ -34,16 +34,12 @@
/**
* ASN.1 DER test for OID type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class OidTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(OidTest.class);
- }
-
private static Object[][] oid = {
//oid array format: string / int array / DER encoding
{ "0.0", // as string
@@ -95,7 +91,7 @@
{ "2.5.4.3",// as string
new int[] { 2, 5, 4, 3 }, // as int array
new byte[] { 0x06, 0x03, 0x55, 0x04, 0x03 } },
- //
+ //
{ "2.39.3", // as string
new int[] { 2, 39, 3 }, // as int array
new byte[] { 0x06, 0x02, 0x77, 0x03 } },
@@ -135,7 +131,7 @@
Arrays.equals((int[]) oid[i][1], // expected array
decoded));
}
-
+
// testing encoding
for (int i = 0; i < oid.length; i++) {
@@ -154,9 +150,9 @@
new byte[] { 0x02, 0x01, 0x00 },
// wrong length: length is 0
new byte[] { 0x06, 0x00 },
- // wrong content: bit 8 of the last byte is not 0
+ // wrong content: bit 8 of the last byte is not 0
new byte[] { 0x06, 0x02, (byte) 0x81, (byte) 0x80 },
- // wrong content: is not encoded in fewest number of bytes
+ // wrong content: is not encoded in fewest number of bytes
//FIXME new byte[] { 0x06, 0x02, (byte) 0x80, (byte) 0x01 }
};
@@ -174,7 +170,7 @@
// oid decoder/encoder for testing
ASN1Oid asn1 = ASN1Oid.getInstanceForString();
-
+
// testing decoding
for (int i = 0; i < oid.length; i++) {
assertEquals("Failed to decode oid: " + oid[i][0], // error message
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceOfTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceOfTest.java
index 5d7ca8e..1c987c6 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceOfTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceOfTest.java
@@ -37,16 +37,12 @@
/**
* ASN.1 DER test for SequenceOf type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class SequenceOfTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SequenceOfTest.class);
- }
-
private static ASN1SequenceOf sequenceOf = new ASN1SequenceOf(ASN1Boolean
.getInstance());
@@ -55,7 +51,7 @@
//
private static Object[][] testcases = new Object[][] {
- // format: object to encode / byte array
+ // format: object to encode / byte array
// sequence : empty sequence
new Object[] { new ArrayList(), new byte[] { 0x30, 0x00 } },
@@ -76,7 +72,7 @@
0x01, 0x01, 0x00 } //false
},
- //TODO add testcase for another ASN.1 type`
+ //TODO add testcase for another ASN.1 type`
};
@@ -133,4 +129,4 @@
return this;
}
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceTest.java
index 846a528..64a879a 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/SequenceTest.java
@@ -41,16 +41,12 @@
/**
* ASN.1 DER test for Sequence type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
public class SequenceTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SequenceTest.class);
- }
-
private static ASN1SequenceOf sequenceOf = new ASN1SequenceOf(ASN1Boolean
.getInstance());
@@ -99,7 +95,7 @@
//
testcases = new Object[][] {
- // format: object to encode / byte array
+ // format: object to encode / byte array
// sequence : all values are default
{ new AppClass(Boolean.TRUE, defaultList),
@@ -117,7 +113,7 @@
{ new AppClass(Boolean.FALSE, new ArrayList()),
new byte[] { 0x30, 0x05, 0x01, 0x01, 0x00, 0x30, 0x00 } },
- //TODO add testcase for another ASN.1 type`
+ //TODO add testcase for another ASN.1 type`
};
}
@@ -194,7 +190,7 @@
}
/**
- * Tests encoding default fields
+ * Tests encoding default fields
*/
public void testEncodeDefault() throws IOException {
@@ -233,9 +229,9 @@
encoded = s.encode(new Object[] { new byte[] { 0x01 } });
assertTrue("Encoded integer:", Arrays.equals(expectedArray, encoded));
}
-
+
/**
- * Tests encoding optional fields
+ * Tests encoding optional fields
*/
public void testEncodeOptional() throws IOException {
@@ -252,7 +248,7 @@
try {
s.encode(new Object[] { null });
- fail("No expected RuntimeException");
+ fail("No expected RuntimeException");
} catch (RuntimeException e) {
}
@@ -274,4 +270,4 @@
byte[] encoded = s.encode(new Object[] { null });
assertTrue("Encoded boolean:", Arrays.equals(expectedArray, encoded));
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/UTCTimeTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/UTCTimeTest.java
index 3f90bbe..1de7522 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/UTCTimeTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/asn1/der/UTCTimeTest.java
@@ -32,7 +32,7 @@
/**
* ASN.1 DER test for UTCTime type
- *
+ *
* @see http://asn1.elibel.tm.fr/en/standards/index.htm
*/
@@ -121,7 +121,4 @@
}
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(UTCTimeTest.class);
- }
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyParserTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyParserTest.java
index 1227741..a6e5e01 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyParserTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyParserTest.java
@@ -38,18 +38,14 @@
/**
* Tests for DefaultPolicyParser
- *
+ *
*/
public class DefaultPolicyParserTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(DefaultPolicyParserTest.class);
- }
-
/**
* Tests parsing of a sample policy from temporary file, validates returned
- * PolicyEntries.
+ * PolicyEntries.
*/
public void testParse() throws Exception {
File tmp = File.createTempFile("policy", null);
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyTest.java
index 552b285..6d230f3 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyTest.java
@@ -43,14 +43,10 @@
/**
* Tests for DefaultPolicy
- *
+ *
*/
public class DefaultPolicyTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(DefaultPolicyTest.class);
- }
-
static class TestParser extends DefaultPolicyParser {
PolicyEntry[] content;
@@ -69,7 +65,7 @@
}
/**
- * Tests that policy is really resetted on refresh().
+ * Tests that policy is really resetted on refresh().
*/
public void testRefresh() {
Permission sp = new SecurityPermission("sdf");
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/DRLCertFactoryTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/DRLCertFactoryTest.java
index 04deb92..b92df7f 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/DRLCertFactoryTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/DRLCertFactoryTest.java
@@ -35,7 +35,7 @@
*/
public class DRLCertFactoryTest extends TestCase {
- // The testing data was generated by using of classes
+ // The testing data was generated by using of classes
// from org.apache.harmony.security.asn1 package.
// 2 consecutively encoded X.509 certificates
@@ -202,7 +202,7 @@
public void testDRLCertFactory() {
CertificateFactory certFactory;
try {
- certFactory =
+ certFactory =
CertificateFactory.getInstance("X509", "DRLCertFactory");
} catch (CertificateException e) {
fail("X509 certificate type is not available: "+e.getMessage());
@@ -214,25 +214,21 @@
// DER encoded certificate generation testing
ByteArrayInputStream bais = new ByteArrayInputStream(certEncoding);
try {
- assertNotNull("Generated certificate is null",
+ assertNotNull("Generated certificate is null",
certFactory.generateCertificate(bais));
} catch (CertificateException e) {
fail("Unexpected CertificateException: " + e.getMessage());
}
-
+
try {
certFactory.generateCertificate(bais);
fail("Expected CertificateException was not thrown.");
} catch (CertificateException e) {
}
}
-
+
public static Test suite() {
return new TestSuite(DRLCertFactoryTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLEntryImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLEntryImplTest.java
index c2b9bdf..9affc33 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLEntryImplTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLEntryImplTest.java
@@ -45,7 +45,7 @@
*/
public void testGetExtensionValue() throws Exception {
// revoked certificate issuer
- X500Principal issuer =
+ X500Principal issuer =
new X500Principal("O=Certificate Issuer");
// revoked certificate serial number
BigInteger serialNumber = BigInteger.valueOf(555);
@@ -77,8 +77,4 @@
return new TestSuite(X509CRLEntryImplTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java
index 9685178..ae09f86 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CRLImplTest.java
@@ -73,7 +73,7 @@
private static String algOID = "1.2.840.10040.4.3";
private static String algName = "SHA1withDSA";
// DER boolean false encoding (http://asn1.elibel.tm.fr)
- // Makes no sense. For testing purposes we need just provide
+ // Makes no sense. For testing purposes we need just provide
// some ASN.1 structure:
private static byte[] algParams = {1, 1, 0};
private static AlgorithmIdentifier signature;
@@ -123,12 +123,12 @@
private static Date revocationDate = new Date();
private static List revokedCertificates = Arrays.asList(
new TBSCertList.RevokedCertificate[] {
- new TBSCertList.RevokedCertificate(certSerialNumber1,
+ new TBSCertList.RevokedCertificate(certSerialNumber1,
revocationDate, null),
// the item for certificate issued by other authority
new TBSCertList.RevokedCertificate(certSerialNumber2,
revocationDate, crlEntryExtensions),
- new TBSCertList.RevokedCertificate(certSerialNumber3,
+ new TBSCertList.RevokedCertificate(certSerialNumber3,
revocationDate, null),
});
private static Extensions crlExtensions;
@@ -140,7 +140,7 @@
new Extension("2.5.29.20", Extension.NON_CRITICAL,
new CRLNumber(BigInteger.valueOf(4444))),
// Authority Key Identifier
- new Extension("2.5.29.35", false,
+ new Extension("2.5.29.35", false,
new AuthorityKeyIdentifier(
// keyIdentifier (random value)
new byte[] {1, 2, 3, 4, 5},
@@ -148,7 +148,7 @@
new GeneralNames(
Arrays.asList(new GeneralName[] {
new GeneralName(new Name(certIssuerName))
- })),
+ })),
// authorityCertSerialNumber
certSerialNumber2)),
// Issuing Distribution Point
@@ -189,7 +189,7 @@
private static X509CRLImpl crl;
private static CertificateList certificateList;
- private static TBSCertList tbscertlist;
+ private static TBSCertList tbscertlist;
private static byte[] encoding;
private static byte[] tbsEncoding;
static CertificateFactory factory;
@@ -198,12 +198,12 @@
try {
Name issuer = new Name(issuerName);
- tbscertlist =
- new TBSCertList(2, signature, issuer, thisUpdate,
+ tbscertlist =
+ new TBSCertList(2, signature, issuer, thisUpdate,
nextUpdate, revokedCertificates, crlExtensions);
-
+
tbsEncoding = tbscertlist.getEncoded();
-
+
try {
Signature sig= Signature.getInstance("DSA");
sig.initSign(privateKey);
@@ -219,20 +219,20 @@
fail("Unexpected Exception was thrown: "+e.getMessage());
}
}
-
+
ByteArrayInputStream stream;
-
+
protected void setUp() throws java.lang.Exception {
if ("testVerify3".equals(getName())) {
signatureValue = new byte[signatureValueBytes.length];
// make incorrect signature value:
- System.arraycopy(signatureValueBytes, 0,
+ System.arraycopy(signatureValueBytes, 0,
signatureValue, 0, signatureValueBytes.length);
signatureValue[20]++;
} else {
signatureValue = signatureValueBytes;
}
- certificateList =
+ certificateList =
new CertificateList(tbscertlist, signature, signatureValue);
encoding = CertificateList.ASN1.encode(certificateList);
@@ -240,7 +240,7 @@
crl = new X509CRLImpl(certificateList);
}
-
+
private static int XXX = 0, counter = 0;
public void testCreationCRL() throws Exception {
@@ -250,23 +250,23 @@
}
byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
System.arraycopy(tmp, 0, stamp, 0, tmp.length);
- System.arraycopy(stamp, 0, encoding,
+ System.arraycopy(stamp, 0, encoding,
encoding.length-stamp.length, stamp.length);
stream.reset();
java.security.cert.X509CRL c = (java.security.cert.X509CRL)
factory.generateCRL(stream);
-
+
if (counter == 1) {
System.out.println("\nUSING: "+ c.getClass());
}
-
+
byte[] enc = c.getEncoded();
byte[] stamp_chek = new byte[stamp.length];
-
- System.arraycopy(enc, enc.length - stamp.length,
+
+ System.arraycopy(enc, enc.length - stamp.length,
stamp_chek, 0, stamp.length);
-
+
if (!Arrays.equals(stamp, stamp_chek)) {
fail("Wrong encoding received.");
}
@@ -278,13 +278,13 @@
*/
public void testX509CRLImpl() {
try {
- new X509CRLImpl((CertificateList)
+ new X509CRLImpl((CertificateList)
CertificateList.ASN1.decode(encoding));
} catch (IOException e) {
fail("Unexpected exception was thrown");
}
}
-
+
/**
* getEncoded() method testing.
*/
@@ -297,30 +297,30 @@
fail("Unexpected CRLException was thrown.");
}
}
-
+
/**
* getVersion() method testing.
*/
public void testGetVersion() {
assertEquals("Incorrect version value", 2, crl.getVersion());
}
-
+
/**
* getIssuerDN() method testing.
*/
public void testGetIssuerDN() {
- assertEquals("Incorrect issuer value",
+ assertEquals("Incorrect issuer value",
new X500Principal(issuerName), crl.getIssuerDN());
}
-
+
/**
* getIssuerX500Principal() method testing.
*/
public void testGetIssuerX500Principal() {
- assertEquals("Incorrect issuer value",
+ assertEquals("Incorrect issuer value",
new X500Principal(issuerName), crl.getIssuerDN());
}
-
+
/**
* getThisUpdate() method testing.
*/
@@ -328,7 +328,7 @@
assertTrue("Incorrect thisUpdate value",
thisUpdate.getTime()/1000 == crl.getThisUpdate().getTime()/1000);
}
-
+
/**
* getNextUpdate() method testing.
*/
@@ -336,7 +336,7 @@
assertTrue("Incorrect nextUpdate value",
nextUpdate.getTime()/1000 == crl.getNextUpdate().getTime()/1000);
}
-
+
/**
* getRevokedCertificate(X509Certificate certificate) method testing.
*/
@@ -344,38 +344,38 @@
try {
X509CertImpl cert1 = new X509CertImpl(
new Certificate(
- new TBSCertificate(2, certSerialNumber1, signature,
- new Name(certIssuerName),
+ new TBSCertificate(2, certSerialNumber1, signature,
+ new Name(certIssuerName),
new Validity(new Date(), new Date()),
- new Name(certIssuerName),
+ new Name(certIssuerName),
new SubjectPublicKeyInfo(signature, new byte[10]),
null, null, null),
signature, new byte[10]));
X509CertImpl cert2 = new X509CertImpl(
new Certificate(
- new TBSCertificate(2, certSerialNumber2, signature,
- new Name(certIssuerName),
+ new TBSCertificate(2, certSerialNumber2, signature,
+ new Name(certIssuerName),
new Validity(new Date(), new Date()),
- new Name(certIssuerName),
+ new Name(certIssuerName),
new SubjectPublicKeyInfo(signature, new byte[10]),
null, null, null),
signature, new byte[10]));
X509CertImpl cert3 = new X509CertImpl(
new Certificate(
- new TBSCertificate(2, certSerialNumber3, signature,
- new Name("O=Another Cert Issuer"),
+ new TBSCertificate(2, certSerialNumber3, signature,
+ new Name("O=Another Cert Issuer"),
new Validity(new Date(), new Date()),
- new Name(certIssuerName),
+ new Name(certIssuerName),
new SubjectPublicKeyInfo(signature, new byte[10]),
null, null, null),
signature, new byte[10]));
- assertNull("Certificate should not be presented in CRL "
- + "because issuer is not the same as CRL issuer",
+ assertNull("Certificate should not be presented in CRL "
+ + "because issuer is not the same as CRL issuer",
crl.getRevokedCertificate(cert1));
- assertNotNull("Certificate should be presented in CRL",
+ assertNotNull("Certificate should be presented in CRL",
crl.getRevokedCertificate(cert2));
- assertNull("Certificate should not be presented in CRL "
- + "because issuer is not the same as CRL issuer",
+ assertNull("Certificate should not be presented in CRL "
+ + "because issuer is not the same as CRL issuer",
crl.getRevokedCertificate(cert3));
} catch (IOException e) {
// should never happen;
@@ -383,22 +383,22 @@
fail("Unexpected IOException was thrown:"+e.getMessage());
}
}
-
+
/**
* getRevokedCertificate(BigInteger serialNumber) method testing.
*/
public void testGetRevokedCertificate2() {
assertNotNull("The revoked certificate with the serial number '"
- + certSerialNumber1 + "' should be presented in CRL.",
+ + certSerialNumber1 + "' should be presented in CRL.",
crl.getRevokedCertificate(certSerialNumber1));
assertNull("The revoked certificate with the serial number '"
- + certSerialNumber2 + "' should not be presented in CRL.",
+ + certSerialNumber2 + "' should not be presented in CRL.",
crl.getRevokedCertificate(certSerialNumber2));
assertNull("The revoked certificate with the serial number '"
- + certSerialNumber3 + "' should not be presented in CRL.",
+ + certSerialNumber3 + "' should not be presented in CRL.",
crl.getRevokedCertificate(certSerialNumber3));
}
-
+
/**
* getRevokedCertificates() method testing.
*/
@@ -408,14 +408,14 @@
assertTrue("The size of returned set is incorrect",
rcerts.size() == revokedCertificates.size());
}
-
+
/**
* getTBSCertList() method testing.
*/
public void testGetTBSCertList() {
try {
assertTrue(
- "Retrieved tbsCertList encoding does not equal to expected",
+ "Retrieved tbsCertList encoding does not equal to expected",
Arrays.equals(tbscertlist.getEncoded(),
crl.getTBSCertList()));
} catch(CRLException e) {
@@ -423,7 +423,7 @@
fail("Unexpected CRLException was thrown: "+e.getMessage());
}
}
-
+
/**
* getSignature() method testing.
*/
@@ -432,7 +432,7 @@
fail("Incorrect Signature value.");
}
}
-
+
/**
* getSigAlgName() method testing.
*/
@@ -440,7 +440,7 @@
assertEquals("Incorrect value of signature algorithm name",
algName, crl.getSigAlgName());
}
-
+
/**
* getSigAlgOID() method testing.
*/
@@ -448,7 +448,7 @@
assertEquals("Incorrect value of signature algorithm OID",
algOID, crl.getSigAlgOID());
}
-
+
/**
* getSigAlgParams() method testing.
*/
@@ -457,14 +457,14 @@
fail("Incorrect SigAlgParams value.");
}
}
-
+
/**
* verify(PublicKey key) method testing.
*/
public void testVerify1() throws Exception {
crl.verify(publicKey);
}
-
+
/**
* verify(PublicKey key, String sigProvider) method testing.
*/
@@ -472,7 +472,7 @@
crl.verify(publicKey, Signature.getInstance("SHA1withDSA")
.getProvider().getName());
}
-
+
/**
* verify(PublicKey key) method testing.
*/
@@ -491,38 +491,38 @@
try {
X509CertImpl cert1 = new X509CertImpl(
new Certificate(
- new TBSCertificate(2, certSerialNumber1, signature,
- new Name(certIssuerName),
+ new TBSCertificate(2, certSerialNumber1, signature,
+ new Name(certIssuerName),
new Validity(new Date(), new Date()),
- new Name(certIssuerName),
+ new Name(certIssuerName),
new SubjectPublicKeyInfo(signature, new byte[10]),
null, null, null),
signature, new byte[10]));
X509CertImpl cert2 = new X509CertImpl(
new Certificate(
- new TBSCertificate(2, certSerialNumber2, signature,
- new Name(certIssuerName),
+ new TBSCertificate(2, certSerialNumber2, signature,
+ new Name(certIssuerName),
new Validity(new Date(), new Date()),
- new Name(certIssuerName),
+ new Name(certIssuerName),
new SubjectPublicKeyInfo(signature, new byte[10]),
null, null, null),
signature, new byte[10]));
X509CertImpl cert3 = new X509CertImpl(
new Certificate(
- new TBSCertificate(2, certSerialNumber3, signature,
- new Name("O=Another Cert Issuer"),
+ new TBSCertificate(2, certSerialNumber3, signature,
+ new Name("O=Another Cert Issuer"),
new Validity(new Date(), new Date()),
- new Name(certIssuerName),
+ new Name(certIssuerName),
new SubjectPublicKeyInfo(signature, new byte[10]),
null, null, null),
signature, new byte[10]));
- assertFalse("Certificate should not be presented in CRL "
- + "because issuer is not the same as CRL issuer",
+ assertFalse("Certificate should not be presented in CRL "
+ + "because issuer is not the same as CRL issuer",
crl.isRevoked(cert1));
- assertTrue("Certificate should be presented in CRL",
+ assertTrue("Certificate should be presented in CRL",
crl.isRevoked(cert2));
- assertFalse("Certificate should not be presented in CRL "
- + "because issuer is not the same as CRL issuer",
+ assertFalse("Certificate should not be presented in CRL "
+ + "because issuer is not the same as CRL issuer",
crl.isRevoked(cert3));
} catch (IOException e) {
// should never happen;
@@ -530,7 +530,7 @@
fail("Unexpected IOException was thrown:"+e.getMessage());
}
}
-
+
/**
* toString() method testing.
*/
@@ -538,7 +538,7 @@
assertNotNull("The string representation should not be null",
crl.toString());
}
-
+
// the following implementations are tested in X509CertImplTest:
/**
@@ -548,7 +548,7 @@
System.out.println("getNonCriticalExtensionOIDs: "
+ crl.getNonCriticalExtensionOIDs());
}
-
+
/**
* getCriticalExtensionOIDs() method testing.
*/
@@ -556,7 +556,7 @@
System.out.println("getCriticalExtensionOIDs: "
+ crl.getCriticalExtensionOIDs());
}
-
+
/**
* getExtensionValue(String oid) method testing.
*/
@@ -565,7 +565,7 @@
assertNull("Null value should be returned in the case of "
+ "nonexisting extension", crl.getExtensionValue("1.1.1.1"));
}
-
+
/**
* hasUnsupportedCriticalExtension() method testing.
*/
@@ -573,22 +573,9 @@
System.out.println("hasUnsupportedCriticalExtension: "
+ crl.hasUnsupportedCriticalExtension());
}
-
+
public static Test suite() {
return new TestSuite(X509CRLImplTest.class);
}
- public static void main(String[] args) throws Exception {
- /*
- X509CRLImplTest test = new X509CRLImplTest();
- test.setUp();
- long startTime = System.currentTimeMillis();
- for (int i=0; i<100000; i++) {
- test.testCreationCRL();
- }
- System.out.println("time: "+(System.currentTimeMillis() - startTime));
- /*/
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryImplTest.java
index d81c4a6..09e8fbc 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryImplTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryImplTest.java
@@ -49,16 +49,16 @@
public void testEngineGenerateCertificate() throws Exception {
X509CertFactoryImpl certFactory = new X509CertFactoryImpl();
Certificate cert;
-
+
// DER encoded certificate generation testing
- ByteArrayInputStream bais =
+ ByteArrayInputStream bais =
new ByteArrayInputStream(
CertFactoryTestData.getCertEncoding());
cert = certFactory.engineGenerateCertificate(bais);
assertNotNull("First generated certificate is null", cert);
cert = certFactory.engineGenerateCertificate(bais);
assertNotNull("Second generated certificate is null", cert);
-
+
try {
certFactory.engineGenerateCertificate(bais);
fail("Expected CertificateException was not thrown.");
@@ -72,50 +72,50 @@
assertNotNull("First generated certificate is null", cert);
cert = certFactory.engineGenerateCertificate(bais);
assertNotNull("Second generated certificate is null", cert);
-
+
try {
certFactory.engineGenerateCertificate(bais);
fail("Expected CertificateException was not thrown.");
} catch (CertificateException e) {
}
}
-
+
/**
* engineGenerateCertificates(InputStream inStream) method testing.
*/
public void testEngineGenerateCertificates() throws Exception {
X509CertFactoryImpl certFactory = new X509CertFactoryImpl();
-
+
// DER encoded certificate generation testing
- ByteArrayInputStream bais =
+ ByteArrayInputStream bais =
new ByteArrayInputStream(
CertFactoryTestData.getCertEncoding());
assertEquals("The size of collection is not correct", 2, certFactory
.engineGenerateCertificates(bais).size());
-
+
// Base64 testing
bais = new ByteArrayInputStream(
CertFactoryTestData.getBase64CertEncoding());
assertEquals("The size of collection is not correct", 2, certFactory
.engineGenerateCertificates(bais).size());
}
-
+
/**
* engineGenerateCRL(InputStream inStream) method testing.
*/
public void testEngineGenerateCRL() throws Exception {
X509CertFactoryImpl certFactory = new X509CertFactoryImpl();
CRL crl;
-
+
// DER encoded crt generation testing
- ByteArrayInputStream bais =
+ ByteArrayInputStream bais =
new ByteArrayInputStream(
CertFactoryTestData.getCRLEncoding());
crl = certFactory.engineGenerateCRL(bais);
assertNotNull("First generated CRL is null", crl);
crl = certFactory.engineGenerateCRL(bais);
assertNotNull("Second generated CRL is null", crl);
-
+
try {
certFactory.engineGenerateCRL(bais);
fail("Expected CRLException was not thrown.");
@@ -130,22 +130,22 @@
assertNotNull("First generated CRL is null", crl);
crl = certFactory.engineGenerateCRL(bais);
assertNotNull("Second generated CRL is null", crl);
-
+
try {
certFactory.engineGenerateCRL(bais);
fail("Expected CRLException was not thrown.");
} catch (CRLException e) {
}
}
-
+
/**
* engineGenerateCRLs(InputStream inStream) method testing.
*/
public void testEngineGenerateCRLs() throws Exception {
X509CertFactoryImpl certFactory = new X509CertFactoryImpl();
-
+
// DER encoded crt generation testing
- ByteArrayInputStream bais =
+ ByteArrayInputStream bais =
new ByteArrayInputStream(
CertFactoryTestData.getCRLEncoding());
assertEquals("The size of collection is not correct", 2, certFactory
@@ -157,13 +157,13 @@
assertEquals("The size of collection is not correct", 2, certFactory
.engineGenerateCRLs(bais).size());
}
-
+
/**
* engineGenerateCertPath(InputStream inStream) method testing.
*/
public void testEngineGenerateCertPath() throws Exception {
X509CertFactoryImpl certFactory = new X509CertFactoryImpl();
- ByteArrayInputStream bais =
+ ByteArrayInputStream bais =
new ByteArrayInputStream(
CertFactoryTestData.getCertPathPkiPathEncoding());
certFactory.engineGenerateCertPath(bais);
@@ -174,14 +174,14 @@
} catch (CertificateException e) {
}
}
-
+
/**
* engineGenerateCertPath(InputStream inStream, String encoding) method
* testing.
*/
public void testEngineGenerateCertPath1() throws Exception {
X509CertFactoryImpl certFactory = new X509CertFactoryImpl();
- ByteArrayInputStream bais =
+ ByteArrayInputStream bais =
new ByteArrayInputStream(
CertFactoryTestData.getCertPathPKCS7Encoding());
certFactory.engineGenerateCertPath(bais, "PKCS7");
@@ -192,7 +192,7 @@
} catch (CertificateException e) {
}
}
-
+
/**
* engineGenerateCertPath(List certificates) method testing.
*/
@@ -217,13 +217,13 @@
} catch (CertificateException e) {
}
}
-
+
/**
* engineGetCertPathEncodings() method testing.
*/
public void testEngineGetCertPathEncodings() {
try {
- Iterator it =
+ Iterator it =
new X509CertFactoryImpl().engineGetCertPathEncodings();
Object encoding = it.next();
assertNotNull("Default encodings should not be null", encoding);
@@ -233,21 +233,9 @@
// pass
}
}
-
+
public static Test suite() {
return new TestSuite(X509CertFactoryImplTest.class);
}
- public static void main(String[] args) {
- /*
- X509CertFactoryImplTest test = new X509CertFactoryImplTest();
- long startTime = System.currentTimeMillis();
- for (int i=0; i<10000; i++) {
- test.testEngineGenerateCertificate();
- }
- System.out.println("time: "+(System.currentTimeMillis() - startTime));
- */
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
index b1095a6..9de4f1d 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
@@ -60,7 +60,7 @@
//
// The values of certificate's fields:
//
-
+
static int version = 2; //v3
static BigInteger serialNumber = BigInteger.valueOf(555555555555555555L);
@@ -69,7 +69,7 @@
static String algName = "SHA1withDSA";
// DER boolean false encoding (http://asn1.elibel.tm.fr)
- // Makes no sense. For testing purposes we need just provide
+ // Makes no sense. For testing purposes we need just provide
// some ASN.1 structure:
static byte[] algParams = {1, 1, 0};
static String issuerName = "O=Certificate Issuer";
@@ -82,14 +82,14 @@
static PrivateKey privateKey;
static byte[] key = new byte[] {1, 2, 3, 4, 5, 6, 7, 8}; // random value
static byte[] keyEncoding = null;
- static boolean[] issuerUniqueID = new boolean[]
+ static boolean[] issuerUniqueID = new boolean[]
{true, false, true, false, true, false, true, false}; // random value
static boolean[] subjectUniqueID = new boolean[]
{false, true, false, true, false, true, false, true}; // random value
// Extensions' values
static byte[] extValEncoding = new byte[] {1, 1, 1}; // random value
- static boolean[] extnKeyUsage = new boolean[]
+ static boolean[] extnKeyUsage = new boolean[]
{true, false, true, false, true, false, true, false, true}; // random value
static List extnExtendedKeyUsage = Arrays.asList(new int[][] {
// Extended key usage values as specified in rfc 3280:
@@ -113,7 +113,7 @@
static int extnBCLen = 5;
static GeneralNames extnSANames;
static GeneralNames extnIANames;
-
+
static {
try {
extnSANames = new GeneralNames(
@@ -139,7 +139,7 @@
new GeneralName(2, "BadDNSName")))
.addSubtree(new GeneralSubtree(
new GeneralName(8, "2.3.4.4444.222"), 2));
- nameConstraints =
+ nameConstraints =
new NameConstraints(permittedNames, excludedNames);
} catch (IOException e) {
// should not be thrown
@@ -162,22 +162,22 @@
// Extensions
static Extension[] extensions = new Extension[] {
-
+
// Supported critical extensions (as specified in rfc 3280
// http://www.ietf.org/rfc/rfc3280.txt):
// Key Usage
- new Extension("2.5.29.15", true,
+ new Extension("2.5.29.15", true,
ASN1BitString.getInstance()
- .encode(new BitString(extnKeyUsage))),
- // Basic Constraints
+ .encode(new BitString(extnKeyUsage))),
+ // Basic Constraints
new Extension("2.5.29.19", true, new BasicConstraints(true, extnBCLen)),
// Certificate Policies with ANY policy
- new Extension("2.5.29.32", true,
+ new Extension("2.5.29.32", true,
new CertificatePolicies()
.addPolicyInformation(new PolicyInformation("2.5.29.32.0"))),
// Subject Alternative Name
- new Extension("2.5.29.17", true,
+ new Extension("2.5.29.17", true,
new AlternativeName(AlternativeName.SUBJECT, extnSANames)),
// Name Constraints
new Extension("2.5.29.30", true, nameConstraints),
@@ -193,21 +193,21 @@
// Non-critical extensions (as specified in rfc 3280
// http://www.ietf.org/rfc/rfc3280.txt):
-
+
// Issuer Alternative Name
- new Extension("2.5.29.18", false,
+ new Extension("2.5.29.18", false,
new AlternativeName(AlternativeName.ISSUER, extnSANames)),
// CRL Distribution Points
- new Extension("2.5.29.31", false,
+ new Extension("2.5.29.31", false,
new CRLDistributionPoints(Arrays.asList(new DistributionPoint[] {
new DistributionPoint(
- new DistributionPointName(extnSANames),
+ new DistributionPointName(extnSANames),
new ReasonFlags(extnKeyUsage),
extnSANames
),
}))),
// Authority Key Identifier
- new Extension("2.5.29.35", false,
+ new Extension("2.5.29.35", false,
new AuthorityKeyIdentifier(
// random value for key identifier
new byte[] {1, 2, 3, 4, 5}, extnSANames, serialNumber)),
@@ -235,28 +235,28 @@
// stored in this field
static byte[] signatureValueBytes;
static byte[] certEncoding, certEncoding_b64;
-
+
static {
try {
- signature =
+ signature =
new AlgorithmIdentifier(algOID, algParams);
Name issuer = new Name(issuerName);
Name subject = new Name(subjectName);
- Validity validity =
+ Validity validity =
new Validity(new Date(notBefore), new Date(notAfter));
- SubjectPublicKeyInfo subjectPublicKeyInfo = (SubjectPublicKeyInfo)
+ SubjectPublicKeyInfo subjectPublicKeyInfo = (SubjectPublicKeyInfo)
SubjectPublicKeyInfo.ASN1.decode(publicKey.getEncoded());
keyEncoding = subjectPublicKeyInfo.getEncoded();
-
+
Extensions exts = new Extensions(Arrays.asList(extensions));
-
- tbsCertificate =
- new TBSCertificate(version, serialNumber,
- signature, issuer, validity, subject, subjectPublicKeyInfo,
+
+ tbsCertificate =
+ new TBSCertificate(version, serialNumber,
+ signature, issuer, validity, subject, subjectPublicKeyInfo,
issuerUniqueID, subjectUniqueID, exts);
tbsCertEncoding = tbsCertificate.getEncoded();
-
+
try {
Signature sig= Signature.getInstance("DSA");
sig.initSign(privateKey);
@@ -271,12 +271,12 @@
e.printStackTrace();
}
}
-
- // the testing data was generated by using of classes
+
+ // the testing data was generated by using of classes
// from org.apache.harmony.security.asn1 package encoded
// by org.apache.harmony.misc.Base64 class.
- private static String base64certEncoding =
+ private static String base64certEncoding =
"-----BEGIN CERTIFICATE-----\n" +
"MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a" +
"WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF" +
@@ -323,24 +323,24 @@
stream_b64 = new ByteArrayInputStream(certEncoding_b64);
stream_b64.mark(certEncoding_b64.length);
}
-
+
/**
- * Creates the master certificate on the base of which
+ * Creates the master certificate on the base of which
* all functionality will be tested.
* @return
- * @throws java.lang.Exception
+ * @throws java.lang.Exception
*/
protected void setUp() throws java.lang.Exception {
if ("testVerify3".equals(getName())) {
signatureValue = new byte[signatureValueBytes.length];
// make incorrect signature value:
- System.arraycopy(signatureValueBytes, 0,
+ System.arraycopy(signatureValueBytes, 0,
signatureValue, 0, signatureValueBytes.length);
signatureValue[20]++;
} else {
signatureValue = signatureValueBytes;
}
- Certificate cert =
+ Certificate cert =
new Certificate(tbsCertificate, signature, signatureValue);
certEncoding = cert.getEncoded();
@@ -362,7 +362,7 @@
}
byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
System.arraycopy(tmp, 0, stamp, 0, tmp.length);
- System.arraycopy(stamp, 0, certEncoding,
+ System.arraycopy(stamp, 0, certEncoding,
certEncoding.length-stamp.length, stamp.length);
stream.reset();
@@ -370,15 +370,15 @@
byte[] enc = c.getEncoded();
byte[] stamp_chek = new byte[stamp.length];
-
- System.arraycopy(enc, enc.length - stamp.length,
+
+ System.arraycopy(enc, enc.length - stamp.length,
stamp_chek, 0, stamp.length);
-
+
if (!Arrays.equals(stamp, stamp_chek)) {
fail("Wrong encoding received.");
}
}
-
+
public void testCreation1() throws Exception {
byte[] stamp = new byte[10];
if ((++flag)%2 != 0) {
@@ -386,7 +386,7 @@
}
byte tmp[] = BigInteger.valueOf(XXX).toByteArray();
System.arraycopy(tmp, 0, stamp, 0, tmp.length);
- System.arraycopy(stamp, 0, certEncoding,
+ System.arraycopy(stamp, 0, certEncoding,
certEncoding.length-stamp.length, stamp.length);
stream.reset();
@@ -394,20 +394,20 @@
byte[] enc = c.getEncoded();
byte[] stamp_chek = new byte[stamp.length];
-
- System.arraycopy(enc, enc.length - stamp.length,
+
+ System.arraycopy(enc, enc.length - stamp.length,
stamp_chek, 0, stamp.length);
-
+
if (!Arrays.equals(stamp, stamp_chek)) {
fail("Wrong encoding received.");
}
}
-
+
public void testCreation2() throws Exception {
stream_b64.reset();
factory.generateCertificate(stream_b64);
}
-
+
/**
* checkValidity() method testing.
*/
@@ -420,7 +420,7 @@
} catch (CertificateExpiredException e) {
}
}
-
+
/**
* checkValidity(Date date) method testing.
*/
@@ -449,59 +449,59 @@
fail("Unexpected CertificateNotYetValidException was thrown.");
}
}
-
+
/**
* getVersion() method testing.
*/
public void testGetVersion() {
- assertEquals("The version of the certificate should be 3",
+ assertEquals("The version of the certificate should be 3",
3, certificate.getVersion());
}
-
+
/**
* getSerialNumber() method testing.
*/
public void testGetSerialNumber() {
- assertEquals("Incorrect value of version",
+ assertEquals("Incorrect value of version",
serialNumber, certificate.getSerialNumber());
}
-
+
/**
* getIssuerDN() method testing.
*/
public void testGetIssuerDN() {
- assertEquals("Incorrect issuer",
- new X500Principal(issuerName).getName(),
+ assertEquals("Incorrect issuer",
+ new X500Principal(issuerName).getName(),
certificate.getIssuerDN().getName());
}
-
+
/**
* getIssuerX500Principal() method testing.
*/
public void testGetIssuerX500Principal() {
- assertEquals("Incorrect issuer",
- new X500Principal(issuerName),
+ assertEquals("Incorrect issuer",
+ new X500Principal(issuerName),
certificate.getIssuerX500Principal());
}
-
+
/**
* getSubjectDN() method testing.
*/
public void testGetSubjectDN() {
- assertEquals("Incorrect subject",
- new X500Principal(subjectName).getName(),
+ assertEquals("Incorrect subject",
+ new X500Principal(subjectName).getName(),
certificate.getSubjectDN().getName());
}
-
+
/**
* getSubjectX500Principal() method testing.
*/
public void testGetSubjectX500Principal() {
- assertEquals("Incorrect subject",
- new X500Principal(subjectName),
+ assertEquals("Incorrect subject",
+ new X500Principal(subjectName),
certificate.getSubjectX500Principal());
}
-
+
/**
* getNotBefore() method testing.
*/
@@ -509,7 +509,7 @@
assertEquals("Incorrect notBefore date",
new Date(notBefore), certificate.getNotBefore());
}
-
+
/**
* getNotAfter() method testing.
*/
@@ -517,23 +517,23 @@
assertEquals("Incorrect notAfter date",
new Date(notAfter), certificate.getNotAfter());
}
-
- public static void printAsHex(int perLine, String prefix,
+
+ public static void printAsHex(int perLine, String prefix,
String delimiter, byte[] data) {
for (int i=0; i<data.length; i++) {
String tail = Integer.toHexString(0x000000ff & data[i]);
if (tail.length() == 1) {
- tail = "0" + tail;
+ tail = "0" + tail;
}
System.out.print(prefix + "0x" + tail + delimiter);
-
+
if (((i+1)%perLine) == 0) {
System.out.println();
}
}
System.out.println();
}
-
+
/**
* getTBSCertificate() method testing.
*/
@@ -552,7 +552,7 @@
fail("Unexpected CertificateEncodingException was thrown.");
}
}
-
+
/**
* getSignature() method testing.
*/
@@ -561,7 +561,7 @@
fail("Incorrect Signature value.");
}
}
-
+
/**
* getSigAlgName() method testing.
*/
@@ -569,7 +569,7 @@
assertEquals("Incorrect value of signature algorithm name",
algName, certificate.getSigAlgName());
}
-
+
/**
* getSigAlgOID() method testing.
*/
@@ -577,7 +577,7 @@
assertEquals("Incorrect value of signature algorithm OID",
algOID, certificate.getSigAlgOID());
}
-
+
/**
* getSigAlgParams() method testing.
*/
@@ -586,7 +586,7 @@
fail("Incorrect Signature value.");
}
}
-
+
/**
* getIssuerUniqueID() method testing.
*/
@@ -595,7 +595,7 @@
fail("Incorrect issuerUniqueID value.");
}
}
-
+
/**
* getSubjectUniqueID() method testing.
*/
@@ -604,7 +604,7 @@
fail("Incorrect subjectUniqueID value.");
}
}
-
+
/**
* getKeyUsage() method testing.
*/
@@ -619,13 +619,13 @@
}
}
}
-
+
/**
* getExtendedKeyUsage() method testing.
*/
public void testGetExtendedKeyUsage() throws Exception {
List exku = certificate.getExtendedKeyUsage();
- if ((exku == null)
+ if ((exku == null)
|| (exku.size() != extnExtendedKeyUsage.size())) {
fail("Incorrect Extended Key Usage value.");
}
@@ -637,14 +637,14 @@
}
}
}
-
+
/**
* getBasicConstraints() method testing.
*/
public void testGetBasicConstraints() {
assertEquals(extnBCLen, certificate.getBasicConstraints());
}
-
+
/**
* getSubjectAlternativeNames() method testing.
*/
@@ -675,7 +675,7 @@
fail("Subject Alternative Name extension was incorrectly encoded.");
}
}
-
+
/**
* getIssuerAlternativeNames() method testing.
*/
@@ -706,7 +706,7 @@
fail("Issuer Alternative Name extension was incorrectly encoded.");
}
}
-
+
/**
* getEncoded() method testing.
*/
@@ -719,7 +719,7 @@
fail("Unexpected CertificateEncodingException was thrown.");
}
}
-
+
/**
* getPublicKey() method testing.
*/
@@ -728,7 +728,7 @@
fail("Incorrect Public Key.");
}
}
-
+
/**
* getExtensionValue(String oid) method testing.
*/
@@ -752,46 +752,46 @@
}
}
}
-
+
/**
* getCriticalExtensionOIDs() method testing.
*/
public void testGetCriticalExtensionOIDs() {
Set certCEOids = certificate.getCriticalExtensionOIDs();
- if (!(certCEOids.containsAll(allCritical)
+ if (!(certCEOids.containsAll(allCritical)
&& allCritical.containsAll(certCEOids))) {
fail("Incorrect value of Critical Extension OIDs");
}
}
-
+
/**
* getNonCriticalExtensionOIDs() method testing.
*/
public void testGetNonCriticalExtensionOIDs() {
Set certNCEOids = certificate.getNonCriticalExtensionOIDs();
- if (!(certNCEOids.containsAll(allNonCritical)
+ if (!(certNCEOids.containsAll(allNonCritical)
&& allNonCritical.containsAll(certNCEOids))) {
fail("Incorrect value of Non Critical Extension OIDs");
}
}
-
+
/**
* hasUnsupportedCriticalExtension() method testing.
*/
public void testHasUnsupportedCriticalExtension() {
- assertTrue("Incorrect value of hasUnsupportedCriticalExtension",
+ assertTrue("Incorrect value of hasUnsupportedCriticalExtension",
certificate.hasUnsupportedCriticalExtension());
if (!certificate.hasUnsupportedCriticalExtension()) {
fail("Incorrect value of hasUnsupportedCriticalExtension");
}
}
-
+
/**
* toString() method testing.
*/
public void testToString() {
- assertNotNull("String representation should not be null",
+ assertNotNull("String representation should not be null",
certificate.toString());
}
@@ -802,17 +802,17 @@
public void testVerify1() throws Exception {
certificate.verify(publicKey);
}
-
+
/**
* TODO
* verify(PublicKey key, String sigProvider) method testing.
*/
public void testVerify2() throws Exception {
- certificate.verify(publicKey,
+ certificate.verify(publicKey,
Signature.getInstance("SHA1withDSA")
.getProvider().getName());
}
-
+
/**
* TODO
* verify(PublicKey key) method testing.
@@ -824,24 +824,9 @@
} catch (Exception e) {
}
}
-
+
public static Test suite() {
return new TestSuite(X509CertFactoryPerfTest.class);
}
- public static void main(String[] args) throws Exception {
- /*
- X509CertFactoryPerfTest test = new X509CertFactoryPerfTest();
- test.setUp();
- long startTime = System.currentTimeMillis();
- for (int i=0; i<100000; i++) {
- test.testCreation1();
- }
- System.out.println("time: "+(System.currentTimeMillis() - startTime));
- */
- junit.textui.TestRunner.run(suite());
- }
}
-
-
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java
index acade8f..9452b4b 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertImplTest.java
@@ -85,36 +85,36 @@
//
// The values of certificate's fields:
//
-
+
int version = 2; //v3
BigInteger serialNumber = BigInteger.valueOf(555L);
-
+
// Algorithm name and its OID (http://oid.elibel.tm.fr)
String algOID = "1.2.840.10040.4.3";
String algName = "SHA1withDSA";
-
+
// DER boolean false encoding (http://asn1.elibel.tm.fr)
- // Makes no sense. For testing purposes we need just provide
+ // Makes no sense. For testing purposes we need just provide
// some ASN.1 structure:
byte[] algParams = {1, 1, 0};
String issuerName = "O=Certificate Issuer";
long notBefore = 1000000000L;
long notAfter = 2000000000L;
String subjectName = "O=Subject Organization";
-
+
// keys are using to make signature and to verify it
static PublicKey publicKey;
static PrivateKey privateKey;
byte[] key = new byte[] {1, 2, 3, 4, 5, 6, 7, 8}; // random value
byte[] keyEncoding = null;
- boolean[] issuerUniqueID = new boolean[]
+ boolean[] issuerUniqueID = new boolean[]
{true, false, true, false, true, false, true, false}; // random value
boolean[] subjectUniqueID = new boolean[]
{false, true, false, true, false, true, false, true}; // random value
// Extensions' values
byte[] extValEncoding = new byte[] {1, 1, 1}; // random value
- boolean[] extnKeyUsage = new boolean[]
+ boolean[] extnKeyUsage = new boolean[]
{true, false, true, false, true, false, true, false, true}; // random value
List extnExtendedKeyUsage = Arrays.asList(new int[][] {
@@ -139,7 +139,7 @@
int extnBCLen = 5;
static GeneralNames extnSANames;
static GeneralNames extnIANames;
-
+
static {
try {
extnSANames = new GeneralNames(
@@ -165,7 +165,7 @@
new GeneralName(2, "BadDNSName")))
.addSubtree(new GeneralSubtree(
new GeneralName(8, "2.3.4.4444.222"), 2));
- nameConstraints =
+ nameConstraints =
new NameConstraints(permittedNames, excludedNames);
} catch (IOException e) {
// should not be thrown
@@ -193,14 +193,14 @@
// http://www.ietf.org/rfc/rfc3280.txt):
// Key Usage
new Extension("2.5.29.15", true, new KeyUsage(extnKeyUsage)),
- // Basic Constraints
+ // Basic Constraints
new Extension("2.5.29.19", true, new BasicConstraints(true, extnBCLen)),
// Certificate Policies with ANY policy
- new Extension("2.5.29.32", true,
+ new Extension("2.5.29.32", true,
new CertificatePolicies()
.addPolicyInformation(new PolicyInformation("2.5.29.32.0"))),
// Subject Alternative Name
- new Extension("2.5.29.17", true,
+ new Extension("2.5.29.17", true,
new AlternativeName(AlternativeName.SUBJECT, extnSANames)),
// Name Constraints
new Extension("2.5.29.30", true, nameConstraints),
@@ -215,24 +215,24 @@
// Unsupported critical extensions:
new Extension("1.2.77.777", true, extValEncoding),
-
+
// Non-critical extensions (as specified in rfc 3280
// http://www.ietf.org/rfc/rfc3280.txt):
-
+
// Issuer Alternative Name
- new Extension("2.5.29.18", false,
+ new Extension("2.5.29.18", false,
new AlternativeName(AlternativeName.ISSUER, extnSANames)),
// CRL Distribution Points
- new Extension("2.5.29.31", false,
+ new Extension("2.5.29.31", false,
new CRLDistributionPoints(Arrays.asList(new DistributionPoint[] {
new DistributionPoint(
- new DistributionPointName(extnSANames),
+ new DistributionPointName(extnSANames),
new ReasonFlags(extnKeyUsage),
extnSANames
),
}))),
// Authority Key Identifier
- new Extension("2.5.29.35", false,
+ new Extension("2.5.29.35", false,
new AuthorityKeyIdentifier(
// random value for key identifier
new byte[] {1, 2, 3, 4, 5}, extnSANames, serialNumber)),
@@ -258,31 +258,31 @@
byte[] certEncoding;
/**
- * Creates the master certificate on the base of which
+ * Creates the master certificate on the base of which
* all functionality will be tested.
* @return
- * @throws java.lang.Exception
+ * @throws java.lang.Exception
*/
protected void setUp() throws java.lang.Exception {
- AlgorithmIdentifier signature =
+ AlgorithmIdentifier signature =
new AlgorithmIdentifier(algOID, algParams);
Name issuer = new Name(issuerName);
Name subject = new Name(subjectName);
- Validity validity =
+ Validity validity =
new Validity(new Date(notBefore), new Date(notAfter));
- SubjectPublicKeyInfo subjectPublicKeyInfo = (SubjectPublicKeyInfo)
+ SubjectPublicKeyInfo subjectPublicKeyInfo = (SubjectPublicKeyInfo)
SubjectPublicKeyInfo.ASN1.decode(publicKey.getEncoded());
keyEncoding = subjectPublicKeyInfo.getEncoded();
Extensions exts = new Extensions(Arrays.asList(extensions));
-
- TBSCertificate tbsCertificate =
- new TBSCertificate(version, serialNumber,
- signature, issuer, validity, subject, subjectPublicKeyInfo,
+
+ TBSCertificate tbsCertificate =
+ new TBSCertificate(version, serialNumber,
+ signature, issuer, validity, subject, subjectPublicKeyInfo,
issuerUniqueID, subjectUniqueID, exts);
tbsCertEncoding = tbsCertificate.getEncoded();
-
+
if (signatureValueBytes == null) {
try {
Signature sig= Signature.getInstance("DSA");//new byte[32];
@@ -297,14 +297,14 @@
if ("testVerify3".equals(getName())) {
signatureValue = new byte[signatureValueBytes.length];
// make incorrect signature value:
- System.arraycopy(signatureValueBytes, 0,
+ System.arraycopy(signatureValueBytes, 0,
signatureValue, 0, signatureValueBytes.length);
signatureValue[20]++;
} else {
signatureValue = signatureValueBytes;
}
-
- Certificate cert =
+
+ Certificate cert =
new Certificate(tbsCertificate, signature, signatureValue);
certEncoding = cert.getEncoded();
@@ -317,7 +317,7 @@
ByteArrayInputStream bis = new ByteArrayInputStream(certEncoding);
certificate = new X509CertImpl(bis);
}
-
+
/**
* checkValidity() method testing.
*/
@@ -330,7 +330,7 @@
} catch (CertificateExpiredException e) {
}
}
-
+
/**
* checkValidity(Date date) method testing.
*/
@@ -359,7 +359,7 @@
fail("Unexpected CertificateNotYetValidException was thrown.");
}
}
-
+
/**
* @tests java.security.cert.X509Certificate#getVersion()
*/
@@ -387,51 +387,51 @@
assertEquals("Version 3:", 3, new X509CertImpl(x509CertEnc)
.getVersion());
}
-
+
/**
* getSerialNumber() method testing.
*/
public void testGetSerialNumber() {
- assertEquals("Incorrect value of version",
+ assertEquals("Incorrect value of version",
serialNumber, certificate.getSerialNumber());
}
-
+
/**
* getIssuerDN() method testing.
*/
public void testGetIssuerDN() {
- assertEquals("Incorrect issuer",
- new X500Principal(issuerName).getName(),
+ assertEquals("Incorrect issuer",
+ new X500Principal(issuerName).getName(),
certificate.getIssuerDN().getName());
}
-
+
/**
* getIssuerX500Principal() method testing.
*/
public void testGetIssuerX500Principal() {
- assertEquals("Incorrect issuer",
- new X500Principal(issuerName),
+ assertEquals("Incorrect issuer",
+ new X500Principal(issuerName),
certificate.getIssuerX500Principal());
}
-
+
/**
* getSubjectDN() method testing.
*/
public void testGetSubjectDN() {
- assertEquals("Incorrect subject",
- new X500Principal(subjectName).getName(),
+ assertEquals("Incorrect subject",
+ new X500Principal(subjectName).getName(),
certificate.getSubjectDN().getName());
}
-
+
/**
* getSubjectX500Principal() method testing.
*/
public void testGetSubjectX500Principal() {
- assertEquals("Incorrect subject",
- new X500Principal(subjectName),
+ assertEquals("Incorrect subject",
+ new X500Principal(subjectName),
certificate.getSubjectX500Principal());
}
-
+
/**
* getNotBefore() method testing.
*/
@@ -439,7 +439,7 @@
assertEquals("Incorrect notBefore date",
new Date(notBefore), certificate.getNotBefore());
}
-
+
/**
* getNotAfter() method testing.
*/
@@ -447,23 +447,23 @@
assertEquals("Incorrect notAfter date",
new Date(notAfter), certificate.getNotAfter());
}
-
- public static void printAsHex(int perLine, String prefix,
+
+ public static void printAsHex(int perLine, String prefix,
String delimiter, byte[] data) {
for (int i=0; i<data.length; i++) {
String tail = Integer.toHexString(0x000000ff & data[i]);
if (tail.length() == 1) {
- tail = "0" + tail;
+ tail = "0" + tail;
}
System.out.print(prefix + "0x" + tail + delimiter);
-
+
if (((i+1)%perLine) == 0) {
System.out.println();
}
}
System.out.println();
}
-
+
/**
* getTBSCertificate() method testing.
*/
@@ -482,7 +482,7 @@
fail("Unexpected CertificateEncodingException was thrown.");
}
}
-
+
/**
* getSignature() method testing.
*/
@@ -491,7 +491,7 @@
fail("Incorrect Signature value.");
}
}
-
+
/**
* getSigAlgName() method testing.
*/
@@ -499,7 +499,7 @@
assertEquals("Incorrect value of signature algorithm name",
algName, certificate.getSigAlgName());
}
-
+
/**
* getSigAlgOID() method testing.
*/
@@ -507,7 +507,7 @@
assertEquals("Incorrect value of signature algorithm OID",
algOID, certificate.getSigAlgOID());
}
-
+
/**
* getSigAlgParams() method testing.
*/
@@ -516,7 +516,7 @@
fail("Incorrect SigAlgParams value.");
}
}
-
+
/**
* getIssuerUniqueID() method testing.
*/
@@ -525,7 +525,7 @@
fail("Incorrect issuerUniqueID value.");
}
}
-
+
/**
* getSubjectUniqueID() method testing.
*/
@@ -534,7 +534,7 @@
fail("Incorrect subjectUniqueID value.");
}
}
-
+
/**
* getKeyUsage() method testing.
*/
@@ -549,13 +549,13 @@
}
}
}
-
+
/**
* getExtendedKeyUsage() method testing.
*/
public void testGetExtendedKeyUsage() throws Exception {
List exku = certificate.getExtendedKeyUsage();
- if ((exku == null)
+ if ((exku == null)
|| (exku.size() != extnExtendedKeyUsage.size())) {
fail("Incorrect Extended Key Usage value.");
}
@@ -567,14 +567,14 @@
}
}
}
-
+
/**
* getBasicConstraints() method testing.
*/
public void testGetBasicConstraints() {
assertEquals(extnBCLen, certificate.getBasicConstraints());
}
-
+
/**
* getSubjectAlternativeNames() method testing.
*/
@@ -605,7 +605,7 @@
fail("Subject Alternative Name extension was incorrectly encoded.");
}
}
-
+
/**
* getIssuerAlternativeNames() method testing.
*/
@@ -636,7 +636,7 @@
fail("Issuer Alternative Name extension was incorrectly encoded.");
}
}
-
+
/**
* getEncoded() method testing.
*/
@@ -649,7 +649,7 @@
fail("Unexpected CertificateEncodingException was thrown.");
}
}
-
+
/**
* getPublicKey() method testing.
*/
@@ -658,7 +658,7 @@
fail("Incorrect Public Key.");
}
}
-
+
/**
* getExtensionValue(String oid) method testing.
*/
@@ -682,49 +682,49 @@
}
}
assertNull("Null value should be returned in the case of "
- + "nonexisting extension",
+ + "nonexisting extension",
certificate.getExtensionValue("1.1.1.1"));
}
-
+
/**
* getCriticalExtensionOIDs() method testing.
*/
public void testGetCriticalExtensionOIDs() {
Set certCEOids = certificate.getCriticalExtensionOIDs();
- if (!(certCEOids.containsAll(allCritical)
+ if (!(certCEOids.containsAll(allCritical)
&& allCritical.containsAll(certCEOids))) {
fail("Incorrect value of Critical Extension OIDs");
}
}
-
+
/**
* getNonCriticalExtensionOIDs() method testing.
*/
public void testGetNonCriticalExtensionOIDs() {
Set certNCEOids = certificate.getNonCriticalExtensionOIDs();
- if (!(certNCEOids.containsAll(allNonCritical)
+ if (!(certNCEOids.containsAll(allNonCritical)
&& allNonCritical.containsAll(certNCEOids))) {
fail("Incorrect value of Non Critical Extension OIDs");
}
}
-
+
/**
* hasUnsupportedCriticalExtension() method testing.
*/
public void testHasUnsupportedCriticalExtension() {
- assertTrue("Incorrect value of hasUnsupportedCriticalExtension",
+ assertTrue("Incorrect value of hasUnsupportedCriticalExtension",
certificate.hasUnsupportedCriticalExtension());
if (!certificate.hasUnsupportedCriticalExtension()) {
fail("Incorrect value of hasUnsupportedCriticalExtension");
}
}
-
+
/**
* toString() method testing.
*/
public void testToString() {
- assertNotNull("String representation should not be null",
+ assertNotNull("String representation should not be null",
certificate.toString());
}
@@ -735,7 +735,7 @@
public void testVerify1() throws Exception {
certificate.verify(publicKey);
}
-
+
/**
* TODO
* verify(PublicKey key, String sigProvider) method testing.
@@ -744,7 +744,7 @@
certificate.verify(publicKey, Signature.getInstance("SHA1withDSA")
.getProvider().getName());
}
-
+
/**
* TODO
* verify(PublicKey key) method testing.
@@ -756,13 +756,9 @@
} catch (Exception e) {
}
}
-
+
public static Test suite() {
return new TestSuite(X509CertImplTest.class);
}
- public static void main(String[] args) throws Exception {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertPathImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertPathImplTest.java
index 55d8a5a..bd6ebb3 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertPathImplTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertPathImplTest.java
@@ -41,7 +41,7 @@
* X509CertPathImplTest
*/
public class X509CertPathImplTest extends TestCase {
-
+
private X509Certificate certificate;
{
try {
@@ -54,7 +54,7 @@
}
private X509CertPathImpl certPath;
private List certList;
-
+
protected void setUp() throws java.lang.Exception {
certList = new ArrayList();
for (int i=0; i<2; i++) {
@@ -62,15 +62,15 @@
}
certPath = new X509CertPathImpl(certList);
}
-
+
/**
* @tests org.apache.harmony.security.provider.cert.X509CertPathImpl.X509CertPathImpl(List)
*/
public void test_X509CertPathImpl_List() throws Exception {
- assertEquals("Certificate list size missmatch",
+ assertEquals("Certificate list size missmatch",
certList.size(), certPath.getCertificates().size());
}
-
+
/**
* @tests org.apache.harmony.security.provider.cert.X509CertPathImpl.getInstance(InputStream)
*/
@@ -81,7 +81,7 @@
assertEquals("Certificate list size missmatch", certList.size(), cpath
.getCertificates().size());
}
-
+
/**
* @tests org.apache.harmony.security.provider.cert.X509CertPathImpl.getInstance(byte[])
*/
@@ -136,14 +136,14 @@
//pass
}
}
-
+
/**
* getEncoded() method testing.
*/
public void testGetEncoded1() throws Exception {
certPath.getEncoded();
}
-
+
/**
* getEncoded(String encoding) method testing.
*/
@@ -154,7 +154,7 @@
} catch (CertificateEncodingException e) {
}
}
-
+
/**
* getEncodings() method testing.
*/
@@ -169,13 +169,9 @@
// pass
}
}
-
+
public static Test suite() {
return new TestSuite(X509CertPathImplTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/CryptoProviderTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/CryptoProviderTest.java
index ae4dfc8..e9f6ba5 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/CryptoProviderTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/CryptoProviderTest.java
@@ -80,13 +80,9 @@
}
}
-
+
public static Test suite() {
return new TestSuite(CryptoProviderTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/DSAKeyFactoryImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/DSAKeyFactoryImplTest.java
index 9bfe617..aeda61a 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/DSAKeyFactoryImplTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/DSAKeyFactoryImplTest.java
@@ -338,7 +338,7 @@
/**
* A compatibility with RI test.
* It checks out that if key encoding in KeySpec has correct ASN1 structure
- * but AlgorithmIdentifier contains value that connot be translated to "DSA"
+ * but AlgorithmIdentifier contains value that connot be translated to "DSA"
* the "generatePublic" method returns DSA public key
* whose algorithm is neither null nor "DSA".
*/
@@ -414,7 +414,7 @@
*/
public final void testGeneratePrivateKeySpec03() throws Exception {
- KeySpec keySpec = (KeySpec) new DSAPrivateKeySpec(privateX,
+ KeySpec keySpec = (KeySpec) new DSAPrivateKeySpec(privateX,
privateP, privateQ, privateG);
checkPrivateKeys( (DSAPrivateKey) kf.generatePrivate(keySpec) );
@@ -463,7 +463,7 @@
/**
* A compatibility with RI test.
* It checks out that if key encoding in KeySpec has correct ASN1 structure
- * but AlgorithmIdentifier contains value that connot be translated to "DSA"
+ * but AlgorithmIdentifier contains value that connot be translated to "DSA"
* the "generatePrivate" method returns DSA private key
* whose algorithm is neither null nor "DSA".
*/
@@ -574,9 +574,9 @@
/**
* A test against the "getKeySpec(Key, Class)" method.
- * The test checks out that
- * 1) a KeySpec returned by the method is being casted to
- * expected "DSAPublicKeySpec" or "X509EncodedKeySpec", and
+ * The test checks out that
+ * 1) a KeySpec returned by the method is being casted to
+ * expected "DSAPublicKeySpec" or "X509EncodedKeySpec", and
* 2) DSAPublickey object generated from KeySpec is equal a "publicKey" argument.
*/
public final void testGetKeySpec03() throws Exception {
@@ -593,9 +593,9 @@
/**
* A test against the "getKeySpec(Key, Class)" method.
- * The test checks out that
- * 1) a KeySpec returned by the method is being casted to
- expected "DSAPrivateKeySpec" or "PKCS8EncodedKeySpec", and
+ * The test checks out that
+ * 1) a KeySpec returned by the method is being casted to
+ expected "DSAPrivateKeySpec" or "PKCS8EncodedKeySpec", and
* 2) DSAPublickey object generated from KeySpec is equal a "privateKey" argument.
*/
public final void testGetKeySpec04() throws Exception {
@@ -743,9 +743,9 @@
/**
* A compatibility with RI test.
* The test against the "translateKey(Key)" method.
- * It checks out that
+ * It checks out that
* if a key encoding in a DSAPrivateKey argument has correct ASN1 structure
- * but AlgorithmIdentifier contains value that connot be translated to "DSA"
+ * but AlgorithmIdentifier contains value that connot be translated to "DSA"
* the method returns DSAPrivateKey whose algorithm is neither null nor "DSA".
*/
public final void testTranslateKey04() throws Exception {
@@ -787,9 +787,9 @@
/**
* A compatibility with RI test.
* The test against the "translateKey(Key)" method.
- * It checks out that
+ * It checks out that
* if a key encoding in a DSAPrivateKey argument has correct ASN1 structure
- * but AlgorithmIdentifier contains value that connot be translated to "DSA"
+ * but AlgorithmIdentifier contains value that connot be translated to "DSA"
* the method returns DSAPrivateKey whose algorithm is neither null nor "DSA".
*/
public final void testTranslateKey05() throws Exception {
@@ -832,8 +832,4 @@
return new TestSuite(DSAKeyFactoryImplTest.class);
}
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1ImplTest.java
index 68f5670..2036a82 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1ImplTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1ImplTest.java
@@ -84,11 +84,11 @@
for ( int k = 0; k < 5; k++ ) {
int i = k*4;
- int j = ((dgst[i ]&0xff)<<24) | ((dgst[i+1]&0xff)<<16) |
+ int j = ((dgst[i ]&0xff)<<24) | ((dgst[i+1]&0xff)<<16) |
((dgst[i+2]&0xff)<<8 ) | (dgst[i+3]&0xff) ;
- assertTrue("false1: k=" + k + " hash1[k]=" + Integer.toHexString(hash1[k]),
- hash[k] == hash1[k] );
+ assertTrue("false1: k=" + k + " hash1[k]=" + Integer.toHexString(hash1[k]),
+ hash[k] == hash1[k] );
assertTrue("false2: k=" + k + " j=" + Integer.toHexString(j), hash[k] == j );
}
@@ -113,7 +113,7 @@
for ( int k = 0; k < 5; k++ ) {
int i = k*4;
- int j = ((dgst[i ]&0xff)<<24) | ((dgst[i+1]&0xff)<<16) |
+ int j = ((dgst[i ]&0xff)<<24) | ((dgst[i+1]&0xff)<<16) |
((dgst[i+2]&0xff)<<8 ) | (dgst[i+3]&0xff) ;
assertTrue("false: k=" + k + " j=" + Integer.toHexString(j), hash[k] == j );
@@ -122,7 +122,7 @@
/*
- * The test checks out that SHA1Impl returns correct values
+ * The test checks out that SHA1Impl returns correct values
* for four different cases of infilling internal buffer and computing intermediate hash.
*/
public final void testLongMessage() {
@@ -150,10 +150,10 @@
for ( int k = 0; k < 5; k++ ) {
int i = k*4;
- int j = ((dgst[i ]&0xff)<<24) | ((dgst[i+1]&0xff)<<16) |
+ int j = ((dgst[i ]&0xff)<<24) | ((dgst[i+1]&0xff)<<16) |
((dgst[i+2]&0xff)<<8 ) | (dgst[i+3]&0xff) ;
- assertTrue("false: n =" + n + " k=" + k + " j" + Integer.toHexString(j),
+ assertTrue("false: n =" + n + " k=" + k + " j" + Integer.toHexString(j),
hash[k] == j );
}
}
@@ -166,7 +166,7 @@
private void alternateHash(int[] bufW, int[] hash) {
// constants defined in Secure Hash Standard
- final int[] K = {
+ final int[] K = {
0x5A827999, 0x5A827999, 0x5A827999, 0x5A827999,
0x5A827999, 0x5A827999, 0x5A827999, 0x5A827999,
@@ -248,8 +248,4 @@
return new TestSuite(SHA1ImplTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
index 7e0cc36..19565c3 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1PRNG_SecureRandomTest.java
@@ -72,7 +72,7 @@
for ( int i = 0; i < LENGTH; i++ ) {
byte[] myBytes = sr.generateSeed(i);
- assertFalse("unexpected: myBytes.length != i :: i==" + i +
+ assertFalse("unexpected: myBytes.length != i :: i==" + i +
" myBytes.length=" + myBytes.length, myBytes.length != i);
}
}
@@ -80,7 +80,7 @@
/**
* test against the "void generateSeed(int)" method;
- * it checks out the quality of entropy
+ * it checks out the quality of entropy
* (# of different bytes in sequential calls is more or equal to 50%)
*/
public final void testGenerateSeedint03() {
@@ -115,11 +115,11 @@
} catch (NullPointerException e) {
}
}
-
+
/**
* test against the "void nextBytes(byte[])" method;
- * it checks out that different SecureRandom objects
+ * it checks out that different SecureRandom objects
* being supplied with the same seed return the same sequencies of bytes
* as results of their "nextBytes(byte[])" methods
*/
@@ -148,7 +148,7 @@
sr2.nextBytes(myBytes2);
for ( int l = 0; l < k; l++ ) {
- assertFalse("unexpected: myBytes1[l] != myBytes2[l] :: l==" + l +
+ assertFalse("unexpected: myBytes1[l] != myBytes2[l] :: l==" + l +
" k=" + k + " i=" + i + " myBytes1[l]=" + myBytes1[l] +
" myBytes2[l]=" + myBytes2[l], myBytes1[l] != myBytes2[l] );
}
@@ -175,7 +175,7 @@
int i2 = k %n1;
int i3 = k /n2;
int i4 = k %n2;
- assertTrue("non-equality: i1="+ i1 +" i2="+i2 +" i3="+i3 +" i4=" +i4,
+ assertTrue("non-equality: i1="+ i1 +" i2="+i2 +" i3="+i3 +" i4=" +i4,
bytes1[i1][i2] == bytes2[i3][i4]);
}
}
@@ -184,7 +184,7 @@
/**
* test against the "void nextBytes(byte[])" method;
- * it checks out that different SecureRandom objects
+ * it checks out that different SecureRandom objects
* being supplied with seed by themselves return different sequencies of bytes
* as results of their "nextBytes(byte[])" methods
*/
@@ -230,7 +230,7 @@
/**
* test against the "void nextBytes(byte[])" method;
- * it checks out behavior of SecureRandom object in cases of passing
+ * it checks out behavior of SecureRandom object in cases of passing
* byte array of zero length to "nextBytes(byte[])" method.
* The test contains two testcases:
* - first testcase checks out that if for two newly created SecureRandom objects
@@ -308,7 +308,7 @@
for ( int k = 0; k < 2 ; k++ ) {
for ( int j = 0; j < n; j++ ) {
assertTrue("non-equality: k="+ k +" j="+j +
- " bytes1[k][j]="+bytes1[k][j] +" bytes2[k][j]=" +bytes2[k][j],
+ " bytes1[k][j]="+bytes1[k][j] +" bytes2[k][j]=" +bytes2[k][j],
bytes1[k][j] == bytes2[k][j] );
}
}
@@ -423,8 +423,4 @@
return new TestSuite(SHA1PRNG_SecureRandomTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1_MessageDigestTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1_MessageDigestTest.java
index e53b8db..77c598e 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1_MessageDigestTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1_MessageDigestTest.java
@@ -16,9 +16,9 @@
*/
/*
- * TODO
+ * TODO
* Two testcases, one in testDigestbyteArrayintint01() and one in testUpdatebyteArrayintint01(),
- * and testUpdatebyteArrayintint03() test are commented out because
+ * and testUpdatebyteArrayintint03() test are commented out because
* current implementations of the MessageDigest and MessageDigestSpi classes
* are not compatible with RI; see JIRA ## 1120 and 1148.
*/
@@ -59,25 +59,25 @@
},{
(byte) 0x80, (byte) 0x47, (byte) 0xf8, (byte) 0x24, // 63 n=1
(byte) 0x13, (byte) 0xbf, (byte) 0x4c, (byte) 0x0b,
- (byte) 0x6e, (byte) 0xfb, (byte) 0x6e, (byte) 0xa0,
- (byte) 0x91, (byte) 0xce, (byte) 0x08, (byte) 0x22,
+ (byte) 0x6e, (byte) 0xfb, (byte) 0x6e, (byte) 0xa0,
+ (byte) 0x91, (byte) 0xce, (byte) 0x08, (byte) 0x22,
(byte) 0x02, (byte) 0x0d, (byte) 0x2e, (byte) 0xfc
},{
(byte) 0x92, (byte) 0xcb, (byte) 0x89, (byte) 0xdf, // 64 n=2
(byte) 0x62, (byte) 0xd9, (byte) 0x00, (byte) 0xb3,
- (byte) 0x50, (byte) 0xd9, (byte) 0x3e, (byte) 0x42,
+ (byte) 0x50, (byte) 0xd9, (byte) 0x3e, (byte) 0x42,
(byte) 0x25, (byte) 0xca, (byte) 0x6f, (byte) 0x08,
(byte) 0x1d, (byte) 0x54, (byte) 0x7a, (byte) 0x28
},{
(byte) 0x70, (byte) 0x59, (byte) 0xd4, (byte) 0x34, // 65 n=3
(byte) 0xa3, (byte) 0xb6, (byte) 0x28, (byte) 0x25,
- (byte) 0x5c, (byte) 0x3e, (byte) 0xf8, (byte) 0xc8,
+ (byte) 0x5c, (byte) 0x3e, (byte) 0xf8, (byte) 0xc8,
(byte) 0x92, (byte) 0x83, (byte) 0x9a, (byte) 0xb3,
(byte) 0xb9, (byte) 0x1c, (byte) 0x4f, (byte) 0xe6
},{
(byte) 0x03, (byte) 0x2f, (byte) 0x1c, (byte) 0x65, // 639 n=4
(byte) 0x44, (byte) 0xcc, (byte) 0x88, (byte) 0xf7,
- (byte) 0x34, (byte) 0xac, (byte) 0xad, (byte) 0xd3,
+ (byte) 0x34, (byte) 0xac, (byte) 0xad, (byte) 0xd3,
(byte) 0xc4, (byte) 0xe2, (byte) 0x19, (byte) 0x32,
(byte) 0xdf, (byte) 0x6c, (byte) 0x88, (byte) 0xfe
},{
@@ -121,8 +121,8 @@
/*
* array of numbers for which above data were calculated
- */
- private static final int[] LENGTHS = { 1, 63,64,65, 639,640,641, 6399,6400,6401, 9999 };
+ */
+ private static final int[] LENGTHS = { 1, 63,64,65, 639,640,641, 6399,6400,6401, 9999 };
private static final int DIGESTLENGTH = 20; // implementation constants
private static final int LENGTH = 100; //
@@ -195,7 +195,7 @@
/**
* test against "byte[] digest()" method;
- * it checks out that for given seed arrays
+ * it checks out that for given seed arrays
* hash arrays returned by the method are the same as in RI
*/
public final void testDigest02() {
@@ -211,7 +211,7 @@
results = md.digest();
for ( int j = 0; j < DIGESTLENGTH; j++ ) {
- assertEquals("results[j] != HASHTOCOMPARE[i][j] :: n=" + n + " j=" + j +
+ assertEquals("results[j] != HASHTOCOMPARE[i][j] :: n=" + n + " j=" + j +
" i=" + i, results[j], HASHTOCOMPARE[i][j]);
}
i++;
@@ -288,7 +288,7 @@
for ( len = DIGESTLENGTH -1; len >=0 ; len-- ) {
try {
md.digest(new byte[DIGESTLENGTH], 0, len);
- fail("md.digest(new byte[DIGESTLENGTH], 0, len) :: len=" +
+ fail("md.digest(new byte[DIGESTLENGTH], 0, len) :: len=" +
len + " :: No DigestException");
} catch (DigestException e) {
}
@@ -298,7 +298,7 @@
// for ( offset = -5; offset < 0 ; offset++ ) {
// try {
// md.digest(new byte[30], offset, DIGESTLENGTH);
-// fail("md.digest(new byte[30], offset, DIGESTLENGTH) :: " +
+// fail("md.digest(new byte[30], offset, DIGESTLENGTH) :: " +
// "offset=" + offset + " :: no ArrayIndexOutOfBoundsException");
// } catch (ArrayIndexOutOfBoundsException e) {
// }
@@ -308,7 +308,7 @@
/**
* test agains "int digest(byte[], int, int)" method
- * it checks out that for given seed arrays
+ * it checks out that for given seed arrays
* hash arrays returned by the method are the same as in RI
*/
public final void testDigestbyteArrayintint02() throws DigestException {
@@ -346,7 +346,7 @@
byte[] bytes2 = new byte[DIGESTLENGTH];
for ( int n = 1 ; n < LENGTH; n++ ) {
-
+
byte[] b = new byte[n];
for ( int j = 0; j < b.length; j++ ) {
b[j] = (byte) j;
@@ -369,7 +369,7 @@
* test against the "int GetDigestLength()" method;
* it checks out that the method returns the same value
* regardless of previous calls to other methods
- */
+ */
public final void testGetDigestLength() throws DigestException {
int digestlength = md.getDigestLength();
@@ -495,7 +495,7 @@
/**
* test against the "void update(byte[],int,int)" method;
- * it checks out that two sequential digest,
+ * it checks out that two sequential digest,
* second is byte array update to first,
* are different, provided length of the byte array > 0.
*/
@@ -559,12 +559,12 @@
// md.update(new byte[1], 0, 0);
// digest2 = md.digest();
//
-// assertTrue("digest's lengths are different : length1=" +
-// digest1.length + " length2=" + digest2.length,
+// assertTrue("digest's lengths are different : length1=" +
+// digest1.length + " length2=" + digest2.length,
// digest1.length == digest2.length );
//
// for ( int i = 0; i < digest1.length ; i++ ) {
-// assertTrue("different digests : i=" +i +
+// assertTrue("different digests : i=" +i +
// " digest1[i]=" + digest1[i] + " digest2[i]=" + digest2[i],
// digest1[i] == digest2[i] );
// }
@@ -576,8 +576,4 @@
return new TestSuite(SHA1_MessageDigestTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1withDSA_SignatureTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1withDSA_SignatureTest.java
index 65e438d..8139a6f 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1withDSA_SignatureTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/SHA1withDSA_SignatureTest.java
@@ -16,8 +16,8 @@
*/
/*
- * Notes.
- * 1. The class doesn't contain tests against "update(..)" methods
+ * Notes.
+ * 1. The class doesn't contain tests against "update(..)" methods
* invoked on a Signature objects whose state is "INIT" or "VERIFY".
* Relevant checks are in tests against MessageDigest class methods.
*
@@ -307,9 +307,9 @@
/**
* The test against "initSign(PrivateKey)" method.
- * It checks out that regardless of a Signature object's state
+ * It checks out that regardless of a Signature object's state
* the method throws InvalidKeyException if
- * PrivateKey is DSAPrivateKey and the key is invalid, that is,
+ * PrivateKey is DSAPrivateKey and the key is invalid, that is,
* BigIntegers constituting the key have incorrect values.
*/
public final void testInitSignPrivateKey02() throws Exception {
@@ -331,7 +331,7 @@
* if it is invoked with a different argument.
*
* Note.
- * In RI, negating effect of previous call includes
+ * In RI, negating effect of previous call includes
* discarding updates done before calling the method.
*/
public final void testInitSignPrivateKey03() throws Exception {
@@ -364,7 +364,7 @@
* if it is invoked with the same argument.
*
* Notes.
- * 1. In RI, negating effect of previous call includes
+ * 1. In RI, negating effect of previous call includes
* discarding updates done before calling the method.
* 2.
* The specification for the method contains the following clause:
@@ -372,7 +372,7 @@
* it negates the effect of this call."
* which meaning requires certainty in case of sequence
* initSign - update - initSign
- * RI behavior is such that with respect to "update"
+ * RI behavior is such that with respect to "update"
* it doesn't matter whether argument is the same or different.
*/
public final void testInitSignPrivateKey04() throws Exception {
@@ -418,9 +418,9 @@
/**
* The test against "initSign(PrivateKey)" method.
- * It checks out that regardless of a Signature object's state
+ * It checks out that regardless of a Signature object's state
* the method throws InvalidKeyException if
- * PublicKey is DSAPublicKey and the key is invalid, that is,
+ * PublicKey is DSAPublicKey and the key is invalid, that is,
* BigIntegers constituting the key have incorrect values.
*/
public final void testInitVerifyPublicKey02() throws Exception {
@@ -457,11 +457,11 @@
* The test against the "initVerify(PublicKey)" method.
* It checks out that the method negates the effect of previous call
* if it is invoked with the same argument.
- * Like it is for "initSign", RI behavior is such that with respect to "update"
+ * Like it is for "initSign", RI behavior is such that with respect to "update"
* it doesn't matter whether argument is the same or different.
*
* Note.
- * In RI negating effect of previous call includes
+ * In RI negating effect of previous call includes
* discarding updates done before calling the method.
*/
public final void testInitVerifyPublicKey04() throws Exception {
@@ -477,7 +477,7 @@
}
/*
- * The method returns
+ * The method returns
* - -1 if a signature's syntax is incorrect
* - length of the signature otherwise.
*/
@@ -593,7 +593,7 @@
//
// signingSigns[i].update(message);
//
- // // because 50 is more than length of any signature,
+ // // because 50 is more than length of any signature,
// // for offset==-1 and len==50 ArrayIndexOutOfBoundsException is expected
// //
// try {
@@ -602,7 +602,7 @@
// } catch (ArrayIndexOutOfBoundsException e) {
// }
//
- // // because 40 is less than length of any signature",
+ // // because 40 is less than length of any signature",
// //for offset==-1 and len==40 ArrayIndexOutOfBoundsException is not expected
// //
// try {
@@ -640,7 +640,7 @@
/**
* The test is against the pair "sign() - verify(byte[])" method.
* It checks out that the "verify" method returns "true"
- * if a verifying Signature object was updated with the same message
+ * if a verifying Signature object was updated with the same message
* which was used to update a signing Signature object.
*/
public final void testVerifybyteArray02() throws Exception {
@@ -677,9 +677,9 @@
/**
* The compatibility with RI test.
- * It checks out that
+ * It checks out that
* for the predefined message and signature signed with PrivateKey from RI
- * the method invoked on a Signature object initialized with corresponding PublicKey from RI
+ * the method invoked on a Signature object initialized with corresponding PublicKey from RI
* returns "true".
*/
public final void testVerifybyteArray03() throws Exception {
@@ -693,7 +693,7 @@
/**
* The test against the pair "sign - verify" methods.
* Its specific is that signing and verifying are performed by two providers,
- * provider and provider1;
+ * provider and provider1;
* so, the test checks up on compatibility signing-verifying between implementations.
*/
public final void testVerifybyteArray04() throws Exception {
@@ -737,12 +737,12 @@
/**
* The test against the "verify(byte[], int, int)" method.
- * It checks out that if Signature object's state is VERIFY
+ * It checks out that if Signature object's state is VERIFY
* the method throws IllegalArgumentException in case of the following arguments :
- * outbufs == null or
- * offset < 0 or
- * length < 0 or
- * offset+length > outbuf.length
+ * outbufs == null or
+ * offset < 0 or
+ * length < 0 or
+ * offset+length > outbuf.length
*/
public final void testVerifybyteArrayintint01() throws Exception {
@@ -780,7 +780,7 @@
* the method throws up SignatureException if
* (1) offset+length < 0
* (2) offset > signature.length
- * (3) SignatureException if outbuf's lentgh is correct
+ * (3) SignatureException if outbuf's lentgh is correct
* whereas a signature doesn't meet ASN1 syntax.
*/
public final void testVerifybyteArrayintint02() throws Exception {
@@ -857,7 +857,7 @@
signingSigns[0].update(message);
n = signingSigns[0].sign(sigBytes, 0, 50);
- // testcase1: first call returns true,
+ // testcase1: first call returns true,
// second returns false though signature is the same
verifyingSign.update(message);
@@ -865,7 +865,7 @@
assertTrue("case1: test failure", verifyingSign.verify(sigBytes, 0, n));
assertFalse("case2: test failure", verifyingSign.verify(sigBytes, 0, n));
- // testcase2: first call returns false (incorrect signature),
+ // testcase2: first call returns false (incorrect signature),
// second returns false too, in spite of correct signature (!),
// because Signature object was reset in first call
@@ -925,7 +925,7 @@
/**
* The test is against the pair "sign(byte[],int,int) - verify(byte[],int,int)" method.
* It checks out that the "verify" method returns "true"
- * if a verifying Signature object was updated with the same message
+ * if a verifying Signature object was updated with the same message
* which was used to update a signing Signature object.
*/
public final void testVerifybyteArrayintint06() throws Exception {
@@ -966,9 +966,6 @@
return new TestSuite(SHA1withDSA_SignatureTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
class Predefined {
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.java
index 9b1c061..fa7d8ea 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/provider/crypto/serialization/SHA1PRNG_SecureRandomTest.java
@@ -50,7 +50,7 @@
private static final int LIMIT2 = 50; //
private static final int CASES = 4;
-
+
static String algorithm = "SHA1PRNG"; // name of algorithm
static String provider = "Crypto"; // name of provider
@@ -70,7 +70,7 @@
SecureRandom sr;
Object[] data = new Object[5];
-
+
for ( int i = 0; i < data.length ; i++ ) {
try {
@@ -93,7 +93,7 @@
break;
}
data[i] = sr;
-
+
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("ATTENTION: " + e);
} catch (NoSuchProviderException e) {
@@ -105,7 +105,7 @@
/**
- * Comparing sequencies of bytes
+ * Comparing sequencies of bytes
* returned by "nextBytes(..)" of referenced and tested objects
*/
private void testingSame(SecureRandom ref, SecureRandom test) {
@@ -137,7 +137,7 @@
/**
- * Comparing sequencies of bytes
+ * Comparing sequencies of bytes
* returned by "nextBytes(..)" of referenced and tested objects
*/
private void testingNotSame(SecureRandom ref, SecureRandom test) {
@@ -173,7 +173,7 @@
b &= refTotalBytes[n1] == testTotalBytes[n1];
if ( j >= 20 || n1 == n ) {
- assertFalse("the same sequencies :: testcase=" + testcase +
+ assertFalse("the same sequencies :: testcase=" + testcase +
" k=" +k + "n1 =" + n1, b);
b = true;
j = 0;
@@ -190,7 +190,7 @@
private SerializableAssert comparator = new SerializableAssert(){
/**
- * Tests that data objects can be serialized and deserialized without exceptions
+ * Tests that data objects can be serialized and deserialized without exceptions
* and the deserialization produces object of the same class.
*/
public void assertDeserialized(Serializable reference, Serializable test) {
@@ -408,8 +408,4 @@
return new TestSuite(SHA1PRNG_SecureRandomTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x501/NameTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x501/NameTest.java
index adb049e..df35525 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x501/NameTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x501/NameTest.java
@@ -29,7 +29,7 @@
/**
* Test Name class
- *
+ *
* @see http://www.ietf.org/rfc/rfc1779.txt
* @see http://www.ietf.org/rfc/rfc2253.txt
*/
@@ -64,10 +64,6 @@
0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x43, 0x41
};
- public static void main(String[] args) {
- junit.textui.TestRunner.run(NameTest.class);
- }
-
public void testGetName1779() throws Exception {
Name principal = (Name) Name.ASN1.decode(mess);
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateListTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateListTest.java
index ab69093..1a68c4e 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateListTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateListTest.java
@@ -71,7 +71,7 @@
private static Extension crlEntryExtension;
static {
// Invalidity Date Extension (rfc 3280)
- crlEntryExtension = new Extension("2.5.29.24",
+ crlEntryExtension = new Extension("2.5.29.24",
ASN1GeneralizedTime.getInstance().encode(new Date()));
}
private static Extensions crlEntryExtensions = new Extensions();
@@ -86,7 +86,7 @@
// RECOMMENDS that implementations recognize this extension."
try {
crlEntryExtensions.addExtension(
- new Extension("2.5.29.29", true,
+ new Extension("2.5.29.29", true,
//*
//ASN1OctetString.getInstance().encode(
GeneralNames.ASN1.encode(
@@ -108,11 +108,11 @@
private static Date revocationDate = new Date();
private static List revokedCertificates = Arrays.asList(
new TBSCertList.RevokedCertificate[] {
- new TBSCertList.RevokedCertificate(BigInteger.valueOf(555),
+ new TBSCertList.RevokedCertificate(BigInteger.valueOf(555),
revocationDate, null),//crlEntryExtensions),
- new TBSCertList.RevokedCertificate(BigInteger.valueOf(666),
+ new TBSCertList.RevokedCertificate(BigInteger.valueOf(666),
revocationDate, crlEntryExtensions),
- new TBSCertList.RevokedCertificate(BigInteger.valueOf(777),
+ new TBSCertList.RevokedCertificate(BigInteger.valueOf(777),
revocationDate, null),//crlEntryExtensions)
});
private static Extensions crlExtensions = new Extensions(
@@ -123,18 +123,18 @@
}));
private CertificateList certificateList;
- private TBSCertList tbscertlist;
+ private TBSCertList tbscertlist;
private byte[] encoding;
-
+
protected void setUp() throws java.lang.Exception {
try {
Name issuer = new Name(issuerName);
- tbscertlist =
- new TBSCertList(2, signature, issuer, thisUpdate,
+ tbscertlist =
+ new TBSCertList(2, signature, issuer, thisUpdate,
nextUpdate, revokedCertificates, crlExtensions);
-
- certificateList =
+
+ certificateList =
new CertificateList(tbscertlist, signature, signatureValue);
encoding = CertificateList.ASN1.encode(certificateList);
@@ -147,28 +147,28 @@
fail("Unexpected IOException was thrown: "+e.getMessage());
}
}
-
-
+
+
/**
* CertificateList(TBSCertList tbsCertList, AlgorithmIdentifier
* signatureAlgorithm, byte[] signatureValue) method testing.
*/
public void testCertificateList() {
try {
- AlgorithmIdentifier signature =
+ AlgorithmIdentifier signature =
new AlgorithmIdentifier(algOID, algParams);
Name issuer = new Name(issuerName);
- TBSCertList tbscl =
+ TBSCertList tbscl =
new TBSCertList(signature, issuer, thisUpdate);
- CertificateList cl =
+ CertificateList cl =
new CertificateList(tbscl, signature, new byte[] {0});
-
+
byte[] encoding = CertificateList.ASN1.encode(cl);
CertificateList.ASN1.decode(encoding);
- tbscl = new TBSCertList(2, signature, issuer, thisUpdate,
+ tbscl = new TBSCertList(2, signature, issuer, thisUpdate,
nextUpdate, revokedCertificates, crlExtensions);
-
+
cl = new CertificateList(tbscl, signature, new byte[] {0});
encoding = CertificateList.ASN1.encode(cl);
@@ -179,7 +179,7 @@
fail("Unexpected IOException was thrown: "+e.getMessage());
}
}
-
+
/**
* getTbsCertList() method testing.
*/
@@ -187,7 +187,7 @@
assertTrue("Returned tbsCertList value is incorrect",
tbscertlist.equals(certificateList.getTbsCertList()));
}
-
+
/**
* getSignatureAlgorithm() method testing.
*/
@@ -195,7 +195,7 @@
assertTrue("Returned signatureAlgorithm value is incorrect",
signature.equals(certificateList.getSignatureAlgorithm()));
}
-
+
/**
* getSignatureValue() method testing.
*/
@@ -210,7 +210,7 @@
new ByteArrayInputStream(encoding));
Set rcerts = crl.getRevokedCertificates();
System.out.println(">> rcerts:"+rcerts);
-
+
System.out.println("}>> "+ rcerts.toArray()[0]);
System.out.println("}>> "+((X509CRLEntry) rcerts.toArray()[0]).getCertificateIssuer());
System.out.println("}>> "+((X509CRLEntry) rcerts.toArray()[1]).getCertificateIssuer());
@@ -218,13 +218,9 @@
System.out.println(">> "+crl.getRevokedCertificate(
BigInteger.valueOf(555)).getCertificateIssuer());
}
-
+
public static Test suite() {
return new TestSuite(CertificateListTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
index 09976ae..bff62ba 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificatePoliciesTest.java
@@ -45,7 +45,7 @@
"1.1.1.1.1.1",
"2.2.2.2.2.2"
};
- CertificatePolicies certificatePolicies =
+ CertificatePolicies certificatePolicies =
new CertificatePolicies();
for (int i=0; i<policies.length; i++) {
PolicyInformation policyInformation =
@@ -54,19 +54,15 @@
}
byte[] encoding = certificatePolicies.getEncoded();
- List policyInformations = ((CertificatePolicies)
+ List policyInformations = ((CertificatePolicies)
CertificatePolicies.ASN1.decode(encoding))
.getPolicyInformations();
Iterator it = policyInformations.iterator();
((PolicyInformation) it.next()).getPolicyIdentifier();
}
-
+
public static Test suite() {
return new TestSuite(CertificatePoliciesTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateTest.java
index da2ab03..2a0dcec 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/CertificateTest.java
@@ -59,7 +59,7 @@
* Certificate ::= SEQUENCE {
* tbsCertificate TBSCertificate,
* signatureAlgorithm AlgorithmIdentifier,
- * signatureValue BIT STRING
+ * signatureValue BIT STRING
* }
*
* TBSCertificate ::= SEQUENCE {
@@ -84,19 +84,19 @@
*
* Validity ::= SEQUENCE {
* notBefore Time,
- * notAfter Time
+ * notAfter Time
* }
*
* Time ::= CHOICE {
* utcTime UTCTime,
- * generalTime GeneralizedTime
+ * generalTime GeneralizedTime
* }
*
* UniqueIdentifier ::= BIT STRING
*
* SubjectPublicKeyInfo ::= SEQUENCE {
* algorithm AlgorithmIdentifier,
- * subjectPublicKey BIT STRING
+ * subjectPublicKey BIT STRING
* }
*
* Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
@@ -104,7 +104,7 @@
* Extension ::= SEQUENCE {
* extnID OBJECT IDENTIFIER,
* critical BOOLEAN DEFAULT FALSE,
- * extnValue OCTET STRING
+ * extnValue OCTET STRING
* }
* </pre>
*/
@@ -121,15 +121,15 @@
public void testCertificate() throws Exception {
// make the TBSCertificate for Certificate
int version = 2; //v3
- BigInteger serialNumber = BigInteger.valueOf(555L);
+ BigInteger serialNumber = BigInteger.valueOf(555L);
AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555"); // random value
Name issuer = new Name("O=Certificate Issuer");
Validity validity = new Validity(new Date(100000000), new Date(200000000));
- Name subject = new Name("O=Subject Organization");
- SubjectPublicKeyInfo subjectPublicKeyInfo =
- new SubjectPublicKeyInfo(new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
+ Name subject = new Name("O=Subject Organization");
+ SubjectPublicKeyInfo subjectPublicKeyInfo =
+ new SubjectPublicKeyInfo(new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
new byte[10]);
- boolean[] issuerUniqueID = new boolean[]
+ boolean[] issuerUniqueID = new boolean[]
{true, false, true, false, true, false, true, false}; // random value
boolean[] subjectUniqueID = new boolean[]
{false, true, false, true, false, true, false, true}; // random value
@@ -153,12 +153,12 @@
Extension extension = new Extension("2.5.29.17", true, sans.getEncoded());
Extensions extensions = new Extensions();
extensions.addExtension(extension);
-
+
byte[] encoding = extensions.getEncoded();
Extensions.ASN1.decode(encoding);
-
- TBSCertificate tbsCertificate = new TBSCertificate(version, serialNumber,
- signature, issuer, validity, subject, subjectPublicKeyInfo,
+
+ TBSCertificate tbsCertificate = new TBSCertificate(version, serialNumber,
+ signature, issuer, validity, subject, subjectPublicKeyInfo,
issuerUniqueID, subjectUniqueID, extensions);
encoding = tbsCertificate.getEncoded();
@@ -167,11 +167,11 @@
Certificate certificate = new Certificate(tbsCertificate, signature, new byte[10]);
encoding = certificate.getEncoded();
-
+
Certificate.ASN1.decode(encoding);
encoding = Certificate.ASN1.encode(certificate);
-
+
ByteArrayInputStream bais = new ByteArrayInputStream(encoding);
//try {
@@ -181,17 +181,17 @@
// there is no X.509 certificate factory implementation installed
//}
}
-
+
/**
* getTbsCertificate() method testing.
*/
public void testGetTbsCertificate() throws IOException {
// manually derived data:
byte[] encoding = new byte[] {
- (byte)0x30,(byte)0x13, // NameConstraints
+ (byte)0x30,(byte)0x13, // NameConstraints
(byte)0xa1,(byte)0x11, // GeneralSubtrees (excludedSubtrees)
- (byte)0x30,(byte)0x0f, // GeneralSubtree
- (byte)0xa0,(byte)0x0a, // GeneralName
+ (byte)0x30,(byte)0x0f, // GeneralSubtree
+ (byte)0xa0,(byte)0x0a, // GeneralName
// OtherName:
(byte)0x06,(byte)0x03, // type-id (OID)
(byte)0x00,(byte)0x01,(byte)0x02, // oid
@@ -201,31 +201,27 @@
};
NameConstraints.ASN1.decode(encoding);
}
-
+
/**
* getSignatureAlgorithm() method testing.
*/
public void testGetSignatureAlgorithm() {
}
-
+
/**
* getSignatureValue() method testing.
*/
public void testGetSignatureValue() {
}
-
+
/**
* getValue() method testing.
*/
public void testGetValue() {
}
-
+
public static Test suite() {
return new TestSuite(CertificateTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
index 40f33cc..f983231 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/EDIPartyNameTest.java
@@ -41,10 +41,10 @@
for (int i=0; i<data.length; i++) {
String tail = Integer.toHexString(0x000000ff & data[i]);
if (tail.length() == 1) {
- tail = "0" + tail;
+ tail = "0" + tail;
}
System.out.print(prefix + "0x" + tail + delimiter);
-
+
if (((i+1)%perLine) == 0) {
System.out.println();
}
@@ -61,14 +61,14 @@
EDIPartyName ediPN = new EDIPartyName("nameAssigner", "partyName");
byte[] encoded = ediPN.getEncoded();
// manually derived data:
- byte[] _encoded = {
- (byte) 0x30, (byte) 0x1d, (byte) 0x80, (byte) 0x0e,
- (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61,
- (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73,
+ byte[] _encoded = {
+ (byte) 0x30, (byte) 0x1d, (byte) 0x80, (byte) 0x0e,
+ (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61,
+ (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73,
(byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e,
- (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b,
- (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61,
- (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e,
+ (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b,
+ (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61,
+ (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e,
(byte) 0x61, (byte) 0x6d, (byte) 0x65
};
if (!Arrays.equals(encoded, _encoded)) {
@@ -84,13 +84,13 @@
encoded = gName.getEncoded();
// manually derived data:
_encoded = new byte[] {
- (byte) 0xa5, (byte) 0x1d, (byte) 0x80, (byte) 0x0e,
- (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61,
- (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73,
- (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e,
- (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b,
- (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61,
- (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e,
+ (byte) 0xa5, (byte) 0x1d, (byte) 0x80, (byte) 0x0e,
+ (byte) 0x13, (byte) 0x0c, (byte) 0x6e, (byte) 0x61,
+ (byte) 0x6d, (byte) 0x65, (byte) 0x41, (byte) 0x73,
+ (byte) 0x73, (byte) 0x69, (byte) 0x67, (byte) 0x6e,
+ (byte) 0x65, (byte) 0x72, (byte) 0x81, (byte) 0x0b,
+ (byte) 0x13, (byte) 0x09, (byte) 0x70, (byte) 0x61,
+ (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x4e,
(byte) 0x61, (byte) 0x6d, (byte) 0x65
};
if (!Arrays.equals(encoded, _encoded)) {
@@ -128,7 +128,7 @@
assertTrue("Some problems occured.", pass);
}
-
+
/**
* EDIPartyName(String nameAssigner, String partyName, byte[] encoding)
* method testing.
@@ -140,70 +140,66 @@
new GeneralName(5, encoding);
GeneralName gn = new GeneralName(ediName);
-
+
new GeneralName(5, gn.getEncodedName());
}
-
+
/**
* getNameAssigner() method testing.
*/
public void testGetNameAssigner() {
}
-
+
/**
* getPartyName() method testing.
*/
public void testGetPartyName() {
}
-
+
/**
* getEncoded() method testing.
*/
public void testGetEncoded() {
}
-
+
/**
* getEncoder() method testing.
*/
public void testGetEncoder() {
}
-
+
/**
* DerEncoder(String nameAssigner, String partyName) method testing.
*/
public void testDerEncoder() {
}
-
+
/**
* getDirStrAlternatives() method testing.
*/
public void testGetDirStrAlternatives() {
}
-
+
/**
* DerDecoder() method testing.
*/
public void testDerDecoder() {
}
-
+
/**
* getValue(byte[] encoding) method testing.
*/
public void testGetValue1() {
}
-
+
/**
* getValue() method testing.
*/
public void testGetValue2() {
}
-
+
public static Test suite() {
return new TestSuite(EDIPartyNameTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNamesTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNamesTest.java
index d7719ce..8021cce 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNamesTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/GeneralNamesTest.java
@@ -35,12 +35,8 @@
public class GeneralNamesTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(GeneralNamesTest.class);
- }
-
public void test_EncodeDecode() throws IOException {
-
+
GeneralNames subj_alt_names = new GeneralNames(Arrays
.asList(new GeneralName[] { new GeneralName(1, "rfc@822.Name"),
new GeneralName(2, "dNSName"),
@@ -48,11 +44,11 @@
new GeneralName(6, "http://uniform.Resource.Id"),
new GeneralName(7, "255.255.255.0"),
new GeneralName(8, "1.2.3.4444.55555") }));
-
+
byte[] encoding = GeneralNames.ASN1.encode(subj_alt_names);
-
+
GeneralNames gnames = (GeneralNames) GeneralNames.ASN1.decode(encoding);
-
+
assertEquals("Names: ", subj_alt_names.getNames(), gnames.getNames());
}
}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java
index 666862c..42ad424 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/ORAddressTest.java
@@ -39,10 +39,10 @@
for (int i=0; i<data.length; i++) {
String tail = Integer.toHexString(0x000000ff & data[i]);
if (tail.length() == 1) {
- tail = "0" + tail;
+ tail = "0" + tail;
}
System.out.print(prefix + "0x" + tail + delimiter);
-
+
if (((i+1)%perLine) == 0) {
System.out.println();
}
@@ -59,7 +59,7 @@
System.out.println("ORAddress:");
printAsHex(8, "", " ", ora.getEncoded());
System.out.println("");
-
+
GeneralName gName = new GeneralName(ora);
System.out.println("GeneralName:");
printAsHex(8, "", " ", gName.getEncoded());
@@ -71,13 +71,9 @@
printAsHex(8, "", " ", gNames.getEncoded());
System.out.println("");
}
-
+
public static Test suite() {
return new TestSuite(ORAddressTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PrivateKeyUsagePeriodTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PrivateKeyUsagePeriodTest.java
index 4eb143d..67e1f80 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PrivateKeyUsagePeriodTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/PrivateKeyUsagePeriodTest.java
@@ -29,10 +29,6 @@
public class PrivateKeyUsagePeriodTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(PrivateKeyUsagePeriodTest.class);
- }
-
public void testEncodeDecode() throws Exception {
Date notBeforeDate = new Date(200000000);
@@ -49,4 +45,4 @@
assertEquals("notBeforeDate", notBeforeDate, pkup.getNotBefore());
assertEquals("notAfterDate", notAfterDate, pkup.getNotAfter());
}
-}
\ No newline at end of file
+}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/TimeTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/TimeTest.java
index 7cfedbb..8b3a9ec 100644
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/x509/TimeTest.java
+++ b/security/src/test/impl/java/org/apache/harmony/security/tests/x509/TimeTest.java
@@ -47,7 +47,4 @@
enc[0]);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(TimeTest.class);
- }
}
diff --git a/support/src/test/java/org/apache/harmony/testframework/CharSinkTester.java b/support/src/test/java/org/apache/harmony/testframework/CharSinkTester.java
new file mode 100644
index 0000000..59b5214
--- /dev/null
+++ b/support/src/test/java/org/apache/harmony/testframework/CharSinkTester.java
@@ -0,0 +1,207 @@
+/*
+ * 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.
+ */
+
+package org.apache.harmony.testframework;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Random;
+
+/**
+ * Tests behaviour common to all implementations of {@link Writer}. This adapts
+ * writers that collects untransformed chars so that they may be tested.
+ */
+public abstract class CharSinkTester {
+
+ private boolean throwsExceptions = true;
+
+ /**
+ * Creates a new writer ready to receive an arbitrary number of chars. Each
+ * time this method is invoked, any previously returned writers may be
+ * discarded.
+ */
+ public abstract Writer create() throws Exception;
+
+ /**
+ * Returns the current set of chars written to the writer last returned by
+ * {@link #create}, and releases any resources held by that writer.
+ */
+ public abstract char[] getChars() throws Exception;
+
+ /**
+ * Configures whether the writer is expected to throw exceptions when an
+ * error is encountered. Classes like {@code PrintWriter} report errors via
+ * an API method instead.
+ */
+ public CharSinkTester setThrowsExceptions(boolean throwsExceptions) {
+ this.throwsExceptions = throwsExceptions;
+ return this;
+ }
+
+ public final TestSuite createTests() {
+ TestSuite result = new TestSuite();
+ result.addTest(new SinkTestCase("sinkTestNoWriting"));
+ result.addTest(new SinkTestCase("sinkTestWriteZeroChars"));
+ result.addTest(new SinkTestCase("sinkTestWriteCharByChar"));
+ result.addTest(new SinkTestCase("sinkTestWriteArray"));
+ result.addTest(new SinkTestCase("sinkTestWriteOffset"));
+ result.addTest(new SinkTestCase("sinkTestWriteLargeArray"));
+
+ if (throwsExceptions) {
+ result.addTest(new SinkTestCase("sinkTestWriteAfterClose"));
+ } else {
+ result.addTest(new SinkTestCase("sinkTestWriteAfterCloseSuppressed"));
+ }
+
+ return result;
+ }
+
+ @Override public String toString() {
+ return getClass().getName();
+ }
+
+ private static void assertArrayEquals(char[] expected, char[] actual) {
+ Assert.assertEquals(Arrays.toString(expected), Arrays.toString(actual));
+ }
+
+ public class SinkTestCase extends TestCase {
+
+ private SinkTestCase(String name) {
+ super(name);
+ }
+
+ public void sinkTestNoWriting() throws Exception {
+ char[] expected = new char[] {};
+
+ Writer out = create();
+ out.close();
+ assertArrayEquals(expected, getChars());
+ }
+
+ public void sinkTestWriteZeroChars() throws Exception {
+ char[] expected = new char[] {};
+
+ Writer out = create();
+ char[] a = new char[1024];
+ out.write(a, 1000, 0);
+ out.write(a, 0, 0);
+ out.write(new char[] {});
+
+ out.close();
+ assertArrayEquals(expected, getChars());
+ }
+
+ public void sinkTestWriteCharByChar() throws Exception {
+ char[] expected = "EFGCDECBA".toCharArray();
+
+ Writer out = create();
+ for (char c : expected) {
+ out.write(c);
+ }
+
+ out.close();
+ assertArrayEquals(expected, getChars());
+ }
+
+ public void sinkTestWriteArray() throws Exception {
+ char[] expected = "EFGCDECBA".toCharArray();
+
+ Writer out = create();
+
+ out.write("EF".toCharArray());
+ out.write("GCDE".toCharArray());
+ out.write("CBA".toCharArray());
+
+ out.close();
+ assertArrayEquals(expected, getChars());
+ }
+
+ public void sinkTestWriteOffset() throws Exception {
+ char[] expected = "EFGCDECBA".toCharArray();
+ Writer out = create();
+
+ char[] a = new char[1024];
+ a[1000] = 'E';
+ a[1001] = 'F';
+ out.write(a, 1000, 2);
+
+ char[] b = new char[1024];
+ b[1020] = 'G';
+ b[1021] = 'C';
+ b[1022] = 'D';
+ b[1023] = 'E';
+ out.write(b, 1020, 4);
+
+ char[] c = new char[1024];
+ c[0] = 'C';
+ c[1] = 'B';
+ c[2] = 'A';
+ out.write(c, 0, 3);
+
+ out.close();
+ assertArrayEquals(expected, getChars());
+ }
+
+ public void sinkTestWriteLargeArray() throws Exception {
+ Random dice = new Random();
+ char[] expected = new char[(1024 * 1024) + 1]; // 2 MB + 1 char
+ for (int c = 0; c < expected.length; c++) {
+ expected[c] = (char) ('A' + dice.nextInt(26));
+ }
+
+ Writer out = create();
+ out.write(expected);
+ out.close();
+
+ assertArrayEquals(expected, getChars());
+ }
+
+ public void sinkTestWriteAfterClose() throws Exception {
+ char[] expectedChars = "EF".toCharArray();
+ Writer out = create();
+
+ out.write(expectedChars);
+ out.close();
+
+ try {
+ out.write("GCDE".toCharArray());
+ fail("expected already closed exception");
+ } catch (IOException expected) {
+ }
+
+ assertArrayEquals(expectedChars, getChars());
+ }
+
+ public void sinkTestWriteAfterCloseSuppressed() throws Exception {
+ Writer out = create();
+ out.write("EF".toCharArray());
+ out.close();
+ out.write("GCDE".toCharArray()); // no exception expected!
+ }
+
+ // adding a new test? Don't forget to update createTests().
+
+ @Override public String getName() {
+ return CharSinkTester.this.toString() + ":" + super.getName();
+ }
+ }
+}
diff --git a/support/src/test/java/org/apache/harmony/testframework/CharWrapperTester.java b/support/src/test/java/org/apache/harmony/testframework/CharWrapperTester.java
new file mode 100644
index 0000000..2744eed
--- /dev/null
+++ b/support/src/test/java/org/apache/harmony/testframework/CharWrapperTester.java
@@ -0,0 +1,241 @@
+/*
+ * 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.
+ */
+
+package org.apache.harmony.testframework;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Tests behaviour common to wrapping and filtering implementations of {@link
+ * Writer}.
+ */
+public abstract class CharWrapperTester {
+
+ private boolean throwsExceptions = true;
+
+ /**
+ * Creates a new output stream that receives one stream of chars, optionally
+ * transforms it, and emits another stream of chars to {@code delegate}.
+ */
+ public abstract Writer create(Writer delegate) throws Exception;
+
+ /**
+ * Decodes the chars received by the delegate into their original form: the
+ * chars originally received by this wrapper.
+ */
+ public abstract char[] decode(char[] delegateChars) throws Exception;
+
+ /**
+ * Configures whether the writer is expected to throw exceptions when an
+ * error is encountered. Classes like {@code PrintWriter} report errors via
+ * an API method instead.
+ */
+ public CharWrapperTester setThrowsExceptions(boolean throwsExceptions) {
+ this.throwsExceptions = throwsExceptions;
+ return this;
+ }
+
+ public final TestSuite createTests() {
+ TestSuite result = new TestSuite();
+ result.addTest(new WrapperSinkTester()
+ .setThrowsExceptions(throwsExceptions)
+ .createTests());
+
+ if (throwsExceptions) {
+ result.addTest(new WrapperTestCase("wrapperTestFlushThrowsViaFlush"));
+ result.addTest(new WrapperTestCase("wrapperTestFlushThrowsViaClose"));
+ result.addTest(new WrapperTestCase("wrapperTestCloseThrows"));
+ } else {
+ result.addTest(new WrapperTestCase("wrapperTestFlushThrowsViaFlushSuppressed"));
+ result.addTest(new WrapperTestCase("wrapperTestFlushThrowsViaCloseSuppressed"));
+ result.addTest(new WrapperTestCase("wrapperTestCloseThrowsSuppressed"));
+ }
+
+ return result;
+ }
+
+ @Override public String toString() {
+ return getClass().getName();
+ }
+
+ private class WrapperSinkTester extends CharSinkTester {
+ private ClosableStringWriter delegate;
+
+ @Override public Writer create() throws Exception {
+ delegate = new ClosableStringWriter();
+ return CharWrapperTester.this.create(delegate);
+ }
+
+ @Override public char[] getChars() throws Exception {
+ return decode(delegate.buffer.toString().toCharArray());
+ }
+
+ @Override public String toString() {
+ return CharWrapperTester.this.toString();
+ }
+ }
+
+ public class WrapperTestCase extends TestCase {
+
+ private WrapperTestCase(String name) {
+ super(name);
+ }
+
+ @Override public String getName() {
+ return CharWrapperTester.this.toString() + ":" + super.getName();
+ }
+
+ public void wrapperTestFlushThrowsViaFlushSuppressed() throws Exception {
+ FailOnFlushWriter delegate = new FailOnFlushWriter();
+ Writer o = create(delegate);
+ o.write("BUT");
+ o.write("TERS");
+ o.flush();
+ assertTrue(delegate.flushed);
+ }
+
+ public void wrapperTestFlushThrowsViaCloseSuppressed() throws Exception {
+ FailOnFlushWriter delegate = new FailOnFlushWriter();
+ Writer o = create(delegate);
+ o.write("BUT");
+ o.write("TERS");
+ o.close();
+ assertTrue(delegate.flushed);
+ }
+
+ public void wrapperTestFlushThrowsViaFlush() throws Exception {
+ FailOnFlushWriter delegate = new FailOnFlushWriter();
+
+ Writer o = create(delegate);
+ try {
+ // any of these is permitted to flush
+ o.write("BUT");
+ o.write("TERS");
+ o.flush();
+ assertTrue(delegate.flushed);
+ fail("flush exception ignored");
+ } catch (IOException expected) {
+ assertEquals("Flush failed" , expected.getMessage());
+ }
+ }
+
+ public void wrapperTestFlushThrowsViaClose() throws Exception {
+ FailOnFlushWriter delegate = new FailOnFlushWriter();
+
+ Writer o = create(delegate);
+ try {
+ // any of these is permitted to flush
+ o.write("BUT");
+ o.write("TERS");
+ o.close();
+ assertTrue(delegate.flushed);
+ fail("flush exception ignored");
+ } catch (IOException expected) {
+ assertEquals("Flush failed" , expected.getMessage());
+ }
+
+ try {
+ o.write("BARK");
+ fail("expected already closed exception");
+ } catch (IOException expected) {
+ }
+ }
+
+ public void wrapperTestCloseThrows() throws Exception {
+ FailOnCloseWriter delegate = new FailOnCloseWriter();
+ Writer o = create(delegate);
+ try {
+ o.close();
+ assertTrue(delegate.closed);
+ fail("close exception ignored");
+ } catch (IOException expected) {
+ assertEquals("Close failed" , expected.getMessage());
+ }
+ }
+
+ public void wrapperTestCloseThrowsSuppressed() throws Exception {
+ FailOnCloseWriter delegate = new FailOnCloseWriter();
+ Writer o = create(delegate);
+ o.close();
+ assertTrue(delegate.closed);
+ }
+
+ // adding a new test? Don't forget to update createTests().
+ }
+
+ /**
+ * A custom Writer that respects the closed state. The built-in StringWriter
+ * doesn't respect close(), which makes testing wrapped streams difficult.
+ */
+ private static class ClosableStringWriter extends Writer {
+ private final StringBuilder buffer = new StringBuilder();
+ private boolean closed = false;
+
+ @Override public void close() throws IOException {
+ closed = true;
+ }
+
+ @Override public void flush() throws IOException {}
+
+ @Override public void write(char[] buf, int offset, int count) throws IOException {
+ if (closed) {
+ throw new IOException();
+ }
+ buffer.append(buf, offset, count);
+ }
+ }
+
+ private static class FailOnFlushWriter extends Writer {
+ boolean flushed = false;
+ boolean closed = false;
+
+ @Override public void write(char[] buf, int offset, int count) throws IOException {
+ if (closed) {
+ throw new IOException("Already closed");
+ }
+ }
+
+ @Override public void close() throws IOException {
+ closed = true;
+ flush();
+ }
+
+ @Override public void flush() throws IOException {
+ if (!flushed) {
+ flushed = true;
+ throw new IOException("Flush failed");
+ }
+ }
+ }
+
+ private static class FailOnCloseWriter extends Writer {
+ boolean closed = false;
+
+ @Override public void flush() throws IOException {}
+
+ @Override public void write(char[] buf, int offset, int count) throws IOException {}
+
+ @Override public void close() throws IOException {
+ closed = true;
+ throw new IOException("Close failed");
+ }
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/org/apache/harmony/testframework/SinkTester.java b/support/src/test/java/org/apache/harmony/testframework/SinkTester.java
new file mode 100644
index 0000000..f2664ee
--- /dev/null
+++ b/support/src/test/java/org/apache/harmony/testframework/SinkTester.java
@@ -0,0 +1,219 @@
+/*
+ * 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.
+ */
+
+package org.apache.harmony.testframework;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Random;
+
+/**
+ * Tests behaviour common to all implementations of {@link OutputStream}. This
+ * adapts streams that collects untransformed bytes so that they may be tested.
+ */
+public abstract class SinkTester {
+
+ private boolean throwsExceptions = true;
+
+ /**
+ * Creates a new output stream ready to receive an arbitrary number of
+ * bytes. Each time this method is invoked, any previously returned output
+ * streams may be discarded.
+ */
+ public abstract OutputStream create() throws Exception;
+
+ /**
+ * Returns the current set of bytes written to the output stream last
+ * returned by {@link #create}, and releases any resources held by that
+ * stream.
+ */
+ public abstract byte[] getBytes() throws Exception;
+
+ /**
+ * Configures whether the stream is expected to throw exceptions when an
+ * error is encountered. Classes like {@code PrintStream} report errors via
+ * an API method instead.
+ */
+ public SinkTester setThrowsExceptions(boolean throwsExceptions) {
+ this.throwsExceptions = throwsExceptions;
+ return this;
+ }
+
+ public final TestSuite createTests() {
+ TestSuite result = new TestSuite();
+ result.addTest(new SinkTestCase("sinkTestNoWriting"));
+ result.addTest(new SinkTestCase("sinkTestWriteZeroBytes"));
+ result.addTest(new SinkTestCase("sinkTestWriteByteByByte"));
+ result.addTest(new SinkTestCase("sinkTestWriteArray"));
+ result.addTest(new SinkTestCase("sinkTestWriteOffset"));
+ result.addTest(new SinkTestCase("sinkTestWriteLargeArray"));
+
+ if (throwsExceptions) {
+ result.addTest(new SinkTestCase("sinkTestWriteAfterClose"));
+ } else {
+ result.addTest(new SinkTestCase("sinkTestWriteAfterCloseSuppressed"));
+ }
+
+ return result;
+ }
+
+ @Override public String toString() {
+ return getClass().getName();
+ }
+
+ private static void assertArrayEquals(byte[] expected, byte[] actual) {
+ Assert.assertEquals(Arrays.toString(expected), Arrays.toString(actual));
+ }
+
+ public class SinkTestCase extends TestCase {
+
+ private SinkTestCase(String name) {
+ super(name);
+ }
+
+ public void sinkTestNoWriting() throws Exception {
+ byte[] expected = new byte[] {};
+
+ OutputStream out = create();
+ out.close();
+ assertArrayEquals(expected, getBytes());
+ }
+
+ public void sinkTestWriteZeroBytes() throws Exception {
+ byte[] expected = new byte[] {};
+
+ OutputStream out = create();
+ byte[] a = new byte[1024];
+ out.write(a, 1000, 0);
+ out.write(a, 0, 0);
+ out.write(new byte[] {});
+
+ out.close();
+ assertArrayEquals(expected, getBytes());
+ }
+
+ public void sinkTestWriteByteByByte() throws Exception {
+ byte[] expected = new byte[] { 5, 6, 7, 3, 4, 5, 3, 2, 1 };
+
+ OutputStream out = create();
+ for (byte b : expected) {
+ out.write(b);
+ }
+
+ out.close();
+ assertArrayEquals(expected, getBytes());
+ }
+
+ public void sinkTestWriteArray() throws Exception {
+ byte[] expected = new byte[] {
+ 5, 6,
+ 7, 3, 4, 5,
+ 3, 2, 1
+ };
+
+ OutputStream out = create();
+
+ byte[] a = new byte[] { 5, 6 };
+ out.write(a);
+
+ byte[] b = new byte[] { 7, 3, 4, 5 };
+ out.write(b);
+
+ byte[] c = new byte[] { 3, 2, 1 };
+ out.write(c);
+
+ out.close();
+ assertArrayEquals(expected, getBytes());
+ }
+
+ public void sinkTestWriteOffset() throws Exception {
+ byte[] expected = new byte[] {
+ 5, 6,
+ 7, 3, 4, 5,
+ 3, 2, 1
+ };
+
+ OutputStream out = create();
+
+ byte[] a = new byte[1024];
+ a[1000] = 5;
+ a[1001] = 6;
+ out.write(a, 1000, 2);
+
+ byte[] b = new byte[1024];
+ b[1020] = 7;
+ b[1021] = 3;
+ b[1022] = 4;
+ b[1023] = 5;
+ out.write(b, 1020, 4);
+
+ byte[] c = new byte[1024];
+ c[0] = 3;
+ c[1] = 2;
+ c[2] = 1;
+ out.write(c, 0, 3);
+
+ out.close();
+ assertArrayEquals(expected, getBytes());
+ }
+
+ public void sinkTestWriteLargeArray() throws Exception {
+ byte[] expected = new byte[(1024 * 1024) + 1]; // 1 MB + 1 byte
+ new Random().nextBytes(expected);
+
+ OutputStream out = create();
+ out.write(expected);
+ out.close();
+
+ assertArrayEquals(expected, getBytes());
+ }
+
+ public void sinkTestWriteAfterClose() throws Exception {
+ byte[] expectedBytes = { 5, 6 };
+ OutputStream out = create();
+
+ out.write(expectedBytes);
+ out.close();
+
+ try {
+ out.write(new byte[] { 7, 3, 4, 5 });
+ fail("expected already closed exception");
+ } catch (IOException expected) {
+ }
+
+ assertArrayEquals(expectedBytes, getBytes());
+ }
+
+ public void sinkTestWriteAfterCloseSuppressed() throws Exception {
+ OutputStream out = create();
+ out.write(new byte[] { 5, 6 });
+ out.close();
+ out.write(new byte[] { 7, 3, 4, 5 }); // no exception expected!
+ }
+
+ // adding a new test? Don't forget to update createTests().
+
+ @Override public String getName() {
+ return SinkTester.this.toString() + ":" + super.getName();
+ }
+ }
+}
diff --git a/support/src/test/java/org/apache/harmony/testframework/WrapperTester.java b/support/src/test/java/org/apache/harmony/testframework/WrapperTester.java
new file mode 100644
index 0000000..b5594c4
--- /dev/null
+++ b/support/src/test/java/org/apache/harmony/testframework/WrapperTester.java
@@ -0,0 +1,232 @@
+/*
+ * 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.
+ */
+
+package org.apache.harmony.testframework;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Tests behaviour common to wrapping and filtering implementations of {@link
+ * OutputStream}.
+ */
+public abstract class WrapperTester {
+
+ private boolean throwsExceptions = true;
+
+ /**
+ * Creates a new output stream that receives one stream of bytes, optionally
+ * transforms it, and emits another stream of bytes to {@code delegate}.
+ */
+ public abstract OutputStream create(OutputStream delegate) throws Exception;
+
+ /**
+ * Decodes the bytes received by the delegate into their original form: the
+ * bytes originally received by this wrapper.
+ */
+ public abstract byte[] decode(byte[] delegateBytes) throws Exception;
+
+ /**
+ * Configures whether the stream is expected to throw exceptions when an
+ * error is encountered. Classes like {@code PrintStream} report errors via
+ * an API method instead.
+ */
+ public WrapperTester setThrowsExceptions(boolean throwsExceptions) {
+ this.throwsExceptions = throwsExceptions;
+ return this;
+ }
+
+ public final TestSuite createTests() {
+ TestSuite result = new TestSuite();
+ result.addTest(new WrapperSinkTester()
+ .setThrowsExceptions(throwsExceptions)
+ .createTests());
+
+ if (throwsExceptions) {
+ result.addTest(new WrapperTestCase("wrapperTestFlushThrowsViaFlush"));
+ result.addTest(new WrapperTestCase("wrapperTestFlushThrowsViaClose"));
+ result.addTest(new WrapperTestCase("wrapperTestCloseThrows"));
+ } else {
+ result.addTest(new WrapperTestCase("wrapperTestFlushThrowsViaFlushSuppressed"));
+ result.addTest(new WrapperTestCase("wrapperTestFlushThrowsViaCloseSuppressed"));
+ result.addTest(new WrapperTestCase("wrapperTestCloseThrowsSuppressed"));
+ }
+
+ return result;
+ }
+
+ @Override public String toString() {
+ return getClass().getName();
+ }
+
+ private class WrapperSinkTester extends SinkTester {
+ private ClosableByteArrayOutputStream delegate;
+
+ @Override public OutputStream create() throws Exception {
+ delegate = new ClosableByteArrayOutputStream();
+ return WrapperTester.this.create(delegate);
+ }
+
+ @Override public byte[] getBytes() throws Exception {
+ return WrapperTester.this.decode(delegate.bytesOut.toByteArray());
+ }
+
+ @Override public String toString() {
+ return WrapperTester.this.toString();
+ }
+ }
+
+ public class WrapperTestCase extends TestCase {
+
+ private WrapperTestCase(String name) {
+ super(name);
+ }
+
+ @Override public String getName() {
+ return WrapperTester.this.toString() + ":" + super.getName();
+ }
+
+ public void wrapperTestFlushThrowsViaFlushSuppressed() throws Exception {
+ FailOnFlushOutputStream delegate = new FailOnFlushOutputStream();
+ OutputStream o = create(delegate);
+ o.write(new byte[] { 8, 6, 7, 5 });
+ o.write(new byte[] { 3, 0, 9 });
+ o.flush();
+ assertTrue(delegate.flushed);
+ }
+
+ public void wrapperTestFlushThrowsViaCloseSuppressed() throws Exception {
+ FailOnFlushOutputStream delegate = new FailOnFlushOutputStream();
+ OutputStream o = create(delegate);
+ o.write(new byte[] { 8, 6, 7, 5 });
+ o.write(new byte[] { 3, 0, 9 });
+ o.close();
+ assertTrue(delegate.flushed);
+ }
+
+ public void wrapperTestFlushThrowsViaFlush() throws Exception {
+ FailOnFlushOutputStream delegate = new FailOnFlushOutputStream();
+
+ OutputStream o = create(delegate);
+ try {
+ // any of these is permitted to flush
+ o.write(new byte[] { 8, 6, 7, 5 });
+ o.write(new byte[] { 3, 0, 9 });
+ o.flush();
+ assertTrue(delegate.flushed);
+ fail("flush exception ignored");
+ } catch (IOException expected) {
+ assertEquals("Flush failed" , expected.getMessage());
+ }
+ }
+
+ public void wrapperTestFlushThrowsViaClose() throws Exception {
+ FailOnFlushOutputStream delegate = new FailOnFlushOutputStream();
+
+ OutputStream o = create(delegate);
+ try {
+ // any of these is permitted to flush
+ o.write(new byte[] { 8, 6, 7, 5 });
+ o.write(new byte[] { 3, 0, 9 });
+ o.close();
+ assertTrue(delegate.flushed);
+ fail("flush exception ignored");
+ } catch (IOException expected) {
+ assertEquals("Flush failed" , expected.getMessage());
+ }
+
+ try {
+ o.write(new byte[] { 4, 4, 5 });
+ fail("expected already closed exception");
+ } catch (IOException expected) {
+ }
+ }
+
+ public void wrapperTestCloseThrows() throws Exception {
+ FailOnCloseOutputStream delegate = new FailOnCloseOutputStream();
+ OutputStream o = create(delegate);
+ try {
+ o.close();
+ assertTrue(delegate.closed);
+ fail("close exception ignored");
+ } catch (IOException expected) {
+ assertEquals("Close failed" , expected.getMessage());
+ }
+ }
+
+ public void wrapperTestCloseThrowsSuppressed() throws Exception {
+ FailOnCloseOutputStream delegate = new FailOnCloseOutputStream();
+ OutputStream o = create(delegate);
+ o.close();
+ assertTrue(delegate.closed);
+ }
+
+ // adding a new test? Don't forget to update createTests().
+ }
+
+ private static class ClosableByteArrayOutputStream extends OutputStream {
+ private final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+ private boolean closed = false;
+
+ @Override public void close() throws IOException {
+ closed = true;
+ }
+
+ @Override public void write(int oneByte) throws IOException {
+ if (closed) {
+ throw new IOException();
+ }
+ bytesOut.write(oneByte);
+ }
+ }
+
+ private static class FailOnFlushOutputStream extends OutputStream {
+ boolean flushed = false;
+ boolean closed = false;
+
+ @Override public void write(int oneByte) throws IOException {
+ if (closed) {
+ throw new IOException("Already closed");
+ }
+ }
+
+ @Override public void close() throws IOException {
+ closed = true;
+ flush();
+ }
+
+ @Override public void flush() throws IOException {
+ if (!flushed) {
+ flushed = true;
+ throw new IOException("Flush failed");
+ }
+ }
+ }
+
+ private static class FailOnCloseOutputStream extends ByteArrayOutputStream {
+ boolean closed = false;
+
+ @Override public void close() throws IOException {
+ closed = true;
+ throw new IOException("Close failed");
+ }
+ }
+}
diff --git a/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java b/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
new file mode 100644
index 0000000..63dcf58
--- /dev/null
+++ b/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
@@ -0,0 +1,670 @@
+/*
+ * 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.
+ */
+
+/**
+* @author Alexey V. Varlamov
+*/
+
+package org.apache.harmony.testframework.serialization;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.UnresolvedPermission;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Framework for serialization testing. Subclasses only need to override
+ * getData() method and, optionally, assertDeserialized() method. The first one
+ * returns array of objects to be de/serialized in tests, and the second
+ * compares reference and deserialized objects (needed only if tested objects do
+ * not provide specific method equals()). <br>
+ * There are two modes of test run: <b>reference generation mode </b> and
+ * <b>testing mode </b>. The actual mode is selected via
+ * <b>"test.mode" </b> system property. The <b>testing mode </b> is
+ * the default mode. <br>
+ * To turn on the <b>reference generation mode </b>, the test.mode property
+ * should be set to value "serial.reference". In this mode, no testing
+ * is performed but golden files are produced, which contain reference
+ * serialized objects. This mode should be run on a pure
+ * Implementation classes, which are targeted for compartibility. <br>
+ * The location of golden files (in both modes) is controlled via
+ * <b>"RESOURCE_DIR" </b> system property.
+ *
+ */
+public abstract class SerializationTest extends TestCase {
+
+ /**
+ * Property name for the testing mode.
+ */
+ public static final String MODE_KEY = "test.mode";
+
+
+ /**
+ * Testing mode.
+ */
+ public static String mode = System.getProperty(MODE_KEY);
+
+ /**
+ * Reference files generation mode switch.
+ */
+ public static final String SERIAL_REFERENCE_MODE = "serial.reference";
+
+ /**
+ * Key to a system property defining root location of golden files.
+ */
+ public static final String GOLDEN_PATH = "RESOURCE_DIR";
+
+ private static final String outputPath = System.getProperty(GOLDEN_PATH,
+ "src/test/resources/serialization");
+
+ /**
+ * Parameterized c-tor inherited from superclass.
+ */
+ public SerializationTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Default c-tor inherited from superclass.
+ */
+ public SerializationTest() {
+ super();
+ }
+
+ /**
+ * Depending on testing mode, produces golden files or performs testing.
+ */
+ @Override
+ public void runBare() throws Throwable {
+
+ if (mode != null && mode.equals(SERIAL_REFERENCE_MODE)) {
+ produceGoldenFiles();
+ } else {
+ super.runBare();
+ }
+ }
+
+ /**
+ * This is the main working method of this framework. Subclasses must
+ * override it to provide actual objects for testing.
+ *
+ * @return array of objects to be de/serialized in tests.
+ */
+ protected abstract Object[] getData();
+
+ /**
+ * Tests that data objects can be serialized and deserialized without
+ * exceptions, and that deserialization really produces deeply cloned
+ * objects.
+ */
+ public void testSelf() throws Throwable {
+
+ if (this instanceof SerializableAssert) {
+ verifySelf(getData(), (SerializableAssert) this);
+ } else {
+ verifySelf(getData());
+
+ }
+ }
+
+ /**
+ * Tests that data objects can be deserialized from golden files, to verify
+ * compartibility with Reference Implementation.
+ */
+ public void testGolden() throws Throwable {
+
+ verifyGolden(this, getData());
+ }
+
+ /**
+ * Returns golden file for an object being tested.
+ *
+ * @param index array index of tested data (as returned by
+ * {@link #getData() getData()})
+ * @return corresponding golden file
+ */
+ protected File getDataFile(int index) {
+ String name = this.getClass().getName();
+ int dot = name.lastIndexOf('.');
+ String path = name.substring(0, dot).replace('.', File.separatorChar);
+ if (outputPath != null && outputPath.length() != 0) {
+ path = outputPath + File.separator + path;
+ }
+
+ return new File(path, name.substring(dot + 1) + "." + index + ".dat");
+ }
+
+ /**
+ * Working method for files generation mode. Serializes test objects
+ * returned by {@link #getData() getData()}to golden files, each object to
+ * a separate file.
+ *
+ * @throws IOException
+ */
+ protected void produceGoldenFiles() throws IOException {
+
+ String goldenPath = outputPath + File.separatorChar
+ + getClass().getName().replace('.', File.separatorChar)
+ + ".golden.";
+
+ Object[] data = getData();
+ for (int i = 0; i < data.length; i++) {
+
+ File goldenFile = new File(goldenPath + i + ".ser");
+ goldenFile.getParentFile().mkdirs();
+ goldenFile.createNewFile();
+
+ putObjectToStream(data[i], new FileOutputStream(goldenFile));
+ }
+ }
+
+ /**
+ * Serializes specified object to an output stream.
+ */
+ public static void putObjectToStream(Object obj, OutputStream os)
+ throws IOException {
+ ObjectOutputStream oos = new ObjectOutputStream(os);
+ oos.writeObject(obj);
+ oos.flush();
+ oos.close();
+ }
+
+ /**
+ * Deserializes single object from an input stream.
+ */
+ public static Serializable getObjectFromStream(InputStream is) throws IOException,
+ ClassNotFoundException {
+ ObjectInputStream ois = new ObjectInputStream(is);
+ Object result = ois.readObject();
+ ois.close();
+ return (Serializable)result;
+ }
+
+ /**
+ * Interface to compare (de)serialized objects
+ *
+ * Should be implemented if a class under test does not provide specific
+ * equals() method and it's instances should to be compared manually.
+ */
+ public interface SerializableAssert {
+
+ /**
+ * Compares deserialized and reference objects.
+ *
+ * @param initial -
+ * initial object used for creating serialized form
+ * @param deserialized -
+ * deserialized object
+ */
+ void assertDeserialized(Serializable initial, Serializable deserialized);
+ }
+
+ // default comparator for a class that has equals(Object) method
+ private final static SerializableAssert DEFAULT_COMPARATOR = new SerializableAssert() {
+ public void assertDeserialized(Serializable initial,
+ Serializable deserialized) {
+
+ Assert.assertEquals(initial, deserialized);
+ }
+ };
+
+ /**
+ * Comparator for verifying that deserialized object is the same as initial.
+ */
+ public final static SerializableAssert SAME_COMPARATOR = new SerializableAssert() {
+ public void assertDeserialized(Serializable initial,
+ Serializable deserialized) {
+
+ Assert.assertSame(initial, deserialized);
+ }
+ };
+
+ /**
+ * Comparator for java.lang.Throwable objects
+ */
+ public final static SerializableAssert THROWABLE_COMPARATOR = new SerializableAssert() {
+ public void assertDeserialized(Serializable initial, Serializable deserialized) {
+
+ Throwable initThr = (Throwable) initial;
+ Throwable dserThr = (Throwable) deserialized;
+
+ // verify class
+ Assert.assertEquals(initThr.getClass(), dserThr.getClass());
+
+ // verify message
+ Assert.assertEquals(initThr.getMessage(), dserThr.getMessage());
+
+ // verify cause
+ if (initThr.getCause() == null) {
+ Assert.assertNull(dserThr.getCause());
+ } else {
+ Assert.assertNotNull(dserThr.getCause());
+
+ THROWABLE_COMPARATOR.assertDeserialized(initThr.getCause(),
+ dserThr.getCause());
+ }
+ }
+ };
+
+ /**
+ * Comparator for java.security.PermissionCollection objects
+ */
+ public final static SerializableAssert PERMISSION_COLLECTION_COMPARATOR = new SerializableAssert() {
+ public void assertDeserialized(Serializable initial, Serializable deserialized) {
+
+ PermissionCollection initPC = (PermissionCollection) initial;
+ PermissionCollection dserPC = (PermissionCollection) deserialized;
+
+ // verify class
+ Assert.assertEquals(initPC.getClass(), dserPC.getClass());
+
+ // verify 'readOnly' field
+ Assert.assertEquals(initPC.isReadOnly(), dserPC.isReadOnly());
+
+ // verify collection of permissions
+ Collection<Permission> refCollection = new HashSet<Permission>(
+ Collections.list(initPC.elements()));
+ Collection<Permission> tstCollection = new HashSet<Permission>(
+ Collections.list(dserPC.elements()));
+
+ Assert.assertEquals(refCollection.size(), tstCollection.size());
+ int size = refCollection.size();
+ if (size > 0) {
+ ArrayList<Permission> refList = Collections.list(initPC
+ .elements());
+ ArrayList<Permission> tstList = Collections.list(dserPC
+ .elements());
+ if (refList.get(0) instanceof UnresolvedPermission
+ && tstList.get(0) instanceof UnresolvedPermission) {
+ boolean found;
+ UnresolvedPermission refPerm, tstPerm;
+ for (int i = 0; i < size; i++) {
+ found = false;
+ refPerm = (UnresolvedPermission) refList.get(i);
+ for (int j = 0; j < size; j++) {
+ tstPerm = (UnresolvedPermission) tstList.get(i);
+ if (equalsUnresolvedPermission(refPerm, tstPerm)) {
+ found = true;
+ break;
+ }
+ }
+
+ Assert.assertTrue(found);
+ }
+ } else {
+ Assert.assertEquals(refCollection, tstCollection);
+ }
+ }
+ }
+
+ /*
+ * check whether the given two UnresolvedPermission objects equal to
+ * each other
+ */
+ private boolean equalsUnresolvedPermission(UnresolvedPermission up1,
+ UnresolvedPermission up2) {
+ java.security.cert.Certificate[] certs = up1.getUnresolvedCerts();
+ if (certs != null && certs.length == 0) {
+ if (null == up2.getUnresolvedCerts()) {
+ if (up1.getName().equals(up2.getName())) {
+ String up1Name = up1.getUnresolvedName();
+ String up2Name = up2.getUnresolvedName();
+ if (up1Name == null ? up2Name == null : up1Name
+ .equals(up2Name)) {
+ String up1Actions = up1.getUnresolvedActions();
+ String up2Actions = up2.getUnresolvedActions();
+ return up1Actions == null ? up2Actions == null
+ : up1Actions.equals(up2Actions);
+ }
+ }
+ }
+ return false;
+ }
+ return up1.equals(up2);
+ }
+ };
+
+ /**
+ * Comparator for java.security.UnresolvedPermission objects
+ */
+ public final static SerializableAssert UNRESOLVED_PERMISSION_COMPARATOR = new SerializableAssert() {
+ public void assertDeserialized(Serializable initial,
+ Serializable deserialized) {
+ UnresolvedPermission initPerm = (UnresolvedPermission) initial;
+ UnresolvedPermission dserPerm = (UnresolvedPermission) deserialized;
+ java.security.cert.Certificate[] certs = initPerm
+ .getUnresolvedCerts();
+ if (certs != null && certs.length == 0) {
+ Assert.assertEquals(initPerm.getUnresolvedType(), dserPerm
+ .getUnresolvedType());
+ Assert.assertEquals(initPerm.getUnresolvedName(), dserPerm
+ .getUnresolvedName());
+ Assert.assertEquals(initPerm.getUnresolvedActions(), dserPerm
+ .getUnresolvedActions());
+ Assert.assertNull(dserPerm.getUnresolvedCerts());
+ } else {
+ Assert.assertEquals(initPerm, dserPerm);
+ }
+ }
+ };
+
+ /**
+ * Returns <code>comparator</code> for provided serializable
+ * <code>object</code>.
+ *
+ * The <code>comparator</code> is searched in the following order: <br>-
+ * if <code>test</code> implements SerializableAssert interface then it is
+ * selected as </code>comparator</code>.<br>- if passed <code>object</code>
+ * has class in its classes hierarchy that overrides <code>equals(Object)</code>
+ * method then <code>DEFAULT_COMPARATOR</code> is selected.<br> - the
+ * method tries to select one of known comparators basing on <code>object's</code>
+ * class,for example, if passed <code>object</code> is instance of
+ * java.lang.Throwable then <code>THROWABLE_COMPARATOR</code> is used.<br>-
+ * otherwise RuntimeException is thrown
+ *
+ * @param test -
+ * test case
+ * @param object -
+ * object to be compared
+ * @return object's comparator
+ */
+ public static SerializableAssert defineComparator(TestCase test,
+ Object object) throws Exception {
+
+ if (test instanceof SerializableAssert) {
+ return (SerializableAssert) test;
+ }
+
+ Method m = object.getClass().getMethod("equals",
+ new Class[] { Object.class });
+
+ if (m.getDeclaringClass() != Object.class) {
+ if (object instanceof UnresolvedPermission) {
+ // object is an instance of UnresolvedPermission, use
+ // UNRESOLVED_PERMISSION_COMPARATOR
+ return UNRESOLVED_PERMISSION_COMPARATOR;
+ }
+ // one of classes overrides Object.equals(Object) method
+ // use default comparator
+ return DEFAULT_COMPARATOR;
+ }
+
+ // TODO use generics to detect comparator
+ // instead of 'instanceof' for the first element
+ if (object instanceof java.lang.Throwable) {
+ return THROWABLE_COMPARATOR;
+ } else if (object instanceof java.security.PermissionCollection) {
+ return PERMISSION_COLLECTION_COMPARATOR;
+ }
+
+ throw new RuntimeException("Failed to detect comparator");
+ }
+
+ /**
+ * Verifies that object deserialized from golden file correctly.
+ *
+ * The method invokes <br>
+ * verifyGolden(test, object, defineComparator(test, object));
+ *
+ * @param test -
+ * test case
+ * @param object -
+ * to be compared
+ */
+ public static void verifyGolden(TestCase test, Object object)
+ throws Exception {
+
+ verifyGolden(test, object, defineComparator(test, object));
+ }
+
+ /**
+ * Verifies that object deserialized from golden file correctly.
+ *
+ * The method loads "<code>testName</code>.golden.ser" resource file
+ * from "<module root>/src/test/resources/serialization/<code>testPackage</code>"
+ * folder, reads an object from the loaded file and compares it with
+ * <code>object</code> using specified <code>comparator</code>.
+ *
+ * @param test-
+ * test case
+ * @param object-
+ * to be compared
+ * @param comparator -
+ * for comparing (de)serialized objects
+ */
+ public static void verifyGolden(TestCase test, Object object,
+ SerializableAssert comparator) throws Exception {
+
+ Assert.assertNotNull("Null comparator", comparator);
+
+ Serializable deserialized = getObject(test, ".golden.ser");
+
+ comparator.assertDeserialized((Serializable) object, deserialized);
+ }
+
+ /**
+ * Verifies that objects from array deserialized from golden files
+ * correctly.
+ *
+ * The method invokes <br>
+ * verifyGolden(test, objects, defineComparator(test, object[0]));
+ *
+ * @param test -
+ * test case
+ * @param objects -
+ * array of objects to be compared
+ */
+ public static void verifyGolden(TestCase test, Object[] objects)
+ throws Exception {
+
+ Assert.assertFalse("Empty array", objects.length == 0);
+ verifyGolden(test, objects, defineComparator(test, objects[0]));
+ }
+
+ /**
+ * Verifies that objects from array deserialized from golden files
+ * correctly.
+ *
+ * The method loads "<code>testName</code>.golden.<code>N</code>.ser"
+ * resource files from "<module root>/src/test/resources/serialization/<code>testPackage</code>"
+ * folder, from each loaded file it reads an object from and compares it
+ * with corresponding object in provided array (i.e. <code>objects[N]</code>)
+ * using specified <code>comparator</code>. (<code>N</code> is index
+ * in object's array.)
+ *
+ * @param test-
+ * test case
+ * @param objects -
+ * array of objects to be compared
+ * @param comparator -
+ * for comparing (de)serialized objects
+ */
+ public static void verifyGolden(TestCase test, Object[] objects,
+ SerializableAssert comparator) throws Exception {
+
+ Assert.assertFalse("Empty array", objects.length == 0);
+ for (int i = 0; i < objects.length; i++) {
+ Serializable deserialized = getObject(test, ".golden." + i + ".ser");
+ comparator.assertDeserialized((Serializable) objects[i],
+ deserialized);
+ }
+ }
+
+ /**
+ * Verifies that object can be smoothly serialized/deserialized.
+ *
+ * The method invokes <br>
+ * verifySelf(object, defineComparator(null, object));
+ *
+ * @param object -
+ * to be serialized/deserialized
+ */
+ public static void verifySelf(Object object)
+ throws Exception {
+
+ verifySelf(object, defineComparator(null, object));
+ }
+
+ /**
+ * Verifies that object can be smoothly serialized/deserialized.
+ *
+ * The method serialize/deserialize <code>object</code> and compare it
+ * with initial <code>object</code>.
+ *
+ * @param object -
+ * object to be serialized/deserialized
+ * @param comparator -
+ * for comparing serialized/deserialized object with initial
+ * object
+ */
+ public static void verifySelf(Object object, SerializableAssert comparator)
+ throws Exception {
+
+ Serializable initial = (Serializable) object;
+
+ comparator.assertDeserialized(initial, copySerializable(initial));
+ }
+
+ /**
+ * Verifies that that objects from array can be smoothly
+ * serialized/deserialized.
+ *
+ * The method invokes <br>
+ * verifySelf(objects, defineComparator(null, object[0]));
+ *
+ * @param objects -
+ * array of objects to be serialized/deserialized
+ */
+ public static void verifySelf(Object[] objects)
+ throws Exception {
+
+ Assert.assertFalse("Empty array", objects.length == 0);
+ verifySelf(objects, defineComparator(null, objects[0]));
+ }
+
+ /**
+ * Verifies that that objects from array can be smoothly
+ * serialized/deserialized.
+ *
+ * The method serialize/deserialize each object in <code>objects</code>
+ * array and compare it with initial object.
+ *
+ * @param objects -
+ * array of objects to be serialized/deserialized
+ * @param comparator -
+ * for comparing serialized/deserialized object with initial
+ * object
+ */
+ public static void verifySelf(Object[] objects, SerializableAssert comparator)
+ throws Exception {
+
+ Assert.assertFalse("Empty array", objects.length == 0);
+ for(Object entry: objects){
+ verifySelf(entry, comparator);
+ }
+ }
+
+ private static Serializable getObject(TestCase test, String toAppend)
+ throws Exception {
+
+ StringBuilder path = new StringBuilder("serialization");
+
+ path.append(File.separatorChar);
+ path.append(test.getClass().getName().replace('.', File.separatorChar));
+ path.append(toAppend);
+
+ InputStream in = ClassLoader.getSystemClassLoader()
+ .getResourceAsStream(path.toString());
+
+ Assert.assertNotNull("Failed to load serialization resource file: "
+ + path, in);
+
+ return getObjectFromStream(in);
+ }
+
+ /**
+ * Creates golden file.
+ *
+ * The folder for created file is: <code>root + test's package name</code>.
+ * The file name is: <code>test's name + "golden.ser"</code>
+ *
+ * @param root -
+ * root directory for serialization resource files
+ * @param test -
+ * test case
+ * @param object -
+ * object to be serialized
+ * @throws IOException -
+ * if I/O error
+ */
+ public static void createGoldenFile(String root, TestCase test,
+ Object object) throws IOException {
+
+ String goldenPath = test.getClass().getName().replace('.',
+ File.separatorChar)
+ + ".golden.ser";
+
+ if (root != null) {
+ goldenPath = root + File.separatorChar + goldenPath;
+ }
+
+
+ File goldenFile = new File(goldenPath);
+ goldenFile.getParentFile().mkdirs();
+ goldenFile.createNewFile();
+
+ putObjectToStream(object, new FileOutputStream(goldenFile));
+
+ // don't forget to remove it from test case after using
+ Assert.fail("Generating golden file.\nGolden file name:"
+ + goldenFile.getAbsolutePath());
+ }
+
+ /**
+ * Copies an object by serializing/deserializing it.
+ *
+ * @param initial -
+ * an object to be copied
+ * @return copy of provided object
+ */
+ public static Serializable copySerializable(Serializable initial)
+ throws IOException, ClassNotFoundException {
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ putObjectToStream(initial, out);
+ ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+
+ return getObjectFromStream(in);
+ }
+}
diff --git a/support/src/test/java/tests/resources/Broken_entry.jar b/support/src/test/java/tests/resources/Broken_entry.jar
new file mode 100644
index 0000000..e6e7927
--- /dev/null
+++ b/support/src/test/java/tests/resources/Broken_entry.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Broken_manifest.jar b/support/src/test/java/tests/resources/Broken_manifest.jar
new file mode 100644
index 0000000..4c3ff31
--- /dev/null
+++ b/support/src/test/java/tests/resources/Broken_manifest.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Created_by_1_4.jar b/support/src/test/java/tests/resources/Created_by_1_4.jar
new file mode 100644
index 0000000..1fe7947
--- /dev/null
+++ b/support/src/test/java/tests/resources/Created_by_1_4.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/EmptyEntries_signed.jar b/support/src/test/java/tests/resources/EmptyEntries_signed.jar
new file mode 100644
index 0000000..237d244
--- /dev/null
+++ b/support/src/test/java/tests/resources/EmptyEntries_signed.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/GZIPInputStream/hyts_gInput.txt.gz b/support/src/test/java/tests/resources/GZIPInputStream/hyts_gInput.txt.gz
new file mode 100644
index 0000000..e0f5a00
--- /dev/null
+++ b/support/src/test/java/tests/resources/GZIPInputStream/hyts_gInput.txt.gz
Binary files differ
diff --git a/support/src/test/java/tests/resources/Harmony.GIF b/support/src/test/java/tests/resources/Harmony.GIF
new file mode 100644
index 0000000..be2dc56
--- /dev/null
+++ b/support/src/test/java/tests/resources/Harmony.GIF
Binary files differ
diff --git a/support/src/test/java/tests/resources/Harmony.jpg b/support/src/test/java/tests/resources/Harmony.jpg
new file mode 100644
index 0000000..85bfc6e
--- /dev/null
+++ b/support/src/test/java/tests/resources/Harmony.jpg
Binary files differ
diff --git a/support/src/test/java/tests/resources/Harmony.png b/support/src/test/java/tests/resources/Harmony.png
new file mode 100644
index 0000000..5ec399c
--- /dev/null
+++ b/support/src/test/java/tests/resources/Harmony.png
Binary files differ
diff --git a/support/src/test/java/tests/resources/Inserted_Entry_Manifest.jar b/support/src/test/java/tests/resources/Inserted_Entry_Manifest.jar
new file mode 100644
index 0000000..154d8d6
--- /dev/null
+++ b/support/src/test/java/tests/resources/Inserted_Entry_Manifest.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Inserted_Entry_Manifest_with_DigestCode.jar b/support/src/test/java/tests/resources/Inserted_Entry_Manifest_with_DigestCode.jar
new file mode 100644
index 0000000..a94ae49
--- /dev/null
+++ b/support/src/test/java/tests/resources/Inserted_Entry_Manifest_with_DigestCode.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Integrate.jar b/support/src/test/java/tests/resources/Integrate.jar
new file mode 100644
index 0000000..16e9c55
--- /dev/null
+++ b/support/src/test/java/tests/resources/Integrate.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_11.jar b/support/src/test/java/tests/resources/JarIndex/hyts_11.jar
new file mode 100644
index 0000000..19cf5f2
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_11.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_12.jar b/support/src/test/java/tests/resources/JarIndex/hyts_12.jar
new file mode 100644
index 0000000..236659b
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_12.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_13.jar b/support/src/test/java/tests/resources/JarIndex/hyts_13.jar
new file mode 100644
index 0000000..9ea6806
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_13.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_14.jar b/support/src/test/java/tests/resources/JarIndex/hyts_14.jar
new file mode 100644
index 0000000..d8bc44b
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_14.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_21.jar b/support/src/test/java/tests/resources/JarIndex/hyts_21.jar
new file mode 100644
index 0000000..c25d4bf
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_21.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_22-new.jar b/support/src/test/java/tests/resources/JarIndex/hyts_22-new.jar
new file mode 100644
index 0000000..542c22a
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_22-new.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_22.jar b/support/src/test/java/tests/resources/JarIndex/hyts_22.jar
new file mode 100644
index 0000000..84c7af0
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_22.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_23.jar b/support/src/test/java/tests/resources/JarIndex/hyts_23.jar
new file mode 100644
index 0000000..a932052
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_23.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_31.jar b/support/src/test/java/tests/resources/JarIndex/hyts_31.jar
new file mode 100644
index 0000000..ab69696
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_31.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_32.jar b/support/src/test/java/tests/resources/JarIndex/hyts_32.jar
new file mode 100644
index 0000000..12de6bb
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_32.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_33.jar b/support/src/test/java/tests/resources/JarIndex/hyts_33.jar
new file mode 100644
index 0000000..086e494
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_33.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_41.jar b/support/src/test/java/tests/resources/JarIndex/hyts_41.jar
new file mode 100644
index 0000000..fb71bf8
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_41.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/JarIndex/hyts_42.jar b/support/src/test/java/tests/resources/JarIndex/hyts_42.jar
new file mode 100644
index 0000000..06a35cd
--- /dev/null
+++ b/support/src/test/java/tests/resources/JarIndex/hyts_42.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Modified_Class.jar b/support/src/test/java/tests/resources/Modified_Class.jar
new file mode 100644
index 0000000..d8113c7
--- /dev/null
+++ b/support/src/test/java/tests/resources/Modified_Class.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Modified_Manifest_EntryAttributes.jar b/support/src/test/java/tests/resources/Modified_Manifest_EntryAttributes.jar
new file mode 100644
index 0000000..bd1dbb1
--- /dev/null
+++ b/support/src/test/java/tests/resources/Modified_Manifest_EntryAttributes.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Modified_Manifest_MainAttributes.jar b/support/src/test/java/tests/resources/Modified_Manifest_MainAttributes.jar
new file mode 100644
index 0000000..5bc60e6
--- /dev/null
+++ b/support/src/test/java/tests/resources/Modified_Manifest_MainAttributes.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Modified_SF_EntryAttributes.jar b/support/src/test/java/tests/resources/Modified_SF_EntryAttributes.jar
new file mode 100644
index 0000000..7b76694
--- /dev/null
+++ b/support/src/test/java/tests/resources/Modified_SF_EntryAttributes.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_all_attributes.jar b/support/src/test/java/tests/resources/Package/hyts_all_attributes.jar
new file mode 100644
index 0000000..bde3f4d
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_all_attributes.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_c.jar b/support/src/test/java/tests/resources/Package/hyts_c.jar
new file mode 100644
index 0000000..111f73c
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_c.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_d.jar b/support/src/test/java/tests/resources/Package/hyts_d.jar
new file mode 100644
index 0000000..1218f76
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_d.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_d1.jar b/support/src/test/java/tests/resources/Package/hyts_d1.jar
new file mode 100644
index 0000000..e4a0b4d
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_d1.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_d2.jar b/support/src/test/java/tests/resources/Package/hyts_d2.jar
new file mode 100644
index 0000000..2665a06
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_d2.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_no_attributes.jar b/support/src/test/java/tests/resources/Package/hyts_no_attributes.jar
new file mode 100644
index 0000000..1879acb
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_no_attributes.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_no_entry.jar b/support/src/test/java/tests/resources/Package/hyts_no_entry.jar
new file mode 100644
index 0000000..66090a5
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_no_entry.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_pq.jar b/support/src/test/java/tests/resources/Package/hyts_pq.jar
new file mode 100644
index 0000000..5919f6c
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_pq.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/Package/hyts_some_attributes.jar b/support/src/test/java/tests/resources/Package/hyts_some_attributes.jar
new file mode 100644
index 0000000..95c87a8
--- /dev/null
+++ b/support/src/test/java/tests/resources/Package/hyts_some_attributes.jar
Binary files differ
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java b/support/src/test/java/tests/resources/ServiceLoader/AbstractService.java
similarity index 66%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/AbstractService.java
index c3ece0e..bff9660 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/AbstractService.java
@@ -15,14 +15,24 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.PreDestroy;
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public abstract class AbstractService {
+ /**
+ * @return name of the class
+ */
+ public abstract String myNameIs();
-import junit.framework.TestCase;
-
-public class PreDestroyTest extends TestCase {
- public void testPreDestroyTest() {
- assertTrue(PreDestroy.class.isAnnotation());
+ /**
+ * test of internal interface
+ */
+ public interface InternalService {
+ /**
+ * @return name
+ */
+ public String myInternalNameIs();
}
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java b/support/src/test/java/tests/resources/ServiceLoader/Service.java
similarity index 74%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/Service.java
index 92dbd6f..c36fdb3 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/Service.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.Resources;
-
-import junit.framework.TestCase;
-
-public class ResourcesTest extends TestCase {
- public void testResources() {
- assertTrue(Resources.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface Service {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceDuplicateIn2File.java
similarity index 74%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/ServiceDuplicateIn2File.java
index 92dbd6f..b09bc81 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceDuplicateIn2File.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.Resources;
-
-import junit.framework.TestCase;
-
-public class ResourcesTest extends TestCase {
- public void testResources() {
- assertTrue(Resources.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface ServiceDuplicateIn2File {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceFinalClass.java
similarity index 73%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/ServiceFinalClass.java
index c3ece0e..767f016 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceFinalClass.java
@@ -15,14 +15,17 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.PreDestroy;
-
-import junit.framework.TestCase;
-
-public class PreDestroyTest extends TestCase {
- public void testPreDestroyTest() {
- assertTrue(PreDestroy.class.isAnnotation());
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public final class ServiceFinalClass {
+ /**
+ * @return name of the class
+ */
+ @SuppressWarnings("nls")
+ public String myNameIs() {
+ return "ServiceFinalClass";
}
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceForAllCommentTest.java
similarity index 74%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/ServiceForAllCommentTest.java
index c3ece0e..e982b3f 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceForAllCommentTest.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.PreDestroy;
-
-import junit.framework.TestCase;
-
-public class PreDestroyTest extends TestCase {
- public void testPreDestroyTest() {
- assertTrue(PreDestroy.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface ServiceForAllCommentTest {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceForEmptyTest.java
similarity index 74%
rename from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
rename to support/src/test/java/tests/resources/ServiceLoader/ServiceForEmptyTest.java
index c3ece0e..d777293 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceForEmptyTest.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.PreDestroy;
-
-import junit.framework.TestCase;
-
-public class PreDestroyTest extends TestCase {
- public void testPreDestroyTest() {
- assertTrue(PreDestroy.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface ServiceForEmptyTest {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceForIllegalNameTest.java
similarity index 74%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/ServiceForIllegalNameTest.java
index c3ece0e..4e9cde7 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceForIllegalNameTest.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.PreDestroy;
-
-import junit.framework.TestCase;
-
-public class PreDestroyTest extends TestCase {
- public void testPreDestroyTest() {
- assertTrue(PreDestroy.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface ServiceForIllegalNameTest {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceForWrongNameTest.java
similarity index 74%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/ServiceForWrongNameTest.java
index c3ece0e..910faec 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceForWrongNameTest.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.PreDestroy;
-
-import junit.framework.TestCase;
-
-public class PreDestroyTest extends TestCase {
- public void testPreDestroyTest() {
- assertTrue(PreDestroy.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface ServiceForWrongNameTest {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceIn2File.java
similarity index 74%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/ServiceIn2File.java
index 92dbd6f..49f19d7 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceIn2File.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.Resources;
-
-import junit.framework.TestCase;
-
-public class ResourcesTest extends TestCase {
- public void testResources() {
- assertTrue(Resources.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface ServiceIn2File {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceIn2FileWithEmptyConfig.java
similarity index 74%
rename from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
rename to support/src/test/java/tests/resources/ServiceLoader/ServiceIn2FileWithEmptyConfig.java
index 92dbd6f..ad63606 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceIn2FileWithEmptyConfig.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.Resources;
-
-import junit.framework.TestCase;
-
-public class ResourcesTest extends TestCase {
- public void testResources() {
- assertTrue(Resources.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface ServiceIn2FileWithEmptyConfig {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceMoreThanOne.java
similarity index 73%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/ServiceMoreThanOne.java
index c3ece0e..895972e 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/PreDestroyTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceMoreThanOne.java
@@ -15,14 +15,17 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.PreDestroy;
-
-import junit.framework.TestCase;
-
-public class PreDestroyTest extends TestCase {
- public void testPreDestroyTest() {
- assertTrue(PreDestroy.class.isAnnotation());
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public class ServiceMoreThanOne {
+ /**
+ * @return name of the class
+ */
+ @SuppressWarnings("nls")
+ public String myNameIs() {
+ return "ServiceMoreThanOne";
}
}
diff --git a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java b/support/src/test/java/tests/resources/ServiceLoader/ServiceWithDuplicateSons.java
similarity index 74%
copy from annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
copy to support/src/test/java/tests/resources/ServiceLoader/ServiceWithDuplicateSons.java
index 92dbd6f..a299931 100644
--- a/annotation/src/test/java/org/apache/harmony/annotation/tests/javax/annotation/ResourcesTest.java
+++ b/support/src/test/java/tests/resources/ServiceLoader/ServiceWithDuplicateSons.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.harmony.annotation.tests.javax.annotation;
+package tests.resources.ServiceLoader;
-import javax.annotation.Resources;
-
-import junit.framework.TestCase;
-
-public class ResourcesTest extends TestCase {
- public void testResources() {
- assertTrue(Resources.class.isAnnotation());
- }
+/**
+ * A class just for test cases of java.util.ServiceLoader.
+ */
+public interface ServiceWithDuplicateSons {
+ /**
+ * @return name of the class
+ */
+ public String myNameIs();
}
diff --git a/support/src/test/java/tests/resources/ServiceLoader/hyts_services.jar b/support/src/test/java/tests/resources/ServiceLoader/hyts_services.jar
new file mode 100644
index 0000000..12503a6
--- /dev/null
+++ b/support/src/test/java/tests/resources/ServiceLoader/hyts_services.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/ServiceLoader/hyts_services2.jar b/support/src/test/java/tests/resources/ServiceLoader/hyts_services2.jar
new file mode 100644
index 0000000..a7a754a
--- /dev/null
+++ b/support/src/test/java/tests/resources/ServiceLoader/hyts_services2.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/TestCodeSigners.jar b/support/src/test/java/tests/resources/TestCodeSigners.jar
new file mode 100644
index 0000000..a4c42aa
--- /dev/null
+++ b/support/src/test/java/tests/resources/TestCodeSigners.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_Bar.ser b/support/src/test/java/tests/resources/hyts_Bar.ser
new file mode 100644
index 0000000..2802528
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_Bar.ser
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_Foo.ser b/support/src/test/java/tests/resources/hyts_Foo.ser
new file mode 100644
index 0000000..9f511ac
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_Foo.ser
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_PropertiesTest.properties b/support/src/test/java/tests/resources/hyts_PropertiesTest.properties
new file mode 100644
index 0000000..6c1b950
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_PropertiesTest.properties
@@ -0,0 +1,29 @@
+
+
+
+
+ \ \r \n \t \f
+
+
+! dshfjklahfjkldashgjl;as
+ #jdfagdfjagkdjfghksdajfd
+
+!!properties
+
+a=a
+b bb as,dn
+c\r\ \t\nu =:: cu
+bu= b\
+ u
+d=d\r\ne=e
+f :f\
+f\
+ f
+g g
+h\u0020h
+\ i=i
+j=\ j
+space=\ c
+
+dblbackslash=\\
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/hyts_ZipFile.zip b/support/src/test/java/tests/resources/hyts_ZipFile.zip
new file mode 100644
index 0000000..f9cd6ed
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_ZipFile.zip
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_att.jar b/support/src/test/java/tests/resources/hyts_att.jar
new file mode 100644
index 0000000..7f4530c
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_att.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_available.tst b/support/src/test/java/tests/resources/hyts_available.tst
new file mode 100644
index 0000000..d67b2f4
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_available.tst
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_checkInput.txt b/support/src/test/java/tests/resources/hyts_checkInput.txt
new file mode 100644
index 0000000..6d49d33
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_checkInput.txt
@@ -0,0 +1,4 @@
+ crc.reset();
+ crc.update(1);
+ //System.out.print("value of crc"+crc.getValue());
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/hyts_compDiction.bin b/support/src/test/java/tests/resources/hyts_compDiction.bin
new file mode 100644
index 0000000..f0478c8
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_compDiction.bin
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_compressD.bin b/support/src/test/java/tests/resources/hyts_compressD.bin
new file mode 100644
index 0000000..36c89f2
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_compressD.bin
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_construO.bin b/support/src/test/java/tests/resources/hyts_construO.bin
new file mode 100644
index 0000000..b6bd7b4
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_construO.bin
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_construOD.bin b/support/src/test/java/tests/resources/hyts_construOD.bin
new file mode 100644
index 0000000..035d12e
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_construOD.bin
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_construODI.bin b/support/src/test/java/tests/resources/hyts_construODI.bin
new file mode 100644
index 0000000..1e5d284
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_construODI.bin
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_flushed.jar b/support/src/test/java/tests/resources/hyts_flushed.jar
new file mode 100644
index 0000000..56b717c
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_flushed.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_htmltest.html b/support/src/test/java/tests/resources/hyts_htmltest.html
new file mode 100644
index 0000000..9464371
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_htmltest.html
@@ -0,0 +1,38 @@
+<HTML>
+<TITLE>Test HTML Document</TITLE>
+<BODY>
+<H2>Test HTML Document</H2>
+This file is used by the <CODE>Test_java_net_URL.test_getContent()</CODE>.
+<p>
+It contains the string <quote>A Seemingly Non Important String</quote>. Which is
+looked for in the testcase.<P>
+<UL>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+<LI>A Line of text</LI>
+</UL>
+<p>
+A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. A bunch of text representing part of a paragraph. <p>
+
+The End.
+</BODY>
+</HTML>
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/hyts_mainClass.ser b/support/src/test/java/tests/resources/hyts_mainClass.ser
new file mode 100644
index 0000000..0421ba9
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_mainClass.ser
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_manifest1.jar b/support/src/test/java/tests/resources/hyts_manifest1.jar
new file mode 100644
index 0000000..fb292b2
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_manifest1.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_missingclass.ser b/support/src/test/java/tests/resources/hyts_missingclass.ser
new file mode 100644
index 0000000..0a71403
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_missingclass.ser
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_patch.jar b/support/src/test/java/tests/resources/hyts_patch.jar
new file mode 100644
index 0000000..f3c51d0
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_patch.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_patch2.jar b/support/src/test/java/tests/resources/hyts_patch2.jar
new file mode 100644
index 0000000..c26f9e7
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_patch2.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_resource.properties b/support/src/test/java/tests/resources/hyts_resource.properties
new file mode 100644
index 0000000..baf5762
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_resource.properties
@@ -0,0 +1,2 @@
+property=parent
+propertyInSystemParent=valueInSystemParent
diff --git a/support/src/test/java/tests/resources/hyts_security.jar b/support/src/test/java/tests/resources/hyts_security.jar
new file mode 100644
index 0000000..abef675
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_security.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/hyts_signed.jar b/support/src/test/java/tests/resources/hyts_signed.jar
new file mode 100644
index 0000000..8ea8489
--- /dev/null
+++ b/support/src/test/java/tests/resources/hyts_signed.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/manifest/hyts_MANIFEST.MF b/support/src/test/java/tests/resources/manifest/hyts_MANIFEST.MF
new file mode 100644
index 0000000..2402bca
--- /dev/null
+++ b/support/src/test/java/tests/resources/manifest/hyts_MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-Name: ClientSupport
+Bundle-Description: Provides SessionService, AuthenticationService. Extends RegistryService.
+Bundle-Activator: com.ibm.ive.eccomm.client.support.ClientSupportActivator
+Import-Package: com.ibm.ive.eccomm.client.services.log,
+ com.ibm.ive.eccomm.client.services.registry,
+ com.ibm.ive.eccomm.service.registry; specification-version=1.0.0,
+ com.ibm.ive.eccomm.service.session; specification-version=1.0.0,
+ com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,
+ org.osgi.framework; specification-version=1.0.0,
+ org.osgi.service.log; specification-version=1.0.0,
+ com.ibm.ive.eccomm.flash; specification-version=1.2.0,
+ com.ibm.ive.eccomm.client.xml,
+ com.ibm.ive.eccomm.client.http.common,
+ com.ibm.ive.eccomm.client.http.client
+Import-Service: org.osgi.service.log.LogReaderService
+ org.osgi.service.log.LogService,
+ com.ibm.ive.eccomm.service.registry.RegistryService
+Export-Package: com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,
+ com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,
+ com.ibm.ive.eccomm.common; specification-version=1.0.0,
+ com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0
+Export-Service: com.ibm.ive.eccomm.service.authentication.AuthenticationService,
+ com.ibm.ive.eccomm.service.session.SessionService
+Bundle-Vendor: IBM
+Bundle-Version: 1.2.0
diff --git a/support/src/test/java/tests/resources/morestuff/hyts_patch.jar b/support/src/test/java/tests/resources/morestuff/hyts_patch.jar
new file mode 100644
index 0000000..f3c51d0
--- /dev/null
+++ b/support/src/test/java/tests/resources/morestuff/hyts_patch.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/morestuff/hyts_patch2.jar b/support/src/test/java/tests/resources/morestuff/hyts_patch2.jar
new file mode 100644
index 0000000..c26f9e7
--- /dev/null
+++ b/support/src/test/java/tests/resources/morestuff/hyts_patch2.jar
Binary files differ
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en.properties b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en.properties
new file mode 100644
index 0000000..40b8caf
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en.properties
@@ -0,0 +1,2 @@
+property=en_resource
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US.java b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US.java
new file mode 100644
index 0000000..1913879
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.norootresources;
+
+public class hyts_resource_en_US extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent3", "enUSValue3" },
+ { "subParent4", "enUSValue4" },
+ { "subChild1", "enUSChildValue1" },
+ { "subChild2", "enUSChildValue2" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US.properties b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US.properties
new file mode 100644
index 0000000..06c99f6
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US.properties
@@ -0,0 +1,2 @@
+property=en_US_resource
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US_VAR.java b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US_VAR.java
new file mode 100644
index 0000000..1c75ec8
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_en_US_VAR.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.norootresources;
+
+public class hyts_resource_en_US_VAR extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent4", "enUSVARValue4" },
+ { "subChild1", "enUSVARChildValue1" },
+ { "subChild2", "enUSVARChildValue2" },
+ { "subChild3", "enUSVARChildValue3" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr.java b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr.java
new file mode 100644
index 0000000..d049d7b
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.norootresources;
+
+public class hyts_resource_fr extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent2", "frValue2" },
+ { "subParent3", "frValue3" }, { "subParent4", "frValue4" },
+ { "subChild1", "frChildValue1" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr.properties b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr.properties
new file mode 100644
index 0000000..447f06c
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr.properties
@@ -0,0 +1,3 @@
+property=fr_resource
+propertyInFR=valueInFR
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR.java b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR.java
new file mode 100644
index 0000000..ae11beb
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.norootresources;
+
+public class hyts_resource_fr_FR extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent3", "frFRValue3" },
+ { "subParent4", "frFRValue4" },
+ { "subChild1", "frFRChildValue1" },
+ { "subChild2", "frFRChildValue2" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR.properties b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR.properties
new file mode 100644
index 0000000..0ac2c73
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR.properties
@@ -0,0 +1,3 @@
+property=fr_FR_resource
+propertyInFRFR=valueInFRFR
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR_VAR.java b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR_VAR.java
new file mode 100644
index 0000000..958c5ff
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR_VAR.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+package tests.resources.subfolder.tests.norootresources;
+
+public class hyts_resource_fr_FR_VAR extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent4", "frFRVARValue4" },
+ { "subChild1", "frFRVARChildValue1" },
+ { "subChild2", "frFRVARChildValue2" },
+ { "subChild3", "frFRVARChildValue3" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR_VAR.properties b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR_VAR.properties
new file mode 100644
index 0000000..dd76478
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/norootresources/hyts_resource_fr_FR_VAR.properties
@@ -0,0 +1,2 @@
+property=fr_FR_VAR_resource
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource.java b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource.java
new file mode 100644
index 0000000..afa3e6e
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.resources;
+
+public class hyts_resource extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent1", "subParentValue1" },
+ { "subParent2", "subParentValue2" },
+ { "subParent3", "subParentValue3" },
+ { "subParent4", "subParentValue4" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource.properties b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource.properties
new file mode 100644
index 0000000..eae054e
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource.properties
@@ -0,0 +1,3 @@
+property=resource
+propertyInURLParent=valueInURLParent
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en.properties b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en.properties
new file mode 100644
index 0000000..40b8caf
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en.properties
@@ -0,0 +1,2 @@
+property=en_resource
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US.java b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US.java
new file mode 100644
index 0000000..16c6e08
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.resources;
+
+public class hyts_resource_en_US extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent3", "enUSValue3" },
+ { "subParent4", "enUSValue4" },
+ { "subChild1", "enUSChildValue1" },
+ { "subChild2", "enUSChildValue2" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US.properties b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US.properties
new file mode 100644
index 0000000..06c99f6
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US.properties
@@ -0,0 +1,2 @@
+property=en_US_resource
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US_VAR.java b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US_VAR.java
new file mode 100644
index 0000000..aba4675
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_en_US_VAR.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.resources;
+
+public class hyts_resource_en_US_VAR extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent4", "enUSVARValue4" },
+ { "subChild1", "enUSVARChildValue1" },
+ { "subChild2", "enUSVARChildValue2" },
+ { "subChild3", "enUSVARChildValue3" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr.java b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr.java
new file mode 100644
index 0000000..adac070
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.resources;
+
+public class hyts_resource_fr extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent2", "frValue2" },
+ { "subParent3", "frValue3" }, { "subParent4", "frValue4" },
+ { "subChild1", "frChildValue1" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr.properties b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr.properties
new file mode 100644
index 0000000..447f06c
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr.properties
@@ -0,0 +1,3 @@
+property=fr_resource
+propertyInFR=valueInFR
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR.java b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR.java
new file mode 100644
index 0000000..001727f
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+package tests.resources.subfolder.tests.resources;
+
+import java.util.Set;
+
+public class hyts_resource_fr_FR extends java.util.ListResourceBundle {
+ @Override
+ public Set<String> handleKeySet() {
+ return super.handleKeySet();
+ }
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent3", "frFRValue3" },
+ { "subParent4", "frFRValue4" },
+ { "subChild1", "frFRChildValue1" },
+ { "subChild2", "frFRChildValue2" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR.properties b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR.properties
new file mode 100644
index 0000000..0ac2c73
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR.properties
@@ -0,0 +1,3 @@
+property=fr_FR_resource
+propertyInFRFR=valueInFRFR
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR_VAR.java b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR_VAR.java
new file mode 100644
index 0000000..5d48aa3
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR_VAR.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+package tests.resources.subfolder.tests.resources;
+
+public class hyts_resource_fr_FR_VAR extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "subParent4", "frFRVARValue4" },
+ { "subChild1", "frFRVARChildValue1" },
+ { "subChild2", "frFRVARChildValue2" },
+ { "subChild3", "frFRVARChildValue3" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR_VAR.properties b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR_VAR.properties
new file mode 100644
index 0000000..dd76478
--- /dev/null
+++ b/support/src/test/java/tests/resources/subfolder/tests/resources/hyts_resource_fr_FR_VAR.properties
@@ -0,0 +1,2 @@
+property=fr_FR_VAR_resource
+
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Streams.java b/support/src/test/java/tests/support/Streams.java
new file mode 100644
index 0000000..566ad54
--- /dev/null
+++ b/support/src/test/java/tests/support/Streams.java
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+
+/**
+ * Utility methods for working with byte and character streams.
+ */
+public class Streams {
+ private Streams() {}
+
+ /**
+ * Drains the stream into a byte array and returns the result.
+ */
+ public static byte[] streamToBytes(InputStream source) throws IOException {
+ byte[] buffer = new byte[1024];
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int count;
+ while ((count = source.read(buffer)) != -1) {
+ out.write(buffer, 0, count);
+ }
+ return out.toByteArray();
+ }
+
+ /**
+ * Drains the stream into a string and returns the result.
+ */
+ public static String streamToString(Reader fileReader) throws IOException {
+ char[] buffer = new char[1024];
+ StringWriter out = new StringWriter();
+ int count;
+ while ((count = fileReader.read(buffer)) != -1) {
+ out.write(buffer, 0, count);
+ }
+ return out.toString();
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_AvailTest.java b/support/src/test/java/tests/support/Support_AvailTest.java
new file mode 100644
index 0000000..98b5ae9
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_AvailTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class Support_AvailTest {
+
+ public static void main(String[] args) {
+ // This test is for:
+
+ // This program accepts from stdin a
+ // string of the form '<int1> <int2> <data>'
+ // where data is some bytes, <int1> is the length of the whole string
+ // and <int2> is the length in bytes of <data> (all bytes until the end
+ // of
+ // the input)
+
+ // If the string is formatted correctly, and the available method works
+ // the string "true" will be sent to stdout, otherwise "false"
+ String output = "true";
+ try {
+ FileInputStream myin = new FileInputStream(FileDescriptor.in);
+ StringBuffer input = new StringBuffer("");
+
+ try {
+ Thread.sleep(500);
+ } catch (Exception sleepException) {
+ }
+
+ int real = myin.available();
+ int expected;
+ int c = 0;
+ while (true) {
+ c = myin.read();
+ if (c == ' ' || c == -1) {
+ break;
+ }
+ input.append((char) c);
+ }
+ expected = Integer.parseInt(input.toString());
+ // Verify correct value at start of read
+ if (real != expected) {
+ output = "Failed avail test1 - " + real + "!=" + expected;
+ }
+
+ c = 0;
+ input = new StringBuffer("");
+ while (true) {
+ c = myin.read();
+ if (c == ' ' || c == -1) {
+ break;
+ }
+ input.append((char) c);
+ }
+ expected = Integer.parseInt(input.toString());
+ real = myin.available();
+ // Verify value at middle of reading
+ // This test doesn't work on Windows, at present
+ // if(real != expected) output = "Failed avail test2 - " + real +
+ // "!=" + expected;
+
+ // Verify value at end of reading
+ // loop to EOF, then check if available = 0
+ // replace this:
+ for (int i = 0; i < 5; i++) {
+ myin.read();
+ // with:
+ // while(myin.read() != -1);
+ }
+
+ // The current for loop reads exactly to the end
+ // of the data, but is dependent on knowing the length of the data
+ // sent to it, which isn't nice
+
+ expected = 0;
+ real = myin.available();
+ if (real != 0) {
+ output = "Failed avail test3 - " + real + "!=" + expected;
+ }
+
+ } catch (IOException e) {
+ output = "IOException during available() testing";
+ }
+
+ try {
+ FileOutputStream myout = new FileOutputStream(FileDescriptor.out);
+ myout.write(output.getBytes());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_CollectionTest.java b/support/src/test/java/tests/support/Support_CollectionTest.java
new file mode 100644
index 0000000..44faa94
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_CollectionTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.util.Collection;
+import java.util.TreeSet;
+
+/**
+ * @tests java.util.Collection
+ */
+public class Support_CollectionTest extends junit.framework.TestCase {
+
+ Collection<Integer> col; // must contain the Integers 0 to 99
+
+ public Support_CollectionTest(String p1) {
+ super(p1);
+ }
+
+ public Support_CollectionTest(String p1, Collection<Integer> c) {
+ super(p1);
+ col = c;
+ }
+
+ @Override
+ public void runTest() {
+ new Support_UnmodifiableCollectionTest("", col).runTest();
+
+ // setup
+ Collection<Integer> myCollection = new TreeSet<Integer>();
+ myCollection.add(new Integer(101));
+ myCollection.add(new Integer(102));
+ myCollection.add(new Integer(103));
+
+ // add
+ assertTrue("CollectionTest - a) add did not work", col.add(new Integer(
+ 101)));
+ assertTrue("CollectionTest - b) add did not work", col
+ .contains(new Integer(101)));
+
+ // remove
+ assertTrue("CollectionTest - a) remove did not work", col
+ .remove(new Integer(101)));
+ assertTrue("CollectionTest - b) remove did not work", !col
+ .contains(new Integer(101)));
+
+ // addAll
+ assertTrue("CollectionTest - a) addAll failed", col
+ .addAll(myCollection));
+ assertTrue("CollectionTest - b) addAll failed", col
+ .containsAll(myCollection));
+
+ // containsAll
+ assertTrue("CollectionTest - a) containsAll failed", col
+ .containsAll(myCollection));
+ col.remove(new Integer(101));
+ assertTrue("CollectionTest - b) containsAll failed", !col
+ .containsAll(myCollection));
+
+ // removeAll
+ assertTrue("CollectionTest - a) removeAll failed", col
+ .removeAll(myCollection));
+ assertTrue("CollectionTest - b) removeAll failed", !col
+ .removeAll(myCollection)); // should not change the colletion
+ // the 2nd time around
+ assertTrue("CollectionTest - c) removeAll failed", !col
+ .contains(new Integer(102)));
+ assertTrue("CollectionTest - d) removeAll failed", !col
+ .contains(new Integer(103)));
+
+ // retianAll
+ col.addAll(myCollection);
+ assertTrue("CollectionTest - a) retainAll failed", col
+ .retainAll(myCollection));
+ assertTrue("CollectionTest - b) retainAll failed", !col
+ .retainAll(myCollection)); // should not change the colletion
+ // the 2nd time around
+ assertTrue("CollectionTest - c) retainAll failed", col
+ .containsAll(myCollection));
+ assertTrue("CollectionTest - d) retainAll failed", !col
+ .contains(new Integer(0)));
+ assertTrue("CollectionTest - e) retainAll failed", !col
+ .contains(new Integer(50)));
+
+ // clear
+ col.clear();
+ assertTrue("CollectionTest - a) clear failed", col.isEmpty());
+ assertTrue("CollectionTest - b) clear failed", !col
+ .contains(new Integer(101)));
+
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_Configuration.java b/support/src/test/java/tests/support/Support_Configuration.java
new file mode 100644
index 0000000..027486a
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Configuration.java
@@ -0,0 +1,475 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Hashtable;
+
+/**
+ * This class is responsible for providing the dynamic names and addresses for
+ * the java.net classes. There are two directories which need to be placed on an
+ * ftp server and an http server which should accompany this source. The
+ * ftp-files have to be placed on an ftp server and have to be the root of a
+ * user jcltest with password jclpass. The testres files must be available on an
+ * HTTP server and the name and location can be configured below.
+ */
+public class Support_Configuration {
+
+ public static String DomainAddress = "apache.org";
+
+ public static String WebName = "jcltest.";
+
+ public static final String HomeAddress;
+
+ public static String TestResourcesDir = "/testres231";
+
+ public static final String TestResources;
+
+ public static String HomeAddressResponse = "HTTP/1.1 200 OK";
+
+ public static String HomeAddressSoftware = "Jetty(6.0.x)";
+
+ public static String ProxyServerTestHost = "jcltest.apache.org";
+
+ public static String SocksServerTestHost = "jcltest.apache.org";
+
+ public static int SocksServerTestPort = 1080;
+
+ // Need an IP address that does not resolve to a host name
+ public static String UnresolvedIP = "192.168.99.99";
+
+ // the bytes for an address which represents an address which is not
+ // one of the addresses for any of our machines on which tests will run
+ // it is used to verify we get the expected error when we try to bind
+ // to an address that is not one of the machines local addresses
+ public static byte nonLocalAddressBytes[] = { 1, 0, 0, 0 };
+
+ public static String InetTestAddress = "localhost";
+
+ public static String InetTestIP = "127.0.0.1";
+
+ public static String InetTestAddress2 = "localhost";
+
+ public static String InetTestIP2 = "127.0.0.1";
+
+ public static byte[] InetTestCaddr = { 9, 26, -56, -111 };
+
+ public static int InetTestHashcode = 2130706433;
+
+ public static final String HomeAddress6 = "jcltest6.apache.org";
+
+ public static String IPv6GlobalAddressJcl4 = "FE80:0000:0000:0000:020D:60FF:FE0F:A776%4"; // this
+
+ public static String ProxyServerTestHostIPv6 = "jcltest6.apache.org";
+
+ public static String InetTestIP6 = "fe80::20d:60ff:fe24:7410";
+
+ public static String InetTestIP6LO = "::1";
+
+ // ip address that resolves to a host that is not present on the local
+ // network
+ // this allows us to check the timeouts for connect
+ public static String ResolvedNotExistingHost = "9.26.194.72";
+
+ /**
+ * You can compute the hash code with the following code: try { String name =
+ * "whatever.xxx.com";
+ * System.out.println(InetAddress.getByName(name).hashCode()); } catch
+ * (UnknownHostException e) {}
+ */
+
+ /**
+ * An address that resolves to more than one IP address so that the
+ * getAllByName test has something to test.
+ */
+ public static String SpecialInetTestAddress = "jcltestmultiple.apache.org";
+
+ public static int SpecialInetTestAddressNumber = 4;
+
+ /**
+ * InetAlias1 and InetAlias2 must be different host names that resolve to
+ * the same IP address.
+ */
+ public static String InetAlias1 = "alias1.apache.org";
+
+ public static String InetAlias2 = "alias2.apache.org";
+
+ public static String FTPTestAddress = "jcltest:jclpass@localhost";
+
+ public static String URLConnectionLastModifiedString = "Mon, 14 Jun 1999 21:06:22 GMT";
+
+ public static long URLConnectionLastModified = 929394382000L;
+
+ public static long URLConnectionDate = 929106872000L;
+
+ public static boolean RunCommTests = false;
+
+ public static String Port1 = "COM1";
+
+ public static String Port2 = "COM2";
+
+ static Hashtable<String, String> props = null;
+ static {
+ loadProperties();
+ HomeAddress = WebName + DomainAddress;
+ TestResources = HomeAddress + TestResourcesDir;
+ }
+
+ static void loadProperties() {
+ InputStream in = null;
+ Hashtable<String, String> props = new Hashtable<String, String>();
+
+ String iniName = System.getProperty("test.ini.file", "JCLAuto.ini");
+ if (System.getProperty("test.comm") != null) {
+ RunCommTests = true;
+ }
+
+ try {
+ in = new FileInputStream(iniName);
+ } catch (IOException e) {
+ } catch (Exception e) {
+ System.out.println("SupportConfiguration.loadProperties()");
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ if (in == null) {
+ try {
+ Class<?> cl = Class
+ .forName("com.ibm.support.Support_Configuration");
+ in = cl.getResourceAsStream(iniName);
+ } catch (ClassNotFoundException e) {
+ }
+ }
+ try {
+ if (in != null) {
+ load(in, props);
+ }
+ } catch (IOException e) {
+ }
+ if (props.size() == 0) {
+ return;
+ }
+ String value;
+
+ value = props.get("DomainAddress");
+ if (value != null) {
+ DomainAddress = value;
+ }
+
+ value = props.get("WebName");
+ if (value != null) {
+ WebName = value;
+ }
+
+ value = props.get("TestResourcesDir");
+ if (value != null) {
+ TestResourcesDir = value;
+ }
+ value = props.get("HomeAddressResponse");
+ if (value != null) {
+ HomeAddressResponse = value;
+ }
+
+ value = props.get("HomeAddressSoftware");
+ if (value != null) {
+ HomeAddressSoftware = value;
+ }
+
+ value = props.get("ProxyServerTestHost");
+ if (value != null) {
+ ProxyServerTestHost = value;
+ }
+
+ value = props.get("SocksServerTestHost");
+ if (value != null) {
+ SocksServerTestHost = value;
+ }
+
+ value = props.get("SocksServerTestPort");
+ if (value != null) {
+ SocksServerTestPort = Integer.parseInt(value);
+ }
+
+ value = props.get("UnresolvedIP");
+ if (value != null) {
+ UnresolvedIP = value;
+ }
+
+ value = props.get("InetTestAddress");
+ if (value != null) {
+ InetTestAddress = value;
+ }
+
+ value = props.get("InetTestIP");
+ if (value != null) {
+ InetTestIP = value;
+ byte[] addr = new byte[4];
+ int last = 0;
+ try {
+ for (int i = 0; i < 3; i++) {
+ int dot = InetTestIP.indexOf('.', last);
+ addr[i] = (byte) Integer.parseInt(InetTestIP.substring(
+ last, dot));
+ last = dot + 1;
+ }
+ addr[3] = (byte) Integer.parseInt(InetTestIP.substring(last));
+ InetTestCaddr = addr;
+ } catch (RuntimeException e) {
+ System.out.println("Error parsing InetTestIP (" + InetTestIP
+ + ")");
+ System.out.println(e);
+ }
+ }
+
+ value = props.get("NonLocalAddressBytes");
+ if (value != null) {
+ String nonLocalAddressBytesString = value;
+ byte[] addr = new byte[4];
+ int last = 0;
+ try {
+ for (int i = 0; i < 3; i++) {
+ int dot = nonLocalAddressBytesString.indexOf('.', last);
+ addr[i] = (byte) Integer
+ .parseInt(nonLocalAddressBytesString.substring(
+ last, dot));
+ last = dot + 1;
+ }
+ addr[3] = (byte) Integer.parseInt(nonLocalAddressBytesString
+ .substring(last));
+ nonLocalAddressBytes = addr;
+ } catch (RuntimeException e) {
+ System.out.println("Error parsing NonLocalAddressBytes ("
+ + nonLocalAddressBytesString + ")");
+ System.out.println(e);
+ }
+ }
+
+ value = props.get("InetTestAddress2");
+ if (value != null) {
+ InetTestAddress2 = value;
+ }
+
+ value = props.get("InetTestIP2");
+ if (value != null) {
+ InetTestIP2 = value;
+ }
+
+ value = props.get("InetTestHashcode");
+ if (value != null) {
+ InetTestHashcode = Integer.parseInt(value);
+ }
+
+ value = props.get("SpecialInetTestAddress");
+ if (value != null) {
+ SpecialInetTestAddress = value;
+ }
+
+ value = props.get("SpecialInetTestAddressNumber");
+ if (value != null) {
+ SpecialInetTestAddressNumber = Integer.parseInt(value);
+ }
+
+ value = props.get("FTPTestAddress");
+ if (value != null) {
+ FTPTestAddress = value;
+ }
+
+ value = props.get("URLConnectionLastModifiedString");
+ if (value != null) {
+ URLConnectionLastModifiedString = value;
+ }
+
+ value = props.get("URLConnectionLastModified");
+ if (value != null) {
+ URLConnectionLastModified = Long.parseLong(value);
+ }
+
+ value = props.get("URLConnectionDate");
+ if (value != null) {
+ URLConnectionDate = Long.parseLong(value);
+ }
+
+ value = props.get("Port1");
+ if (value != null) {
+ Port1 = value;
+ }
+
+ value = props.get("Port2");
+ if (value != null) {
+ Port2 = value;
+ }
+
+ value = props.get("InetTestIP6");
+ if (value != null) {
+ InetTestIP6 = value;
+ }
+
+ value = props.get("InetTestIP6LO");
+ if (value != null) {
+ InetTestIP6LO = value;
+ }
+
+ value = props.get("ProxyServerTestHostIPv6");
+ if (value != null) {
+ ProxyServerTestHostIPv6 = value;
+ }
+
+ value = props.get("ResolvedNotExistingHost");
+ if (value != null) {
+ ResolvedNotExistingHost = value;
+ }
+
+ value = props.get("InetAlias1");
+ if (value != null) {
+ InetAlias1 = value;
+ }
+
+ value = props.get("InetAlias2");
+ if (value != null) {
+ InetAlias2 = value;
+ }
+
+ value = props.get("IPv6GlobalAddressJcl4");
+ if (value != null) {
+ IPv6GlobalAddressJcl4 = value;
+ }
+
+ }
+
+ static void load(InputStream in, Hashtable<String, String> result) throws IOException {
+ int NONE = 0, SLASH = 1, UNICODE = 2, CONTINUE = 3, DONE = 4, IGNORE = 5;
+ int mode = NONE, unicode = 0, count = 0, nextChar;
+ StringBuffer key = new StringBuffer(), value = new StringBuffer(), buffer = key;
+ boolean firstChar = true;
+
+ while ((nextChar = in.read()) != -1) {
+ if (mode == UNICODE) {
+ int digit = Character.digit((char) nextChar, 16);
+ if (digit >= 0) {
+ unicode = (unicode << 4) + digit;
+ if (++count < 4) {
+ continue;
+ }
+ }
+ mode = NONE;
+ buffer.append((char) unicode);
+ if (nextChar != '\n') {
+ continue;
+ }
+ }
+ if (mode == SLASH) {
+ mode = NONE;
+ switch (nextChar) {
+ case '\r':
+ mode = CONTINUE; // Look for a following \n
+ continue;
+ case '\n':
+ mode = IGNORE; // Ignore whitespace on the next line
+ continue;
+ case 'b':
+ nextChar = '\b';
+ break;
+ case 'f':
+ nextChar = '\f';
+ break;
+ case 'n':
+ nextChar = '\n';
+ break;
+ case 'r':
+ nextChar = '\r';
+ break;
+ case 't':
+ nextChar = '\t';
+ break;
+ case 'u':
+ mode = UNICODE;
+ unicode = count = 0;
+ continue;
+ }
+ } else {
+ switch (nextChar) {
+ case '#':
+ case '!':
+ if (firstChar) {
+ while ((nextChar = in.read()) != -1) {
+ if (nextChar == '\r' || nextChar == '\n') {
+ break;
+ }
+ }
+ continue;
+ }
+ break;
+ case '\n':
+ if (mode == CONTINUE) { // Part of a \r\n sequence
+ mode = IGNORE; // Ignore whitespace on the next line
+ continue;
+ }
+ // fall into the next case
+ case '\r':
+ mode = NONE;
+ firstChar = true;
+ if (key.length() > 0 || buffer == value) {
+ result.put(key.toString(), value.toString());
+ }
+ key.setLength(0);
+ value.setLength(0);
+ buffer = key;
+ continue;
+ case '\\':
+ mode = SLASH;
+ continue;
+ case ':':
+ case '=':
+ if (buffer == key) {
+ buffer = value;
+ continue;
+ }
+ break;
+ }
+ char c = (char) nextChar;
+ if ((c >= 0x1c && c <= 0x20) || (c >= 0x9 && c <= 0xd)) {
+ if (mode == CONTINUE) {
+ mode = IGNORE;
+ }
+ if (buffer.length() == 0 || mode == IGNORE) {
+ continue;
+ }
+ if (buffer == key) {
+ mode = DONE;
+ continue;
+ }
+ }
+ if (mode == IGNORE || mode == CONTINUE) {
+ mode = NONE;
+ }
+ }
+ firstChar = false;
+ if (mode == DONE) {
+ buffer = value;
+ mode = NONE;
+ }
+ buffer.append((char) nextChar);
+ }
+ if (key.length() > 0 || buffer == value) {
+ result.put(key.toString(), value.toString());
+ }
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_DeleteOnExitTest.java b/support/src/test/java/tests/support/Support_DeleteOnExitTest.java
new file mode 100644
index 0000000..d3532a3
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_DeleteOnExitTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.File;
+
+public class Support_DeleteOnExitTest {
+
+ public static void main(java.lang.String[] args) {
+ for (int i = 0; i < args.length; i++) {
+ File f1 = new File(args[i]);
+ f1.deleteOnExit();
+ }
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java b/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java
new file mode 100644
index 0000000..2f49afd
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.KeyStoreSpi;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.Date;
+import java.util.Enumeration;
+
+/**
+ * Empty implementation used to enable unit tests to run.
+ */
+public class Support_DummyPKCS12Keystore extends KeyStoreSpi {
+
+ public Support_DummyPKCS12Keystore() {
+ super();
+ }
+
+ @Override
+ public Key engineGetKey(String arg0, char[] arg1)
+ throws NoSuchAlgorithmException, UnrecoverableKeyException {
+ return null;
+ }
+
+ @Override
+ public Certificate[] engineGetCertificateChain(String arg0) {
+ return null;
+ }
+
+ @Override
+ public Certificate engineGetCertificate(String arg0) {
+ return null;
+ }
+
+ @Override
+ public Date engineGetCreationDate(String arg0) {
+ return null;
+ }
+
+ @Override
+ public void engineSetKeyEntry(String arg0, Key arg1, char[] arg2,
+ Certificate[] arg3) throws KeyStoreException {
+ }
+
+ @Override
+ public void engineSetKeyEntry(String arg0, byte[] arg1, Certificate[] arg2)
+ throws KeyStoreException {
+ }
+
+ @Override
+ public void engineSetCertificateEntry(String arg0, Certificate arg1)
+ throws KeyStoreException {
+ }
+
+ @Override
+ public void engineDeleteEntry(String arg0) throws KeyStoreException {
+ }
+
+ @Override
+ public Enumeration<String> engineAliases() {
+ return null;
+ }
+
+ @Override
+ public boolean engineContainsAlias(String arg0) {
+ return false;
+ }
+
+ @Override
+ public int engineSize() {
+ return 0;
+ }
+
+ @Override
+ public boolean engineIsKeyEntry(String arg0) {
+ return false;
+ }
+
+ @Override
+ public boolean engineIsCertificateEntry(String arg0) {
+ return false;
+ }
+
+ @Override
+ public String engineGetCertificateAlias(Certificate arg0) {
+ return null;
+ }
+
+ @Override
+ public void engineStore(OutputStream arg0, char[] arg1) throws IOException,
+ NoSuchAlgorithmException, CertificateException {
+ }
+
+ @Override
+ public void engineLoad(InputStream arg0, char[] arg1) throws IOException,
+ NoSuchAlgorithmException, CertificateException {
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_Exec.java b/support/src/test/java/tests/support/Support_Exec.java
new file mode 100644
index 0000000..2e40ffd
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Exec.java
@@ -0,0 +1,288 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import junit.framework.TestCase;
+
+public class Support_Exec extends TestCase {
+
+ /**
+ * Exec java returns the exitCode, and stdOut and stdErr as strings
+ */
+ public static Object[] runJava(List<String> args, String[] envp,
+ boolean displayOutput)
+ throws IOException, InterruptedException {
+ String executable = System.getProperty("java.home");
+ if (!executable.endsWith(File.separator)) {
+ executable += File.separator;
+ }
+ executable += "bin" + File.separator + "java";
+
+ // parse hy.test.vmargs if was given
+ String testVMArgs = System.getProperty("hy.test.vmargs");
+ if (testVMArgs != null) {
+ StringTokenizer st = new StringTokenizer(testVMArgs, " ");
+ int i = 0; // add at the beginning but maintain order
+ while (st.hasMoreTokens()) {
+ args.add(i++, st.nextToken());
+ }
+ }
+
+ return run(executable, args, envp, displayOutput);
+ }
+
+ /**
+ * Exec command returns the exitCode, and stdOut and stdErr as strings
+ */
+ public static Object[] run(String command, List<String> args, String[] envp,
+ boolean displayOutput)
+ throws IOException, InterruptedException {
+ Object[] arr = exec(command, args, envp, displayOutput);
+
+ Process proc = (Process) arr[0];
+ StringBuilder output = new StringBuilder();
+ InputStream in = proc.getInputStream();
+ int result;
+ byte[] bytes = new byte[1024];
+
+ while ((result = in.read(bytes)) != -1) {
+ output.append(new String(bytes, 0, result));
+ if (displayOutput) {
+ System.out.write(bytes, 0, result);
+ }
+ }
+
+ in.close();
+ proc.waitFor();
+ int exitCode = proc.exitValue();
+ proc.destroy();
+ return new Object[] {
+ Integer.valueOf(exitCode),
+ output.toString(),
+ ((StringBuilder)arr[1]).toString()
+ };
+ }
+
+ /**
+ * This function returns the output of the process as a string
+ */
+ public static String execJava(String[] args, String[] classpath,
+ boolean displayOutput)
+ throws IOException, InterruptedException {
+ Object[] arr =
+ execJavaCommon(args, classpath, null, displayOutput, true);
+
+ return getProcessOutput(arr, displayOutput, true);
+ }
+
+ /**
+ * This function returns the output of the process as a string
+ */
+ public static String execJava(String[] args, String[] classpath,
+ String[] envp, boolean displayOutput)
+ throws IOException, InterruptedException {
+ Object[] arr =
+ execJavaCommon(args, classpath, envp, displayOutput, false);
+
+ return getProcessOutput(arr, displayOutput, true);
+ }
+
+ private static String getProcessOutput(Object[] arr, boolean displayOutput,
+ boolean checkStderr)
+ throws IOException, InterruptedException {
+ Process proc = (Process) arr[0];
+ StringBuilder output = new StringBuilder();
+ InputStream in = proc.getInputStream();
+ int result;
+ byte[] bytes = new byte[1024];
+
+ while ((result = in.read(bytes)) != -1) {
+ output.append(new String(bytes, 0, result));
+ if (displayOutput) {
+ System.out.write(bytes, 0, result);
+ }
+ }
+
+ in.close();
+ proc.waitFor();
+ if (checkStderr) {
+ checkStderr(arr);
+ }
+ proc.destroy();
+
+ return output.toString();
+ }
+
+ public static void checkStderr(Object[] execArgs) {
+ StringBuilder errBuf = (StringBuilder) execArgs[1];
+
+ synchronized (errBuf) {
+ if (errBuf.length() > 0) {
+ fail(errBuf.toString());
+ }
+ }
+ }
+
+ public static Object[] execJava2(String[] args, String[] classpath,
+ boolean displayOutput)
+ throws IOException, InterruptedException {
+ return execJavaCommon(args, classpath, null, displayOutput, true);
+ }
+
+ private static Object[] execJavaCommon(String[] args, String[] classpath,
+ String[] envp,
+ boolean displayOutput,
+ boolean appendToSystemClassPath)
+ throws IOException, InterruptedException {
+ // this function returns the resulting process from the exec
+ ArrayList<String> execArgs = null;
+ StringBuilder classPathString = new StringBuilder();
+ StringBuilder command;
+
+ execArgs = new ArrayList<String>(3 + args.length);
+
+ // construct the name of executable file
+ String executable = System.getProperty("java.home");
+ if (!executable.endsWith(File.separator)) {
+ executable += File.separator;
+ }
+ executable += "bin" + File.separator + "java";
+
+ // add classpath string
+ if (classpath != null) {
+ for (String element : classpath) {
+ classPathString.append(File.pathSeparator);
+ classPathString.append(element);
+ }
+ }
+ if (appendToSystemClassPath) {
+ execArgs.add("-cp");
+ execArgs.add(System.getProperty("java.class.path") +
+ classPathString);
+ } else {
+ if (classpath != null) {
+ execArgs.add("-cp");
+ execArgs.add(classPathString.toString());
+ }
+ }
+
+ // parse hy.test.vmargs if was given
+ String testVMArgs = System.getProperty("hy.test.vmargs");
+ if (testVMArgs != null) {
+ StringTokenizer st = new StringTokenizer(testVMArgs, " ");
+
+ while (st.hasMoreTokens()) {
+ execArgs.add(st.nextToken());
+ }
+ }
+
+ // add custom args given as parameter
+ for (String arg : args) {
+ execArgs.add(arg);
+ }
+ return exec(executable, execArgs, envp, displayOutput);
+ }
+
+ private static Object[] exec(String command, List<String> args,
+ String[] envp,
+ boolean displayOutput)
+ throws IOException, InterruptedException {
+ // this function returns the resulting process from the exec
+ args.add(0, command);
+
+ if (displayOutput) {
+ StringBuilder commandLine;
+ // construct command line string and print it to stdout
+ commandLine = new StringBuilder(args.get(0));
+ for (int i = 1; i < args.size(); i++) {
+ commandLine.append(" ");
+ commandLine.append(args.get(i));
+ }
+ System.out.println("Exec: " + commandLine.toString());
+ System.out.println();
+ }
+
+ // execute java process
+ final Process proc =
+ Runtime.getRuntime().exec(args.toArray(new String[args.size()]),
+ envp);
+
+ final StringBuilder errBuf = new StringBuilder();
+ Thread errThread = new Thread(new Runnable() {
+ public void run() {
+ synchronized (errBuf) {
+ InputStream err;
+ int result;
+ byte[] bytes = new byte[1024];
+
+ synchronized (proc) {
+ proc.notifyAll();
+ }
+
+ err = proc.getErrorStream();
+ try {
+ while ((result = err.read(bytes)) != -1) {
+ System.err.write(bytes, 0, result);
+ errBuf.append(new String(bytes));
+ }
+ err.close();
+ } catch (IOException e) {
+ ByteArrayOutputStream out =
+ new ByteArrayOutputStream();
+ PrintStream printer = new PrintStream(out);
+
+ e.printStackTrace();
+ e.printStackTrace(printer);
+ printer.close();
+ errBuf.append(new String(out.toByteArray()));
+ }
+ }
+ }
+ });
+
+ synchronized (proc) {
+ errThread.start();
+ // wait for errThread to start
+ int count = 0;
+ boolean isFinished = false;
+ while(!isFinished) {
+ try {
+ proc.wait();
+ isFinished = true;
+ } catch (InterruptedException e) {
+ if(++count == 2) {
+ throw e;
+ }
+ }
+ }
+ if(count > 0) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ return new Object[] { proc, errBuf };
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_Field.java b/support/src/test/java/tests/support/Support_Field.java
new file mode 100644
index 0000000..ea5b73f
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Field.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_Field {
+
+ protected Object objectField;
+
+ protected boolean booleanField;
+
+ protected byte byteField;
+
+ protected char charField;
+
+ protected short shortField;
+
+ protected int intField;
+
+ protected long longField;
+
+ protected float floatField;
+
+ protected double doubleField;
+
+ /**
+ *
+ */
+ public Support_Field() {
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Support_GetLocal.java b/support/src/test/java/tests/support/Support_GetLocal.java
new file mode 100644
index 0000000..0e99f78
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_GetLocal.java
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import tests.support.resource.Support_Resources;
+
+public class Support_GetLocal {
+
+ static Hashtable<String, File> cache = new Hashtable<String, File>(20);
+
+ public static File getLocalFile(String url) throws IOException,
+ MalformedURLException {
+ url = Support_Resources.RESOURCE_PACKAGE + url;
+ File temp = cache.get(url);
+ if (temp == null) {
+ InputStream in = Support_GetLocal.class.getResourceAsStream(url);
+ temp = File.createTempFile("hyts_local", ".tmp", null);
+ temp.deleteOnExit();
+ FileOutputStream out = new FileOutputStream(temp);
+ int result;
+ byte[] buf = new byte[4096];
+ while ((result = in.read(buf)) != -1) {
+ out.write(buf, 0, result);
+ }
+ in.close();
+ out.close();
+ cache.put(url, temp);
+ }
+ return temp;
+ }
+
+ public static File getExternalLocalFile(String url) throws IOException,
+ MalformedURLException {
+ File temp = cache.get(url);
+ if (temp == null) {
+ InputStream in = new URL(url).openStream();
+ temp = File.createTempFile("hyts_local", ".tmp", null);
+ temp.deleteOnExit();
+ FileOutputStream out = new FileOutputStream(temp);
+ int result;
+ byte[] buf = new byte[4096];
+ while ((result = in.read(buf)) != -1) {
+ out.write(buf, 0, result);
+ }
+ in.close();
+ out.close();
+ cache.put(url, temp);
+ }
+ return temp;
+ }
+
+ static ByteArrayInputStream getStream(String url) throws IOException,
+ MalformedURLException {
+ InputStream in = new URL(url).openStream();
+ ByteArrayOutputStream out = new ByteArrayOutputStream(256);
+ int result;
+ byte[] buf = new byte[256];
+ while ((result = in.read(buf)) != -1) {
+ out.write(buf, 0, result);
+ }
+ return new ByteArrayInputStream(out.toByteArray());
+ }
+
+ public static File createTempFile(String suffix) throws IOException {
+ return File.createTempFile("hyts_", suffix, null);
+ }
+
+ public static JarURLConnection getJarURLConnection() throws IOException {
+ JarURLConnection con1 = null;
+ File file = getLocalFile("hyts_att.jar");
+ URL fUrl1 = new URL("jar:file:" + file.getPath() + "!/");
+ con1 = (JarURLConnection) fUrl1.openConnection();
+ return con1;
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Support_GetResource.java b/support/src/test/java/tests/support/Support_GetResource.java
new file mode 100644
index 0000000..5fef7a1
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_GetResource.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_GetResource {
+
+ public static String getResourceURL(String resource) {
+ return "http://" + Support_Configuration.TestResources + resource;
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Support_HttpConnector.java b/support/src/test/java/tests/support/Support_HttpConnector.java
new file mode 100644
index 0000000..3903334
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_HttpConnector.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * This interface contains the basic methods necessary to open and use a
+ * connection to an HTTP server.
+ *
+ */
+public interface Support_HttpConnector {
+
+ public void open(String address) throws IOException;
+
+ public void close() throws IOException;
+
+ public InputStream getInputStream() throws IOException;
+
+ public OutputStream getOutputStream() throws IOException;
+
+ public boolean isChunkedOnFlush();
+
+ public void setRequestProperty(String key, String value) throws IOException;
+
+ public String getHeaderField(int index) throws IOException;
+
+ public String getHeaderFieldKey(int index) throws IOException;
+
+}
diff --git a/support/src/test/java/tests/support/Support_HttpServer.java b/support/src/test/java/tests/support/Support_HttpServer.java
new file mode 100644
index 0000000..5dec542
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_HttpServer.java
@@ -0,0 +1,524 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InterruptedIOException;
+import java.io.OutputStream;
+import java.util.Vector;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class Support_HttpServer {
+
+ private static final int timeout = 10000;
+
+ public static final String AUTHTEST = "/authTest";
+
+ public static final String CHUNKEDTEST = "/chunkedTest.html";
+
+ public static final String CONTENTTEST = "/contentTest.html";
+
+ public static final String REDIRECTTEST = "/redirectTest.html";
+
+ public static final String PORTREDIRTEST = "/portredirTest.html";
+
+ public static final String OTHERTEST = "/otherTest.html";
+
+ public static final String POSTTEST = "/postTest.html";
+
+ public static final String HEADERSTEST = "/headersTest.html";
+
+ public static final int OK = 200;
+
+ public static final int MULT_CHOICE = 300;
+
+ public static final int MOVED_PERM = 301;
+
+ public static final int FOUND = 302;
+
+ public static final int SEE_OTHER = 303;
+
+ public static final int NOT_MODIFIED = 304;
+
+ public static final int UNUSED = 306;
+
+ public static final int TEMP_REDIRECT = 307;
+
+ public static final int UNAUTHORIZED = 401;
+
+ public static final int NOT_FOUND = 404;
+
+ private int port;
+
+ private boolean proxy = false;
+
+ private boolean started = false;
+
+ private boolean portRedirectTestEnable = false;
+
+ private volatile Support_ServerSocket serversocket;
+
+ private boolean shuttingDown = false;
+
+ // synchronization
+ private final Object lock = new Object();
+
+ TestCase testcase = null;
+
+ public Support_HttpServer(Support_ServerSocket serversocket, TestCase test) {
+ this.serversocket = serversocket;
+ this.testcase = test;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void startServer(final int port) {
+ if (started) {
+ return;
+ }
+ started = true;
+ this.port = port;
+ Thread serverThread = new Thread(new Runnable() {
+ public void run() {
+ try {
+
+ synchronized (lock) {
+ serversocket.setPort(port);
+ serversocket.setTimeout(timeout);
+ serversocket.open();
+ lock.notifyAll();
+ }
+
+ while (true) {
+ // wait for a connection to be made
+ Support_Socket socket = serversocket.accept();
+ Thread thread = new Thread(new ServerThread(socket));
+ thread.start();
+ }
+ } catch (InterruptedIOException e) {
+ System.out
+ .println("Wait timed out. Test HTTP Server shut down.");
+ started = false;
+ try {
+ if (serversocket != null) {
+ serversocket.close();
+ }
+ } catch (IOException e2) {
+ }
+ } catch (IOException e) {
+ // release the lock so the tests will finish running
+ if (!shuttingDown) {
+ e.printStackTrace();
+ Assert.fail("Test server error on HTTP Server on port "
+ + port + ": " + e);
+ }
+ synchronized (lock) {
+ lock.notifyAll();
+ }
+ } finally {
+ try {
+ if (serversocket != null) {
+ serversocket.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+
+ // start the server and continue
+ synchronized (lock) {
+ serverThread.start();
+
+ // wait for the port to be opened before continuing
+ // to eliminate a race condition between starting the
+ // server and the clients accessing the server
+ try {
+ lock.wait();
+ } catch (InterruptedException e) {
+ System.err.println("Unexpected interrupt 2");
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ public void stopServer() {
+ try {
+ shuttingDown = true;
+ serversocket.close();
+ } catch (IOException e) {
+ }
+ }
+
+ class ServerThread implements Runnable {
+
+ Support_Socket socket;
+
+ ServerThread(Support_Socket s) {
+ socket = s;
+ }
+
+ String readln(InputStream is) throws IOException {
+ boolean lastCr = false;
+ StringBuffer result = new StringBuffer();
+ int c = is.read();
+ if (c < 0) {
+ return null;
+ }
+ while (c != '\n') {
+ if (lastCr) {
+ result.append('\r');
+ lastCr = false;
+ }
+ if (c == '\r') {
+ lastCr = true;
+ } else {
+ result.append((char) c);
+ }
+ c = is.read();
+ if (c < 0) {
+ break;
+ }
+ }
+ return result.toString();
+ }
+
+ void print(OutputStream os, String text) throws IOException {
+ os.write(text.getBytes("ISO8859_1"));
+ }
+
+ public void run() {
+ try {
+ // get the input stream
+
+ // parse the result headers until the first blank line
+ InputStream in = socket.getInputStream();
+ String line;
+ boolean authenticated = false, contentLength = false, chunked = false;
+ int length = -1;
+ String resourceName = "";
+ Vector<String> headers = new Vector<String>();
+ while (((line = readln(in)) != null) && (line.length() > 1)) {
+ headers.addElement(line);
+ String lline = line.toLowerCase();
+ // determine the resource requested in the first line
+ if (lline.startsWith("get") || lline.startsWith("post")) {
+ int start = line.indexOf(' ') + 1;
+ int end = line.indexOf(' ', start);
+ if (start > 0 && end > -1) {
+ resourceName = line.substring(start, end);
+ }
+ }
+ if (lline.startsWith("authorization:")) {
+ authenticated = true;
+ }
+ if (lline.startsWith("content-length")) {
+ if (contentLength) {
+ Assert.fail("Duplicate Content-Length: " + line);
+ }
+ contentLength = true;
+ length = Integer.parseInt(line.substring(line
+ .indexOf(' ') + 1));
+ }
+ if (line.startsWith("transfer-encoding")) {
+ if (chunked) {
+ Assert.fail("Duplicate Transfer-Encoding: "
+ + line);
+ }
+ chunked = true;
+ String encoding = line.substring(line.indexOf(' ') + 1);
+ if ("chunked".equals(encoding)) {
+ Assert.fail("Unknown Transfer-Encoding: "
+ + encoding);
+ }
+ }
+
+ }
+ if (contentLength && chunked) {
+ Assert.fail("Found both Content-Length and Transfer-Encoding");
+ }
+
+ // call the test function based on the requested resource
+ if (resourceName.equals(CHUNKEDTEST)) {
+ chunkedTest();
+ } else if (resourceName.equals(CONTENTTEST)) {
+ contentTest();
+ } else if (resourceName.equals(AUTHTEST)) {
+ authenticateTest(authenticated);
+ } else if (resourceName.startsWith(REDIRECTTEST)) {
+ redirectTest(resourceName);
+ } else if (portRedirectTestEnable
+ && resourceName.equals(PORTREDIRTEST)) {
+ contentTest();
+ } else if (resourceName.equals(OTHERTEST)) {
+ otherTest();
+ } else if (resourceName.equals(HEADERSTEST)) {
+ headersTest(headers);
+ } else if (resourceName.startsWith("http://")
+ && resourceName.indexOf(OTHERTEST) > -1) {
+ // redirection to a proxy passes an absolute URI to the
+ // proxy server
+ otherTest();
+ } else if (resourceName.equals(POSTTEST)) {
+ postTest(length, in);
+ } else {
+ notFound(); // return a not found error
+ }
+
+ in.close();
+ socket.close();
+
+ } catch (IOException e) {
+ System.err.println("Error performing http server test.");
+ e.printStackTrace();
+ }
+
+ }
+
+ private void contentTest() {
+ // send 5 bytes of data, specifying a content-length
+ try {
+ OutputStream os = socket.getOutputStream();
+ print(os, "HTTP/1.1 " + OK + " OK\r\n");
+ print(os, "Content-Length: 5\r\n");
+ print(os, "\r\nABCDE");
+ os.flush();
+ os.close();
+ } catch (IOException e) {
+ System.err.println("Error performing content coding test.");
+ e.printStackTrace();
+ }
+
+ }
+
+ private void chunkedTest() {
+ // send 5 bytes of chunked data
+ try {
+ OutputStream os = socket.getOutputStream();
+ print(os, "HTTP/1.1 " + OK + " OK\r\n");
+ print(os, "Transfer-Encoding: chunked\r\n");
+ print(os, "\r\n");
+ print(os, "5\r\nFGHIJ");
+ print(os, "\r\n0\r\n\r\n");
+ os.flush();
+ os.close();
+ } catch (IOException e) {
+ System.err
+ .println("Error performing chunked transfer coding test.");
+ e.printStackTrace();
+ }
+
+ }
+
+ private void authenticateTest(boolean authenticated) {
+ // send an authentication required response
+ // the client should respond with a new request
+ // that includes authorization credentials
+ try {
+ OutputStream os = socket.getOutputStream();
+
+ // if the user has not sent along credentials, return
+ // unauthorized, which should prompt them to repeat
+ // the request with an authorization header added
+ if (!authenticated) {
+ print(os, "HTTP/1.1 " + UNAUTHORIZED + " Unauthorized\r\n");
+ print(os, "WWW-Authenticate: Basic realm=\"test\"\r\n");
+ } else {
+ print(os, "HTTP/1.1 " + OK + " OK\r\n");
+ }
+
+ print(os, "Content-Length: 5\r\n");
+ print(os, "\r\nKLMNO");
+ os.flush();
+ os.close();
+ } catch (IOException e) {
+ System.err.println("Error performing authentication test.");
+ e.printStackTrace();
+ }
+ }
+
+ private void redirectTest(String test) {
+ // send a redirect response
+
+ // the URL was in the format:
+ // "http://localhost:<port>/redirectTest.html/<3XX level response
+ // code>-<new URL>"
+ // "eg.
+ // http://localhost:8080/redirectTest.html/301-http://www.apache.org"
+ int responseNum = Integer.parseInt(test.substring(
+ test.indexOf('3'), test.indexOf('3') + 3));
+ String location = test.substring(test.lastIndexOf('-') + 1);
+
+ try {
+ OutputStream os = socket.getOutputStream();
+ print(os, "HTTP/1.1 " + responseNum + " Irrelevant\r\n");
+ print(os, "Location: " + location + "\r\n");
+ print(os, "Content-Length: 5\r\n");
+ print(os, "\r\nPQRST");
+ os.flush();
+ os.close();
+
+ } catch (IOException e) {
+ System.err.println("Error performing redirection test.");
+ e.printStackTrace();
+ }
+
+ }
+
+ private void otherTest() {
+ // send 5 bytes of content coded data
+ try {
+ OutputStream os = socket.getOutputStream();
+ if (!proxy) {
+ print(os, "HTTP/1.1 " + 305 + " Use Proxy\r\n");
+ print(os, "Location: http://localhost:" + (port + 1)
+ + "/otherTest.html\r\n");
+ print(os, "Content-Length: 9\r\n");
+ print(os, "\r\nNOT PROXY");
+ } else {
+ print(os, "HTTP/1.1 " + OK + " OK\r\n");
+ print(os, "Content-Length: 5\r\n");
+ print(os, "\r\nPROXY");
+ }
+ os.flush();
+ os.close();
+
+ } catch (IOException e) {
+ System.err.println("Error performing content coding test.");
+ e.printStackTrace();
+ }
+
+ }
+
+ private void headersTest(Vector<String> headers) {
+ int found = 0;
+ for (int i = 0; i < headers.size(); i++) {
+ String header = headers.elementAt(i);
+ if (header.startsWith("header1:")) {
+ found++;
+ Assert.assertTrue("unexpected header: " + header,
+ found == 1);
+ Assert.assertTrue("invalid header: " + header,
+ "header1: value2".equals(header));
+ }
+ }
+ // send duplicate headers
+ try {
+ OutputStream os = socket.getOutputStream();
+ print(os, "HTTP/1.1 " + OK + " OK\r\n");
+ print(os, "Cache-Control: no-cache=\"set-cookie\"\r\n");
+ print(os, "Cache-Control: private\r\n");
+ print(os, "Cache-Control: no-transform\r\n\r\n");
+ os.flush();
+ os.close();
+ } catch (IOException e) {
+ System.err.println("Error performing headers test.");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Method postTest.
+ */
+ private void postTest(int length, InputStream in) {
+ try {
+ ByteArrayOutputStream data = new ByteArrayOutputStream();
+ // read content-length specified data
+ for (int i = 0; i < length; i++) {
+ data.write(in.read());
+ }
+
+ // read chunked-encoding data
+ if (length == -1) {
+ int len = in.read() - 48;
+ in.read();
+ in.read();
+ while (len > 0) {
+ for (int i = 0; i < len; i++) {
+ data.write(in.read());
+ }
+ in.read();
+ in.read();
+ len = in.read() - 48;
+ in.read();
+ in.read();
+ }
+ in.read();
+ in.read();
+ }
+
+ OutputStream os = socket.getOutputStream();
+ print(os, "HTTP/1.1 " + OK + " OK\r\n");
+ print(os, "Content-Length: " + data.size() + "\r\n\r\n");
+ os.write(data.toByteArray());
+ os.flush();
+ os.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void notFound() {
+ try {
+ // System.out.println("File not found on test server.");
+ OutputStream os = socket.getOutputStream();
+ print(os, "HTTP/1.1 " + NOT_FOUND + " Not Found\r\n");
+ print(os, "Content-Length: 1\r\n");
+ print(os, "\r\nZ");
+ os.flush();
+ os.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ /**
+ * Sets portRedirectTestEnable.
+ *
+ * @param portRedirectTestEnable
+ * The portRedirectTestEnable to set
+ */
+ public void setPortRedirectTestEnable(boolean portRedirectTestEnable) {
+ // enables an additional resource ("portredirTest.html") to be returned
+ // so that the port redirection test can distinguish
+ // between the two servers (on different ports).
+
+ this.portRedirectTestEnable = portRedirectTestEnable;
+ }
+
+ /**
+ * Sets the proxy.
+ *
+ * @param proxy
+ * The proxy to set
+ */
+ public void setProxy(boolean proxy) {
+ this.proxy = proxy;
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_HttpServerSocket.java b/support/src/test/java/tests/support/Support_HttpServerSocket.java
new file mode 100644
index 0000000..b9fb923
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_HttpServerSocket.java
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * This class implements the Support_ServerSocket interface using java.net
+ * Serversockets
+ */
+
+public class Support_HttpServerSocket implements Support_ServerSocket {
+ private ServerSocket instance = null;
+
+ private int port = -1;
+
+ private int timeout = 8000;
+
+ /**
+ * Blocks until a connection is made, or the socket times out.
+ *
+ * @see tests.support.Support_ServerSocket#accept()
+ */
+ public Support_Socket accept() throws IOException {
+ if (port == -1) {
+ return null;
+ }
+ if (instance == null) {
+ return null;
+ }
+ instance.setSoTimeout(timeout);
+ Socket s = instance.accept();
+ return new Support_HttpSocket(s);
+ }
+
+ /**
+ * @see tests.support.Support_ServerSocket#setTimeout(int) Sets the
+ * timeout for the server.
+ */
+ public void setTimeout(int timeout) {
+ this.timeout = timeout;
+ }
+
+ /**
+ * @see tests.support.Support_ServerSocket#setPort(int)
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public void open() throws IOException {
+ instance = new ServerSocket(port);
+ }
+
+ /**
+ * @see tests.support.Support_ServerSocket#close()
+ */
+ public void close() throws IOException {
+ if (instance != null) {
+ instance.close();
+ }
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_HttpSocket.java b/support/src/test/java/tests/support/Support_HttpSocket.java
new file mode 100644
index 0000000..088f978
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_HttpSocket.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+
+/**
+ * This class implements the Support_Socket interface using java.net Sockets.
+ */
+public class Support_HttpSocket implements Support_Socket {
+
+ private final Socket instance;
+
+ private boolean streamOpen = false;
+
+ Support_HttpSocket(Socket socket) {
+ instance = socket;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ streamOpen = true;
+ return instance.getInputStream();
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ streamOpen = true;
+ return instance.getOutputStream();
+ }
+
+ public void close() throws IOException {
+ if (!streamOpen && instance != null) {
+ instance.close();
+ }
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_HttpTests.java b/support/src/test/java/tests/support/Support_HttpTests.java
new file mode 100644
index 0000000..a3ab0ea
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_HttpTests.java
@@ -0,0 +1,429 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import junit.framework.Assert;
+
+/**
+ * Performs some basic testing of either HttpConnection or HttpURLConnection
+ * depending on the Support_ServerSocket and Support_HttpConnector passed to the
+ * constructor.
+ *
+ */
+public class Support_HttpTests {
+
+ private Support_ServerSocket serversocket;
+
+ private Support_HttpConnector connector;
+
+ public Support_HttpTests(Support_ServerSocket serversocket,
+ Support_HttpConnector client) {
+ this.serversocket = serversocket;
+ this.connector = client;
+ }
+
+ public void runTests(junit.framework.TestCase test) {
+
+ // get a port to use for the test
+ int portNumber = Support_PortManager.getNextPort();
+
+ // url's for the various tests
+ final String chunkedTestUrl = "http://localhost:" + portNumber
+ + Support_HttpServer.CHUNKEDTEST;
+ final String contentTestUrl = "http://localhost:" + portNumber
+ + Support_HttpServer.CONTENTTEST;
+ final String redirectTestUrl = "http://localhost:" + portNumber
+ + Support_HttpServer.REDIRECTTEST;
+ final String postTestUrl = "http://localhost:" + portNumber
+ + Support_HttpServer.POSTTEST;
+ final String headersTestUrl = "http://localhost:" + portNumber
+ + Support_HttpServer.HEADERSTEST;
+
+ // start the test server. It will timeout and shut down after
+ // 5 seconds of inactivity
+ Support_HttpServer server = new Support_HttpServer(serversocket, test);
+ server.startServer(portNumber);
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ InputStream is;
+ int c;
+
+ // Chunked HTTP Transfer Coding Test
+ try {
+ // access the url and open a stream
+ connector.open(chunkedTestUrl);
+ is = connector.getInputStream();
+
+ // receive the data, and then read again after EOF
+ c = is.read();
+ while (c > 0) {
+ c = is.read();
+ }
+ c = is.read();
+ is.close();
+ connector.close();
+ Assert.assertEquals("Error receiving chunked transfer coded data",
+ -1, c);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Exception during test a: " + e);
+ }
+
+ // Content-Length Test
+ try {
+ connector.open(contentTestUrl);
+ is = connector.getInputStream();
+ bout.reset();
+ do {
+ c = is.read();
+ if (c != -1) {
+ bout.write(c);
+ }
+ } while (c != -1);
+ is.close();
+ connector.close();
+ String result = new String(bout.toByteArray(), "ISO8859_1");
+ Assert.assertTrue("Error receiving content coded data: " + result,
+ "ABCDE".equals(result));
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Exception during test b: " + e);
+ }
+
+ // Headers Test
+ try {
+ connector.open(headersTestUrl);
+ connector.setRequestProperty("header1", "value1");
+ connector.setRequestProperty("header1", "value2");
+ int i = 0, found = 0;
+ String[] expected = new String[] { "no-cache=\"set-cookie\"",
+ "private", "no-transform" };
+ while (true) {
+ String key = connector.getHeaderFieldKey(i);
+ if (key == null && i > 0) {
+ break;
+ }
+ if ("Cache-Control".equals(key)) {
+ Assert.assertTrue("Too many headers at: " + i, found <= 2);
+ String value = connector.getHeaderField(i);
+ Assert.assertTrue("Invalid header value: " + found + ": "
+ + value, expected[found].equals(value));
+ found++;
+ }
+ i++;
+ }
+ Assert.assertTrue("Invalid headers: " + found, found == 3);
+ connector.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Exception during test c: " + e);
+ }
+
+ // Post Test
+ // Same as "Basic post" test below, but uses read() instead
+ // of read(buf, offset, length) to read the results
+ try {
+ String toWrite = "abcdef";
+ connector.open(postTestUrl);
+ OutputStream out = connector.getOutputStream();
+ out.write(toWrite.getBytes("ISO8859_1"));
+ out.close();
+ is = connector.getInputStream();
+ bout.reset();
+ do {
+ c = is.read();
+ if (c != -1) {
+ bout.write(c);
+ }
+ } while (c != -1);
+ is.close();
+ connector.close();
+ String result = new String(bout.toByteArray(), "ISO8859_1");
+ Assert.assertTrue("Error sending data 1: " + result, toWrite
+ .equals(result));
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Exception during test d: " + e);
+ }
+
+ // Post Test chunked
+ try {
+ String toWrite = "zyxwvuts";
+ connector.open(postTestUrl);
+ connector.setRequestProperty("Transfer-encoding", "chunked");
+ OutputStream out = connector.getOutputStream();
+ out.write(toWrite.getBytes("ISO8859_1"));
+ out.close();
+ is = connector.getInputStream();
+ bout.reset();
+ do {
+ c = is.read();
+ if (c != -1) {
+ bout.write(c);
+ }
+ } while (c != -1);
+ is.close();
+ connector.close();
+ String result = new String(bout.toByteArray(), "ISO8859_1");
+ Assert.assertEquals(toWrite, result);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Exception during test e: " + e);
+ }
+
+ OutputStream os = null;
+
+ byte[] data = new byte[1024];
+ int len = 0;
+
+ // Basic post
+ try {
+ String message = "test";
+ connector.open(postTestUrl);
+ os = connector.getOutputStream();
+ os.write(message.getBytes("ISO8859_1"));
+ os.close();
+ is = connector.getInputStream();
+ len = 0;
+ do {
+ int r = is.read(data, len, data.length - len);
+ if (r == -1) {
+ break;
+ }
+ len += r;
+ } while (true);
+ is.close();
+ connector.close();
+ String result = new String(data, 0, len, "ISO8859_1");
+ Assert.assertTrue("Basic port error: " + result, message
+ .equals(result));
+ } catch (IOException e) {
+ e.printStackTrace();
+ Assert.fail("Exception during basic post test: " + e);
+ }
+
+ String chunkChar = connector.isChunkedOnFlush() ? "C" : "";
+
+ // Flushing with post
+ try {
+ String message1 = "test2", message2 = "test3";
+ connector.open(postTestUrl);
+ os = connector.getOutputStream();
+ os.write(message1.getBytes("ISO8859_1"));
+ os.flush();
+ os.write(message2.getBytes("ISO8859_1"));
+ os.close();
+ is = connector.getInputStream();
+ len = 0;
+ do {
+ int r = is.read(data, len, data.length - len);
+ if (r == -1) {
+ break;
+ }
+ len += r;
+ } while (true);
+ is.close();
+ connector.close();
+ String result = new String(data, 0, len, "ISO8859_1");
+ Assert.assertTrue("Flushing with post: " + result, (chunkChar
+ + message1 + chunkChar + message2).equals(result));
+ } catch (IOException e) {
+ e.printStackTrace();
+ Assert.fail("Exception during flushing post test: " + e);
+ }
+
+ // Flushing with post and setting content-length
+ try {
+ String message1 = "test4", message2 = "test5";
+ connector.open(postTestUrl);
+ connector.setRequestProperty("Content-Length", "10");
+ os = connector.getOutputStream();
+ os.write(message1.getBytes("ISO8859_1"));
+ os.flush();
+ os.write(message2.getBytes("ISO8859_1"));
+ os.close();
+ is = connector.getInputStream();
+ len = 0;
+ do {
+ int r = is.read(data, len, data.length - len);
+ if (r == -1) {
+ break;
+ }
+ len += r;
+ } while (true);
+ is.close();
+ connector.close();
+ String result = new String(data, 0, len, "ISO8859_1");
+ Assert.assertTrue("Flushing with post and setting content-length: "
+ + result, (chunkChar + message1 + chunkChar + message2)
+ .equals(result));
+ } catch (IOException e) {
+ e.printStackTrace();
+ Assert.fail("Exception during flushing with content-length post test: "
+ + e);
+ }
+
+ // Flushing followed immediately by a close()
+ try {
+ String message = "test6";
+ connector.open(postTestUrl);
+ os = connector.getOutputStream();
+ os.write(message.getBytes("ISO8859_1"));
+ os.flush();
+ os.close();
+ is = connector.getInputStream();
+ len = 0;
+ do {
+ int r = is.read(data, len, data.length - len);
+ if (r == -1) {
+ break;
+ }
+ len += r;
+ } while (true);
+ is.close();
+ connector.close();
+ String result = new String(data, 0, len, "ISO8859_1");
+ Assert.assertTrue("Flushing followed immediately by a close(): "
+ + result, (chunkChar + message).equals(result));
+ } catch (IOException e) {
+ e.printStackTrace();
+ Assert.fail("Exception during flush followed by close post test: "
+ + e);
+ }
+
+ // Redirection Tests
+ final int[] testCodes = { Support_HttpServer.MULT_CHOICE,
+ Support_HttpServer.MOVED_PERM, Support_HttpServer.FOUND,
+ Support_HttpServer.SEE_OTHER, Support_HttpServer.NOT_MODIFIED,
+ Support_HttpServer.UNUSED, Support_HttpServer.TEMP_REDIRECT, };
+
+ final int[] results = { 'A', 'A', 'A', 'A', 'P', 'P', 'P' };
+ // see Support_HTTPServer for the source of this data
+
+ final String fullLocalLocation = contentTestUrl;
+ final String partLocalLocation = Support_HttpServer.CONTENTTEST;
+
+ for (int i = 0; i < testCodes.length; i++) {
+
+ // test each of the redirection response codes
+ try {
+ // append the response code for the server to return
+ // and the location to redirect to
+ connector.open(redirectTestUrl + "/" + testCodes[i] + "-"
+ + fullLocalLocation);
+ is = connector.getInputStream();
+ connector.close();
+
+ c = is.read();
+
+ if (testCodes[i] == Support_HttpServer.NOT_MODIFIED) {
+ // accept either the message-body or nothing, since the spec
+ // says there MUST NOT be a message body on 304 responses.
+ // But Java returns the message-body
+ if (!(c == results[i] || c == -1)) {
+ Assert.fail("Incorrect data returned on test of HTTP response "
+ + testCodes[i]);
+ }
+ } else if (c != results[i]) {
+ Assert.fail("Incorrect data returned on test of HTTP response "
+ + testCodes[i]);
+ }
+ while (c > 0) {
+ c = is.read();
+ }
+ c = is.read();
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Error during redirection test " + i + ": " + e);
+ }
+ }
+
+ // Test redirecting to a location on a different port
+ Class<?> serversocketclass = serversocket.getClass();
+ try {
+ Support_ServerSocket serversocket2 = (Support_ServerSocket) serversocketclass
+ .newInstance();
+
+ Support_HttpServer server2 = new Support_HttpServer(serversocket2,
+ test);
+ int newport = Support_PortManager.getNextPort();
+ server2.startServer(newport);
+ server2.setPortRedirectTestEnable(true);
+
+ // Test if redirection to a different port works
+ final String otherPortLocation = "http://localhost:" + newport
+ + Support_HttpServer.PORTREDIRTEST;
+
+ try {
+ // append the response code for the server to return
+ // and the location to redirect to
+
+ connector.open(redirectTestUrl + "/"
+ + Support_HttpServer.MOVED_PERM + "-"
+ + otherPortLocation);
+ is = connector.getInputStream();
+ connector.close();
+
+ c = is.read();
+ Assert.assertEquals("Incorrect data returned on redirection to a different port.",
+ 'A', c);
+ while (c > 0) {
+ c = is.read();
+ }
+ c = is.read();
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Exception during test f: " + e);
+ }
+ server2.stopServer();
+ } catch (IllegalAccessException e) {
+ Assert.fail("Exception during redirection to a different port:" + e);
+ } catch (InstantiationException e) {
+ Assert.fail("Exception during redirection to a different port:" + e);
+ }
+
+ // test redirecting to a relative URL on the same host
+ try {
+ // append the response code for the server to return
+ connector.open(redirectTestUrl + "/"
+ + Support_HttpServer.MOVED_PERM + "-" + partLocalLocation);
+ is = connector.getInputStream();
+ connector.close();
+
+ c = is.read();
+ Assert.assertEquals("Incorrect data returned on redirect to relative URI.",
+ 'A', c);
+ while (c > 0) {
+ c = is.read();
+ }
+ c = is.read();
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Exception during redirection test to a relative URL: " + e);
+ }
+ server.stopServer();
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_Jetty.java b/support/src/test/java/tests/support/Support_Jetty.java
new file mode 100644
index 0000000..ea25c9e
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Jetty.java
@@ -0,0 +1,172 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/*
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.mortbay.jetty.HttpConnection;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.handler.ResourceHandler;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+*/
+
+public class Support_Jetty {
+ /*
+ public static Server DEFAULT_SERVER = null;
+
+ public static int DEFAULT_PORT = 0;
+
+ public static Server DEFAULT_SERVLET = null;
+
+ public static int DEFAULT_SERVLET_PORT = 0;
+
+ public static Server SERVER = null;
+
+ public static int PORT = 0;
+
+ static {
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ try {
+ stopDefaultServer();
+ stopServer();
+ stopDefaultServlet();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ private static class HYDefaultServlet extends HttpServlet
+ {
+ private static final long serialVersionUID = -7650071946216123835L;
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ InputStream in = request.getInputStream();
+ int i;
+ StringBuilder s = new StringBuilder();
+ while((i = in.read())!=-1){
+ s.append((char)i);
+ }
+ response.setContentType("text/html");
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.getWriter().print(s);
+ }
+ }
+
+ private static class HYDefaultHandler extends AbstractHandler
+ {
+ public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
+ {
+ Request base_request = (request instanceof Request) ? (Request)request:HttpConnection.getCurrentConnection().getRequest();
+ base_request.setHandled(true);
+ response.setContentType("text/html");
+ response.addDateHeader("Date", System.currentTimeMillis());
+ response.addDateHeader("Last-Modified", Support_Configuration.URLConnectionLastModified);
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.getWriter().print("<h1>Hello OneHandler</h1>");
+ }
+ }
+*/
+ public static int startDefaultHttpServer() throws Exception{
+ /*
+ if (DEFAULT_SERVER != null){
+ return DEFAULT_PORT;
+ }
+ DEFAULT_SERVER = new Server(0);
+ DEFAULT_SERVER.setHandler(new HYDefaultHandler());
+ Context context = new Context(DEFAULT_SERVER,"/",Context.SESSIONS);
+ context.addServlet(new ServletHolder(new HYDefaultServlet()), "/servlet");
+ DEFAULT_SERVER.start();
+ DEFAULT_PORT = DEFAULT_SERVER.getConnectors()[0].getLocalPort();
+ return DEFAULT_PORT;
+ */
+ return -1;
+ }
+
+ public static int startDefaultServlet() throws Exception{
+ /*
+ if (DEFAULT_SERVLET != null){
+ return DEFAULT_SERVLET_PORT;
+ }
+ DEFAULT_SERVLET = new Server(0);
+ Context context = new Context(DEFAULT_SERVLET,"/",Context.SESSIONS);
+ context.addServlet(new ServletHolder(new HYDefaultServlet()), "/*");
+ DEFAULT_SERVLET.start();
+ DEFAULT_SERVLET_PORT = DEFAULT_SERVLET.getConnectors()[0].getLocalPort();
+ return DEFAULT_SERVLET_PORT;
+ */
+ return -1;
+ }
+
+ public static int startHttpServerWithDocRoot(String root) throws Exception {
+ /*
+ if (SERVER != null) {
+ SERVER.stop();
+ SERVER = null;
+ }
+ SERVER = new Server(0);
+ ResourceHandler resource_handler = new ResourceHandler();
+ resource_handler.setResourceBase(root);
+ SERVER.setHandler(resource_handler);
+ SERVER.start();
+ PORT = SERVER.getConnectors()[0].getLocalPort();
+ return PORT;
+ */
+ return -1;
+ }
+
+ private static void stopDefaultServer() throws Exception {
+ /*
+ if (DEFAULT_SERVER != null) {
+ DEFAULT_SERVER.stop();
+ DEFAULT_SERVER = null;
+ }
+ */
+ }
+
+ private static void stopServer() throws Exception {
+ /*
+ if (SERVER != null) {
+ SERVER.stop();
+ SERVER = null;
+ }
+ */
+ }
+
+ private static void stopDefaultServlet() throws Exception {
+ /*
+ if (DEFAULT_SERVLET != null) {
+ DEFAULT_SERVLET.stop();
+ DEFAULT_SERVLET = null;
+ }
+ */
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_ListTest.java b/support/src/test/java/tests/support/Support_ListTest.java
new file mode 100644
index 0000000..a7d5559
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_ListTest.java
@@ -0,0 +1,220 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+
+public class Support_ListTest extends junit.framework.TestCase {
+
+ List<Integer> list; // must contain the Integers 0 to 99 in order
+
+ public Support_ListTest(String p1) {
+ super(p1);
+ }
+
+ public Support_ListTest(String p1, List<Integer> l) {
+ super(p1);
+ list = l;
+ }
+
+ @Override
+ public void runTest() {
+ int hashCode = 1;
+ for (int counter = 0; counter < 100; counter++) {
+ Object elem;
+ elem = list.get(counter);
+ hashCode = 31 * hashCode + elem.hashCode();
+ assertTrue("ListTest - get failed", elem
+ .equals(new Integer(counter)));
+ }
+ assertTrue("ListTest - hashCode failed", hashCode == list.hashCode());
+
+ list.add(50, new Integer(1000));
+ assertTrue("ListTest - a) add with index failed--did not insert", list
+ .get(50).equals(new Integer(1000)));
+ assertTrue(
+ "ListTest - b) add with index failed--did not move following elements",
+ list.get(51).equals(new Integer(50)));
+ assertTrue(
+ "ListTest - c) add with index failed--affected previous elements",
+ list.get(49).equals(new Integer(49)));
+
+ list.set(50, new Integer(2000));
+ assertTrue("ListTest - a) set failed--did not set", list.get(50)
+ .equals(new Integer(2000)));
+ assertTrue("ListTest - b) set failed--affected following elements",
+ list.get(51).equals(new Integer(50)));
+ assertTrue("ListTest - c) set failed--affected previous elements", list
+ .get(49).equals(new Integer(49)));
+
+ list.remove(50);
+ assertTrue("ListTest - a) remove with index failed--did not remove",
+ list.get(50).equals(new Integer(50)));
+ assertTrue(
+ "ListTest - b) remove with index failed--did not move following elements",
+ list.get(51).equals(new Integer(51)));
+ assertTrue(
+ "ListTest - c) remove with index failed--affected previous elements",
+ list.get(49).equals(new Integer(49)));
+
+ List<Integer> myList = new LinkedList<Integer>();
+ myList.add(new Integer(500));
+ myList.add(new Integer(501));
+ myList.add(new Integer(502));
+
+ list.addAll(50, myList);
+ assertTrue("ListTest - a) addAll with index failed--did not insert",
+ list.get(50).equals(new Integer(500)));
+ assertTrue("ListTest - b) addAll with index failed--did not insert",
+ list.get(51).equals(new Integer(501)));
+ assertTrue("ListTest - c) addAll with index failed--did not insert",
+ list.get(52).equals(new Integer(502)));
+ assertTrue(
+ "ListTest - d) addAll with index failed--did not move following elements",
+ list.get(53).equals(new Integer(50)));
+ assertTrue(
+ "ListTest - e) addAll with index failed--affected previous elements",
+ list.get(49).equals(new Integer(49)));
+
+ List<Integer> mySubList = list.subList(50, 53);
+ assertEquals(3, mySubList.size());
+ assertTrue(
+ "ListTest - a) sublist Failed--does not contain correct elements",
+ mySubList.get(0).equals(new Integer(500)));
+ assertTrue(
+ "ListTest - b) sublist Failed--does not contain correct elements",
+ mySubList.get(1).equals(new Integer(501)));
+ assertTrue(
+ "ListTest - c) sublist Failed--does not contain correct elements",
+ mySubList.get(2).equals(new Integer(502)));
+
+ t_listIterator(mySubList);
+
+ mySubList.clear();
+ assertEquals("ListTest - Clearing the sublist did not remove the appropriate elements from the original list",
+ 100, list.size());
+
+ t_listIterator(list);
+ ListIterator<Integer> li = list.listIterator();
+ for (int counter = 0; li.hasNext(); counter++) {
+ Object elem;
+ elem = li.next();
+ assertTrue("ListTest - listIterator failed", elem
+ .equals(new Integer(counter)));
+ }
+
+ new Support_CollectionTest("", list).runTest();
+
+ }
+
+ public void t_listIterator(List<Integer> list) {
+ ListIterator<Integer> li = list.listIterator(1);
+ assertTrue("listIterator(1)", li.next() == list.get(1));
+
+ int orgSize = list.size();
+ li = list.listIterator();
+ for (int i = 0; i <= orgSize; i++) {
+ if (i == 0) {
+ assertTrue("list iterator hasPrevious(): " + i, !li
+ .hasPrevious());
+ } else {
+ assertTrue("list iterator hasPrevious(): " + i, li
+ .hasPrevious());
+ }
+ if (i == list.size()) {
+ assertTrue("list iterator hasNext(): " + i, !li.hasNext());
+ } else {
+ assertTrue("list iterator hasNext(): " + i, li.hasNext());
+ }
+ assertTrue("list iterator nextIndex(): " + i, li.nextIndex() == i);
+ assertTrue("list iterator previousIndex(): " + i, li
+ .previousIndex() == i - 1);
+ boolean exception = false;
+ try {
+ assertTrue("list iterator next(): " + i, li.next() == list
+ .get(i));
+ } catch (NoSuchElementException e) {
+ exception = true;
+ }
+ if (i == list.size()) {
+ assertTrue("list iterator next() exception: " + i, exception);
+ } else {
+ assertTrue("list iterator next() exception: " + i, !exception);
+ }
+ }
+
+ for (int i = orgSize - 1; i >= 0; i--) {
+ assertTrue("list iterator previous(): " + i, li.previous() == list
+ .get(i));
+ assertTrue("list iterator nextIndex()2: " + i, li.nextIndex() == i);
+ assertTrue("list iterator previousIndex()2: " + i, li
+ .previousIndex() == i - 1);
+ if (i == 0) {
+ assertTrue("list iterator hasPrevious()2: " + i, !li
+ .hasPrevious());
+ } else {
+ assertTrue("list iterator hasPrevious()2: " + i, li
+ .hasPrevious());
+ }
+ assertTrue("list iterator hasNext()2: " + i, li.hasNext());
+ }
+ boolean exception = false;
+ try {
+ li.previous();
+ } catch (NoSuchElementException e) {
+ exception = true;
+ }
+ assertTrue("list iterator previous() exception", exception);
+
+ Integer add1 = new Integer(600);
+ Integer add2 = new Integer(601);
+ li.add(add1);
+ assertTrue("list iterator add(), size()", list.size() == (orgSize + 1));
+ assertEquals("list iterator add(), nextIndex()", 1, li.nextIndex());
+ assertEquals("list iterator add(), previousIndex()",
+ 0, li.previousIndex());
+ Object next = li.next();
+ assertTrue("list iterator add(), next(): " + next, next == list.get(1));
+ li.add(add2);
+ Object previous = li.previous();
+ assertTrue("list iterator add(), previous(): " + previous,
+ previous == add2);
+ assertEquals("list iterator add(), nextIndex()2", 2, li.nextIndex());
+ assertEquals("list iterator add(), previousIndex()2",
+ 1, li.previousIndex());
+
+ li.remove();
+ assertTrue("list iterator remove(), size()",
+ list.size() == (orgSize + 1));
+ assertEquals("list iterator remove(), nextIndex()", 2, li.nextIndex());
+ assertEquals("list iterator remove(), previousIndex()", 1, li
+ .previousIndex());
+ assertTrue("list iterator previous()2", li.previous() == list.get(1));
+ assertTrue("list iterator previous()3", li.previous() == list.get(0));
+ assertTrue("list iterator next()2", li.next() == list.get(0));
+ li.remove();
+ assertTrue("list iterator hasPrevious()3", !li.hasPrevious());
+ assertTrue("list iterator hasNext()3", li.hasNext());
+ assertTrue("list iterator size()", list.size() == orgSize);
+ assertEquals("list iterator nextIndex()3", 0, li.nextIndex());
+ assertEquals("list iterator previousIndex()3", -1, li.previousIndex());
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_MapTest2.java b/support/src/test/java/tests/support/Support_MapTest2.java
new file mode 100644
index 0000000..ae3ee40
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_MapTest2.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.util.Map;
+import junit.framework.TestCase;
+
+public class Support_MapTest2 extends TestCase {
+
+ Map<String, String> map;
+
+ public Support_MapTest2(Map<String, String> m) {
+ super();
+ map = m;
+ if (!map.isEmpty()) {
+ fail("Map must be empty");
+ }
+ }
+
+ @Override
+ public void runTest() {
+ try {
+ map.put("one", "1");
+ assertEquals("size should be one", 1, map.size());
+ map.clear();
+ assertEquals("size should be zero", 0, map.size());
+ assertTrue("Should not have entries", !map.entrySet().iterator()
+ .hasNext());
+ assertTrue("Should not have keys", !map.keySet().iterator()
+ .hasNext());
+ assertTrue("Should not have values", !map.values().iterator()
+ .hasNext());
+ } catch (UnsupportedOperationException e) {
+ }
+
+ try {
+ map.put("one", "1");
+ assertEquals("size should be one", 1, map.size());
+ map.remove("one");
+ assertEquals("size should be zero", 0, map.size());
+ assertTrue("Should not have entries", !map.entrySet().iterator()
+ .hasNext());
+ assertTrue("Should not have keys", !map.keySet().iterator()
+ .hasNext());
+ assertTrue("Should not have values", !map.values().iterator()
+ .hasNext());
+ } catch (UnsupportedOperationException e) {
+ }
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_NetworkInterface.java b/support/src/test/java/tests/support/Support_NetworkInterface.java
new file mode 100644
index 0000000..7ecaf12
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_NetworkInterface.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package tests.support;
+
+
+import java.net.NetworkInterface;
+
+public class Support_NetworkInterface {
+
+ /**
+ * On windows platforms with IPV6 enabled there are a number of pseudo
+ * interfaces which don't work with our tests. This function is called to
+ * make sure we only use the non-pseudo interfaces
+ */
+ public static boolean useInterface(NetworkInterface theInterface) {
+ boolean result = true;
+ String platform = System.getProperty("os.name");
+ // only use these on windows platforms
+ if (platform.startsWith("Windows")) {
+ if ((theInterface.getDisplayName()
+ .equals("Teredo Tunneling Pseudo-Interface"))
+ || (theInterface.getDisplayName()
+ .equals("6to4 Tunneling Pseudo-Interface"))
+ || (theInterface.getDisplayName()
+ .equals("Automatic Tunneling Pseudo-Interface"))
+ || (theInterface.getDisplayName()
+ .equals("Loopback Pseudo-Interface"))
+ || (theInterface.getDisplayName().equals("MS TCP Loopback interface"))) {
+ result = false;
+ }
+ }
+
+ if (platform.startsWith("Linux")) {
+ if ((theInterface.getDisplayName().equals("lo"))
+ || (theInterface.getDisplayName().equals("teredo"))) {
+ result = false;
+ }
+ }
+ return result;
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_PermissionCollection.java b/support/src/test/java/tests/support/Support_PermissionCollection.java
new file mode 100644
index 0000000..e7dbe3a
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_PermissionCollection.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.BasicPermission;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+
+public class Support_PermissionCollection {
+
+ public static void main(String[] args) throws Exception {
+ System.setSecurityManager(new SecurityManager());
+ java.net.URL[] urls = new java.net.URL[1];
+ Class<?> c = null;
+ java.net.URLClassLoader ucl = null;
+ try {
+ URL url = new URL(args[0]);
+ urls[0] = url;
+ ucl = URLClassLoader.newInstance(urls, null);
+ c = Class.forName("coucou.FileAccess", true, ucl);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ ProtectionDomain pd = c.getProtectionDomain();
+ PermissionCollection coll = Policy.getPolicy().getPermissions(pd);
+ Class<?> myPermission = Class.forName("mypackage.MyPermission");
+ BasicPermission myperm = (BasicPermission) myPermission.newInstance();
+ System.out.println(
+ coll.implies(new java.io.FilePermission("test1.txt", "write"))
+ + ","
+ + coll.implies(myperm)
+ + ","
+ + coll.implies(new java.io.FilePermission("test2.txt", "write"))
+ + ","
+ + coll.implies(new java.io.FilePermission("test3.txt", "read"))
+ + ",");
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Support_PlatformFile.java b/support/src/test/java/tests/support/Support_PlatformFile.java
new file mode 100644
index 0000000..9c42f3c
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_PlatformFile.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_PlatformFile {
+
+ private static String platformId = null;
+
+ public static String getNewPlatformFile(String pre, String post) {
+ if (platformId == null) {
+ String property = System.getProperty("com.ibm.oti.configuration");
+ if (property == null) {
+ property = "JDK";
+ }
+ platformId = property
+ + System.getProperty("java.vm.version").replace('.', '-');
+ }
+ return pre + platformId + post;
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_PortManager.java b/support/src/test/java/tests/support/Support_PortManager.java
new file mode 100644
index 0000000..81f5e8d
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_PortManager.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.net.DatagramSocket;
+import java.net.ServerSocket;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+/**
+ * The port manager is supposed to help finding a free
+ * network port on the machine; however, it uses strange
+ * logic, so leave it to the OS.
+ *
+ * @deprecated Use OS to find free ports.
+ */
+public class Support_PortManager {
+
+ private static int lastAssignedPort = somewhatRandomPort();
+ private static boolean failedOnce = false;
+
+ public static synchronized int getNextPort() {
+ if (!failedOnce) {
+ try {
+ ServerSocket ss = new ServerSocket(0);
+ int port = ss.getLocalPort();
+
+ ss.close();
+ return port;
+ } catch (Exception ex) {
+ failedOnce = true;
+ }
+ }
+ return getNextPort_unsafe();
+ }
+
+ /**
+ * Returns 1 free ports to be used.
+ */
+ public static synchronized int getNextPortForUDP() {
+ return getNextPortsForUDP(1)[0];
+ }
+
+ /**
+ * Returns the specified number of free ports to be used.
+ */
+ public static synchronized int[] getNextPortsForUDP(int num) {
+ if (num <= 0) {
+ throw new IllegalArgumentException("Invalid ports number: " + num);
+ }
+ DatagramSocket[] dss = new DatagramSocket[num];
+ int[] ports = new int[num];
+
+ try {
+ for (int i = 0; i < num; ++i) {
+ dss[i] = new DatagramSocket(0);
+ ports[i] = dss[i].getLocalPort();
+ }
+ } catch (Exception ex) {
+ throw new Error("Unable to get " + num + " ports for UDP: " + ex);
+ } finally {
+ for (int i = 0; i < num; ++i) {
+ if (dss[i] != null) {
+ dss[i].close();
+ }
+ }
+ }
+ return ports;
+ }
+
+ public static synchronized int getNextPort_unsafe() {
+ if (++lastAssignedPort > 65534) {
+ lastAssignedPort = 6000;
+ }
+ return lastAssignedPort;
+ }
+
+ /*
+ * Returns a different port number every 6 seconds or so. The port number
+ * should be about += 100 at each 6 second interval
+ */
+ private static int somewhatRandomPort() {
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ int minutes = c.get(Calendar.MINUTE);
+ int seconds = c.get(Calendar.SECOND);
+
+ return 6000 + (1000 * minutes) + ((seconds / 6) * 100);
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_ProcessReadWriteTest.java b/support/src/test/java/tests/support/Support_ProcessReadWriteTest.java
new file mode 100644
index 0000000..9ccb226
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_ProcessReadWriteTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class Support_ProcessReadWriteTest {
+
+ public static void main(String[] args) {
+ try {
+ FileInputStream input = new FileInputStream(FileDescriptor.in);
+ FileOutputStream output = new FileOutputStream(FileDescriptor.out);
+
+ // read just three lines since EOF isn't working properly. It would
+ // be better to read to the end and echo it all
+ for (int i = 0; i < 3; i++) {
+ int c = input.read();
+ while (c != '\n') {
+ output.write(c);
+ c = input.read();
+ }
+ output.write(c);
+ }
+ input.close();
+ output.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_ProviderJCE.java b/support/src/test/java/tests/support/Support_ProviderJCE.java
new file mode 100644
index 0000000..1d428e8
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_ProviderJCE.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+
+/**
+ * This class implements a dummy security provider
+ */
+public class Support_ProviderJCE extends Provider {
+ private static final long serialVersionUID = 1L;
+
+ // Provider name
+ private static final String NAME = "ProviderJCE";
+
+ // Version of the services
+ private static final double VERSION = 1.0;
+
+ private static final String INFO = NAME
+ + " DSA key, parameter generation and signing; SHA-1 digest";
+
+ /**
+ * Constructs a new instance of the dummy provider.
+ */
+ public Support_ProviderJCE() {
+ super(NAME, VERSION, INFO);
+ registerServices();
+ }
+
+ /**
+ * Register the services the receiver provides.
+ */
+ private void registerServices() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ // Digest engine
+ put("MessageDigest.SHA",
+ "made.up.provider.name.MessageDigestSHA");
+ put("MessageDigest.MD5",
+ "made.up.provider.name.MessageDigestMD5");
+
+ // Algorithm parameter generator
+ put("AlgorithmParameterGenerator.DSA",
+ "made.up.provider.name.AlgorithmParameterGeneratorDSA");
+
+ // Algorithm parameters
+ put("AlgorithmParameters.DSA",
+ "made.up.provider.name.AlgorithmParametersDSA");
+
+ // Key pair generator
+ put("KeyPairGenerator.DSA",
+ "made.up.provider.name.KeyPairGeneratorDSA");
+
+ // Key factory
+ put("KeyFactory.DSA", "made.up.provider.name.KeyFactoryDSA");
+ put("KeyFactory.RSA", "made.up.provider.name.KeyFactoryRSA");
+
+ // Signature algorithm
+ put("Signature.SHA1withDSA",
+ "made.up.provider.name.SignatureDSA");
+
+ // KeyStore
+ put("KeyStore.PKCS#12/Netscape",
+ "made.up.provider.name.KeyStore");
+
+ // Certificate
+ put("CertificateFactory.X509",
+ "made.up.provider.name.CertificateFactoryX509");
+ return null;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Support_ProviderRSA.java b/support/src/test/java/tests/support/Support_ProviderRSA.java
new file mode 100644
index 0000000..bb75e00
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_ProviderRSA.java
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+
+/**
+ * This class implements a dummy provider.
+ */
+public class Support_ProviderRSA extends Provider {
+ private static final long serialVersionUID = 1L;
+
+ // Provider name
+ private static final String NAME = "ProviderRSA";
+
+ // Version of the services provided
+ private static final double VERSION = 1.0;
+
+ private static final String INFO = NAME
+ + " DSA key, parameter generation and signing; SHA-1 digest";
+
+ /**
+ * Constructs a new instance of the dummy provider.
+ */
+ public Support_ProviderRSA() {
+ super(NAME, VERSION, INFO);
+ registerServices();
+ }
+
+ /**
+ * Register the services the receiver provides.
+ */
+ private void registerServices() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ // Digest engine
+ put("MessageDigest.SHA",
+ "made.up.provider.name.MessageDigestSHA");
+ put("MessageDigest.MD5",
+ "made.up.provider.name.MessageDigestMD5");
+
+ // Secure Random
+ put("SecureRandom.SHA1PRNG",
+ "made.up.provider.name.SecureRandomImpl");
+
+ // Algorithm parameter generator
+ put("AlgorithmParameterGenerator.DSA",
+ "made.up.provider.name.AlgorithmParameterGeneratorDSA");
+
+ // Algorithm parameters
+ put("AlgorithmParameters.DSA",
+ "made.up.provider.name.AlgorithmParametersDSA");
+
+ // Key pair generator
+ put("KeyPairGenerator.DSA",
+ "made.up.provider.name.KeyPairGeneratorDSA");
+
+ // Key factory
+ put("KeyFactory.DSA",
+ "made.up.provider.name.KeyFactoryDSA");
+ put("KeyFactory.RSA",
+ "made.up.provider.name.KeyFactoryRSA");
+
+ // Signature algorithm
+ put("Signature.SHA1withDSA",
+ "made.up.provider.name.SignatureDSA");
+
+ // KeyStore
+ put("KeyStore.PKCS#12/Netscape",
+ "made.up.provider.name.KeyStore");
+
+ // Certificate
+ put("CertificateFactory.X509",
+ "made.up.provider.name.CertificateFactoryX509");
+ return null;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Support_ProviderTrust.java b/support/src/test/java/tests/support/Support_ProviderTrust.java
new file mode 100644
index 0000000..4c38866
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_ProviderTrust.java
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+
+/**
+ * This class implements a dummy provider.
+ *
+ */
+public class Support_ProviderTrust extends Provider {
+ private static final long serialVersionUID = 1L;
+
+ // Provider name
+ private static final String NAME = "ProviderTrust";
+
+ // Version of the services
+ private static final double VERSION = 1.0;
+
+ private static final String INFO = NAME
+ + " DSA key, parameter generation and signing; SHA-1 digest; SHA1PRNG SecureRandom";
+
+ /**
+ * Constructs a new instance of the dummy provider.
+ *
+ */
+ public Support_ProviderTrust() {
+ super(NAME, VERSION, INFO);
+ registerServices();
+ }
+
+ /**
+ * Register the services the receiver provides.
+ */
+ private void registerServices() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ // Digest engine
+ put("MessageDigest.SHA",
+ "made.up.provider.name.MessageDigestSHA");
+ put("MessageDigest.MD5",
+ "made.up.provider.name.MessageDigestMD5");
+
+ // Algorithm parameter generator
+ put("AlgorithmParameterGenerator.DSA",
+ "made.up.provider.name.AlgorithmParameterGeneratorDSA");
+
+ // Algorithm parameters
+ put("AlgorithmParameters.DSA",
+ "made.up.provider.name.AlgorithmParametersDSA");
+
+ // Key pair generator
+ put("KeyPairGenerator.DSA",
+ "made.up.provider.name.KeyPairGeneratorDSA");
+
+ // Key factory
+ put("KeyFactory.DSA", "made.up.provider.name.KeyFactoryDSA");
+ put("KeyFactory.RSA", "made.up.provider.name.KeyFactoryRSA");
+
+ // Signature algorithm
+ put("Signature.SHA1withDSA",
+ "made.up.provider.name.SignatureDSA");
+
+ // KeyStore
+ put("KeyStore.PKCS#12/Netscape",
+ "made.up.provider.name.KeyStore");
+
+ // Certificate
+ put("CertificateFactory.X509",
+ "made.up.provider.name.CertificateFactoryX509");
+
+ return null;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Support_Proxy_I1.java b/support/src/test/java/tests/support/Support_Proxy_I1.java
new file mode 100644
index 0000000..fcac557
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Proxy_I1.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public interface Support_Proxy_I1 {
+ boolean equals(Object o);
+
+ int[] array(long[] f);
+
+ void foo(int i, boolean b);
+
+ String string(String s) throws Support_Proxy_ParentException, LinkageError;
+}
diff --git a/support/src/test/java/tests/support/Support_Proxy_I2.java b/support/src/test/java/tests/support/Support_Proxy_I2.java
new file mode 100644
index 0000000..56ab8e8
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Proxy_I2.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public interface Support_Proxy_I2 {
+
+ int[] array(long[] f);
+
+ void foo(boolean b, int i);
+
+ String string(String s) throws Support_Proxy_SubException, Error;
+}
diff --git a/support/src/test/java/tests/support/Support_Proxy_ParentException.java b/support/src/test/java/tests/support/Support_Proxy_ParentException.java
new file mode 100644
index 0000000..13ac4c0
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Proxy_ParentException.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_Proxy_ParentException extends Exception {
+ private static final long serialVersionUID = -2760151845410887038L;
+}
diff --git a/support/src/test/java/tests/support/Support_Proxy_SubException.java b/support/src/test/java/tests/support/Support_Proxy_SubException.java
new file mode 100644
index 0000000..0d43630
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Proxy_SubException.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_Proxy_SubException extends Support_Proxy_ParentException {
+ private static final long serialVersionUID = -2615472925826542925L;
+
+}
diff --git a/support/src/test/java/tests/support/Support_ServerSocket.java b/support/src/test/java/tests/support/Support_ServerSocket.java
new file mode 100644
index 0000000..f3baafe
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_ServerSocket.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+
+/**
+ * The interface for a generic server socket.
+ *
+ */
+public interface Support_ServerSocket {
+
+ public Support_Socket accept() throws IOException;
+
+ public void setTimeout(int timeout);
+
+ public void setPort(int port);
+
+ public void open() throws IOException;
+
+ public void close() throws IOException;
+}
diff --git a/support/src/test/java/tests/support/Support_SetTest.java b/support/src/test/java/tests/support/Support_SetTest.java
new file mode 100644
index 0000000..27aaba5
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_SetTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.util.Set;
+
+public class Support_SetTest extends junit.framework.TestCase {
+
+ Set<Integer> set; // must contain only the Integers 0 to 99
+
+ public Support_SetTest(String p1) {
+ super(p1);
+ }
+
+ public Support_SetTest(String p1, Set<Integer> s) {
+ super(p1);
+ set = s;
+ }
+
+ @Override
+ public void runTest() {
+ // add
+ assertTrue("Set Test - Adding a duplicate element changed the set",
+ !set.add(new Integer(50)));
+ assertTrue("Set Test - Removing an element did not change the set", set
+ .remove(new Integer(50)));
+ assertTrue(
+ "Set Test - Adding and removing a duplicate element failed to remove it",
+ !set.contains(new Integer(50)));
+ set.add(new Integer(50));
+ new Support_CollectionTest("", set).runTest();
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_Socket.java b/support/src/test/java/tests/support/Support_Socket.java
new file mode 100644
index 0000000..050508d
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_Socket.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * This interface provides an extremely basic set of socket operations.
+ */
+public interface Support_Socket {
+
+ public InputStream getInputStream() throws IOException;
+
+ public OutputStream getOutputStream() throws IOException;
+
+ public void close() throws IOException;
+}
diff --git a/support/src/test/java/tests/support/Support_StringReader.java b/support/src/test/java/tests/support/Support_StringReader.java
new file mode 100644
index 0000000..70f4884
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_StringReader.java
@@ -0,0 +1,247 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.io.Reader;
+
+public class Support_StringReader extends Reader {
+ private String str;
+
+ private int markpos = -1;
+
+ private int pos = 0;
+
+ private int count;
+
+ /**
+ * Construct a StringReader on the String <code>str</code>. The size of
+ * the reader is set to the <code>length()</code> of the String and the
+ * Object to synchronize access through is set to <code>str</code>.
+ *
+ * @param str
+ * the String to filter reads on.
+ */
+ public Support_StringReader(String str) {
+ super(str);
+ this.str = str;
+ this.count = str.length();
+ }
+
+ /**
+ * This method closes this StringReader. Once it is closed, you can no
+ * longer read from it. Only the first invocation of this method has any
+ * effect.
+ *
+ */
+ @Override
+ public void close() {
+ synchronized (lock) {
+ if (isOpen()) {
+ str = null;
+ }
+ }
+ }
+
+ /**
+ * Answer a boolean indicating whether or not this StringReader is open.
+ */
+ private boolean isOpen() {
+ return str != null;
+ }
+
+ /**
+ * Set a Mark position in this Reader. The parameter <code>readLimit</code>
+ * is ignored for StringReaders. Sending reset() will reposition the reader
+ * back to the marked position provided the mark has not been invalidated.
+ *
+ * @param readlimit
+ * ignored for StringReaders.
+ *
+ * @exception java.io.IOException
+ * If an error occurs attempting mark this StringReader.
+ */
+ @Override
+ public void mark(int readLimit) throws IOException {
+ if (readLimit >= 0) {
+ synchronized (lock) {
+ if (isOpen()) {
+ markpos = pos;
+ } else {
+ throw new IOException("StringReader is closed");
+ }
+ }
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * Answers a boolean indicating whether or not this StringReader supports
+ * mark() and reset(). This method always returns true.
+ *
+ * @return <code>true</code> if mark() and reset() are supported,
+ * <code>false</code> otherwise. This implementation always
+ * returns <code>true</code>.
+ */
+ @Override
+ public boolean markSupported() {
+ return true;
+ }
+
+ /**
+ * Reads a single character from this StringReader and returns the result as
+ * an int. The 2 higher-order bytes are set to 0. If the end of reader was
+ * encountered then return -1.
+ *
+ * @return the character read or -1 if end of reader.
+ *
+ * @exception java.io.IOException
+ * If the StringReader is already closed.
+ */
+ @Override
+ public int read() throws IOException {
+ synchronized (lock) {
+ if (isOpen()) {
+ if (pos != count) {
+ return str.charAt(pos++);
+ }
+ return -1;
+ }
+ throw new IOException("StringReader is closed");
+ }
+ }
+
+ /**
+ * Reads at most <code>count</code> characters from this StringReader and
+ * stores them at <code>offset</code> in the character array
+ * <code>buf</code>. Returns the number of characters actually read or -1
+ * if the end of reader was encountered.
+ *
+ * @param buf
+ * character array to store the read characters
+ * @param offset
+ * offset in buf to store the read characters
+ * @param count
+ * maximum number of characters to read
+ * @return the number of characters read or -1 if end of reader.
+ *
+ * @exception java.io.IOException
+ * If the StringReader is closed.
+ */
+ @Override
+ public int read(char buf[], int offset, int count) throws IOException {
+ // avoid int overflow
+ if (0 <= offset && offset <= buf.length && 0 <= count
+ && count <= buf.length - offset) {
+ synchronized (lock) {
+ if (isOpen()) {
+ if (pos == this.count) {
+ return -1;
+ }
+ int end = pos + count > this.count ? this.count : pos
+ + count;
+ str.getChars(pos, end, buf, offset);
+ int read = end - pos;
+ pos = end;
+ return read;
+ }
+ throw new IOException("StringReader is closed");
+ }
+ }
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ /**
+ * Answers a <code>boolean</code> indicating whether or not this
+ * StringReader is ready to be read without blocking. If the result is
+ * <code>true</code>, the next <code>read()</code> will not block. If
+ * the result is <code>false</code> this Reader may or may not block when
+ * <code>read()</code> is sent. The implementation in StringReader always
+ * returns <code>true</code> even when it has been closed.
+ *
+ * @return <code>true</code> if the receiver will not block when
+ * <code>read()</code> is called, <code>false</code> if unknown
+ * or blocking will occur.
+ *
+ * @exception java.io.IOException
+ * If an IO error occurs.
+ */
+ @Override
+ public boolean ready() throws IOException {
+ synchronized (lock) {
+ if (isOpen()) {
+ return true;
+ }
+ throw new IOException("StringReader is closed");
+ }
+ }
+
+ /**
+ * Reset this StringReader's position to the last <code>mark()</code>
+ * location. Invocations of <code>read()/skip()</code> will occur from
+ * this new location. If this Reader was not marked, the StringReader is
+ * reset to the beginning of the String.
+ *
+ * @exception java.io.IOException
+ * If this StringReader has already been closed.
+ */
+ @Override
+ public void reset() throws IOException {
+ synchronized (lock) {
+ if (isOpen()) {
+ pos = markpos != -1 ? markpos : 0;
+ } else {
+ throw new IOException("StringReader is closed");
+ }
+ }
+ }
+
+ /**
+ * Skips <code>count</code> number of characters in this StringReader.
+ * Subsequent <code>read()</code>'s will not return these characters
+ * unless <code>reset()</code> is used.
+ *
+ * @param count
+ * The number of characters to skip.
+ * @return the number of characters actually skipped.
+ *
+ * @exception java.io.IOException
+ * If this StringReader has already been closed.
+ */
+ @Override
+ public long skip(long count) throws IOException {
+ synchronized (lock) {
+ if (isOpen()) {
+ if (count <= 0) {
+ return 0;
+ }
+ long skipped = 0;
+ if (count < this.count - pos) {
+ pos = pos + (int) count;
+ skipped = count;
+ } else {
+ skipped = this.count - pos;
+ pos = this.count;
+ }
+ return skipped;
+ }
+ throw new IOException("StringReader is closed");
+ }
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_StringWriter.java b/support/src/test/java/tests/support/Support_StringWriter.java
new file mode 100644
index 0000000..2ce387f
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_StringWriter.java
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.io.Writer;
+
+public class Support_StringWriter extends Writer {
+ private StringBuffer buf;
+
+ /**
+ * Constructs a new StringWriter which has a StringBuffer allocated with the
+ * default size of 16 characters. The StringBuffer is also the
+ * <code>lock</code> used to synchronize access to this Writer.
+ */
+ public Support_StringWriter() {
+ super();
+ buf = new StringBuffer(16);
+ lock = buf;
+ }
+
+ /**
+ * Constructs a new StringWriter which has a StringBuffer allocated with the
+ * size of <code>initialSize</code> characters. The StringBuffer is also
+ * the <code>lock</code> used to synchronize access to this Writer.
+ */
+ public Support_StringWriter(int initialSize) {
+ if (initialSize >= 0) {
+ buf = new StringBuffer(initialSize);
+ lock = buf;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * Close this Writer. This is the concrete implementation required. This
+ * particular implementation does nothing.
+ *
+ * @exception java.io.IOException
+ * If an IO error occurs closing this StringWriter.
+ */
+ @Override
+ public void close() throws IOException {
+ }
+
+ /**
+ * Flush this Writer. This is the concrete implementation required. This
+ * particular implementation does nothing.
+ *
+ */
+ @Override
+ public void flush() {
+ }
+
+ /**
+ * Answer the contents of this StringWriter as a StringBuffer. Any changes
+ * made to the StringBuffer by the receiver or the caller are reflected in
+ * this StringWriter.
+ *
+ * @return this StringWriters local StringBuffer.
+ */
+ public StringBuffer getBuffer() {
+ synchronized (lock) {
+ return buf;
+ }
+ }
+
+ /**
+ * Answer the contents of this StringWriter as a String. Any changes made to
+ * the StringBuffer by the receiver after returning will not be reflected in
+ * the String returned to the caller.
+ *
+ * @return this StringWriters current contents as a String.
+ */
+ @Override
+ public String toString() {
+ synchronized (lock) {
+ return buf.toString();
+ }
+ }
+
+ /**
+ * Writes <code>count</code> characters starting at <code>offset</code>
+ * in <code>buf</code> to this StringWriter.
+ *
+ * @param buf
+ * the non-null array containing characters to write.
+ * @param offset
+ * offset in buf to retrieve characters
+ * @param count
+ * maximum number of characters to write
+ *
+ * @exception java.lang.ArrayIndexOutOfBoundsException
+ * If offset or count are outside of bounds.
+ */
+ @Override
+ public void write(char[] buf, int offset, int count) {
+ // avoid int overflow
+ if (0 <= offset && offset <= buf.length && 0 <= count
+ && count <= buf.length - offset) {
+ synchronized (lock) {
+ this.buf.append(buf, offset, count);
+ }
+ } else {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ }
+
+ /**
+ * Writes the specified character <code>oneChar</code> to this
+ * StringWriter. This implementation writes the low order two bytes to the
+ * Stream.
+ *
+ * @param oneChar
+ * The character to write
+ *
+ */
+ @Override
+ public void write(int oneChar) {
+ synchronized (lock) {
+ buf.append((char) oneChar);
+ }
+ }
+
+ /**
+ * Writes the characters from the String <code>str</code> to this
+ * StringWriter.
+ *
+ * @param str
+ * the non-null String containing the characters to write.
+ *
+ */
+ @Override
+ public void write(String str) {
+ synchronized (lock) {
+ buf.append(str);
+ }
+ }
+
+ /**
+ * Writes <code>count</code> number of characters starting at
+ * <code>offset</code> from the String <code>str</code> to this
+ * StringWriter.
+ *
+ * @param str
+ * the non-null String containing the characters to write.
+ * @param offset
+ * the starting point to retrieve characters.
+ * @param count
+ * the number of characters to retrieve and write.
+ *
+ * @exception java.lang.ArrayIndexOutOfBoundsException
+ * If offset or count are outside of bounds.
+ */
+ @Override
+ public void write(String str, int offset, int count) {
+ String sub = str.substring(offset, offset + count);
+ synchronized (lock) {
+ buf.append(sub);
+ }
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_TestProvider.java b/support/src/test/java/tests/support/Support_TestProvider.java
new file mode 100644
index 0000000..56ab830
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_TestProvider.java
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+
+/**
+ * This class implements a dummy provider.
+ */
+public class Support_TestProvider extends Provider {
+ private static final long serialVersionUID = 1L;
+
+ // Provider name
+ private static final String NAME = "TestProvider";
+
+ // Version of the services provided
+ private static final double VERSION = 1.0;
+
+ private static final String INFO = NAME
+ + " DSA key, parameter generation and signing; SHA-1 digest; "
+ + "SHA1PRNG SecureRandom; PKCS#12/Netscape KeyStore";
+
+ /**
+ * Constructs a new instance of the dummy provider.
+ */
+ public Support_TestProvider() {
+ super(NAME, VERSION, INFO);
+ registerServices();
+ }
+
+ /**
+ * Register the services the receiver provides.
+ */
+ private void registerServices() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ // Digest engine
+ put("MessageDigest.SHA",
+ "made.up.provider.name.MessageDigestSHA");
+ put("MessageDigest.MD2",
+ "made.up.provider.name.MessageDigestMD2");
+ // aliases
+ put("Alg.Alias.MessageDigest.SHA1", "SHA");
+ put("Alg.Alias.MessageDigest.SHA-1", "SHA");
+ put("Alg.Alias.MessageDigest.OID.1.3.14.3.2.26", "SHA");
+ put("Alg.Alias.MessageDigest.1.3.14.3.2.26", "SHA");
+
+ // Algorithm parameter generator
+ put("AlgorithmParameterGenerator.DSA",
+ "made.up.provider.name.AlgorithmParameterGeneratorDSA");
+
+ // Algorithm parameters
+ put("AlgorithmParameters.DSA",
+ "made.up.provider.name.AlgorithmParametersDSA");
+ // aliases
+ put("Alg.Alias.AlgorithmParameters.1.2.840.10040.4.1", "DSA");
+ put("Alg.Alias.AlgorithmParameters.1.3.14.3.2.12", "DSA");
+
+ // Key pair generator
+ put("KeyPairGenerator.DSA",
+ "made.up.provider.name.KeyPairGeneratorDSA");
+ // aliases
+ put("Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1", "DSA");
+ put("Alg.Alias.KeyPairGenerator.1.2.840.10040.4.1", "DSA");
+ put("Alg.Alias.KeyPairGenerator.1.3.14.3.2.12", "DSA");
+
+ // Key factory
+ put("KeyFactory.DSA", "made.up.provider.name.KeyFactoryDSA");
+ put("KeyFactory.RSA", "made.up.provider.name.KeyFactoryRSA");
+ // aliases
+ put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
+ put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSA");
+
+ // Signature algorithm
+ put("Signature.SHA1withDSA",
+ "made.up.provider.name.SignatureDSA");
+
+ // aliases
+ put("Alg.Alias.Signature.DSA", "SHA1withDSA");
+ put("Alg.Alias.Signature.DSS", "SHA1withDSA");
+ put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA");
+ put("Alg.Alias.Signature.SHA1/DSA", "SHA1withDSA");
+ put("Alg.Alias.Signature.SHA-1/DSA", "SHA1withDSA");
+ put("Alg.Alias.Signature.SHAwithDSA", "SHA1withDSA");
+ put("Alg.Alias.Signature.DSAwithSHA1", "SHA1withDSA");
+ put("Alg.Alias.Signature.DSAWithSHA1", "SHA1withDSA");
+ put("Alg.Alias.Signature.SHA-1withDSA", "SHA1withDSA");
+ put("Alg.Alias.Signature.OID.1.2.840.10040.4.3", "SHA1withDSA");
+ put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA");
+ put("Alg.Alias.Signature.1.3.14.3.2.13", "SHA1withDSA");
+ put("Alg.Alias.Signature.1.3.14.3.2.27", "SHA1withDSA");
+ put("Alg.Alias.Signature.OID.1.3.14.3.2.13", "SHA1withDSA");
+ put("Alg.Alias.Signature.OID.1.3.14.3.2.27", "SHA1withDSA");
+
+ put("KeyStore.PKCS#12/Netscape",
+ "tests.support.Support_DummyPKCS12Keystore");
+
+ // Certificate
+ put("CertificateFactory.X509",
+ "made.up.provider.name.CertificateFactoryX509");
+ // aliases
+ put("Alg.Alias.CertificateFactory.X.509", "X509");
+
+ return null;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/support/src/test/java/tests/support/Support_TestResource.java b/support/src/test/java/tests/support/Support_TestResource.java
new file mode 100644
index 0000000..3106d27
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_TestResource.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_TestResource extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "parent1", "parentValue1" },
+ { "parent2", "parentValue2" }, { "parent3", "parentValue3" },
+ { "parent4", "parentValue4" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_TestResource_en.java b/support/src/test/java/tests/support/Support_TestResource_en.java
new file mode 100644
index 0000000..4a53279
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_TestResource_en.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_TestResource_en extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "parent2", "enValue2" },
+ { "parent3", "enValue3" }, { "parent4", "enValue4" },
+ { "child1", "enChildValue1" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_TestResource_en_US.java b/support/src/test/java/tests/support/Support_TestResource_en_US.java
new file mode 100644
index 0000000..42ab370
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_TestResource_en_US.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_TestResource_en_US extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "parent3", "enUSValue3" },
+ { "parent4", "enUSValue4" }, { "child1", "enUSChildValue1" },
+ { "child2", "enUSChildValue2" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_TestResource_fr.java b/support/src/test/java/tests/support/Support_TestResource_fr.java
new file mode 100644
index 0000000..9857a68
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_TestResource_fr.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_TestResource_fr extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "parent2", "frValue2" },
+ { "parent3", "frValue3" }, { "parent4", "frValue4" },
+ { "child1", "frChildValue1" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_TestResource_fr_FR.java b/support/src/test/java/tests/support/Support_TestResource_fr_FR.java
new file mode 100644
index 0000000..cb9fa6b
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_TestResource_fr_FR.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+public class Support_TestResource_fr_FR extends java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "parent3", "frFRValue3" },
+ { "parent4", "frFRValue4" }, { "child1", "frFRChildValue1" },
+ { "child2", "frFRChildValue2" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_TestResource_fr_FR_VAR.java b/support/src/test/java/tests/support/Support_TestResource_fr_FR_VAR.java
new file mode 100644
index 0000000..a2c7bb7
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_TestResource_fr_FR_VAR.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+package tests.support;
+
+public class Support_TestResource_fr_FR_VAR extends
+ java.util.ListResourceBundle {
+
+ @Override
+ protected Object[][] getContents() {
+ Object[][] contents = { { "parent4", "frFRVARValue4" },
+ { "child1", "frFRVARChildValue1" },
+ { "child2", "frFRVARChildValue2" },
+ { "child3", "frFRVARChildValue3" }, };
+ return contents;
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_TimeZone.java b/support/src/test/java/tests/support/Support_TimeZone.java
new file mode 100644
index 0000000..6056fc3
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_TimeZone.java
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+/**
+ * Sample java.util.TimeZone subclass to test getDSTSavings() and getOffset(long)
+ * APIs
+ *
+ */
+public class Support_TimeZone extends TimeZone {
+ private static final long serialVersionUID = 1L;
+
+ int rawOffset;
+
+ boolean useDaylightTime;
+
+ public Support_TimeZone(int rawOffset, boolean useDaylightTime) {
+ this.rawOffset = rawOffset;
+ this.useDaylightTime = useDaylightTime;
+ }
+
+ @Override
+ public int getRawOffset() {
+ return rawOffset;
+ }
+
+ /**
+ * let's assume this timezone has daylight savings from the 4th month till
+ * the 10th month of the year to ame things simple.
+ */
+ @Override
+ public boolean inDaylightTime(java.util.Date p1) {
+ if (!useDaylightTime) {
+ return false;
+ }
+ GregorianCalendar cal = new GregorianCalendar();
+ cal.setTime(p1);
+ int month = cal.get(Calendar.MONTH);
+
+ if (month > 4 && month < 10) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean useDaylightTime() {
+ return useDaylightTime;
+ }
+
+ /*
+ * return 0 to keep it simple, since this subclass is not used to test this
+ * method..
+ */
+ @Override
+ public int getOffset(int p1, int p2, int p3, int p4, int p5, int p6) {
+ return 0;
+ }
+
+ @Override
+ public void setRawOffset(int p1) {
+ rawOffset = p1;
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_URLConnector.java b/support/src/test/java/tests/support/Support_URLConnector.java
new file mode 100644
index 0000000..6aba108
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_URLConnector.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * This class implements the Support_HttpConnector interface using java.net
+ * URL's
+ */
+public class Support_URLConnector implements Support_HttpConnector {
+ private URLConnection instance;
+
+ private boolean streamOpen = false;
+
+ /**
+ * @see com.ibm.support.Support_HttpConnector#open(String)
+ */
+ public void open(String address) throws IOException {
+ instance = new URL(address).openConnection();
+ }
+
+ public void close() throws IOException {
+ if (!streamOpen) {
+ ((HttpURLConnection) instance).disconnect();
+ }
+ }
+
+ /**
+ * @see com.ibm.support.Support_HttpConnector#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException {
+ if (instance == null) {
+ return null;
+ }
+ streamOpen = true;
+ return instance.getInputStream();
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ if (instance == null) {
+ return null;
+ }
+ instance.setDoOutput(true);
+ ((HttpURLConnection) instance).setRequestMethod("POST");
+ streamOpen = true;
+ return instance.getOutputStream();
+ }
+
+ public boolean isChunkedOnFlush() {
+ return false;
+ }
+
+ public void setRequestProperty(String key, String value) throws IOException {
+ instance.setRequestProperty(key, value);
+ }
+
+ public String getHeaderField(int index) throws IOException {
+ return ((HttpURLConnection) instance).getHeaderField(index);
+ }
+
+ public String getHeaderFieldKey(int index) throws IOException {
+ return ((HttpURLConnection) instance).getHeaderFieldKey(index);
+ }
+}
diff --git a/support/src/test/java/tests/support/Support_UnmodifiableCollectionTest.java b/support/src/test/java/tests/support/Support_UnmodifiableCollectionTest.java
new file mode 100644
index 0000000..2935607
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_UnmodifiableCollectionTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import junit.framework.TestCase;
+
+public class Support_UnmodifiableCollectionTest extends TestCase {
+
+ Collection<Integer> col;
+
+ // must be a collection containing the Integers 0 to 99 (which will iterate
+ // in order)
+
+ public Support_UnmodifiableCollectionTest(String p1) {
+ super(p1);
+ }
+
+ public Support_UnmodifiableCollectionTest(String p1, Collection<Integer> c) {
+ super(p1);
+ col = c;
+ }
+
+ @Override
+ public void runTest() {
+
+ // contains
+ assertTrue("UnmodifiableCollectionTest - should contain 0", col
+ .contains(new Integer(0)));
+ assertTrue("UnmodifiableCollectionTest - should contain 50", col
+ .contains(new Integer(50)));
+ assertTrue("UnmodifiableCollectionTest - should not contain 100", !col
+ .contains(new Integer(100)));
+
+ // containsAll
+ HashSet<Integer> hs = new HashSet<Integer>();
+ hs.add(new Integer(0));
+ hs.add(new Integer(25));
+ hs.add(new Integer(99));
+ assertTrue(
+ "UnmodifiableCollectionTest - should contain set of 0, 25, and 99",
+ col.containsAll(hs));
+ hs.add(new Integer(100));
+ assertTrue(
+ "UnmodifiableCollectionTest - should not contain set of 0, 25, 99 and 100",
+ !col.containsAll(hs));
+
+ // isEmpty
+ assertTrue("UnmodifiableCollectionTest - should not be empty", !col
+ .isEmpty());
+
+ // iterator
+ Iterator<Integer> it = col.iterator();
+ SortedSet<Integer> ss = new TreeSet<Integer>();
+ while (it.hasNext()) {
+ ss.add(it.next());
+ }
+ it = ss.iterator();
+ for (int counter = 0; it.hasNext(); counter++) {
+ int nextValue = it.next().intValue();
+ assertTrue(
+ "UnmodifiableCollectionTest - Iterator returned wrong value. Wanted: "
+ + counter + " got: " + nextValue,
+ nextValue == counter);
+ }
+
+ // size
+ assertTrue(
+ "UnmodifiableCollectionTest - returned wrong size. Wanted 100, got: "
+ + col.size(), col.size() == 100);
+
+ // toArray
+ Object[] objArray;
+ objArray = col.toArray();
+ for (int counter = 0; it.hasNext(); counter++) {
+ assertTrue(
+ "UnmodifiableCollectionTest - toArray returned incorrect array",
+ objArray[counter] == it.next());
+ }
+
+ // toArray (Object[])
+ objArray = new Object[100];
+ col.toArray(objArray);
+ for (int counter = 0; it.hasNext(); counter++) {
+ assertTrue(
+ "UnmodifiableCollectionTest - toArray(Object) filled array incorrectly",
+ objArray[counter] == it.next());
+ }
+
+ }
+
+}
diff --git a/support/src/test/java/tests/support/Support_UnmodifiableMapTest.java b/support/src/test/java/tests/support/Support_UnmodifiableMapTest.java
new file mode 100644
index 0000000..74cf215
--- /dev/null
+++ b/support/src/test/java/tests/support/Support_UnmodifiableMapTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+
+package tests.support;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import junit.framework.TestCase;
+
+public class Support_UnmodifiableMapTest extends TestCase {
+
+ Map<String, Integer> map;
+
+ // must be a map containing the string keys "0"-"99" paired with the Integer
+ // values Integer(0) to Integer(99)
+
+ public Support_UnmodifiableMapTest(String p1) {
+ super(p1);
+ }
+
+ public Support_UnmodifiableMapTest(String p1, Map<String, Integer> m) {
+ super(p1);
+ map = m;
+ }
+
+ @Override
+ public void runTest() {
+ // containsKey
+ assertTrue("UnmodifiableMapTest - Should contain the key \"0\"", map
+ .containsKey("0"));
+ assertTrue("UnmodifiableMapTest - Should contain the key \"50\"", map
+ .containsKey("50"));
+ assertTrue("UnmodifiableMapTest - Should not contain the key \"100\"",
+ !map.containsKey("100"));
+
+ // containsValue
+ assertTrue("UnmodifiableMapTest - Should contain the value 0", map
+ .containsValue(new Integer(0)));
+ assertTrue("UnmodifiableMapTest - Should contain the value 50", map
+ .containsValue(new Integer(50)));
+ assertTrue("UnmodifiableMapTest - Should not contain value 100", !map
+ .containsValue(new Integer(100)));
+
+ // entrySet
+ Set<?> entrySet = map.entrySet();
+ Iterator<?> entrySetIterator = entrySet.iterator();
+ int myCounter = 0;
+ while (entrySetIterator.hasNext()) {
+ Map.Entry<?, ?> me = (Map.Entry<?, ?>) entrySetIterator.next();
+ assertTrue("UnmodifiableMapTest - Incorrect Map.Entry returned",
+ map.get(me.getKey()).equals(me.getValue()));
+ myCounter++;
+ }
+ assertEquals("UnmodifiableMapTest - Incorrect number of map entries returned",
+ 100, myCounter);
+
+ // get
+ assertTrue("UnmodifiableMapTest - getting \"0\" didn't return 0",
+ map.get("0").intValue() == 0);
+ assertTrue("UnmodifiableMapTest - getting \"50\" didn't return 0",
+ map.get("0").intValue() == 0);
+ assertNull("UnmodifiableMapTest - getting \"100\" didn't return null",
+ map.get("100"));
+
+ // isEmpty
+ assertTrue(
+ "UnmodifiableMapTest - should have returned false to isEmpty",
+ !map.isEmpty());
+
+ // keySet
+ Set<?> keySet = map.keySet();
+ t_KeySet(keySet);
+
+ // size
+ assertTrue("Size should return 100, returned: " + map.size(), map
+ .size() == 100);
+
+ // values
+ new Support_UnmodifiableCollectionTest("Unmod--from map test", map
+ .values());
+
+ }
+
+ void t_KeySet(Set<?> keySet) {
+ // keySet should be a set of the strings "0" to "99"
+
+ // contains
+ assertTrue("UnmodifiableMapTest - keySetTest - should contain \"0\"",
+ keySet.contains("0"));
+ assertTrue("UnmodifiableMapTest - keySetTest - should contain \"50\"",
+ keySet.contains("50"));
+ assertTrue(
+ "UnmodifiableMapTest - keySetTest - should not contain \"100\"",
+ !keySet.contains("100"));
+
+ // containsAll
+ HashSet<String> hs = new HashSet<String>();
+ hs.add("0");
+ hs.add("25");
+ hs.add("99");
+ assertTrue(
+ "UnmodifiableMapTest - keySetTest - should contain set of \"0\", \"25\", and \"99\"",
+ keySet.containsAll(hs));
+ hs.add("100");
+ assertTrue(
+ "UnmodifiableMapTest - keySetTest - should not contain set of \"0\", \"25\", \"99\" and \"100\"",
+ !keySet.containsAll(hs));
+
+ // isEmpty
+ assertTrue("UnmodifiableMapTest - keySetTest - should not be empty",
+ !keySet.isEmpty());
+
+ // iterator
+ Iterator<?> it = keySet.iterator();
+ while (it.hasNext()) {
+ assertTrue(
+ "UnmodifiableMapTest - keySetTest - Iterator returned wrong values",
+ keySet.contains(it.next()));
+ }
+
+ // size
+ assertTrue(
+ "UnmodifiableMapTest - keySetTest - returned wrong size. Wanted 100, got: "
+ + keySet.size(), keySet.size() == 100);
+
+ // toArray
+ Object[] objArray;
+ objArray = keySet.toArray();
+ for (int counter = 0; it.hasNext(); counter++) {
+ assertTrue(
+ "UnmodifiableMapTest - keySetTest - toArray returned incorrect array",
+ objArray[counter] == it.next());
+ }
+
+ // toArray (Object[])
+ objArray = new Object[100];
+ keySet.toArray(objArray);
+ for (int counter = 0; it.hasNext(); counter++) {
+ assertTrue(
+ "UnmodifiableMapTest - keySetTest - toArray(Object) filled array incorrectly",
+ objArray[counter] == it.next());
+ }
+ }
+
+}
diff --git a/support/src/test/java/tests/support/resource/Support_Resources.java b/support/src/test/java/tests/support/resource/Support_Resources.java
new file mode 100644
index 0000000..849b9bb
--- /dev/null
+++ b/support/src/test/java/tests/support/resource/Support_Resources.java
@@ -0,0 +1,177 @@
+/*
+ * 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.
+ */
+
+package tests.support.resource;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import tests.support.Support_Configuration;
+
+public class Support_Resources {
+
+ public static final String RESOURCE_PACKAGE = "/tests/resources/";
+
+ public static final String RESOURCE_PACKAGE_NAME = "tests.resources";
+
+ public static InputStream getStream(String name) {
+ return Support_Resources.class.getResourceAsStream(RESOURCE_PACKAGE
+ + name);
+ }
+
+ public static String getURL(String name) {
+ String folder = null;
+ String fileName = name;
+ File resources = createTempFolder();
+ int index = name.lastIndexOf("/");
+ if (index != -1) {
+ folder = name.substring(0, index);
+ name = name.substring(index + 1);
+ }
+ copyFile(resources, folder, name);
+ URL url = null;
+ String resPath = resources.toString();
+ if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\') {
+ resPath = resPath.substring(1);
+ }
+ try {
+ url = new URL("file:/" + resPath + "/" + fileName);
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return url.toString();
+ }
+
+ public static File createTempFolder() {
+
+ File folder = null;
+ try {
+ folder = File.createTempFile("hyts_resources", "", null);
+ folder.delete();
+ folder.mkdirs();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ folder.deleteOnExit();
+ return folder;
+ }
+
+ public static void copyFile(File root, String folder, String file) {
+ File f;
+ if (folder != null) {
+ f = new File(root.toString() + "/" + folder);
+ if (!f.exists()) {
+ f.mkdirs();
+ f.deleteOnExit();
+ }
+ } else {
+ f = root;
+ }
+
+ File dest = new File(f.toString() + "/" + file);
+
+ InputStream in = Support_Resources.getStream(folder == null ? file
+ : folder + "/" + file);
+ try {
+ copyLocalFileto(dest, in);
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public static File createTempFile(String suffix) throws IOException {
+ return File.createTempFile("hyts_", suffix, null);
+ }
+
+ public static void copyLocalFileto(File dest, InputStream in)
+ throws FileNotFoundException, IOException {
+ if (!dest.exists()) {
+ FileOutputStream out = new FileOutputStream(dest);
+ int result;
+ byte[] buf = new byte[4096];
+ while ((result = in.read(buf)) != -1) {
+ out.write(buf, 0, result);
+ }
+ in.close();
+ out.close();
+ dest.deleteOnExit();
+ }
+ }
+
+ public static File getExternalLocalFile(String url) throws IOException,
+ MalformedURLException {
+ File resources = createTempFolder();
+ InputStream in = new URL(url).openStream();
+ File temp = new File(resources.toString() + "/local.tmp");
+ copyLocalFileto(temp, in);
+ return temp;
+ }
+
+ public static String getResourceURL(String resource) {
+ return "http://" + Support_Configuration.TestResources + resource;
+ }
+
+ /**
+ * Util method to load resource files
+ *
+ * @param name - name of resource file
+ * @return - resource input stream
+ */
+ public static InputStream getResourceStream(String name) {
+
+ InputStream is = ClassLoader.getSystemClassLoader()
+ .getResourceAsStream(name);
+
+ if (is == null) {
+ throw new RuntimeException("Failed to load resource: " + name);
+ }
+
+ return is;
+ }
+
+ /**
+ * Util method to get absolute path to resource file
+ *
+ * @param name - name of resource file
+ * @return - path to resource
+ */
+ public static String getAbsoluteResourcePath(String name) {
+
+ URL url = ClassLoader.getSystemClassLoader().getResource(name);
+ if (url == null) {
+ throw new RuntimeException("Failed to load resource: " + name);
+ }
+
+ try {
+ return new File(url.toURI()).getAbsolutePath();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Failed to load resource: " + name);
+ }
+ }
+}
diff --git a/support/src/test/java/tests/util/CallVerificationStack.java b/support/src/test/java/tests/util/CallVerificationStack.java
new file mode 100644
index 0000000..8f4e012
--- /dev/null
+++ b/support/src/test/java/tests/util/CallVerificationStack.java
@@ -0,0 +1,353 @@
+/*
+ * 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.
+ */
+
+package tests.util;
+
+import java.util.Stack;
+
+/**
+ * A stack to store the parameters of a call, as well as the call stack.
+ *
+ */
+public class CallVerificationStack extends Stack<Object> {
+
+ /*
+ * --------------------------------------------------------------------
+ * Class variables
+ * --------------------------------------------------------------------
+ */
+
+ private static final long serialVersionUID = 1L;
+
+ // the singleton
+ private static final CallVerificationStack _instance = new CallVerificationStack();
+
+ /*
+ * --------------------------------------------------------------------
+ * Instance variables
+ * --------------------------------------------------------------------
+ */
+
+ // the call stack, store StackTraceElement
+ private final Stack<StackTraceElement> callStack = new Stack<StackTraceElement>();
+
+ /*
+ * -------------------------------------------------------------------
+ * Constructors
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Can't be instantiated.
+ */
+ private CallVerificationStack() {
+ // empty
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Gets the singleton instance.
+ *
+ * @return the singleton instance
+ */
+ public static CallVerificationStack getInstance() {
+ return _instance;
+ }
+
+ /**
+ * Pushes the call stack.
+ */
+ private void pushCallStack() {
+ StackTraceElement[] eles = (new Throwable()).getStackTrace();
+ int i;
+ for (i = 1; i < eles.length; i++) {
+ if (!eles[i].getClassName().equals(this.getClass().getName())) {
+ break;
+ }
+ }
+ this.callStack.push(eles[i]);
+ }
+
+ /**
+ * Gets the "current" calling class name.
+ *
+ * @return the "current" calling class name
+ */
+ public String getCurrentSourceClass() {
+ return this.callStack.peek().getClassName();
+ }
+
+ /**
+ * Gets the "current" calling method name.
+ *
+ * @return the "current" calling method name
+ */
+ public String getCurrentSourceMethod() {
+ return this.callStack.peek().getMethodName();
+ }
+
+ /**
+ * Clear the parameter stack and the call stack.
+ *
+ */
+ @Override
+ public void clear() {
+ this.callStack.clear();
+ super.clear();
+ }
+
+ @Override
+ public Object push(Object o) {
+ pushCallStack();
+ return super.push(o);
+ }
+
+ /**
+ * Pushes a boolean onto the top of this stack.
+ *
+ * @param val
+ * the value to push
+ */
+ public void push(boolean val) {
+ this.push(new BaseTypeWrapper(val));
+ }
+
+ /**
+ * Pushes a char onto the top of this stack.
+ *
+ * @param val
+ * the value to push
+ */
+ public void push(char val) {
+ this.push(new BaseTypeWrapper(val));
+ }
+
+ /**
+ * Pushes a double onto the top of this stack.
+ *
+ * @param val
+ * the value to push
+ */
+ public void push(double val) {
+ this.push(new BaseTypeWrapper(val));
+ }
+
+ /**
+ * Pushes a float onto the top of this stack.
+ *
+ * @param val
+ * the value to push
+ */
+ public void push(float val) {
+ this.push(new BaseTypeWrapper(val));
+ }
+
+ /**
+ * Pushes an int onto the top of this stack.
+ *
+ * @param val
+ * the value to push
+ */
+ public void push(int val) {
+ this.push(new BaseTypeWrapper(val));
+ }
+
+ /**
+ * Pushes a long onto the top of this stack.
+ *
+ * @param val
+ * the value to push
+ */
+ public void push(long val) {
+ this.push(new BaseTypeWrapper(val));
+ }
+
+ /**
+ * Pushes a short onto the top of this stack.
+ *
+ * @param val
+ * the value to push
+ */
+ public void push(short val) {
+ this.push(new BaseTypeWrapper(val));
+ }
+
+ /**
+ * Pop an object.
+ *
+ * @return the object
+ */
+ @Override
+ public Object pop() {
+ this.callStack.pop();
+ return super.pop();
+ }
+
+ /**
+ * Pop a boolean.
+ *
+ * @return the value
+ */
+ public boolean popBoolean() {
+ BaseTypeWrapper wrapper = (BaseTypeWrapper) this.pop();
+ Boolean value = (Boolean) wrapper.getValue();
+ return value.booleanValue();
+ }
+
+ /**
+ * Pop a char.
+ *
+ * @return the value
+ */
+ public char popChar() {
+ BaseTypeWrapper wrapper = (BaseTypeWrapper) this.pop();
+ Character value = (Character) wrapper.getValue();
+ return value.charValue();
+ }
+
+ /**
+ * Pop a double.
+ *
+ * @return the value
+ */
+ public double popDouble() {
+ BaseTypeWrapper wrapper = (BaseTypeWrapper) this.pop();
+ Double value = (Double) wrapper.getValue();
+ return value.doubleValue();
+ }
+
+ /**
+ * Pop a float.
+ *
+ * @return the value
+ */
+ public float popFloat() {
+ BaseTypeWrapper wrapper = (BaseTypeWrapper) this.pop();
+ Float value = (Float) wrapper.getValue();
+ return value.floatValue();
+ }
+
+ /**
+ * Pop a int.
+ *
+ * @return the value
+ */
+ public int popInt() {
+ BaseTypeWrapper wrapper = (BaseTypeWrapper) this.pop();
+ Integer value = (Integer) wrapper.getValue();
+ return value.intValue();
+ }
+
+ /**
+ * Pop a long.
+ *
+ * @return the value
+ */
+ public long popLong() {
+ BaseTypeWrapper wrapper = (BaseTypeWrapper) this.pop();
+ Long value = (Long) wrapper.getValue();
+ return value.longValue();
+ }
+
+ /**
+ * Pop a short.
+ *
+ * @return the value
+ */
+ public short popShort() {
+ BaseTypeWrapper wrapper = (BaseTypeWrapper) this.pop();
+ Short value = (Short) wrapper.getValue();
+ return value.shortValue();
+ }
+
+ /*
+ * Wrapper of base types.
+ */
+ class BaseTypeWrapper {
+
+ // the internal value
+ private Object value;
+
+ /*
+ * Constructs a wrapper object for the base type <code> boolean </code> .
+ */
+ public BaseTypeWrapper(boolean val) {
+ this.value = new Boolean(val);
+ }
+
+ /*
+ * Constructs a wrapper object for the base type <code> c </code> .
+ */
+ public BaseTypeWrapper(byte val) {
+ this.value = new Byte(val);
+ }
+
+ /*
+ * Constructs a wrapper object for the base type <code> char </code> .
+ */
+ public BaseTypeWrapper(char val) {
+ this.value = new Character(val);
+ }
+
+ /*
+ * Constructs a wrapper object for the base type <code> double </code> .
+ */
+ public BaseTypeWrapper(double val) {
+ this.value = new Double(val);
+ }
+
+ /*
+ * Constructs a wrapper object for the base type <code> float </code> .
+ */
+ public BaseTypeWrapper(float val) {
+ this.value = new Float(val);
+ }
+
+ /*
+ * Constructs a wrapper object for the base type <code> int </code> .
+ */
+ public BaseTypeWrapper(int val) {
+ this.value = new Integer(val);
+ }
+
+ /*
+ * Constructs a wrapper object for the base type <code> long </code> .
+ */
+ public BaseTypeWrapper(long val) {
+ this.value = new Long(val);
+ }
+
+ /*
+ * Constructs a wrapper object for the base type <code> short </code> .
+ */
+ public BaseTypeWrapper(short val) {
+ this.value = new Short(val);
+ }
+
+ /*
+ * Gets the internal value.
+ */
+ public Object getValue() {
+ return this.value;
+ }
+ }
+}
diff --git a/support/src/test/java/tests/util/SerializationTester.java b/support/src/test/java/tests/util/SerializationTester.java
new file mode 100644
index 0000000..be5ac8e
--- /dev/null
+++ b/support/src/test/java/tests/util/SerializationTester.java
@@ -0,0 +1,246 @@
+/*
+ * 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.
+ */
+
+package tests.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.URL;
+
+/**
+ * This class simplifies the serialization test.
+ *
+ */
+public class SerializationTester {
+
+ /*
+ * --------------------------------------------------------------------
+ * Class variables
+ * --------------------------------------------------------------------
+ */
+
+ // the last deserialized object
+ private static Object lastOutput = null;
+
+ /*
+ * -------------------------------------------------------------------
+ * Constructors
+ * -------------------------------------------------------------------
+ */
+
+ private SerializationTester() {
+
+ }
+
+ /*
+ * -------------------------------------------------------------------
+ * Methods
+ * -------------------------------------------------------------------
+ */
+
+ /**
+ * Serialize an object and then deserialize it.
+ *
+ * @param inputObject
+ * the input object
+ * @return the deserialized object
+ */
+ public static Object getDeserilizedObject(Object inputObject)
+ throws IOException, ClassNotFoundException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeObject(inputObject);
+ oos.close();
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bis);
+ Object outputObject = ois.readObject();
+ lastOutput = outputObject;
+ ois.close();
+ return outputObject;
+ }
+
+ /**
+ * Tests the serialization and deserialization of const objects.
+ *
+ * @param inputObject
+ * A const object
+ * @return true if the deserialized object is the same as the input object,
+ * otherwise false
+ * @throws Exception
+ * If any occurs.
+ */
+ public static boolean assertSame(Object inputObject) throws Exception {
+ return inputObject == getDeserilizedObject(inputObject);
+ }
+
+ /**
+ * Tests the serialization and deserialization of instance objects.
+ *
+ * @param inputObject
+ * An object
+ * @return true if the deserialized object is equal to the input object,
+ * otherwise false
+ * @throws Exception
+ * If any occurs.
+ */
+ public static boolean assertEquals(Object inputObject) throws Exception {
+ return inputObject.equals(getDeserilizedObject(inputObject));
+ }
+
+ /**
+ * Tests the serialization compatibility with reference const objects.
+ *
+ * @param obj
+ * the object to be checked
+ * @param fileName
+ * the serialization output file generated by reference
+ * @return true if compatible, otherwise false
+ * @throws Exception
+ * If any occurs.
+ */
+ public static boolean assertCompabilitySame(Object obj, String fileName)
+ throws Exception {
+ return obj == readObject(obj, fileName);
+ }
+
+ /**
+ * Tests the serialization compatibility with reference for instance
+ * objects.
+ *
+ * @param obj
+ * the object to be checked
+ * @param fileName
+ * the serialization output file generated by reference
+ * @return true if compatible, otherwise false
+ * @throws Exception
+ * If any occurs.
+ */
+ public static boolean assertCompabilityEquals(Object obj, String fileName)
+ throws Exception {
+ return obj.equals(readObject(obj, fileName));
+ }
+
+ /**
+ * Deserialize an object from a file.
+ *
+ * @param obj
+ * the object to be serialized if no serialization file is found
+ * @param fileName
+ * the serialization file
+ * @return the deserialized object
+ * @throws Exception
+ * If any occurs.
+ */
+ public static Object readObject(Object obj, String fileName)
+ throws Exception {
+ InputStream input = null;
+ ObjectInputStream oinput = null;
+ URL url = SerializationTester.class.getClassLoader().getResource(
+ fileName);
+ if (null == url) {
+ // serialization file does not exist, create one in the current dir
+ writeObject(obj, new File(fileName).getName());
+ throw new Error(
+ "Serialization file does not exist, created in the current dir.");
+ }
+ input = url.openStream();
+ try {
+ oinput = new ObjectInputStream(input);
+ Object newObj = oinput.readObject();
+ return newObj;
+ } finally {
+ try {
+ if (null != oinput) {
+ oinput.close();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ try {
+ if (null != input) {
+ input.close();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ /*
+ * Creates a serialization output.
+ *
+ * @param obj the object to be serialized @param fileName the output file
+ * @throws Exception If any occurs.
+ */
+ public static void writeObject(Object obj, String fileName)
+ throws Exception {
+ // String path = SerializationTester.class.getResource(".").getPath();
+ // if (path.endsWith(".")) {
+ // path = path.substring(0, path.length() - 1);
+ // }
+ // if (!path.endsWith("/")) {
+ // path += "/";
+ // }
+ // path += fileName;
+ // System.out.println(path);
+ OutputStream output = null;
+ ObjectOutputStream ooutput = null;
+ try {
+ output = new FileOutputStream(fileName);
+ ooutput = new ObjectOutputStream(output);
+ ooutput.writeObject(obj);
+ } finally {
+ try {
+ if (null != ooutput) {
+ ooutput.close();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ try {
+ if (null != output) {
+ output.close();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ /**
+ * Gets the last deserialized object.
+ *
+ * @return the last deserialized object
+ */
+ public static Object getLastOutput() {
+ return lastOutput;
+ }
+
+ /*
+ * For test purpose.
+ */
+ public static void main(String[] args) {
+ }
+}
diff --git a/support/src/test/resources/config/excludes.xsd b/support/src/test/resources/config/excludes.xsd
new file mode 100644
index 0000000..33909ee
--- /dev/null
+++ b/support/src/test/resources/config/excludes.xsd
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://incubator.apache.org/harmony/testing"
+ targetNamespace="http://incubator.apache.org/harmony/testing">
+
+ <!--
+ * A suite contains zero or more type declarations
+ -->
+ <xsd:element name="suite">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="type" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!--
+ * A type contains one or more exclude elements.
+ * A type has a single attribute (id) which can be
+ * any meaningful character value that is based on
+ * proper XML naming conventions (must begin with a
+ * letter or underscore).
+ -->
+ <xsd:element name="type">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="exclude" minOccurs="1" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="idtype" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <!--
+ * An exclude element can have an optional reason
+ * element.
+ -->
+ <xsd:element name="exclude">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="reason" minOccurs="0" maxOccurs="1"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="idtype" default="all" />
+ <xsd:attribute name="platform" type="platformlisttype" default="all" />
+ <xsd:attribute name="shouldfix" type="booleanstringtype" default="true" />
+ </xsd:complexType>
+ </xsd:element>
+
+<!--
+ * A reason element has no attributes, only parsed
+ * character data.
+ -->
+ <xsd:element name="reason">
+ <xsd:complexType mixed="true"/>
+ </xsd:element>
+
+
+ <!--
+ * Type idtype is any string data.
+ -->
+ <xsd:simpleType name="idtype">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+
+
+ <!--
+ * Type platformstringtype is one of the
+ * strings "all", "win.IA32" or "linux.IA32".
+ -->
+ <xsd:simpleType name="platformstringtype" >
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="win.IA32"/>
+ <xsd:enumeration value="linux.IA32"/>
+ <xsd:enumeration value="all"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:simpleType name="platformlisttype">
+ <xsd:list itemType="platformstringtype"/>
+ </xsd:simpleType>
+
+
+ <!--
+ * Type booleanstringtype is one of the
+ * strings "true" or "false".
+ -->
+ <xsd:simpleType name="booleanstringtype" >
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="true"/>
+ <xsd:enumeration value="false"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+</xsd:schema>
diff --git a/support/src/test/resources/config/jcltest-excludes.xml b/support/src/test/resources/config/jcltest-excludes.xml
new file mode 100644
index 0000000..4a3920e
--- /dev/null
+++ b/support/src/test/resources/config/jcltest-excludes.xml
@@ -0,0 +1,2241 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hy:suite xmlns:hy="http://incubator.apache.org/harmony/testing"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://incubator.apache.org/harmony/testing excludes.xsd">
+
+ <!-- Applet module test exclusions -->
+
+
+ <!-- Archive module test exclusions -->
+ <hy:type id="tests.api.java.util.zip.GZIPInputStreamTest">
+ <hy:exclude id="test_read$BII" shouldfix="true">
+ <hy:reason>java.io.IOException: Size mismatch</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_close" shouldfix="true">
+ <hy:reason>java.io.IOException: Size mismatch</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.util.zip.InflaterInputStreamTest">
+ <hy:exclude id="test_ConstructorLjava_io_InputStream" shouldfix="true">
+ <hy:reason>read() threw an exception while testing constructor</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.util.zip.InflaterTest">
+ <hy:exclude id="test_setDictionary$B" shouldfix="true">
+ <hy:reason>java.lang.IllegalArgumentException in native method</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- Auth module test exclusions -->
+ <hy:type id="javax.security.auth.login.serialization.SerAccountExpiredExceptionTest">
+ <hy:exclude id="testGolden" shouldfix="true">
+ <hy:reason>java.io.EOFException</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.security.auth.login.serialization.SerCredentialExpiredExceptionTest">
+ <hy:exclude id="testGolden" shouldfix="true">
+ <hy:reason>java.io.EOFException</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.security.auth.x500.X500PrincipalTest">
+ <hy:exclude id="testValidEncoding" shouldfix="true">
+ <hy:reason>Undiagnosed Error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.javax.security.auth.x500.X500PrincipalTest">
+ <hy:exclude id="all" shouldfix="true">
+ <hy:reason>Undiagnosed Error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- AWT module test exclusions -->
+
+
+ <!-- Beans module test exclusions -->
+ <hy:type id="java.beans.beancontext.BeanContextServicesSupportTest">
+ <hy:exclude id="all" shouldfix="true">
+ <hy:reason>protected system package 'java.beans.beancontext'</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="java.beans.beancontext.BeanContextSupportTest">
+ <hy:exclude id="all" shouldfix="true">
+ <hy:reason>protected system package 'java.beans.beancontext'</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.tests.java.beans.BeansTest">
+ <hy:exclude id="testLoadBySpecificClassLoader" shouldfix="true">
+ <hy:reason>Class with name org.apache.harmony.tests.beans.auxiliary.SampleBean is not found</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testLoadByDefaultClassLoader" shouldfix="true">
+ <hy:reason>Class with name org.apache.harmony.tests.beans.auxiliary.SampleBean is not found</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.tests.java.beans.EventHandlerTest">
+ <hy:exclude id="testNullListenerMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInvoke" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInvokeWithNullPropertyName" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateWithDottedParameterCall" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateWithMethodCallWhichIsSetter" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateForStaticMethodAsPropertyGetter" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.tests.java.beans.SimpleBeanInfoTest">
+ <hy:exclude id="testLoadImage" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.BeanDescriptorTest">
+ <hy:exclude id="testBeanDescriptorClass" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBeanDescriptorClassClass_CustomizerClassNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.BeansTest">
+ <hy:exclude id="testInstantiateClassLoaderString_Class" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiateClassLoaderString_Ser" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiateClassLoaderStringBeanContext_Class" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiateClassLoaderStringBeanContext_Ser" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiateClassLoaderStringBeanContextAppletInitializer_Class" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiateClassLoaderStringBeanContextAppletInitializer_Ser" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIsInstanceOf_BeanNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.CustomizedPersistenceDelegateTest">
+ <hy:exclude id="testArrayPD" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testProxyPD" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPrimitivePD" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMethodPD" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFieldPD" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.DefaultPersistenceDelegateTest">
+ <hy:exclude id="testInstantiate_NullProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiate_EmptyProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiate_NonExistingGetter" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiate_NonExistingGetterNulEncoder" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiate_InitialUpperCasePropName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiate_NoGetter" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiate_NotRegularGetter" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMutatesTo_NormalNoProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMutatesTo_NormalWithEmptyPropertyPublicEqualMethod" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMutatesTo_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_NormalBeanInfo" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_SameInstance" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_TransientProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_NullClass" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_NullInstances" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_NullEncoder" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_NotRegularGetter" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.EncoderTest">
+ <hy:exclude id="testGetExceptionListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetExceptionListener_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetExceptionListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteExpression_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetPersistenceDelegate_BeanInfo" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetPersistenceDelegate_Default" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetPersistenceDelegate_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGet_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGet_Integer" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemove_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.EventHandlerTest">
+ <hy:exclude id="testCreateClassObjectString_ObjectNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectString_MethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectString_MethodEmpty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringString_TargetNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringString_ActionNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringString_ActionInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringString_PropertyNameNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringString_PropertyNameInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringStringString_TargetNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringStringString_ActionNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringStringString_ActionInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringStringString_PropertyNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateClassObjectStringStringString_PropertyInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInvoke_1" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIncompatibleMethod" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCoverage_1" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInvoke_extend2" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInvoke_extend2_2" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInvoke_extend4_BooleanObject" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventHandlerCreate" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.EventSetDescriptorTest">
+ <hy:exclude id="testEventSetDescriptorClassStringClassString2" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassString_EventNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassString_EventEmpty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassString_EventInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassString_ListenerInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringString" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringString_sourceClassNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringString_eventNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringString_eventEmpty" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesEmpty" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringString_addListenerMethodNameNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringString_removeListenerMethodNameNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringStringString" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethod" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethod_EventNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethod_EventEmpty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethod_ListenerTypeNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethod_addListenerMethodInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethod_removeListenerMethodInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethodMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodArrayMethodMethodMethod_getListenerMethodInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.ExpressionTest">
+ <hy:exclude id="testConstructor_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NullTarget" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_ArrayTarget" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NullMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NewMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_EmptyMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NullArguments" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NullArgument" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_NullTarget" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_ArrayTarget" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_NullMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_NewMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_EmptyMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_NullArguments" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_NullArgument" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_NullValue" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetValue_UnboundedNormalInstanceMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetValue_UnboundedNullMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetValue_UnboundedOverloadedMethods" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetValue_UnboundedNormalConstructor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetValue_UnboundedOverloadedConstructorsNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetValue_UnboundedAmbitiousStaticMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetValue_UnboundedClassForName" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetValue_UnboundedVoidMethod" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_Value_SetValueCalledIn" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.FeatureDescriptorTest">
+ <hy:exclude id="testSetDisplayName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetValue_ValueNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.IndexedPropertyDescriptorTest">
+ <hy:exclude id="testEquals" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_ReadMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_ReadMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_WriteMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_WriteMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_IndexedR" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_IndexedRNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_IndexedW" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_IndexWNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEquals_PropertyType" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringClass" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringClass_PropertyNameInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringClass_NotIndexedProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringClassStringStringStringString" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedReadMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedRWNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringClassStringStringStringString_RNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_propInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_ReadMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_WriteMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedReadMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedWriteMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_RWNull" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_RWIncompatible" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWIncompatible" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedReadMethod_invalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedReadMethod_null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedReadMethod_RInvalidArgs" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedReadMethod_RInvalidArgType" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedReadMethod_RInvalidReturn" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedWriteMethod_null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedWriteMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedWriteMethod_noargs" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedWriteMethod_badargtype" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedWriteMethod_return" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetIndexedWriteMethod_InvalidIndexType" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.IntrospectionExceptionTest">
+ <hy:exclude id="testSerialization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.IntrospectorTest">
+ <hy:exclude id="testGetBeanInfoClassClass_ClassInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetBeanInfoClassint_IGNORE_IMMEDIATE_Event" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetBeanInfoClassint_IGNORE_ALL_Event" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetBeanInfoSearchPath" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetBeanInfoSearchPath_Default" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntrospection_5" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntrospection_8" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntrospection_9" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntrospection_10" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntrospection_11" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntrospection_13" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBeanInfo_1" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetBeanInfoSearchPath2" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.MethodDescriptorTest">
+ <hy:exclude id="testMethodDescriptorMethod" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMethodDescriptorMethodParameterDescriptorArray" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMethodDescriptorMethodParameterDescriptorArray_PDNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.PersistenceDelegateTest">
+ <hy:exclude id="testWriteObject_NormalMutatesToFalse" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_NullObject" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_NullClass" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_NullInstances" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInitialize_NullEncoder" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMutatesTo_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.PropertyChangeEventTest">
+ <hy:exclude id="testSerializationCompatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.PropertyChangeSupportTest">
+ <hy:exclude id="testAddPropertyChangeListener_PropertyChangeListener_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddPropertyChangeListener_PropertyChangeListener_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddPropertyChangeListener_PropertyChangeListener_String_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddPropertyChangeListener_PropertyChangeListener_String_NullListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddPropertyChangeListener_PropertyChangeListener_String_NullProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddPropertyChangeListener_PropertyChangeListener_String_Duplicate" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener_PropertyChangeListener_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener_PropertyChangeListener_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener_PropertyChangeListener_String_PropertyRegistered" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener_PropertyChangeListener_String_NullListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener_PropertyChangeListener_String_NullProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetPropertyChangeListener_String_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetPropertyChangeListener_String_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testHasListener_PropertyRegistered" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testHasListener_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFirePropertyChange_Object_NullProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFirePropertyChange_Object_NullListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFirePropertyChange_PropertyChangeEvent_NullProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFirePropertyChange_PropertyChangeEvent_NullListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFirePropertyChange_Boolean_NullProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFirePropertyChange_Boolean_NullListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFirePropertyChange_Int_NullProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFirePropertyChange_Int_NullListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerializationCompatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.PropertyDescriptorTest">
+ <hy:exclude id="testPropertyDescriptorStringClass" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringClass_PropertyNameInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringClass_ProtectedGetter" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringClassStringString" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringClassStringString_ReadMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringClassStringString_ReadMethodInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringClassStringString_WriteMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringClassStringString_WriteMethodEmpty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringClassStringString_WriteMethodInvalid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringMethodMethod" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringMethodMethod_ReadMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyDescriptorStringMethodMethod_WriteMethodNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetReadMethod_Invalid_returnVoid" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetBound_true" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetBound_false" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetConstrained_true" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetConstrained_false" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.PropertyEditorManagerTest">
+ <hy:exclude id="testGetEditorSearchPath_default" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetEditorSearchPath_null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBoolEditor_setAsText" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBoolEditor_setAsText_null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBoolEditor_setAsText_Invalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testByteEditor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testByteEditor_null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testByteEditor_invalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testByteEditor_invalid2" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testDoubleEditor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testDoubleEditor_SetAsText_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testDoubleEditor_SetAsText_Invalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFloatEditor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFloatEditor_SetAsText_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFloatEditor_SetAsText_Invalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testLongEditor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testLongEditor_SetAsText_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testLongEditor_SetAsText_Invalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testShortEditor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testShortEditor_SetAsText_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testShortEditor_SetAsText_Invalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntegerEditor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntegerEditor_SetAsText_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIntegerEditor_SetAsText_Invalid" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testStringEditor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testStringEditor_SetAsText_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testStringEditor_SetAsText_SpecialChars" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.PropertyEditorSupportTest">
+ <hy:exclude id="testPropertyEditorSupport" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyEditorSupportObject" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyEditorSupportObject_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddPropertyChangeListener" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddPropertyChangeListener_source_null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddPropertyChangeListener_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener_null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener_diff" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemovePropertyChangeListener_null_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetAsText" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetValue" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetValue_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.PropertyVetoExceptionTest">
+ <hy:exclude id="testSerializablization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.StatementTest">
+ <hy:exclude id="testConstructor_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NullTarget" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_ArrayTarget" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NullMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NewMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_EmptyMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NullArguments" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testConstructor_NullArgument" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_NormalInstanceMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_NullMethodName" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_OverloadedMethods" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_NormalConstructor" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_OverloadedConstructorsNull" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_AmbitiousStaticMethod" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_ClassForName" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_ArrayGet" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_ArrayInvalidSet" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_PrimitiveVSWrapper" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExecute_IntMethodNullParameter" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.VetoableChangeListenerProxyTest">
+ <hy:exclude id="testVetoableChangeListenerProxy" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.VetoableChangeSupportTest">
+ <hy:exclude id="testAddVetoableChangeListenerStringVetoableChangeListener_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddVetoableChangeListenerVetoableChangeListener_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddVetoableChangeListenerVetoableChangeListener_Proxy" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFireVetoableChangePropertyChangeEvent_Veto" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFireVetoableChangePropertyChangeEvent_listener_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFireVetoableChangeStringbooleanboolean_listener_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFireVetoableChangeStringbooleanboolean_listener_null_property" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerStringVetoableChangeListener_property" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerStringVetoableChangeListener_property_more" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerStringVetoableChangeListener_property_diff" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerStringVetoableChangeListener_listener_diff" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerStringVetoableChangeListener_listener_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerStringVetoableChangeListener_propertyName_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerStringVetoableChangeListener_listener_null_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerVetoableChangeListener_all_more_diff" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerVetoableChangeListener_all_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveVetoableChangeListenerVetoableChangeListener_null_null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.XMLDecoderTest">
+ <hy:exclude id="testGetExceptionListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_Integer" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_StringCodec" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_IntArray" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_PropertyDependency" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_NoChange" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_BornFriendChange" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_ManyChanges" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_StaticField" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_Owner" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadObject_Owner_WithWriteStatement" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetExceptionListener_CatchException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testXMLDecoderInputStream" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testXMLDecoderInputStreamObject" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.XMLEncoderTest">
+ <hy:exclude id="testWriteObject_Null" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_Integer" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_StringCodec" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_IntArray" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_PropertyDependency" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_NoChange" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_BornFriendChange" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_ManyChanges" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_ManyChanges_2" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_SetOwner" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_SetOwnerWithWriteStatement" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testWriteObject_StaticField" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFlush" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.beancontext.BeanContextChildSupportTest">
+ <hy:exclude id="testAddPropertyChangeListener_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddVetoableChangeListener_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testServiceAvailable" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testServiceRevoked" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetBeanContext" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetBeanContext_VetoedByListener" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetBeanContext_VetoedByValidateMethod" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_NoPeer" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_WithPeer" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.beancontext.BeanContextMembershipEventTest">
+ <hy:exclude id="testSerialization" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.beancontext.BeanContextServiceAvailableEventTest">
+ <hy:exclude id="testSerialization" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.beancontext.BeanContextServiceRevokedEventTest">
+ <hy:exclude id="testBeanContextServiceRevokedEvent_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBeanContextServiceRevokedEvent" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetSourceAsBeanContextServices" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.beancontext.BeanContextServicesSupportTest">
+ <hy:exclude id="testAddServiceClassBeanContextServiceProvider_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddServiceClassBeanContextServiceProvider_Exist" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddServiceClassBeanContextServiceProviderboolean_FalseParam" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testChildJustRemovedHook" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFireServiceRevokedClassboolean" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetCurrentServiceClasses" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetCurrentServiceSelectors_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetCurrentServiceSelectors_NonExist" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetCurrentServiceSelectors" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetService_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetService_NonChild" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetService_ThisContext" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetService_ParentContext" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testHasService_ParentService" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReleaseBeanContextResources" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReleaseService_WrongChildOrRequestor" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReleaseService" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRevokeService_ChildContext" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.beans.beancontext.BeanContextSupportTest">
+ <hy:exclude id="testAdd_NonBCC" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAdd_BCC" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAdd_BCP" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAdd_Exist" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAdd_Veto" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddAll" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAddBeanContextMembershipListener" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testAvoidingGui_VisibleChild" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBcsChildren" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBcsPreDeserializationHook" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBcsPreSerializationHook" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testChildDeserializedHook" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testContains" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testContainsAll" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testContainsKey" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCopyChildren" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetChildBeanContextChild_Both" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetResource_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetResource_NonChild" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetResource_NotExist" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetResource" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetResourceAsStream_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetResourceAsStream_NonChild" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetResourceAsStream_NotExist" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetResourceAsStream" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInstantiateChild" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIsEmpty" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testIterator" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testNeedsGui_NoVisibleChild" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testNeedsGui_VisibilityChild" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testPropertyChange" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testReadChildren" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveBeanContextMembershipListener" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveObject_NonBCC" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveObject_BCC" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveObject_BCP" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveObject_BCP2" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveObject_NonExist" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveObject_Veto" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testRemoveObjectboolean" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetDesignTime" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetLocale_NullParam" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetLocale" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetLocale_Veto" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testToArray" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testToArrayObjectArray_WrongType" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testToArrayObjectArray_LesserLength" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testToArrayObjectArray_RightLength" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testToArrayObjectArray_GreaterLength" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testVetoableChange" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_NoPeer" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_Peer" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSerialization_Compatibility" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- Crypto module test exclusions -->
+
+
+ <!-- JNDI module test exclusions -->
+
+
+ <!-- Logging module test exclusions -->
+ <hy:type id="org.apache.harmony.logging.tests.java.util.logging.FileHandlerTest">
+ <hy:exclude id="testSecurity" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFileSecurity" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInvalidProperty" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testInvalidParams" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSetOutputStream" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testFileHandlerString" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.logging.tests.java.util.logging.LogManagerTest">
+ <hy:exclude id="testDefaultLoggerProperties" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetProperty" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.logging.tests.java.util.logging.SocketHandlerTest">
+ <hy:exclude id="testPublish_Null" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- LUNI module test exclusions -->
+ <hy:type id="tests.api.java.io.InputStreamReaderTest">
+ <hy:exclude id="test_read" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.io.ObjectInputStreamTest">
+ <hy:exclude id="test_ConstructorLjava_io_InputStream_subtest0" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.io.ObjectOutputStreamTest">
+ <hy:exclude id="test_ConstructorLjava_io_OutputStream_subtest0" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_writeObject_NotSerializable" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.io.OutputStreamWriterTest">
+ <hy:exclude id="testSingleCharIO" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testBlockIO" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_close" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.io.PipedInputStreamTest">
+ <hy:exclude id="test_receive" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.lang.AssertionErrorTest">
+ <hy:exclude id="test_ObjectConstructor" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.lang.ClassTest">
+ <hy:exclude id="test_getResourceLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getResourceAsStreamLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.lang.ProcessTest">
+ <hy:exclude id="test_getOutputStream" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.lang.StringTest">
+ <hy:exclude id="test_concatLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getBytes" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getBytesLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.DatagramSocketTest">
+ <hy:exclude id="test_connectLjava_net_InetAddressI" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.HttpURLConnectionTest">
+ <hy:exclude id="test_getResponseCode" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getResponseMessage" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getHeaderFields" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_usingProxy" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.InetAddressTest">
+ <hy:exclude id="test_getHostName" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_toString" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.JarURLConnectionTest">
+ <hy:exclude id="test_getAttributes" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getJarEntry" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getMainAttributes" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.MulticastSocketTest">
+ <hy:exclude id="test_ConstructorI" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getInterface" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getNetworkInterface" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getTimeToLive" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getTTL" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_joinGroupLjava_net_InetAddress" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_joinGroupLjava_net_SocketAddressLjava_net_NetworkInterface" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_leaveGroupLjava_net_InetAddress" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_leaveGroupLjava_net_SocketAddressLjava_net_NetworkInterface" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_sendLjava_net_DatagramPacketB" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setInterfaceLjava_net_InetAddress" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setNetworkInterfaceLjava_net_NetworkInterface" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setTimeToLiveI" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setTTLB" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setLoopbackModeZ" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setReuseAddressZ" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.ServerSocketTest">
+ <hy:exclude id="test_toString" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.SocketImplTest">
+ <hy:exclude id="test_Constructor" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.SocketTest">
+ <hy:exclude id="test_ConstructorLjava_lang_StringILjava_net_InetAddressI" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.URLClassLoaderTest">
+ <hy:exclude id="test_findResourcesLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_newInstance$Ljava_net_URL" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_findClassLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_findResourceLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.URLConnectionTest">
+ <hy:exclude id="test_getContent" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getContentLength" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getContentType" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getHeaderFieldI" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getHeaderFields" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getHeaderFieldKeyI" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getInputStream" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getOutputStream" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_guessContentTypeFromStreamLjava_io_InputStream" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.net.URLTest">
+ <hy:exclude id="test_ConstructorLjava_lang_StringLjava_lang_StringLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_openStream" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getAuthority" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.util.CalendarTest">
+ <hy:exclude id="test_setII" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.util.LocaleTest">
+ <hy:exclude id="test_toString" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- Math module test exclusions -->
+
+
+ <!-- NIO module test exclusions -->
+
+
+ <!-- NIO_Char module test exclusions -->
+ <hy:type id="tests.api.java.nio.charset.ASCCharsetEncoderTest">
+ <hy:exclude id="testCanEncodeCharSequence" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMultiStepEncode" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEncodeCharBufferException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.CharsetEncoderTest">
+ <hy:exclude id="testEncodeCharBufferException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.CharsetEncoderTest">
+ <hy:exclude id="all" shouldfix="true">
+ <hy:reason>Failure - Exception in constructor</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.CharsetTest">
+ <hy:exclude id="testEncode_CharBuffer_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEncode_String_Normal" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.ConcreteCharsetTest">
+ <hy:exclude id="all" shouldfix="true">
+ <hy:reason>Failure - No public constructor</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.GBCharsetEncoderTest">
+ <hy:exclude id="testEncodeCharBufferException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMultiStepEncode" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.ISOCharsetEncoderTest">
+ <hy:exclude id="testCanEncodeCharSequence" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSpecificDefaultValue" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMultiStepEncode" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEncodeCharBufferException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.UTF16BECharsetEncoderTest">
+ <hy:exclude id="testSpecificDefaultValue" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEncodeCharBufferException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMultiStepEncode" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.UTF16CharsetDecoderTest">
+ <hy:exclude id="testMultiStepDecode" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.UTF16CharsetEncoderTest">
+ <hy:exclude id="testEncodeCharBufferException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMultiStepEncode" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.UTF16LECharsetEncoderTest">
+ <hy:exclude id="testSpecificDefaultValue" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testEncodeCharBufferException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMultiStepEncode" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.nio.charset.UTFCharsetEncoderTest">
+ <hy:exclude id="testEncodeCharBufferException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testMultiStepEncode" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- Prefs module test exclusions -->
+ <hy:type id="org.apache.harmony.prefs.tests.java.util.prefs.AbstractPreferencesTest">
+ <hy:exclude id="testPutByteArray" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExportNode" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testExportSubtree" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.prefs.tests.java.util.prefs.FilePreferencesImplTest">
+ <hy:exclude id="testPutGet" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testChildNodes" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testSecurityException" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.prefs.tests.java.util.prefs.PreferencesTest">
+ <hy:exclude id="testImportPreferences" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- Regex module test exclusions -->
+
+
+ <!-- RMI module test exclusions -->
+
+
+ <!-- Security module test exclusions -->
+ <hy:type id="java.security.serialization.KeyPairTest">
+ <hy:exclude id="testSerialization02" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.AccessControllerTest">
+ <hy:exclude id="test_doPrivilegedLjava_security_PrivilegedAction" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.AlgorithmParameterGeneratorTest">
+ <hy:exclude id="test_initLjava_security_spec_AlgorithmParameterSpec" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_initLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.AlgorithmParametersTest">
+ <hy:exclude id="test_getEncodedLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.KeyStoreTest">
+ <hy:exclude id="test_aliases" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_containsAliasLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getCertificateLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getCertificateAliasLjava_security_cert_Certificate" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getCertificateChainLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getInstanceLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getInstanceLjava_lang_StringLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getKeyLjava_lang_String$C" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getProvider" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getType" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_isCertificateEntryLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_isKeyEntryLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_loadLjava_io_InputStream$C" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setCertificateEntryLjava_lang_StringLjava_security_cert_Certificate" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setKeyEntryLjava_lang_String$B$Ljava_security_cert_Certificate" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setKeyEntryLjava_lang_StringLjava_security_Key$C$Ljava_security_cert_Certificate" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_size" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.PermissionCollectionTest">
+ <hy:exclude id="test_impliesLjava_security_Permission" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.SecureRandomTest">
+ <hy:exclude id="test_getInstanceLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getInstanceLjava_lang_StringLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.SecurityTest">
+ <hy:exclude id="test_addProviderLjava_security_Provider" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getProvidersLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getProvidersLjava_util_Map" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.cert.CertificateFactoryTest">
+ <hy:exclude id="test_generateCertificateLjava_io_InputStream" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.cert.X509CertificateTest">
+ <hy:exclude id="test_getExtensionValueLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.cert.X509CRLEntryTest">
+ <hy:exclude id="test_getExtensionValueLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="tests.api.java.security.cert.X509CRLTest">
+ <hy:exclude id="test_getExtensionValueLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- SQL module test exclusions -->
+ <hy:type id="org.apache.harmony.sql.tests.java.sql.ArrayTest">
+ <hy:exclude id="all" shouldfix="true">
+ <hy:reason>This class contains no test methods</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- Text module test exclusions -->
+ <hy:type id="org.apache.harmony.text.tests.java.text.AttributedCharacterIteratorTest">
+ <hy:exclude id="test_getRunLimitLjava_text_AttributedCharacterIterator$Attribute" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.text.tests.java.text.ChoiceFormatTest">
+ <hy:exclude id="test_toPattern" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.text.tests.java.text.CollationKeyTest">
+ <hy:exclude id="test_toByteArray" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.text.tests.java.text.CollatorTest">
+ <hy:exclude id="test_getAvailableLocales" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getDecomposition" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_setDecompositionI" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.text.tests.java.text.DecimalFormatSymbolsTest">
+ <hy:exclude id="test_RIHarmony_compatible" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.text.tests.java.text.DecimalFormatTest">
+ <hy:exclude id="test_formatDLjava_lang_StringBufferLjava_text_FieldPosition" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_formatJLjava_lang_StringBufferLjava_text_FieldPosition" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_formatToCharacterIteratorLjava_lang_Object" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getCurrency" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_parseLjava_lang_StringLjava_text_ParsePosition" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.text.tests.java.text.MessageFormatTest">
+ <hy:exclude id="test_applyPatternLjava_lang_String" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_formatToCharacterIteratorLjava_lang_Object" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="org.apache.harmony.text.tests.java.text.NumberFormatTest">
+ <hy:exclude id="test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition" shouldfix="true">
+ <hy:reason>Undiagnosed failure</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="test_getCurrency" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+
+ <!-- X-Net module test exclusions -->
+ <hy:type id="javax.net.ServerSocketFactoryTest">
+ <hy:exclude id="testGetDefault" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.net.SocketFactoryTest">
+ <hy:exclude id="testGetDefault" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.net.ssl.DefaultSSLServerSocketFactoryTest">
+ <hy:exclude id="testCreateServerSocketint" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateServerSocketintint" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateServerSocketintintInetAddress" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetDefaultCipherSuites" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetSupportedCipherSuites" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.net.ssl.DefaultSSLSocketFactoryTest">
+ <hy:exclude id="testCreateSocketStringint" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateSocketStringintInetAddressint" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateSocketInetAddressint" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateSocketInetAddressintInetAddressint" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetDefaultCipherSuites" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetSupportedCipherSuites" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testCreateSocketSocketStringintboolean" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.net.ssl.HttpsURLConnectionTest">
+ <hy:exclude id="testGetDefaultHostnameVerifier" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGetHostnameVerifier" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.net.ssl.SSLServerSocketFactoryTest">
+ <hy:exclude id="testGetDefault" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.net.ssl.SSLSocketFactoryTest">
+ <hy:exclude id="testGetDefault" shouldfix="true">
+ <hy:reason>Undiagnosed error</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.net.ssl.serialization.HandshakeCompletedEventTest">
+ <hy:exclude id="testSelf" shouldfix="true">
+ <hy:reason>This test requires a JSSE provider</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGolden" shouldfix="true">
+ <hy:reason>This test requires a JSSE provider</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+ <hy:type id="javax.net.ssl.serialization.SSLSessionBindingEventTest">
+ <hy:exclude id="testSelf" shouldfix="true">
+ <hy:reason>This test requires a JSSE provider</hy:reason>
+ </hy:exclude>
+ <hy:exclude id="testGolden" shouldfix="true">
+ <hy:reason>This test requires a JSSE provider</hy:reason>
+ </hy:exclude>
+ </hy:type>
+
+</hy:suite>
diff --git a/support/src/test/resources/config/localhosttest.ini b/support/src/test/resources/config/localhosttest.ini
new file mode 100644
index 0000000..7fb25da
--- /dev/null
+++ b/support/src/test/resources/config/localhosttest.ini
@@ -0,0 +1,30 @@
+DomainAddress=
+WebName=localhost.
+TestResourcesDir=/testres231
+HomeAddressResponse=HTTP/1.1 200 OK
+HomeAddressSoftware=Jetty(6.0.x)
+ProxyServerTestHost=localhost
+SocksServerTestHost=localhost
+SocksServerTestPort=2080
+UnresolvedIP=192.168.99.99
+InetTestAddress=localhost
+InetTestIP=127.0.0.1
+NonLocalAddressBytes=1.0.0.0
+InetTestAddress2=localhost
+InetTestIP2=127.0.0.1
+InetTestHashcode=2130706433
+SpecialInetTestAddress=localhost
+SpecialInetTestAddressNumber=1
+FTPTestAddress=jcltest:jclpass@localhost
+URLConnectionLastModifiedString=Sat, 07 Jan 2006 13:50:52 GMT
+URLConnectionLastModified=1136641852000
+URLConnectionDate=929092440000
+InetTestIP6=fe80::20d:60ff:fe24:7410
+ResolvedNotExistingHost=9.26.194.72
+InetAlias1=localhost
+InetAlias2=localhost
+IPv6GlobalAddressJcl4=
+
+
+
+
diff --git a/support/src/test/resources/config/testing.policy b/support/src/test/resources/config/testing.policy
new file mode 100644
index 0000000..fe3337a
--- /dev/null
+++ b/support/src/test/resources/config/testing.policy
@@ -0,0 +1,9 @@
+grant {
+ // so we can remove the security manager
+ permission java.lang.RuntimePermission "setSecurityManager";
+
+ permission java.io.SerializablePermission "enableSubclassImplementation";
+
+ permission java.util.PropertyPermission "user.dir", "read";
+ permission java.io.FilePermission "${user.dir}${/}bin${/}tests${/}resources${/}-", "read";
+};
\ No newline at end of file
diff --git a/support/src/test/resources/hyts_Foo.c b/support/src/test/resources/hyts_Foo.c
new file mode 100644
index 0000000..907de59
--- /dev/null
+++ b/support/src/test/resources/hyts_Foo.c
@@ -0,0 +1 @@
+/* Some random file for it to look at. */
\ No newline at end of file
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
index 0897bd7..1d5bb70 100644
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
+++ b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
@@ -31,15 +31,11 @@
/**
* Tests for SSLEngine class
- *
+ *
*/
public class SSLEngineTest extends TestCase {
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SSLEngineTest.class);
- }
-
/**
* Test for <code>SSLEngine()</code> constructor Assertion: creates
* SSLEngine object with null host and -1 port
@@ -85,10 +81,10 @@
/**
* Test for <code>wrap(ByteBuffer src, ByteBuffer dst)</code> method
- * Assertions:
- * throws IllegalArgumentException when src or dst is null
+ * Assertions:
+ * throws IllegalArgumentException when src or dst is null
* throws ReadOnlyBufferException when dst is ReadOnly byte buffer
- *
+ *
* Check that implementation behavior follows RI:
* jdk 1.5 does not throw IllegalArgumentException when parameters are null
* and does not throw ReadOnlyBufferException if dst is read only byte buffer
@@ -111,11 +107,11 @@
/**
* Test for <code>wrap(ByteBuffer[] srcs, ByteBuffer dst)</code> method
- *
+ *
* Assertions: throws IllegalArgumentException when srcs or dst is null or
* srcs contains null byte buffer; throws ReadOnlyBufferException when dst
* is read only byte buffer
- *
+ *
* Check that implementation behavior follows RI:
* jdk 1.5 does not throw IllegalArgumentException when dst is null or
* if srcs contains null elements It does not throw ReadOnlyBufferException
@@ -151,7 +147,7 @@
/**
* Test for <code>wrap(ByteBuffer src, ByteBuffer dst)</code> and
* <code>wrap(ByteBuffer[] srcs, ByteBuffer dst)</code> methods
- *
+ *
* Assertion: these methods throw SSLException
*/
public void testWrap03() throws SSLException {
@@ -181,24 +177,24 @@
/**
* Test for <code>wrap(ByteBuffer src, ByteBuffer dst)</code> method
- *
+ *
* Assertion: encodes a buffer data into network data.
- *
+ *
*/
public void testWrap04() throws SSLException {
String host = "new host";
int port = 8080;
ByteBuffer bb = ByteBuffer.allocate(10);
SSLEngine e = new mySSLEngine(host, port);
-
+
SSLEngineResult res = e.wrap(bb, ByteBuffer.allocate(10));
assertEquals(10, res.bytesConsumed());
assertEquals(20, res.bytesProduced());
}
-
+
/**
* Test for <code>wrap(ByteBuffer[] srcs, ByteBuffer dst)</code> method
- *
+ *
* Assertion: encodes datas from buffers into network data.
*/
public void testWrap05() throws SSLException {
@@ -214,14 +210,14 @@
assertEquals(10, res.bytesConsumed());
assertEquals(20, res.bytesProduced());
}
-
+
/**
* Test for <code>unwrap(ByteBuffer src, ByteBuffer dst)</code> method
- *
- * Assertions:
+ *
+ * Assertions:
* throws IllegalArgumentException when src or dst is null
* throws ReadOnlyBufferException when dst is read only byte buffer
- *
+ *
* Check that implementation behavior follows RI:
* jdk 1.5 does not throw IllegalArgumentException when parameters are null
* and does not throw ReadOnlyBufferException if dst is read only byte buffer
@@ -244,11 +240,11 @@
/**
* Test for <code>unwrap(ByteBuffer src, ByteBuffer[] dsts)</code> method
- *
+ *
* Assertions: throws IllegalArgumentException if parameters are null or
* when dsts contains null elements throws ReadOnlyBufferException when dsts
* contains read only elements
- *
+ *
* Check that implementation behavior follows RI:
* jdk 1.5 does not throw IllegalArgumentException when src is null or
* if dsts contains null elements It does not throw ReadOnlyBufferException
@@ -285,7 +281,7 @@
/**
* Test for <code>unwrap(ByteBuffersrc, ByteBuffer dst)</code> and
* <code>unwrap(ByteBuffer src, ByteBuffer[] dsts)</code> methods
- *
+ *
* Assertion: these methods throw SSLException
*/
public void testUnwrap03() throws SSLException {
@@ -310,11 +306,11 @@
assertEquals(1, res.bytesConsumed());
assertEquals(2, res.bytesProduced());
}
-
+
/**
* Test for <code>unwrap(ByteBuffer src, ByteBuffer dst)</code> method
- *
- * Assertion: decodes network data into a data buffer.
+ *
+ * Assertion: decodes network data into a data buffer.
*/
public void testUnwrap04() throws SSLException {
String host = "new host";
@@ -322,15 +318,15 @@
ByteBuffer bb = ByteBuffer.allocate(10);
SSLEngine e = new mySSLEngine(host, port);
SSLEngineResult res = e.unwrap(bb, ByteBuffer.allocate(10));
-
+
assertEquals(1, res.bytesConsumed());
assertEquals(2, res.bytesProduced());
}
-
+
/**
* Test for <code>unwrap(ByteBuffer src, ByteBuffer[] dsts)</code> method
- *
- * Assertion:
+ *
+ * Assertion:
* decode network data into data buffers.
*/
public void testUnwrap05() throws SSLException {
@@ -556,4 +552,4 @@
return super.wrap(src, dst);
}
-}
\ No newline at end of file
+}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.java
index 12a1384..b44e892 100644
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.java
+++ b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLHandshakeExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for SSLHandshakeException seialization
- *
+ *
*/
public class SSLHandshakeExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new SSLHandshakeException(msgs[0]), new SSLHandshakeException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SSLHandshakeExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.java
index 4c5b471..50b55fb 100644
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.java
+++ b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLKeyExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for SSLKeyException serialization
- *
+ *
*/
public class SSLKeyExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new SSLKeyException(msgs[0]), new SSLKeyException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SSLKeyExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.java
index 767e0dc..5b0b2ef 100644
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.java
+++ b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLPeerUnverifiedExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for SSLPeerUnverifiedException serialization
- *
+ *
*/
public class SSLPeerUnverifiedExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new SSLPeerUnverifiedException(msgs[0]), new SSLPeerUnverifiedException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SSLPeerUnverifiedExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.java
index 6f32292..ef17591 100644
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.java
+++ b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/serialization/SSLProtocolExceptionTest.java
@@ -28,7 +28,7 @@
/**
* Test for SSLProtocolException serialization
- *
+ *
*/
public class SSLProtocolExceptionTest extends SerializationTest {
@@ -43,7 +43,4 @@
new SSLProtocolException(msgs[0]), new SSLProtocolException(msgs[1]) };
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(SSLProtocolExceptionTest.class);
- }
-}
\ No newline at end of file
+}
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLEngineImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLEngineImplTest.java
index 79cae39..21a7b08 100644
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLEngineImplTest.java
+++ b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLEngineImplTest.java
@@ -1375,8 +1375,4 @@
return new TestSuite(SSLEngineImplTest.class);
}
- public static void main(String[] args) throws Exception {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImplTest.java
index dcac5dd..03cd1ea 100644
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImplTest.java
+++ b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImplTest.java
@@ -644,8 +644,4 @@
return new TestSuite(SSLServerSocketImplTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFactoriesTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFactoriesTest.java
index cf9ea03..680de3d 100644
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFactoriesTest.java
+++ b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFactoriesTest.java
@@ -461,8 +461,4 @@
return new TestSuite(SSLSocketFactoriesTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFunctionalTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFunctionalTest.java
index 3bafdfb..9925ac9 100644
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFunctionalTest.java
+++ b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketFunctionalTest.java
@@ -357,8 +357,4 @@
return new TestSuite(SSLSocketFunctionalTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketImplTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketImplTest.java
index 278dd0f..548a265 100644
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketImplTest.java
+++ b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLSocketImplTest.java
@@ -1153,8 +1153,4 @@
return new TestSuite(SSLSocketImplTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-
diff --git a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLStreamedInputTest.java b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLStreamedInputTest.java
index a86e61f..d8d267d 100644
--- a/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLStreamedInputTest.java
+++ b/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/SSLStreamedInputTest.java
@@ -51,8 +51,4 @@
return new TestSuite(SSLStreamedInputTest.class);
}
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
}
-