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/20 23:42:22 UTC

svn commit: r509784 - in /myfaces/core/branches/jsf12/api/src/test/java: javax/faces/application/ApplicationTest.java org/apache/myfaces/ExceptionTestCase.java

Author: mbr
Date: Tue Feb 20 14:42:21 2007
New Revision: 509784

URL: http://svn.apache.org/viewvc?view=rev&rev=509784
Log:
tests added

Added:
    myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java   (with props)
    myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/ExceptionTestCase.java   (with props)

Added: 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=auto&rev=509784
==============================================================================
--- myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java (added)
+++ myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java Tue Feb 20 14:42:21 2007
@@ -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 javax.faces.application;
+
+import org.apache.myfaces.ExceptionTestCase;
+
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.NoOp;
+
+import javax.el.ValueExpression;
+
+/**
+ * Tests for {@link Application}
+ * 
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class ApplicationTest extends ExceptionTestCase
+{
+    private Application app;
+
+    protected void setUp() throws Exception
+    {
+        app = (Application) Enhancer.create(Application.class, NoOp.INSTANCE);
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#addELResolver(javax.el.ELResolver)}.
+     */
+    public void testAddELResolver()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.addELResolver(null);
+            }
+        });
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#getELResolver()}.
+     */
+    public void testGetELResolver()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.getELResolver();
+            }
+        });
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#getResourceBundle(javax.faces.context.FacesContext, java.lang.String)}.
+     */
+    public void testGetResourceBundle()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.getResourceBundle(null, null);
+            }
+        });
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#createComponent(javax.el.ValueExpression, javax.faces.context.FacesContext, java.lang.String)}.
+     */
+    public void testCreateComponentValueExpressionFacesContextString()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.createComponent((ValueExpression) null, null, null);
+            }
+        });
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#getExpressionFactory()}.
+     */
+    public void testGetExpressionFactory()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.getExpressionFactory();
+            }
+        });
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#addELContextListener(javax.el.ELContextListener)}.
+     */
+    public void testAddELContextListener()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.addELContextListener(null);
+            }
+        });
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#removeELContextListener(javax.el.ELContextListener)}.
+     */
+    public void testRemoveELContextListener()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.removeELContextListener(null);
+            }
+        });
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#getELContextListeners()}.
+     */
+    public void testGetELContextListeners()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.getELContextListeners();
+            }
+        });
+    }
+
+    /**
+     * Test method for
+     * {@link javax.faces.application.Application#evaluateExpressionGet(javax.faces.context.FacesContext, java.lang.String, java.lang.Class)}.
+     */
+    public void testEvaluateExpressionGet()
+    {
+        assertException(UnsupportedOperationException.class, new Runnable()
+        {
+            public void run()
+            {
+                app.evaluateExpressionGet(null, null, null);
+            }
+        });
+    }
+}

Propchange: myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/jsf12/api/src/test/java/javax/faces/application/ApplicationTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: 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/ExceptionTestCase.java?view=auto&rev=509784
==============================================================================
--- myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/ExceptionTestCase.java (added)
+++ myfaces/core/branches/jsf12/api/src/test/java/org/apache/myfaces/ExceptionTestCase.java Tue Feb 20 14:42:21 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.myfaces;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public abstract class ExceptionTestCase extends TestCase
+{
+
+    /**
+     * 
+     */
+    public ExceptionTestCase()
+    {
+        super();
+    }
+
+    protected void assertException(Class<? extends Exception> expected,
+            Runnable testCase)
+    {
+        try
+        {
+            testCase.run();
+            fail(expected + " expected");
+        }
+        catch (Exception e)
+        {
+            if (e.getClass() != expected)
+            {
+                fail("caught exception <" + e + "> does not match expected <"
+                        + expected + ">");
+            }
+        }
+    }
+
+}
\ No newline at end of file

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

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