[seam-commits] Seam SVN: r13126 - in modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam: exceptionhandling and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Jun 11 12:54:53 EDT 2010


Author: lightguard
Date: 2010-06-11 12:54:52 -0400 (Fri, 11 Jun 2010)
New Revision: 13126

Added:
   modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/
   modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java
   modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java
Log:
First test, it doesn't work though.

Added: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java	2010-06-11 16:54:52 UTC (rev 13126)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.faces.environment.FacesContextProducer;
+import org.jboss.seam.faces.environment.MockFacesContext;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.*;
+
+import javax.enterprise.inject.Instance;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+
+ at RunWith(Arquillian.class)
+public class ExceptionHandlerTest
+{
+   @Deployment
+   public static Archive<?> createTestArchive()
+   {
+      return ShrinkWrap.create("test.jar", JavaArchive.class)
+         .addClass(FacesContextProducer.class)
+         .addClass(UnsupportedOperationExceptionHandler.class)
+         .addManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml"));
+   }
+
+   @Inject
+   private Instance<FacesContext> facesContextInstance;
+
+   @Inject
+   private UnsupportedOperationExceptionHandler handler;
+
+   @Test
+   public void testHandlerIsCalled()
+   {
+      new MockFacesContext().set();
+      
+      this.facesContextInstance.get().getApplication();
+
+      assertTrue(this.handler.isHandleCalled());
+   }
+}


Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/ExceptionHandlerTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java	2010-06-11 16:54:52 UTC (rev 13126)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+public class UnsupportedOperationExceptionHandler implements ExceptionHandler<UnsupportedOperationException, FacesState>
+{
+   private boolean handleCalled;
+
+   /**
+    * @return the numeric priority of this handler in relationship to
+    *         other handlers, 1 being top priority
+    */
+   public int getPriority()
+   {
+      return 0;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   /**
+    * Method called to execute logic for an uncaught exception.
+    *
+    * @param chain Chain object used to continue handling chain
+    * @param state container for any useful application state
+    * @param e     uncaught exception
+    */
+   public void handle(HandlerChain chain, FacesState state, UnsupportedOperationException e)
+   {
+      this.handleCalled = true;
+   }
+
+   public boolean isHandleCalled()
+   {
+      return this.handleCalled;
+   }
+}


Property changes on: modules/faces/branches/exception_handling/impl/src/test/java/org/jboss/seam/exceptionhandling/UnsupportedOperationExceptionHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native



More information about the seam-commits mailing list