You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/12/29 02:26:54 UTC

svn commit: r1053501 - /myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/SimplePageInteraction.java

Author: gpetracek
Date: Wed Dec 29 01:26:54 2010
New Revision: 1053501

URL: http://svn.apache.org/viewvc?rev=1053501&view=rev
Log:
check the correct usage

Modified:
    myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/SimplePageInteraction.java

Modified: myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/SimplePageInteraction.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/SimplePageInteraction.java?rev=1053501&r1=1053500&r2=1053501&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/SimplePageInteraction.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/SimplePageInteraction.java Wed Dec 29 01:26:54 2010
@@ -25,18 +25,25 @@ import com.gargoylesoftware.htmlunit.htm
 import com.gargoylesoftware.htmlunit.html.HtmlPage;
 import org.apache.http.conn.HttpHostConnectException;
 import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewConfigCache;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewConfigExtension;
+import org.apache.myfaces.extensions.cdi.test.junit4.AbstractJsfAwareTest;
 
+import javax.enterprise.inject.Typed;
 import java.io.IOException;
+import java.util.logging.Logger;
 
 import static org.junit.Assert.*;
 
 /**
  * @author Gerhard Petracek
  */
+@Typed()
 public class SimplePageInteraction
 {
+    private static final Logger LOGGER = Logger.getLogger(SimplePageInteraction.class.getName());
+
     private WebClient webClient;
 
     private String baseURL;
@@ -58,6 +65,7 @@ public class SimplePageInteraction
 
     public SimplePageInteraction with(Class<? extends ViewConfig> pageDefinition)
     {
+        checkUsage();
         new ViewConfigExtension()
         {
             @Override
@@ -69,6 +77,32 @@ public class SimplePageInteraction
         return this;
     }
 
+    protected void checkUsage()
+    {
+        @SuppressWarnings({"ThrowableInstanceNeverThrown"})
+        RuntimeException runtimeException = new RuntimeException();
+
+        StackTraceElement[] stackTrace = runtimeException.getStackTrace();
+
+        Class currentClass;
+        for(StackTraceElement element : stackTrace)
+        {
+            currentClass = ClassUtils.tryToLoadClassForName(element.getClassName());
+            if(currentClass == null)
+            {
+                continue;
+            }
+
+            if(AbstractJsfAwareTest.class.isAssignableFrom(currentClass) &&
+                    !AbstractSimpleCargoTest.class.isAssignableFrom(currentClass))
+            {
+                LOGGER.warning(getClass().getName() + "#with is only required for tests which extend " +
+                    AbstractSimpleCargoTest.class.getName() + ". It's used with " + element.getClassName());
+                return;
+            }
+        }
+    }
+
     public SimplePageInteraction start(Class<? extends ViewConfig> pageDefinition)
     {
         this.currentPage = getPage(pageDefinition);