You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mb...@apache.org on 2007/02/25 14:02:33 UTC

svn commit: r511496 - in /myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test: AssertThrowables.java TestRunnable.java

Author: mbr
Date: Sun Feb 25 05:02:32 2007
New Revision: 511496

URL: http://svn.apache.org/viewvc?view=rev&rev=511496
Log:
Support classes to test exceptions

Added:
    myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/AssertThrowables.java   (with props)
    myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/TestRunnable.java   (with props)

Added: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/AssertThrowables.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/AssertThrowables.java?view=auto&rev=511496
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/AssertThrowables.java (added)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/AssertThrowables.java Sun Feb 25 05:02:32 2007
@@ -0,0 +1,63 @@
+/*
+ * 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.myfaces.test;
+
+import static junit.framework.Assert.fail;
+
+/**
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class AssertThrowables
+{
+    public static void assertThrowable(Class<? extends Throwable> expected,
+            TestRunnable test)
+    {
+        try
+        {
+            test.run();
+            fail("expected exception: " + expected);
+        }
+        catch (Throwable e)
+        {
+            if (!expected.isAssignableFrom(e.getClass()))
+            {
+                fail("expected exception: " + expected + " but got "
+                        + e.getClass());
+            }
+        }
+    }
+
+    public static void assertThrowable(String message,
+            Class<? extends Throwable> expected, TestRunnable test)
+    {
+        try
+        {
+            test.run();
+            fail(message);
+        }
+        catch (Throwable e)
+        {
+            if (!expected.isAssignableFrom(e.getClass()))
+            {
+                fail(message);
+            }
+        }
+    }
+}

Propchange: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/AssertThrowables.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/AssertThrowables.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/TestRunnable.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/TestRunnable.java?view=auto&rev=511496
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/TestRunnable.java (added)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/TestRunnable.java Sun Feb 25 05:02:32 2007
@@ -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 org.apache.myfaces.test;
+
+/**
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public interface TestRunnable
+{
+    void run() throws Throwable;
+}

Propchange: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/TestRunnable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/test/TestRunnable.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL