[richfaces-svn-commits] JBoss Rich Faces SVN: r18898 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Aug 20 20:01:11 EDT 2010


Author: lfryc at redhat.com
Date: 2010-08-20 20:01:10 -0400 (Fri, 20 Aug 2010)
New Revision: 18898

Modified:
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerFailureLoggingTestListener.java
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerTestInfo.java
Log:
modified Metamer specific configuration and utility classes to enable extensions in form of pagespeed tests

Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java	2010-08-20 22:42:08 UTC (rev 18897)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java	2010-08-21 00:01:10 UTC (rev 18898)
@@ -66,13 +66,12 @@
     IMethodInterceptor {
 
     static Map<Field, Object> currentConfiguration;
-    
+
     Map<Class<?>, Map<Method, Configuration>> configurations = new HashMap<Class<?>, Map<Method, Configuration>>();
     LinkedList<Method> methods = new LinkedList<Method>();
     boolean methodConfigured = false;
     Field templatesField = null;
-    
-    
+
     public static Map<Field, Object> getCurrentConfiguration() {
         return currentConfiguration;
     }
@@ -104,9 +103,13 @@
             || m.isAfterSuiteConfiguration() || m.isAfterTestConfiguration();
     }
 
-    private void configureMethod(ITestResult testResult) {
-        Method realMethod = ((Queue<Method>) methods).poll();
+    private Method getCurrentRealMethod() {
+        return ((Queue<Method>) methods).poll();
+    }
 
+    protected void configureMethod(ITestResult testResult) {
+        Method realMethod = getCurrentRealMethod();
+
         if (realMethod == null) {
             throw new IllegalStateException("can't find more configured methods");
         }
@@ -157,8 +160,10 @@
                 if (field.getAnnotation(Use.class) != null) {
                     parameters.put(field, getUseParameter(realClass, field.getType(), field.getAnnotation(Use.class)));
                 } else if (field.getAnnotation(Templates.class) != null) {
-                    parameters.put(field,
-                        getTemplatesParameter(realClass, field.getType(), field.getAnnotation(Templates.class), parameters));
+                    parameters.put(
+                        field,
+                        getTemplatesParameter(realClass, field.getType(), field.getAnnotation(Templates.class),
+                            parameters));
                     templatesField = field;
                 } else {
                     parameters.put(field, null);
@@ -166,7 +171,7 @@
                 }
             }
         }
-        
+
         if (templatesField == null) {
             throw new IllegalStateException("there is no field annotated @Templates in " + realClass.getName());
         }
@@ -181,7 +186,7 @@
         } finally {
             templatesField = null;
         }
-        
+
         if (!unsatisfied.isEmpty()) {
             throw new IllegalStateException("cannot satisfy following injection points: " + unsatisfied.toString());
         }
@@ -222,7 +227,8 @@
             }
             if (annotation.annotationType() == Templates.class) {
                 Templates templatesAnnotation = (Templates) annotation;
-                parameters.put(templatesField, getTemplatesParameter(testClass, templatesField.getType(), templatesAnnotation, parameters));
+                parameters.put(templatesField,
+                    getTemplatesParameter(testClass, templatesField.getType(), templatesAnnotation, parameters));
             }
         }
     }
@@ -286,8 +292,8 @@
             String namePattern = useAnnotation.value()[i];
             namePattern = StringUtils.replace(namePattern, "*", ".+");
             namePattern = StringUtils.replace(namePattern, "?", ".");
-            
-            for (Field field : getAllFields(testClass)) { 
+
+            for (Field field : getAllFields(testClass)) {
                 Pattern pattern = Pattern.compile(namePattern);
                 if (pattern.matcher(field.getName()).matches()) {
                     boolean isArray = field.getType().isArray();
@@ -312,7 +318,8 @@
             if (satisfied) {
                 continue;
             }
-            throw new IllegalStateException("cannot find the field satysfying injection point with name pattern: " + useAnnotation.value()[i]);
+            throw new IllegalStateException("cannot find the field satysfying injection point with name pattern: "
+                + useAnnotation.value()[i]);
         }
         return result;
     }
@@ -362,20 +369,20 @@
         }
 
         List<TemplatesList> templates = null;
-        
+
         // if templates was already set, load them
         if (templatesField != null) {
             templates = (List<TemplatesList>) parameters.get(templatesField);
         }
