You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/03/02 14:15:31 UTC

svn commit: r1296189 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools: ./ AfterSeleniumFailure.java ArchivaSeleniumRunner.java RunAfterSeleniumFailures.java

Author: olamy
Date: Fri Mar  2 13:15:30 2012
New Revision: 1296189

URL: http://svn.apache.org/viewvc?rev=1296189&view=rev
Log:
missed to add tooling class around junit for screenshot capture

Added:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/AfterSeleniumFailure.java   (with props)
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/ArchivaSeleniumRunner.java   (with props)
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/RunAfterSeleniumFailures.java   (with props)

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/AfterSeleniumFailure.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/AfterSeleniumFailure.java?rev=1296189&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/AfterSeleniumFailure.java (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/AfterSeleniumFailure.java Fri Mar  2 13:15:30 2012
@@ -0,0 +1,38 @@
+package org.apache.archiva.web.test.tools;
+/*
+ * 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.
+ */
+
+/**
+ * @author Olivier Lamy
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to mark a method being called after a failure
+ *
+ */
+@Retention( RetentionPolicy.RUNTIME)
+@Target( ElementType.METHOD)
+public @interface AfterSeleniumFailure
+{
+}

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/AfterSeleniumFailure.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/AfterSeleniumFailure.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/ArchivaSeleniumRunner.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/ArchivaSeleniumRunner.java?rev=1296189&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/ArchivaSeleniumRunner.java (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/ArchivaSeleniumRunner.java Fri Mar  2 13:15:30 2012
@@ -0,0 +1,60 @@
+package org.apache.archiva.web.test.tools;
+/*
+ * 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.
+ */
+
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ArchivaSeleniumRunner
+    extends BlockJUnit4ClassRunner
+{
+
+    /**
+     * @param clazz Test class
+     * @throws InitializationError if the test class is malformed.
+     */
+    public ArchivaSeleniumRunner( Class<?> clazz )
+        throws InitializationError
+    {
+        super( clazz );
+    }
+
+    /*
+     * FIXME move that to a Rule.
+     */
+    @Override
+    protected Statement withAfters( FrameworkMethod method, Object target, Statement statement )
+    {
+        statement = super.withAfters( method, target, statement );
+        return withAfterFailures( method, target, statement );
+    }
+
+    protected Statement withAfterFailures( FrameworkMethod method, Object target, Statement statement )
+    {
+        List<FrameworkMethod> failures = getTestClass().getAnnotatedMethods( AfterSeleniumFailure.class );
+        return new RunAfterSeleniumFailures( statement, failures, target );
+    }
+}

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/ArchivaSeleniumRunner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/ArchivaSeleniumRunner.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/RunAfterSeleniumFailures.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/RunAfterSeleniumFailures.java?rev=1296189&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/RunAfterSeleniumFailures.java (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/RunAfterSeleniumFailures.java Fri Mar  2 13:15:30 2012
@@ -0,0 +1,85 @@
+package org.apache.archiva.web.test.tools;
+/*
+ * 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.
+ */
+
+
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.MultipleFailureException;
+import org.junit.runners.model.Statement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class RunAfterSeleniumFailures
+    extends Statement
+{
+
+    private final Statement next;
+
+    private final Object target;
+
+    private final List<FrameworkMethod> afterFailures;
+
+    public RunAfterSeleniumFailures( Statement next, List<FrameworkMethod> afterFailures, Object target )
+    {
+        this.next = next;
+        this.afterFailures = afterFailures;
+        this.target = target;
+    }
+
+    @Override
+    public void evaluate()
+        throws Throwable
+    {
+        List<Throwable> errors = new ArrayList<Throwable>();
+        errors.clear();
+        try
+        {
+            next.evaluate();
+        }
+        catch ( Throwable t )
+        {
+            errors.add( t );
+            for ( FrameworkMethod each : afterFailures )
+            {
+                try
+                {
+                    each.invokeExplosively( target, t );
+                }
+                catch ( Throwable t2 )
+                {
+                    errors.add( t2 );
+                }
+            }
+        }
+        if ( errors.isEmpty() )
+        {
+            return;
+        }
+        if ( errors.size() == 1 )
+        {
+            throw errors.get( 0 );
+        }
+        throw new MultipleFailureException( errors );
+    }
+
+}

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/RunAfterSeleniumFailures.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/tools/RunAfterSeleniumFailures.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision