Author: lfryc(a)redhat.com
Date: 2010-07-30 09:24:55 -0400 (Fri, 30 Jul 2010)
New Revision: 18296
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerConsoleStatusTestListener.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerFailureLoggingTestListener.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerSeleniumLoggingTestListener.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerTestInfo.java
Removed:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/ConsoleStatusTestListener.java
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java
root/tests/metamer/trunk/ftest/pom.xml
Log:
own extension to logging to include test parameters
Modified: root/tests/metamer/trunk/ftest/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/pom.xml 2010-07-30 13:24:03 UTC (rev 18295)
+++ root/tests/metamer/trunk/ftest/pom.xml 2010-07-30 13:24:55 UTC (rev 18296)
@@ -275,7 +275,7 @@
<properties>
<property>
<name>listener</name>
- <value>org.richfaces.tests.metamer.ftest.MatrixConfigurator,org.richfaces.tests.metamer.ftest.ConsoleStatusTestListener,org.jboss.test.selenium.listener.SeleniumLoggingTestListener,org.jboss.test.selenium.listener.FailureLoggingTestListener</value>
+ <value>org.richfaces.tests.metamer.ftest.MatrixConfigurator,org.richfaces.tests.metamer.ftest.MetamerSeleniumLoggingTestListener,org.richfaces.tests.metamer.ftest.MetamerFailureLoggingTestListener,org.richfaces.tests.metamer.ftest.MetamerConsoleStatusTestListener</value>
</property>
</properties>
</configuration>
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/ConsoleStatusTestListener.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/ConsoleStatusTestListener.java 2010-07-30
13:24:03 UTC (rev 18295)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/ConsoleStatusTestListener.java 2010-07-30
13:24:55 UTC (rev 18296)
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * JBoss, Home of Professional Open Source
- * Copyright 2009-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.richfaces.tests.metamer.ftest;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.jboss.test.selenium.utils.testng.TestLoggingUtils;
-import org.testng.ITestResult;
-import org.testng.TestListenerAdapter;
-
-/**
- * This class is used as ITestListener in testNG tests to put test's status to the
console output
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>, <a
href="mailto:pjha@redhat.com">Prabhat Jha</a>, <a
- * href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- *
- */
-public class ConsoleStatusTestListener extends TestListenerAdapter {
-
- @Override
- public void onTestStart(ITestResult result) {
- logStatus(result, true);
- }
-
- @Override
- public void onTestFailure(ITestResult result) {
- logStatus(result, false);
- }
-
- @Override
- public void onTestSkipped(ITestResult result) {
- logStatus(result, false);
- }
-
- @Override
- public void onTestSuccess(ITestResult result) {
- logStatus(result, false);
- }
-
- @Override
- public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
- logStatus(result, false);
- }
-
- /**
- * This method will output method name and status on the standard output
- *
- * @param result
- * from the fine-grained listener's method such as
onTestFailure(ITestResult)
- */
- private void logStatus(ITestResult result, boolean isTestStart) {
- String message = TestLoggingUtils.getTestDescription(result, isTestStart);
-
- Map<Field, Object> configuration = (Map<Field, Object>)
result.getAttribute("matrix-configuration");
- if (!configuration.isEmpty()) {
- message += " {";
- for (Entry<Field, Object> entry : configuration.entrySet()) {
-
- final String name = entry.getKey().getName();
- final Object value = entry.getValue();
-
- if (value != null) {
- message += name + ": " + value + ", ";
- }
- }
- message += "}";
- }
-
- System.out.println(message);
- if (!isTestStart) {
- System.out.println();
- }
- }
-}
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java 2010-07-30
13:24:03 UTC (rev 18295)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java 2010-07-30
13:24:55 UTC (rev 18296)
@@ -54,7 +54,6 @@
import org.testng.IMethodInstance;
import org.testng.IMethodInterceptor;
import org.testng.ITestContext;
-import org.testng.ITestListener;
import org.testng.ITestNGMethod;
import org.testng.ITestResult;
import org.testng.annotations.ITestAnnotation;
@@ -64,12 +63,18 @@
* @version $Revision$
*/
public class MatrixConfigurator extends TestMethodSelector implements
IAnnotationTransformer, IInvokedMethodListener,
- IMethodInterceptor, ITestListener {
+ 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;
- Map<Field, Object> currentConfiguration;
+
+
+ public static Map<Field, Object> getCurrentConfiguration() {
+ return currentConfiguration;
+ }
public List<IMethodInstance> intercept(List<IMethodInstance>
methodInstances, ITestContext context) {
for (IMethodInstance methodInstance : methodInstances) {
@@ -410,34 +415,4 @@
throw new UnsupportedOperationException();
}
}
-
- public void onTestStart(ITestResult result) {
- setCurrentConfigurationToTestResultAttributes(result);
- }
-
- public void onTestSuccess(ITestResult result) {
- setCurrentConfigurationToTestResultAttributes(result);
- }
-
- public void onTestFailure(ITestResult result) {
- setCurrentConfigurationToTestResultAttributes(result);
- }
-
- public void onTestSkipped(ITestResult result) {
- setCurrentConfigurationToTestResultAttributes(result);
- }
-
- public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
- setCurrentConfigurationToTestResultAttributes(result);
- }
-
- private void setCurrentConfigurationToTestResultAttributes(ITestResult result) {
- result.setAttribute("matrix-configuration", currentConfiguration);
- }
-
- public void onStart(ITestContext context) {
- }
-
- public void onFinish(ITestContext context) {
- }
}
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerConsoleStatusTestListener.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerConsoleStatusTestListener.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerConsoleStatusTestListener.java 2010-07-30
13:24:55 UTC (rev 18296)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009-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.richfaces.tests.metamer.ftest;
+
+import org.jboss.test.selenium.listener.ConsoleStatusTestListener;
+import org.testng.ITestResult;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ *
+ */
+public class MetamerConsoleStatusTestListener extends ConsoleStatusTestListener {
+ protected String getMessage(ITestResult result) {
+ String message = super.getMessage(result);
+ return message + " " +
MetamerTestInfo.getConfigurationInfoInParenthesses();
+ }
+}
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerFailureLoggingTestListener.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerFailureLoggingTestListener.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerFailureLoggingTestListener.java 2010-07-30
13:24:55 UTC (rev 18296)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.richfaces.tests.metamer.ftest;
+
+import org.jboss.test.selenium.listener.FailureLoggingTestListener;
+import org.testng.ITestResult;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class MetamerFailureLoggingTestListener extends FailureLoggingTestListener {
+ @Override
+ protected String getFilenameIdentification(ITestResult result) {
+ String testInfo = MetamerTestInfo.getConfigurationInfo();
+ testInfo = testInfo.replaceAll(" ", "");
+ return super.getFilenameIdentification(result) + "-" + testInfo;
+ }
+
+ @Override
+ protected String getSeleniumLogIdentification(ITestResult result) {
+ String id = super.getSeleniumLogIdentification(result);
+ return id + " " +
MetamerTestInfo.getConfigurationInfoInParenthesses();
+ }
+}
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerSeleniumLoggingTestListener.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerSeleniumLoggingTestListener.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerSeleniumLoggingTestListener.java 2010-07-30
13:24:55 UTC (rev 18296)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.richfaces.tests.metamer.ftest;
+
+import org.jboss.test.selenium.listener.SeleniumLoggingTestListener;
+import org.testng.ITestResult;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class MetamerSeleniumLoggingTestListener extends SeleniumLoggingTestListener {
+ @Override
+ protected String getMessage(ITestResult result) {
+ String message = super.getMessage(result);
+ return message + " " +
MetamerTestInfo.getConfigurationInfoInParenthesses();
+ }
+}
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerTestInfo.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerTestInfo.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerTestInfo.java 2010-07-30
13:24:55 UTC (rev 18296)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.richfaces.tests.metamer.ftest;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public final class MetamerTestInfo {
+ private MetamerTestInfo() {
+ }
+
+ public static String getConfigurationInfo() {
+ Map<Field, Object> configuration =
MatrixConfigurator.getCurrentConfiguration();
+ StringBuffer info = new StringBuffer();
+ if (!configuration.isEmpty()) {
+ for (Entry<Field, Object> entry : configuration.entrySet()) {
+ final String name = entry.getKey().getName();
+ final Object value = entry.getValue();
+
+ if (value != null) {
+ if (info.length() > 0) {
+ info.append(", ");
+ }
+ info.append(name + ": " + value);
+ }
+ }
+ }
+
+ return info.toString();
+ }
+
+ public static String getConfigurationInfoInParenthesses() {
+ return "{ " + getConfigurationInfo() + " }";
+ }
+}