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/26 16:46:35 UTC
svn commit: r511863 - in /myfaces/core/branches/jsf12/api/src/test/java:
javax/faces/application/ApplicationTest.java org/apache/myfaces/Assert.java
org/apache/myfaces/ExceptionTestCase.java org/apache/myfaces/TestRunner.java
Author: mbr
Date: Mon Feb 26 07:46:34 2007
New Revision: 511863
URL: http://svn.apache.org/viewvc?view=rev&rev=511863
Log:
Assert now supports checked exceptions
Added:
myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/Assert.java (contents, props changed)
- copied, changed from r511752, myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/ExceptionTestCase.java
myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/TestRunner.java (with props)
Removed:
myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/ExceptionTestCase.java
Modified:
myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java
Modified: myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java?view=diff&rev=511863&r1=511862&r2=511863
==============================================================================
--- myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java (original)
+++ myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java Mon Feb 26 07:46:34 2007
@@ -18,20 +18,23 @@
*/
package javax.faces.application;
-import org.apache.myfaces.ExceptionTestCase;
-
+import static org.apache.myfaces.Assert.assertException;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.NoOp;
+import org.apache.myfaces.TestRunner;
+
import javax.el.ValueExpression;
+import junit.framework.TestCase;
+
/**
* Tests for {@link Application}
*
* @author Mathias Broekelmann (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class ApplicationTest extends ExceptionTestCase
+public class ApplicationTest extends TestCase
{
private Application app;
@@ -41,12 +44,11 @@
}
/**
- * Test method for
- * {@link javax.faces.application.Application#addELResolver(javax.el.ELResolver)}.
+ * Test method for {@link javax.faces.application.Application#addELResolver(javax.el.ELResolver)}.
*/
public void testAddELResolver()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
@@ -56,12 +58,11 @@
}
/**
- * Test method for
- * {@link javax.faces.application.Application#getELResolver()}.
+ * Test method for {@link javax.faces.application.Application#getELResolver()}.
*/
public void testGetELResolver()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
@@ -76,7 +77,7 @@
*/
public void testGetResourceBundle()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
@@ -91,7 +92,7 @@
*/
public void testCreateComponentValueExpressionFacesContextString()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
@@ -101,12 +102,11 @@
}
/**
- * Test method for
- * {@link javax.faces.application.Application#getExpressionFactory()}.
+ * Test method for {@link javax.faces.application.Application#getExpressionFactory()}.
*/
public void testGetExpressionFactory()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
@@ -116,12 +116,11 @@
}
/**
- * Test method for
- * {@link javax.faces.application.Application#addELContextListener(javax.el.ELContextListener)}.
+ * Test method for {@link javax.faces.application.Application#addELContextListener(javax.el.ELContextListener)}.
*/
public void testAddELContextListener()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
@@ -131,12 +130,11 @@
}
/**
- * Test method for
- * {@link javax.faces.application.Application#removeELContextListener(javax.el.ELContextListener)}.
+ * Test method for {@link javax.faces.application.Application#removeELContextListener(javax.el.ELContextListener)}.
*/
public void testRemoveELContextListener()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
@@ -146,12 +144,11 @@
}
/**
- * Test method for
- * {@link javax.faces.application.Application#getELContextListeners()}.
+ * Test method for {@link javax.faces.application.Application#getELContextListeners()}.
*/
public void testGetELContextListeners()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
@@ -166,7 +163,7 @@
*/
public void testEvaluateExpressionGet()
{
- assertException(UnsupportedOperationException.class, new Runnable()
+ assertException(UnsupportedOperationException.class, new TestRunner()
{
public void run()
{
Copied: myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/Assert.java (from r511752, myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/ExceptionTestCase.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/Assert.java?view=diff&rev=511863&p1=myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/ExceptionTestCase.java&r1=511752&p2=myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/Assert.java&r2=511863
==============================================================================
--- myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/ExceptionTestCase.java (original)
+++ myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/Assert.java Mon Feb 26 07:46:34 2007
@@ -18,37 +18,42 @@
*/
package org.apache.myfaces;
-import junit.framework.TestCase;
-
/**
+ * Provides various assert calls which can be used for tests.
+ *
* @author Mathias Broekelmann (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public abstract class ExceptionTestCase extends TestCase
+public class Assert
{
+ protected Assert()
+ {
+ }
/**
+ * Asserts that the execution of the {@link TestRunner#run()} method will throw the <code>expected</code>
+ * exception
*
+ * @param expected
+ * the expected Exception
+ * @param testCase
+ * the testcase to run
*/
- public ExceptionTestCase()
- {
- super();
- }
-
- protected void assertException(Class<? extends Exception> expected,
- Runnable testCase)
+ public static void assertException(Class<? extends Throwable> expected, TestRunner testCase)
{
+ junit.framework.Assert.assertNotNull(expected);
+ junit.framework.Assert.assertNotNull(testCase);
try
{
testCase.run();
- fail(expected + " expected");
+ junit.framework.Assert.fail(expected + " expected");
}
- catch (Exception e)
+ catch (Throwable e)
{
- if (e.getClass() != expected)
+ if (!expected.isAssignableFrom(e.getClass()))
{
- fail("caught exception <" + e + "> does not match expected <"
- + expected + ">");
+ junit.framework.Assert.fail("caught exception <" + e.getClass() + "> does not match expected <"
+ + expected + ">: " + e.getMessage());
}
}
}
Propchange: myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/Assert.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/Assert.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/TestRunner.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/TestRunner.java?view=auto&rev=511863
==============================================================================
--- myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/TestRunner.java (added)
+++ myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/TestRunner.java Mon Feb 26 07:46:34 2007
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Implement a testcase which might throw an exception
+ *
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public interface TestRunner {
+ void run() throws Throwable;
+}
Propchange: myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/TestRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/TestRunner.java
------------------------------------------------------------------------------
svn:keywords = URL Author Revision Date