-        
+
         // get user defined templates
         List<TemplatesList> userTemplates = MetamerProperties.getTemplates();
-        
+
         // if "value" is defined, takes precedens
         if (templatesAnnotation.value().length > 0) {
             templates = MetamerProperties.parseTemplates(templatesAnnotation.value());
         }
-        
+
         // include all "include" to current list
         if (templatesAnnotation.include().length > 0) {
             List<TemplatesList> includeTemplates = MetamerProperties.parseTemplates(templatesAnnotation.include());
@@ -386,7 +393,7 @@
                 templates.addAll(includeTemplates);
             }
         }
-        
+
         // exclude all "exclude" from current list
         if (templatesAnnotation.exclude().length > 0) {
             List<TemplatesList> excludeTemplates = MetamerProperties.parseTemplates(templatesAnnotation.exclude());
@@ -394,7 +401,7 @@
                 templates.removeAll(excludeTemplates);
             }
         }
-        
+
         // remove all templates which wasn't in user defined set
         if (userTemplates != null) {
             if (templates == null) {

Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerFailureLoggingTestListener.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerFailureLoggingTestListener.java	2010-08-20 22:42:08 UTC (rev 18897)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerFailureLoggingTestListener.java	2010-08-21 00:01:10 UTC (rev 18898)
@@ -21,12 +21,7 @@
  *******************************************************************************/
 package org.richfaces.tests.metamer.ftest;
 
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.lang.StringUtils;
 import org.jboss.test.selenium.listener.FailureLoggingTestListener;
-import org.jboss.test.selenium.utils.testng.TestInfo;
 import org.testng.ITestResult;
 
 /**
@@ -36,22 +31,7 @@
 public class MetamerFailureLoggingTestListener extends FailureLoggingTestListener {
     @Override
     protected String getFilenameIdentification(ITestResult result) {
-        String packageName = TestInfo.getContainingPackageName(result);
-        String className = TestInfo.getClassName(result);
-        String methodName = TestInfo.getMethodName(result);
-
-        String testInfo = MetamerTestInfo.getConfigurationInfo();
-        testInfo = StringUtils.replaceChars(testInfo, "\\/*?\"<>|", "");
-        testInfo = StringUtils.replaceChars(testInfo, "\r\n \t", "_");
-        testInfo = StringUtils.replaceChars(testInfo, ":", "-");
-
-        // derives template and sort it as sub-directory after other attributes
-        Matcher matcher = Pattern.compile("^(template-[^;]+);(.*)$").matcher(testInfo);
-        if (matcher.find()) {
-            testInfo = matcher.group(2) + "/" + matcher.group(1);
-        }
-
-        return packageName + "/" + className + "/" + methodName + "/" + testInfo;
+        return MetamerTestInfo.getAssociatedFilename(result);
     }
 
     @Override

Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerTestInfo.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerTestInfo.java	2010-08-20 22:42:08 UTC (rev 18897)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerTestInfo.java	2010-08-21 00:01:10 UTC (rev 18898)
@@ -28,8 +28,12 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.commons.lang.StringUtils;
+import org.jboss.test.selenium.utils.testng.TestInfo;
+import org.testng.ITestResult;
 
 /**
  * @author <a href="mailto:ppitonak at redhat.com">Lukas Fryc</a>
@@ -72,4 +76,23 @@
     public static String getConfigurationInfoInParenthesses() {
         return "{ " + getConfigurationInfo() + " }";
     }
+    
+    public static String getAssociatedFilename(ITestResult result) {
+        String packageName = TestInfo.getContainingPackageName(result);
+        String className = TestInfo.getClassName(result);
+        String methodName = TestInfo.getMethodName(result);
+
+        String testInfo = getConfigurationInfo();
+        testInfo = StringUtils.replaceChars(testInfo, "\\/*?\"<>|", "");
+        testInfo = StringUtils.replaceChars(testInfo, "\r\n \t", "_");
+        testInfo = StringUtils.replaceChars(testInfo, ":", "-");
+
+        // derives template and sort it as sub-directory after other attributes
+        Matcher matcher = Pattern.compile("^(template-[^;]+);(.*)$").matcher(testInfo);
+        if (matcher.find()) {
+            testInfo = matcher.group(2) + "/" + matcher.group(1);
+        }
+
+        return packageName + "/" + className + "/" + methodName + "/" + testInfo;
+    }
 }



More information about the richfaces-svn-commits mailing list