You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by li...@apache.org on 2007/03/22 07:49:52 UTC
svn commit: r521138 -
/harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/
Author: liangyx
Date: Wed Mar 21 23:49:51 2007
New Revision: 521138
URL: http://svn.apache.org/viewvc?view=rev&rev=521138
Log:
Apply patch for HARMONY-3466([classlib][luni] Add testcases for package java.lang.annotation)
Added:
harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java (with props)
harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java (with props)
harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java (with props)
harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java (with props)
Modified:
harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java
Added: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java?view=auto&rev=521138
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java Wed Mar 21 23:49:51 2007
@@ -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 org.apache.harmony.annotation.tests.java.lang.annotation;
+
+import java.lang.annotation.AnnotationFormatError;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case of java.lang.annotation.AnnotationFormatError
+ */
+public class AnnotationFormatErrorTest extends TestCase {
+ /**
+ * @tests java.lang.annotation.AnnotationFormatError#AnnotationFormatError(String)
+ */
+ @SuppressWarnings("nls")
+ public void test_constructorLjava_lang_String() {
+ AnnotationFormatError e = new AnnotationFormatError("some message");
+ assertEquals("some message", e.getMessage());
+ }
+
+ /**
+ * @tests java.lang.annotation.AnnotationFormatError#AnnotationFormatError(Throwable)
+ */
+ public void test_constructorLjava_lang_Throwable() {
+ IllegalArgumentException iae = new IllegalArgumentException();
+ AnnotationFormatError e = new AnnotationFormatError(iae);
+ assertSame(iae, e.getCause());
+ }
+
+ /**
+ * @tests java.lang.annotation.AnnotationFormatError#AnnotationFormatError(String,Throwable)
+ */
+ @SuppressWarnings("nls")
+ public void test_constructorLjava_lang_StringLjava_lang_Throwable() {
+ IllegalArgumentException iae = new IllegalArgumentException();
+ AnnotationFormatError e = new AnnotationFormatError("some message", iae);
+ assertEquals("some message", e.getMessage());
+ assertSame(iae, e.getCause());
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationFormatErrorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java?view=auto&rev=521138
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java Wed Mar 21 23:49:51 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.java.lang.annotation;
+
+import java.lang.annotation.AnnotationTypeMismatchException;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case of java.lang.annotation.AnnotationTypeMismatchException
+ */
+public class AnnotationTypeMismatchExceptionTest extends TestCase {
+
+ /**
+ * @throws ClassNotFoundException
+ * @throws SecurityException
+ * @tests java.lang.annotation.AnnotationTypeMismatchException#AnnotationTypeMismatchException(Method,
+ * String)
+ */
+ @SuppressWarnings("nls")
+ public void test_constructorLjava_lang_reflect_MethodLjava_lang_String() throws SecurityException, ClassNotFoundException {
+ Method[] methods = Class.forName("java.lang.String").getMethods();
+ Method m = methods[0];
+ AnnotationTypeMismatchException e = new AnnotationTypeMismatchException(
+ m, "some type");
+ assertNotNull("can not instanciate AnnotationTypeMismatchException", e);
+ assertSame("wrong method name", m, e.element());
+ assertEquals("wrong found type", "some type", e.foundType());
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/AnnotationTypeMismatchExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java?view=auto&rev=521138
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java Wed Mar 21 23:49:51 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.java.lang.annotation;
+
+import java.lang.annotation.ElementType;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case of java.lang.annotation.ElementType
+ */
+public class ElementTypeTest extends TestCase {
+
+ /**
+ * @throws Exception
+ * @tests java.lang.annotation.ElementType#valueOf(String)
+ */
+ @SuppressWarnings("nls")
+ public void test_valueOfLjava_lang_String() throws Exception {
+ assertSame(ElementType.ANNOTATION_TYPE, ElementType
+ .valueOf("ANNOTATION_TYPE"));
+ assertSame(ElementType.CONSTRUCTOR, ElementType.valueOf("CONSTRUCTOR"));
+ assertSame(ElementType.FIELD, ElementType.valueOf("FIELD"));
+ assertSame(ElementType.LOCAL_VARIABLE, ElementType
+ .valueOf("LOCAL_VARIABLE"));
+ assertSame(ElementType.METHOD, ElementType.valueOf("METHOD"));
+ assertSame(ElementType.PACKAGE, ElementType.valueOf("PACKAGE"));
+ assertSame(ElementType.PARAMETER, ElementType.valueOf("PARAMETER"));
+ assertSame(ElementType.TYPE, ElementType.valueOf("TYPE"));
+ try {
+ ElementType.valueOf("OTHER");
+ fail("Should throw an IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @throws Exception
+ * @tests java.lang.annotation.ElementType#values()
+ */
+ @SuppressWarnings("nls")
+ public void test_values() throws Exception {
+ ElementType[] values = ElementType.values();
+ assertTrue(values.length > 1);
+ Arrays.sort(values);
+ assertTrue(Arrays.binarySearch(values, ElementType.METHOD) >= 0);
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/ElementTypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java?view=diff&rev=521138&r1=521137&r2=521138
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/IncompleteAnnotationExceptionTest.java Wed Mar 21 23:49:51 2007
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.harmony.annotation.tests.java.lang.annotation;
import java.lang.annotation.IncompleteAnnotationException;
@@ -36,5 +37,22 @@
} catch (NullPointerException e) {
// Expected
}
+ }
+
+ /**
+ * @throws Exception
+ * @tests java.lang.annotation.IncompleteAnnotationException#IncompleteAnnotationException(Class,
+ * String)
+ */
+ @SuppressWarnings("nls")
+ public void test_constructorLjava_lang_Class_Ljava_lang_String()
+ throws Exception {
+ Class clazz = String.class;
+ String elementName = "some element";
+ IncompleteAnnotationException e = new IncompleteAnnotationException(
+ clazz, elementName);
+ assertNotNull("can not instanciate IncompleteAnnotationException", e);
+ assertSame("wrong annotation type", clazz, e.annotationType());
+ assertSame("wrong element name", elementName, e.elementName());
}
}
Added: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java?view=auto&rev=521138
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java Wed Mar 21 23:49:51 2007
@@ -0,0 +1,60 @@
+/*
+ * 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.java.lang.annotation;
+
+import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case of java.lang.annotation.RetentionPolicy
+ */
+public class RetentionPolicyTest extends TestCase {
+ /**
+ * @throws Exception
+ * @tests java.lang.annotation.RetentionPolicy#valueOf(String)
+ */
+ @SuppressWarnings("nls")
+ public void test_valueOfLjava_lang_String() throws Exception {
+ assertSame(RetentionPolicy.CLASS, RetentionPolicy
+ .valueOf("CLASS"));
+ assertSame(RetentionPolicy.RUNTIME, RetentionPolicy
+ .valueOf("RUNTIME"));
+ assertSame(RetentionPolicy.SOURCE, RetentionPolicy
+ .valueOf("SOURCE"));
+ try {
+ RetentionPolicy.valueOf("OTHER");
+ fail("Should throw an IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @throws Exception
+ * @tests java.lang.annotation.RetentionPolicy#values()
+ */
+ @SuppressWarnings("nls")
+ public void test_values() throws Exception {
+ RetentionPolicy[] values = RetentionPolicy.values();
+ assertTrue(values.length > 1);
+ Arrays.sort(values);
+ assertTrue(Arrays.binarySearch(values, RetentionPolicy.RUNTIME) >= 0);
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/annotation/src/test/java/org/apache/harmony/annotation/tests/java/lang/annotation/RetentionPolicyTest.java
------------------------------------------------------------------------------
svn:eol-style = native