harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r417920 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni: ./ src/main/java/java/lang/ src/test/api/ src/test/api/java/ src/test/api/java/org/ src/test/api/java/org/apache/ src/test/api/java/org/apache/harmony/ src/test/api/java/...
Date Thu, 29 Jun 2006 01:54:17 GMT
Author: ndbeyer
Date: Wed Jun 28 18:54:17 2006
New Revision: 417920

URL: http://svn.apache.org/viewvc?rev=417920&view=rev
Log:
Implement AssertionError cause initialization and implement a new test case.

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java
  (with props)
Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AssertionErrorTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/.classpath
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AssertionError.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/.classpath
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/.classpath?rev=417920&r1=417919&r2=417920&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/.classpath (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/.classpath Wed Jun 28 18:54:17
2006
@@ -4,6 +4,7 @@
 	<classpathentry output="bin/main" kind="src" path="src/main/resources"/>
 	<classpathentry output="bin/test" kind="src" path="src/test/java"/>
 	<classpathentry output="bin/test" kind="src" path="src/test/resources"/>
+	<classpathentry output="bin/test" kind="src" path="src/test/api/java"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
 	<classpathentry kind="output" path="bin/main"/>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AssertionError.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AssertionError.java?rev=417920&r1=417919&r2=417920&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AssertionError.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/AssertionError.java
Wed Jun 28 18:54:17 2006
@@ -1,114 +1,128 @@
-/* Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable
+/*
+ * Copyright 2002, 2004 The Apache Software Foundation or its licensors, as
+ * applicable
  * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
  * 
  *     http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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 java.lang;
 
-
 /**
- * Assert statement support
+ * <p>
+ * Indicates that an assertion has failed.
+ * </p>
+ * 
+ * @since 1.4
  */
 public class AssertionError extends Error {
 
     private static final long serialVersionUID = -5013299493970297370L;
 
     /**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public AssertionError() {
-		super();
-	}
-
-	/**
-	 * Constructs a new instance of this class with its message filled in.
-	 * 
-	 * @param detailMessage
-	 *            Object The detail message for the exception.
-	 */
-	public AssertionError(Object detailMessage) {
-		super(String.valueOf(detailMessage));
-	}
-
-	/**
-	 * Constructs a new instance of this class with its message filled in from
-	 * the value of argument.
-	 * 
-	 * @param detailMessage
-	 *            boolean Constructs the detail message from the boolean value
-	 *            of argument.
-	 */
-	public AssertionError(boolean detailMessage) {
-		this(String.valueOf(detailMessage));
-	}
-
-	/**
-	 * Constructs a new instance of this class with its message filled in from
-	 * the value of argument.
-	 * 
-	 * @param detailMessage
-	 *            char Constructs the detail message from the char argument.
-	 */
-	public AssertionError(char detailMessage) {
-		this(String.valueOf(detailMessage));
-	}
-
-	/**
-	 * Constructs a new instance of this class with its message filled in from
-	 * the value of argument.
-	 * 
-	 * @param detailMessage
-	 *            int Constructs the detail message from the value of int
-	 *            argument.
-	 */
-	public AssertionError(int detailMessage) {
-		this(Integer.toString(detailMessage));
-	}
-
-	/**
-	 * Constructs a new instance of this class with its message filled in from
-	 * the value of argument.
-	 * 
-	 * @param detailMessage
-	 *            long Constructs the detail message from the value of long
-	 *            argument.
-	 */
-	public AssertionError(long detailMessage) {
-		this(Long.toString(detailMessage));
-	}
-
-	/**
-	 * Constructs a new instance of this class with its message filled in from
-	 * the value of argument.
-	 * 
-	 * @param detailMessage
-	 *            float Constructs the detail message from the value of float
-	 *            argument.
-	 */
-	public AssertionError(float detailMessage) {
-		this(Float.toString(detailMessage));
-	}
-
-	/**
-	 * Constructs a new instance of this class with its message filled in from
-	 * the value of argument.
-	 * 
-	 * @param detailMessage
-	 *            double Constructs the detail message from the value of double
-	 *            argument.
-	 */
-
-	public AssertionError(double detailMessage) {
-		this(Double.toString(detailMessage));
-	}
+     * <p>
+     * Constructs an instance without a message.
+     * </p>
+     */
+    public AssertionError() {
+        super();
+    }
+
+    /**
+     * <p>
+     * Constructs an instance with a message that is the
+     * {@link String#valueOf(Object)} of the object passed. If the object passed
+     * is an instanceof {@link Throwable}, then it also becomes the cause of
+     * this error.
+     * </p>
+     * 
+     * @param detailMessage The value to be converted into the message and
+     *        optionally the cause.
+     */
+    public AssertionError(Object detailMessage) {
+        super(String.valueOf(detailMessage),
+                (detailMessage instanceof Throwable ? (Throwable) detailMessage
+                        : null));
+    }
+
+    /**
+     * <p>
+     * Constructs an instance with a message that is the
+     * {@link String#valueOf(boolean)} of the boolean passed.
+     * </p>
+     * 
+     * @param detailMessage The value to be converted into the message.
+     */
+    public AssertionError(boolean detailMessage) {
+        this(String.valueOf(detailMessage));
+    }
+
+    /**
+     * <p>
+     * Constructs an instance with a message that is the
+     * {@link String#valueOf(char)} of the char passed.
+     * </p>
+     * 
+     * @param detailMessage The value to be converted into the message.
+     */
+    public AssertionError(char detailMessage) {
+        this(String.valueOf(detailMessage));
+    }
+
+    /**
+     * <p>
+     * Constructs an instance with a message that is the
+     * {@link String#valueOf(int)} of the int passed.
+     * </p>
+     * 
+     * @param detailMessage The value to be converted into the message.
+     */
+    public AssertionError(int detailMessage) {
+        this(Integer.toString(detailMessage));
+    }
+
+    /**
+     * <p>
+     * Constructs an instance with a message that is the
+     * {@link String#valueOf(long)} of the long passed.
+     * </p>
+     * 
+     * @param detailMessage The value to be converted into the message.
+     */
+    public AssertionError(long detailMessage) {
+        this(Long.toString(detailMessage));
+    }
+
+    /**
+     * <p>
+     * Constructs an instance with a message that is the
+     * {@link String#valueOf(float)} of the float passed.
+     * </p>
+     * 
+     * @param detailMessage The value to be converted into the message.
+     */
+    public AssertionError(float detailMessage) {
+        this(Float.toString(detailMessage));
+    }
+
+    /**
+     * <p>
+     * Constructs an instance with a message that is the
+     * {@link String#valueOf(double)} of the double passed.
+     * </p>
+     * 
+     * @param detailMessage The value to be converted into the message.
+     */
+    public AssertionError(double detailMessage) {
+        this(Double.toString(detailMessage));
+    }
 }

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java?rev=417920&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java
Wed Jun 28 18:54:17 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2002, 2004 The Apache Software Foundation or its licensors, as
+ * applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.harmony.luni.tests.java.lang;
+
+import junit.framework.TestCase;
+
+public class AssertionErrorTest extends TestCase {
+
+    public void test_Constructor() {
+        AssertionError e = new AssertionError();
+        assertNull(e.getMessage());
+        assertNull(e.getCause());
+    }
+
+    public void test_ConstructorObject() {
+        Object obj = "toString";
+        AssertionError e = new AssertionError(obj);
+        assertEquals("toString", e.getMessage());
+        assertNull(e.getCause());
+        
+        NullPointerException npe = new NullPointerException("null value");
+        e = new AssertionError(npe);
+        assertEquals(npe.toString(), e.getMessage());
+        assertSame(npe, e.getCause());
+    }
+
+    public void test_ConstructorBoolean() {
+        AssertionError e = new AssertionError(true);
+        assertEquals("true", e.getMessage());
+        assertNull(e.getCause());
+    }
+
+    public void test_ConstructorChar() {
+        AssertionError e = new AssertionError('a');
+        assertEquals("a", e.getMessage());
+        assertNull(e.getCause());
+    }
+
+    public void test_ConstructorInt() {
+        AssertionError e = new AssertionError(1);
+        assertEquals("1", e.getMessage());
+        assertNull(e.getCause());
+    }
+
+    public void test_ConstructorLong() {
+        AssertionError e = new AssertionError(1L);
+        assertEquals("1", e.getMessage());
+        assertNull(e.getCause());
+    }
+
+    public void test_ConstructorFloat() {
+        AssertionError e = new AssertionError(1.0F);
+        assertEquals("1.0", e.getMessage());
+        assertNull(e.getCause());
+    }
+
+    public void test_ConstructorDouble() {
+        AssertionError e = new AssertionError(1.0D);
+        assertEquals("1.0", e.getMessage());
+        assertNull(e.getCause());
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/java/org/apache/harmony/luni/tests/java/lang/AssertionErrorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java?rev=417920&r1=417919&r2=417920&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java
Wed Jun 28 18:54:17 2006
@@ -33,7 +33,6 @@
 		suite.addTestSuite(ArithmeticExceptionTest.class);
 		suite.addTestSuite(ArrayIndexOutOfBoundsExceptionTest.class);
 		suite.addTestSuite(ArrayStoreExceptionTest.class);
-		suite.addTestSuite(AssertionErrorTest.class);
 		suite.addTestSuite(BooleanTest.class);
 		suite.addTestSuite(ByteTest.class);
 		suite.addTestSuite(CharacterTest.class);



Mime
View raw message