JBoss Rich Faces SVN: r18264 - root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-07-28 13:14:35 -0400 (Wed, 28 Jul 2010)
New Revision: 18264
Modified:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml
Log:
RF-8983
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-07-28 16:14:09 UTC (rev 18263)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-07-28 17:14:35 UTC (rev 18264)
@@ -40,18 +40,18 @@
</cc:interface>
<cc:implementation>
<span id="#{clientId}" class="rf-ins">
- <a class="rf-ins-db" href="javascript:void(0);" />
+ <a class="rf-ins-db" href="#" />
<span class="rf-ins-ta">
<span class="rf-ins-mn">0</span>
<span class="rf-ins-mx">100</span>
<span class="rf-ins-t">
<span class="rf-ins-h" />
- <span class="rf-ins-tt">#{getInputValue(facesContext, component)}</span>
</span>
</span>
- <a class="rf-ins-ib" href="javascript:void(0);" />
+ <a class="rf-ins-ib" href="#" />
<input name="#{clientId}" type="text" class="rf-ins-i" size="3"
value="#{getInputValue(facesContext, component)}" />
+ <span class="rf-ins-tt">#{getInputValue(facesContext, component)}</span>
<script type="text/javascript">new RichFaces.ui.InputNumberSlider('#{clientId}');</script>
</span>
</cc:implementation>
14 years, 5 months
JBoss Rich Faces SVN: r18263 - in root/cdk-sandbox/trunk/dynamic-resources-prerenderer: src and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-28 12:14:09 -0400 (Wed, 28 Jul 2010)
New Revision: 18263
Added:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/src/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/src/main/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/src/main/java/
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/verify.bsh
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java
Removed:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/MarkerResourcesScanner.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java
Log:
Dynamic resources prerenderer: converted to Maven plugin
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml 2010-07-28 16:14:09 UTC (rev 18263)
@@ -2,14 +2,16 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
<groupId>org.richfaces.cdk</groupId>
- <artifactId>dynamic-resources-prerenderer</artifactId>
-
- <!--
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
- -->
- <version>4.0.0-SNAPSHOT</version>
- <name>dynamic-resources-processor</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -25,21 +27,74 @@
<dependencies>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>file-management</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <!-- TODO - review dependencies -->
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-velocity</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.9.5-RC2</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>google-collections</artifactId>
+ <groupId>com.google.collections</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
<dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>2.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.el</groupId>
+ <artifactId>el-ri</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.3-b03</version>
</dependency>
<dependency>
- <groupId>org.richfaces.ui</groupId>
- <artifactId>richfaces-components-ui</artifactId>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
@@ -48,28 +103,6 @@
<artifactId>slf4j-simple</artifactId>
<version>1.5.8</version>
</dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- <version>0.9.5-RC2</version>
- <exclusions>
- <exclusion>
- <artifactId>google-collections</artifactId>
- <groupId>com.google.collections</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>com.sun.el</groupId>
- <artifactId>el-ri</artifactId>
- <version>1.0</version>
- </dependency>
</dependencies>
<build>
@@ -84,4 +117,42 @@
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>it</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <configuration>
+ <debug>true</debug>
+ <projectsDirectory>src/it</projectsDirectory>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <preBuildHookScript>setup</preBuildHookScript>
+ <postBuildHookScript>verify</postBuildHookScript>
+ <!-- localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath -->
+ <!-- settingsFile>src/it/settings.xml</settingsFile -->
+ <goals>
+ <goal>compile</goal>
+ <goal>test</goal>
+ </goals>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml 2010-07-28 16:14:09 UTC (rev 18263)
@@ -0,0 +1,60 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>richfaces-application</artifactId>
+ <name>Test component annotations</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <configuration>
+ </configuration>
+ <executions>
+ <execution>
+ <id>process</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <outputDir>images</outputDir>
+ <skins>
+ <skin>blueSky</skin>
+ <skin>classic</skin>
+ <skin>ruby</skin>
+ <skin>emeraldTown</skin>
+ <skin>wine</skin>
+ </skins>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.2-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-components-ui</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/verify.bsh
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/verify.bsh (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/verify.bsh 2010-07-28 16:14:09 UTC (rev 18263)
@@ -0,0 +1,11 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try {
+} catch(Throwable t) {
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Deleted: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -1,92 +0,0 @@
-/*
- * 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.cdk;
-
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import org.richfaces.cdk.concurrent.CountingExecutorCompletionService;
-import org.richfaces.cdk.faces.FacesImpl;
-import org.richfaces.cdk.naming.FileNameMapperImpl;
-import org.richfaces.cdk.resource.ResourceWriterImpl;
-import org.richfaces.cdk.resource.ResourcesScannerImpl;
-import org.richfaces.cdk.task.ResourceTaskFactoryImpl;
-
-import com.google.common.collect.Lists;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class Main {
-
- private static ExecutorService createExecutorService() {
- return Executors.newSingleThreadExecutor();
- }
-
- public static void main(String[] args) throws Exception {
- String dstDir = args[0];
- ResourceWriterImpl resourceWriter = new ResourceWriterImpl(dstDir);
- ResourceTaskFactory taskFactory = new ResourceTaskFactoryImpl();
- taskFactory.setResourceWriter(resourceWriter);
-
- // TODO set webroot
- Faces faces = new FacesImpl(null, new FileNameMapperImpl(), taskFactory);
- faces.start();
-
- ResourcesScanner resourcesScanner = new ResourcesScannerImpl();
- resourcesScanner.scan();
-
- ExecutorService executorService = createExecutorService();
- CompletionService<Object> completionService = new CountingExecutorCompletionService<Object>(executorService);
- taskFactory.setCompletionService(completionService);
- taskFactory.setSkins(Lists.newArrayList("blueSky", "ruby", "classic"));
- for (ResourceInfo resourceInfo : resourcesScanner.getResources()) {
- taskFactory.submit(resourceInfo);
- }
-
- try {
- Future<Object> future = null;
- while (true) {
- future = completionService.take();
- if (future != null) {
- try {
- future.get();
- } catch (ExecutionException e) {
- // TODO: handle exception
- e.getCause().printStackTrace();
- }
- } else {
- break;
- }
- }
- } finally {
- executorService.shutdown();
- }
-
- faces.stop();
- }
-
-}
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -0,0 +1,171 @@
+/*
+ * 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.cdk;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.richfaces.cdk.concurrent.CountingExecutorCompletionService;
+import org.richfaces.cdk.faces.FacesImpl;
+import org.richfaces.cdk.naming.FileNameMapperImpl;
+import org.richfaces.cdk.resource.ResourceWriterImpl;
+import org.richfaces.cdk.resource.ResourcesScannerImpl;
+import org.richfaces.cdk.task.ResourceTaskFactoryImpl;
+
+/**
+ * @goal process
+ * @requiresDependencyResolution compile
+ * @phase generate-resources
+ */
+public class ProcessMojo extends AbstractMojo {
+
+ /**
+ * @parameter
+ * @required
+ */
+ private String outputDir;
+
+ /**
+ * @parameter
+ * @required
+ */
+ private String[] skins;
+
+ /**
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ private MavenProject project;
+
+ private static ExecutorService createExecutorService() {
+ return Executors.newSingleThreadExecutor();
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ try {
+ List<?> compileClasspathElements = project.getCompileClasspathElements();
+ String outputDirectory = project.getBuild().getOutputDirectory();
+ URL[] urls = new URL[compileClasspathElements.size() + 1];
+ int i = 0;
+
+ urls[i++] = new File(outputDirectory).toURI().toURL();
+
+ for (Iterator<?> iter = compileClasspathElements.iterator(); iter.hasNext(); ) {
+ String element = (String) iter.next();
+
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ if (useCCL) {
+ classLoader = new URLClassLoader(urls, classLoader);
+ } else {
+ classLoader = new URLClassLoader(urls);
+ }
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ } catch (DependencyResolutionRequiredException e) {
+ getLog().error("Dependencies not resolved ", e);
+ }
+
+ return classLoader;
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ ClassLoader cCL = Thread.currentThread().getContextClassLoader();
+ Faces faces = null;
+ ExecutorService executorService = null;
+
+ try {
+ ClassLoader projectCL = createProjectClassLoader(project, true);
+ Thread.currentThread().setContextClassLoader(projectCL);
+
+ File outputDirFile = new File(outputDir);
+ if (!outputDirFile.exists()) {
+ outputDirFile = new File(project.getBuild().getOutputDirectory(), outputDir);
+ }
+
+ ResourceWriterImpl resourceWriter = new ResourceWriterImpl(outputDirFile);
+ ResourceTaskFactoryImpl taskFactory = new ResourceTaskFactoryImpl();
+ taskFactory.setResourceWriter(resourceWriter);
+
+ // TODO set webroot
+ faces = new FacesImpl(null, new FileNameMapperImpl(), taskFactory);
+ faces.start();
+
+ ResourcesScanner resourcesScanner = new ResourcesScannerImpl();
+ resourcesScanner.scan();
+
+ executorService = createExecutorService();
+ CompletionService<Object> completionService = new CountingExecutorCompletionService<Object>(executorService);
+ taskFactory.setCompletionService(completionService);
+ taskFactory.setSkins(skins);
+ taskFactory.setLog(getLog());
+ for (ResourceInfo resourceInfo : resourcesScanner.getResources()) {
+ taskFactory.submit(resourceInfo);
+ }
+
+ Future<Object> future = null;
+ while (true) {
+ future = completionService.take();
+ if (future != null) {
+ try {
+ future.get();
+ } catch (ExecutionException e) {
+ // TODO: handle exception
+ e.getCause().printStackTrace();
+ }
+ } else {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ } finally {
+ //TODO review finally block
+ if (executorService != null) {
+ executorService.shutdown();
+ }
+ if (faces != null) {
+ faces.stop();
+ }
+ Thread.currentThread().setContextClassLoader(cCL);
+ }
+ }
+
+}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -21,7 +21,6 @@
*/
package org.richfaces.cdk;
-import java.util.Collection;
import java.util.concurrent.CompletionService;
/**
@@ -30,7 +29,7 @@
*/
public interface ResourceTaskFactory {
- public void setSkins(Collection<String> skins);
+ public void setSkins(String[] skins);
public void setCompletionService(CompletionService<Object> completionService);
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -295,12 +295,13 @@
if (root.exists()) {
String[] list = root.list();
for (String childName : list) {
- File child = new File(root, childName);
+ String name = childName;
+ File child = new File(root, name);
if (child.isDirectory()) {
- childName += '/';
+ name += '/';
}
- result.add(path + '/' + childName);
+ result.add(path + '/' + name);
}
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -31,6 +31,8 @@
*/
public abstract class ReadOnlyValueExpression extends ValueExpression {
+ private static final long serialVersionUID = 7424302517400727467L;
+
@Override
public abstract Object getValue(ELContext context);
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -40,7 +40,6 @@
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
-import com.sun.faces.util.Util;
/**
* @author Nick Belaevski
@@ -102,7 +101,7 @@
if (!prop.contains(":")) {
resource = handler.createResource(prop);
} else {
- String[] parts = Util.split(prop, ":");
+ String[] parts = prop.split(":");
if (parts.length != 2) {
throw new ELException(MessageFormat.format("Invalid resource format. Property {0} contains more than one colon (:)", prop));
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -113,6 +113,7 @@
result.setResourceName(resourceName);
result.setLibraryName(libraryName);
+ //TODO simply discover & process all available resources
ResourceTaskFactory resourceTaskFactory = ServiceTracker.getService(ResourceTaskFactory.class);
resourceTaskFactory.submit(new ResourceInfo(resourceName, libraryName));
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/MarkerResourcesScanner.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/MarkerResourcesScanner.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/MarkerResourcesScanner.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -32,11 +32,11 @@
*/
public class MarkerResourcesScanner extends AbstractScanner {
+ static final String STORE_KEY = "org.richfaces.cdk.dynamicResourceNames";
+
private static final String RESOURCE_PROPERTIES_EXT = ".resource.properties";
private static final String META_INF = "META-INF/";
-
- static final String STORE_KEY = "org.richfaces.cdk.dynamicResourceNames";
@Override
public void scan(Object cls) {
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -48,12 +48,12 @@
private static final Predicate<String> ECSS_RESOURCE_PREDICATE = new Predicate<String>() {
- private final Pattern PATH_PATTERN = Pattern.compile(MessageFormat.format("^{0}.+\\.ecss$",
+ private final Pattern pathPattern = Pattern.compile(MessageFormat.format("^{0}.+\\.ecss$",
ResourceInfo.CLASSPATH_RESOURCES_LOCATION));
@Override
public boolean apply(String input) {
- return PATH_PATTERN.matcher(input).matches();
+ return pathPattern.matcher(input).matches();
}
};
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -42,8 +42,8 @@
private File baseDir;
- public ResourceWriterImpl(String baseDirectoryName) {
- baseDir = new File(baseDirectoryName);
+ public ResourceWriterImpl(File baseDir) {
+ this.baseDir = baseDir;
baseDir.mkdirs();
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -100,12 +100,8 @@
};
- private static boolean containsFacesConfig(Dir dir) {
- return Iterators.any(dir.getFiles().iterator(), IS_FACES_CONFIG);
- }
-
private static final Predicate<URL> FACES_URL = new Predicate<URL>() {
-
+
public boolean apply(URL input) {
Dir dir = Vfs.fromURL(input);
if (dir instanceof ZipDir) {
@@ -115,8 +111,12 @@
}
}
};
-
+
private Collection<ResourceInfo> resources = Sets.newHashSet();
+
+ private static boolean containsFacesConfig(Dir dir) {
+ return Iterators.any(dir.getFiles().iterator(), IS_FACES_CONFIG);
+ }
public void scan() {
resources.clear();
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java 2010-07-28 15:59:19 UTC (rev 18262)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java 2010-07-28 16:14:09 UTC (rev 18263)
@@ -22,8 +22,6 @@
package org.richfaces.cdk.task;
import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ConcurrentMap;
@@ -32,16 +30,14 @@
import javax.faces.component.StateHolder;
import javax.faces.context.FacesContext;
+import org.apache.maven.plugin.logging.Log;
import org.richfaces.cdk.Faces;
import org.richfaces.cdk.ResourceInfo;
import org.richfaces.cdk.ResourceTaskFactory;
import org.richfaces.cdk.ResourceWriter;
import org.richfaces.cdk.faces.CurrentResourceContext;
import org.richfaces.resource.StateHolderResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
@@ -52,8 +48,6 @@
*/
public class ResourceTaskFactoryImpl implements ResourceTaskFactory {
- private static final Logger LOGGER = LoggerFactory.getLogger(ResourceTaskFactoryImpl.class);
-
private class ResourcesRendererCallable implements Callable<Object> {
private String skinName;
@@ -101,7 +95,7 @@
//TODO check content type
resourceWriter.writeResource(skinName, resource);
} catch (Exception e) {
- LOGGER.error(MessageFormat.format("Exception rendering resorce {0} using skin {1}: {2}", resourceInfo, skinName, e.getMessage()), e);
+ log.error(MessageFormat.format("Exception rendering resorce {0} using skin {1}: {2}", resourceInfo, skinName, e.getMessage()), e);
} finally {
faces.setSkin(null);
faces.stopRequest();
@@ -115,6 +109,8 @@
}
+ private Log log;
+
private Faces faces;
private ResourceWriter resourceWriter;
@@ -123,8 +119,12 @@
private CompletionService<Object> completionService;
- private Collection<String> skins = Collections.emptySet();
+ private String[] skins = new String[0];
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
public void setFaces(Faces faces) {
this.faces = faces;
}
@@ -133,8 +133,8 @@
this.resourceWriter = resourceWriter;
}
- public void setSkins(Collection<String> skins) {
- this.skins = Lists.newArrayList(skins);
+ public void setSkins(String[] skins) {
+ this.skins = skins;
}
public void setCompletionService(CompletionService<Object> completionService) {
14 years, 5 months
JBoss Rich Faces SVN: r18262 - in root/ui-sandbox/inputs/trunk/inputnumberslider/src/main: java/org and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-07-28 11:59:19 -0400 (Wed, 28 Jul 2010)
New Revision: 18262
Added:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBottom.java
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowLeft.java
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowRight.java
Removed:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/handler.gif
Modified:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml
Log:
RF-8983
Added: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java (rev 0)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2010-07-28 15:59:19 UTC (rev 18262)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+@DynamicResource
+public abstract class SliderArrowBase implements Java2DUserResource, StateHolderResource {
+
+ private Dimension dimension = new Dimension(7, 7);
+ private int color;
+ private final String colorName;
+
+ public SliderArrowBase() {
+ this(Skin.GENERAL_TEXT_COLOR);
+ }
+
+ public SliderArrowBase(String colorName) {
+ this.colorName = colorName;
+ }
+
+ private void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+ this.color = skin.getColorParameter(context, colorName);
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics2d.setColor(new Color(color));
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ initialize();
+ dataOutput.writeInt(this.color);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ this.color = dataInput.readInt();
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+}
Property changes on: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
___________________________________________________________________
Name: svn:executable
+ *
Added: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBottom.java
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBottom.java (rev 0)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBottom.java 2010-07-28 15:59:19 UTC (rev 18262)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderArrowBottom extends SliderArrowBase {
+
+ @Override
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ super.paint(graphics2d, dimension);
+ graphics2d.drawLine(0, 1, 6, 1);
+ graphics2d.drawLine(1, 2, 5, 2);
+ graphics2d.drawLine(2, 3, 4, 3);
+ graphics2d.drawLine(3, 4, 3, 4);
+ }
+}
Added: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowLeft.java
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowLeft.java (rev 0)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowLeft.java 2010-07-28 15:59:19 UTC (rev 18262)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderArrowLeft extends SliderArrowBase {
+
+ @Override
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ super.paint(graphics2d, dimension);
+ graphics2d.drawLine(4, 0, 4, 6);
+ graphics2d.drawLine(3, 1, 3, 5);
+ graphics2d.drawLine(2, 2, 2, 4);
+ graphics2d.drawLine(1, 3, 1, 3);
+ }
+}
Added: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowRight.java
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowRight.java (rev 0)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowRight.java 2010-07-28 15:59:19 UTC (rev 18262)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderArrowRight extends SliderArrowBase {
+
+ @Override
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ super.paint(graphics2d, dimension);
+ graphics2d.drawLine(2, 0, 2, 6);
+ graphics2d.drawLine(3, 1, 3, 5);
+ graphics2d.drawLine(4, 2, 4, 4);
+ graphics2d.drawLine(5, 3, 5, 3);
+ }
+}
Deleted: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/handler.gif
===================================================================
(Binary files differ)
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss 2010-07-28 14:46:12 UTC (rev 18261)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss 2010-07-28 15:59:19 UTC (rev 18262)
@@ -38,8 +38,6 @@
}
.rf-ins-mn, .rf-ins-mx {
- width: 25%;
- overflow: hidden;
display: block;
margin-bottom: 3px;
}
@@ -57,15 +55,14 @@
text-align: right;
}
-.rf-ins-i {
+input.rf-ins-i {
background: url("#{resource['bg_field.gif']}") top repeat-x #fff;
border: 1px inset #C0C0C0;
- margin: 0px 10px 0px 10px;
+ margin-left: 10px;
}
.rf-ins-tt {
- position: relative;
- top: -17px;
+ position: absolute;
display: none;
}
@@ -73,15 +70,24 @@
background: url("#{resource['bg.gif']}") 1px 1px repeat-x #FFFFFF;
border: 1px solid #C0C0C0;
display: block;
- font-size: 1px;
height: 6px;
clear: both;
}
+.rf-ins-h, .rf-ins-db, .rf-ins-ib {
+ display: inline-block;
+ width: 7px;
+ height: 7px;
+}
+
.rf-ins-h {
- width: 7px;
- height: 8px;
- border: none;
- position: relative;
- top: -1px;
+ background-image: url("#{resource['org.richfaces.renderkit.html.images.SliderArrowBottom']}");
+}
+
+.rf-ins-db {
+ background-image: url("#{resource['org.richfaces.renderkit.html.images.SliderArrowLeft']}");
+}
+
+.rf-ins-ib {
+ background-image: url("#{resource['org.richfaces.renderkit.html.images.SliderArrowRight']}");
}
\ No newline at end of file
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-07-28 14:46:12 UTC (rev 18261)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-07-28 15:59:19 UTC (rev 18262)
@@ -41,13 +41,15 @@
this.tooltip = this.element.find(".rf-ins-tt");
this.track[0].tabIndex = 0;
- this.handle.css("left", this.input.val() * (this.track.width() - this.handle.width()) / this.range);
+ this.handle.css("margin-left", this.input.val() * (this.track.width() - this.handle.width()) / this.range);
var proxy = jQuery.proxy(this.__inputHandler, this)
this.input.change(proxy);
this.input.submit(proxy);
+ this.track.keydown(jQuery.proxy(this.__keydownHandler, this));
+ this.element.find(".rf-ins-db").mousedown(jQuery.proxy(this.__decreaseHandler, this));
+ this.element.find(".rf-ins-ib").mousedown(jQuery.proxy(this.__increaseHandler, this));
this.track.mousedown(jQuery.proxy(this.__mousedownHandler, this));
- this.track.keydown(jQuery.proxy(this.__keydownHandler, this));
},
setValue: function (value) {
@@ -57,14 +59,14 @@
} else if (value < this.minValue) {
value = this.minValue;
} else {
- value = Math.round(value / this.step) * this.step; //TODO Add support of float values.
+ value = Math.round(value / this.step) * this.step; //TODO Add normal support of float values. E.g. '0.3' should be instead of '0.30000000000000004'.
}
if (value != this.input.val()) {
this.input.val(value);
var left = value * (this.track.width() - this.handle.width()) / this.range;
- this.handle.css("left", left);
+ this.handle.css("margin-left", left);
this.tooltip.text(value);
- this.tooltip.css("left", left - this.handle.width());
+ this.tooltip.setPosition(this.handle,{from: 'LT', offset: [0, -3]}); //TODO Seems offset doesn't work now.
}
},
@@ -82,6 +84,14 @@
}
},
+ __decreaseHandler: function (event) {
+ this.setValue(Number(this.input.val()) - this.step);
+ },
+
+ __increaseHandler: function (event) {
+ this.setValue(Number(this.input.val()) + this.step);
+ },
+
__mousedownHandler: function (event) {
this.__mousemoveHandler(event);
this.track.focus();
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-07-28 14:46:12 UTC (rev 18261)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-07-28 15:59:19 UTC (rev 18262)
@@ -33,22 +33,23 @@
<cdk:resource-dependency name="inputNumberSlider.ecss" />
<cdk:resource-dependency library="javax.faces" name="jsf.js" />
<cdk:resource-dependency name="jquery.js" />
+ <cdk:resource-dependency name="jquery.position.js" />
<cdk:resource-dependency name="richfaces.js" />
- <cdk:resource-dependency name="richfaces.js" />
<cdk:resource-dependency name="richfaces-base-component.js" />
<cdk:resource-dependency name="inputNumberSlider.js" />
</cc:interface>
<cc:implementation>
<span id="#{clientId}" class="rf-ins">
+ <a class="rf-ins-db" href="javascript:void(0);" />
<span class="rf-ins-ta">
<span class="rf-ins-mn">0</span>
<span class="rf-ins-mx">100</span>
<span class="rf-ins-t">
- <img src="#{facesContext.application.resourceHandler.createResource('handler.gif').requestPath}"
- alt="" class="rf-ins-h" />
+ <span class="rf-ins-h" />
<span class="rf-ins-tt">#{getInputValue(facesContext, component)}</span>
</span>
</span>
+ <a class="rf-ins-ib" href="javascript:void(0);" />
<input name="#{clientId}" type="text" class="rf-ins-i" size="3"
value="#{getInputValue(facesContext, component)}" />
<script type="text/javascript">new RichFaces.ui.InputNumberSlider('#{clientId}');</script>
14 years, 5 months
JBoss Rich Faces SVN: r18261 - in root/examples/richfaces-showcase/trunk/src/main: webapp/richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-07-28 10:46:12 -0400 (Wed, 28 Jul 2010)
New Revision: 18261
Added:
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/modalPopup.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/simplePopup.xhtml
Modified:
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
https://jira.jboss.org/browse/RF-8967 popup added
Modified: root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-07-28 13:49:06 UTC (rev 18260)
+++ root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-07-28 14:46:12 UTC (rev 18261)
@@ -303,6 +303,20 @@
</sample>
</samples>
</demo>
+ <demo>
+ <id>popup</id>
+ <name>rich:popup</name>
+ <samples>
+ <sample>
+ <id>simplePopup</id>
+ <name>Simple popup example</name>
+ </sample>
+ <sample>
+ <id>modalPopup</id>
+ <name>Modal panel example</name>
+ </sample>
+ </samples>
+ </demo>
</demos>
</group>
Added: root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/modalPopup.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/modalPopup.xhtml (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/modalPopup.xhtml 2010-07-28 14:46:12 UTC (rev 18261)
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:a4j="http://richfaces.org/a4j">
+
+<ui:composition>
+ <p>There you could check the modal panel which blocks the main
+ screen for any operations defined by using <b>popupPanel</b> component
+ with <b>modal="true"</b></p>
+ <p>In that sample the panel also defined as resizable so you could
+ change its sizes using mouse</p>
+ <h:commandButton value="Call the popup">
+ <rich:componentControl target="popup" operation="show" />
+ </h:commandButton>
+ <rich:popupPanel id="popup" modal="true"
+ resizeable="true" onmaskclick="#{rich:component('popup')}.hide()">
+ <f:facet name="header">
+ <h:outputText value="Simple popup panel" />
+ </f:facet>
+ <f:facet name="controls">
+ <h:outputLink value="#"
+ onclick="#{rich:component('popup')}.hide(); return false;">
+ X
+ </h:outputLink>
+ </f:facet>
+ <p>Additionally there you could check how to handle the clicks
+ outside the panel.</p>
+ <p>In this sample the click outside - closes the panel as well as
+ clicking hide control in the header</p>
+ </rich:popupPanel>
+</ui:composition>
+
+</html>
\ No newline at end of file
Added: root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/simplePopup.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/simplePopup.xhtml (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/popup/simplePopup.xhtml 2010-07-28 14:46:12 UTC (rev 18261)
@@ -0,0 +1,49 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:a4j="http://richfaces.org/a4j">
+
+<ui:composition>
+ <p>Popup panel component used to create any kind of popups on the page.</p>
+ <p>Main features:</p>
+ <ul>
+ <li>Has two states modal and non-modal</li>
+ <li>Could be defined as resizable</li>
+ <li>Could be autosized according to content</li>
+ <li>Could be moved across the screen</li>
+ <li>Could be automatically positioned as centered or use user defined position</li>
+ </ul>
+ <p>This sample shows simple <b>non-modal popup</b> which are <b>movable</b> but not resizable
+ as defined to use <b>autosizing</b> according to it's content</p>
+ <h:commandButton value="Call the popup">
+ <rich:componentControl target="popup" operation="show" />
+ </h:commandButton>
+ <rich:popupPanel id="popup" modal="false" autosized="true"
+ resizeable="false">
+ <f:facet name="header">
+ <h:outputText value="Simple popup panel" />
+ </f:facet>
+ <f:facet name="controls">
+ <h:outputLink value="#"
+ onclick="#{rich:component('popup')}.hide(); return false;">
+ X
+ </h:outputLink>
+ </f:facet>
+ <p>Any content might be inside the panel.</p>
+ <p>Consider inclusion of the form elements into the popup or
+ redefinition of <b>domElementAttachment</b> attribute.</p>
+ <p>The popup panel is open and closed from the javascript function
+ of component client side object. The following code <a href="#"
+ onclick="#{rich:component('popup')}.hide()">hide this panel</a>: <f:verbatim>#</f:verbatim>{rich:component('popup')}.hide()</p>
+ </rich:popupPanel>
+ <p>Besides this sample shows two variants of working with the component JS API:</p>
+ <ul>
+ <li>The popup is called by the <b>rich:componentControl</b> attached to button</li>
+ <li>The popup is closed by simple JS calls which defined using <b>rich:component</b> function</li>
+ </ul>
+</ui:composition>
+
+</html>
\ No newline at end of file
14 years, 5 months
JBoss Rich Faces SVN: r18260 - in root/tests/metamer/trunk/application/src/main: resources/org/richfaces/tests/metamer/bean and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-07-28 09:49:06 -0400 (Wed, 28 Jul 2010)
New Revision: 18260
Added:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichComponentControlBean.java
root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichComponentControlBean.properties
root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/
root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/list.xhtml
root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/simple.xhtml
root/tests/metamer/trunk/application/src/main/webapp/resources/css/richComponentControl.css
Modified:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
Log:
* added component rich:componentControl
Modified: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
--- root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-28 13:43:29 UTC (rev 18259)
+++ root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-28 13:49:06 UTC (rev 18260)
@@ -104,6 +104,7 @@
components.put("a4jRegion", "A4J Region");
components.put("a4jRepeat", "A4J Repeat");
components.put("commandButton", "JSF Command Button");
+ components.put("richComponentControl", "Rich Component Control");
components.put("richDataGrid", "Rich Data Grid");
components.put("richDataScroller", "Rich Data Scroller");
components.put("richDataTable", "Rich Data Table");
Added: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichComponentControlBean.java
===================================================================
--- root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichComponentControlBean.java (rev 0)
+++ root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichComponentControlBean.java 2010-07-28 13:49:06 UTC (rev 18260)
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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.bean;
+
+import java.io.Serializable;
+import javax.annotation.PostConstruct;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+import org.richfaces.component.behavior.ComponentControlBehavior;
+import org.richfaces.tests.metamer.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for rich:componentControl.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "richComponentControlBean")
+@SessionScoped
+public class RichComponentControlBean implements Serializable {
+
+ private static final long serialVersionUID = 4476643239809L;
+ private static Logger logger;
+ private Attributes attributes;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+
+ attributes = Attributes.getBehaviorAttributes(ComponentControlBehavior.class, getClass());
+
+ attributes.setAttribute("operation", "previous");
+ attributes.setAttribute("target", "scroller");
+
+ // TODO has to be tested in another way
+ attributes.remove("event");
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+}
Added: root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichComponentControlBean.properties
===================================================================
--- root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichComponentControlBean.properties (rev 0)
+++ root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichComponentControlBean.properties 2010-07-28 13:49:06 UTC (rev 18260)
@@ -0,0 +1,5 @@
+attr.operation.none=
+attr.operation.first=first
+attr.operation.last=last
+attr.operation.previous=previous
+attr.operation.next=next
\ No newline at end of file
Added: root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/list.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/list.xhtml (rev 0)
+++ root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/list.xhtml 2010-07-28 13:49:06 UTC (rev 18260)
@@ -0,0 +1,41 @@
+<!--
+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.
+-->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:ta="http://java.sun.com/jsf/composite/testapp">
+
+ <ui:composition template="/templates/list.xhtml">
+
+ <ui:define name="pageTitle">Rich Component Control</ui:define>
+
+ <ui:define name="links">
+
+ <ta:testPageLink id="simple" outcome="simple" value="Simple">
+ Simple page that contains a <b>rich:componentControl</b> controlling a <b>rich:dataScroller</b> and input boxes for all component control's attributes.
+ </ta:testPageLink>
+
+ </ui:define>
+
+ </ui:composition>
+
+</html>
Added: root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/simple.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/simple.xhtml (rev 0)
+++ root/tests/metamer/trunk/application/src/main/webapp/components/richComponentControl/simple.xhtml 2010-07-28 13:49:06 UTC (rev 18260)
@@ -0,0 +1,84 @@
+<!--
+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.
+-->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:ta="http://java.sun.com/jsf/composite/testapp" xmlns:rich="http://richfaces.org/rich">
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates" value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ <h:outputStylesheet library="css" name="richComponentControl.css"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ <br/>
+ </ui:define>
+
+ <ui:define name="component">
+
+ <rich:dataTable id="richDataTable"
+ rows="10"
+ value="#{model.employees}"
+ var="record"
+ >
+
+ <rich:column id="columnName">
+ <f:facet name="header">
+ <h:outputText id="columnHeaderName" value="Name" />
+ </f:facet>
+
+ <h:outputText value="#{record.name}" />
+ </rich:column>
+
+ <f:facet name="footer">
+ <rich:dataScroller id="scroller" for="richDataTable" page="3"/>
+ </f:facet>
+
+ </rich:dataTable>
+
+ <br/>
+
+ <h:commandButton id="button" value="button">
+ <rich:componentControl id="richComponentControl"
+ event="click"
+ operation="#{richComponentControlBean.attributes['operation'].value}"
+ selector="#{richComponentControlBean.attributes['selector'].value}"
+ target="#{richComponentControlBean.attributes['target'].value}" />
+ </h:commandButton>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <br/>
+
+ <ta:attributes value="#{richComponentControlBean.attributes}" id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/application/src/main/webapp/resources/css/richComponentControl.css
===================================================================
14 years, 5 months
JBoss Rich Faces SVN: r18259 - in root/tests/metamer/trunk/ftest-source/src/main/java/org: richfaces/tests/metamer/ftest/model and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-28 09:43:29 -0400 (Wed, 28 Jul 2010)
New Revision: 18259
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AbstractModel.java
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
Log:
derived new AbstractModel for component part models encapsulation such as DataTable, DataScroller
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java 2010-07-28 13:42:37 UTC (rev 18258)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java 2010-07-28 13:43:29 UTC (rev 18259)
@@ -45,4 +45,9 @@
public void setLocator(T locator) {
this.reference = locator;
}
+
+ @Override
+ public String toString() {
+ return "ref@" + reference;
+ }
}
Copied: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AbstractModel.java (from rev 18258, root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java)
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AbstractModel.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AbstractModel.java 2010-07-28 13:43:29 UTC (rev 18259)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.model;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+import org.jboss.test.selenium.locator.IterableLocator;
+import org.jboss.test.selenium.locator.reference.LocatorReference;
+
+/**
+ * Abstract DataModel defining root reference for deriving all other locators.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ *
+ * @param <T>
+ * the iterable locator type of root
+ */
+public abstract class AbstractModel<T extends IterableLocator<T>> {
+
+ protected LocatorReference<T> root = new LocatorReference<T>(null);
+
+ public AbstractModel(T root) {
+ setRoot(root);
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).append(root).toString();
+ }
+
+ public void setRoot(T root) {
+ this.root.setLocator(root);
+ }
+
+ public T getRoot() {
+ return root.getLocator();
+ }
+}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-07-28 13:42:37 UTC (rev 18258)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-07-28 13:43:29 UTC (rev 18259)
@@ -22,29 +22,26 @@
package org.richfaces.tests.metamer.ftest.model;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
+
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.reference.LocatorReference;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
-import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
-
/**
* Provides DataScroller control methods.
*
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class DataScroller {
+public class DataScroller extends AbstractModel<JQueryLocator> {
protected static final String CLASS_DISABLED = "rf-ds-dis";
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
-
ReferencedLocator<JQueryLocator> numberedPages = ref(root, "> .rf-ds-dtl");
ReferencedLocator<JQueryLocator> specificNumberedPage = ref(root, "> .rf-ds-dtl:textEquals('{0}')");
@@ -61,17 +58,9 @@
Integer lastPage = null;
public DataScroller(JQueryLocator root) {
- setRoot(root);
+ super(root);
}
- public JQueryLocator getRoot() {
- return root.getLocator();
- }
-
- public void setRoot(JQueryLocator root) {
- this.root.setLocator(root);
- }
-
public void setFastStep(int fastStep) {
this.fastStep = fastStep;
}
@@ -208,6 +197,4 @@
public void clickFastRewind() {
guardXhr(selenium).click(fastRewindButton);
}
-
-
}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java 2010-07-28 13:42:37 UTC (rev 18258)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java 2010-07-28 13:43:29 UTC (rev 18259)
@@ -24,7 +24,6 @@
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.reference.LocatorReference;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
@@ -35,16 +34,14 @@
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class DataTable {
+public class DataTable extends AbstractModel<JQueryLocator> {
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
-
ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b table table tr");
- public DataTable(JQueryLocator tableRoot) {
- root.setLocator(tableRoot);
+ public DataTable(JQueryLocator root) {
+ super(root);
}
public int getCountOfTableRows() {
14 years, 5 months
JBoss Rich Faces SVN: r18258 - in root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: a4jOutputPanel and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-28 09:42:37 -0400 (Wed, 28 Jul 2010)
New Revision: 18258
Added:
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/annotations/Uses.java
Removed:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Named.java
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/a4jOutputPanel/TestA4JOutputPanel.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Inject.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Templates.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
Log:
support for replacing data provider (configuration on method/class basis)
Added: 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 (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/ConsoleStatusTestListener.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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-28 13:41:42 UTC (rev 18257)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -27,6 +27,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -46,70 +47,40 @@
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Templates;
import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.annotations.Uses;
import org.testng.IAnnotationTransformer;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
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.DataProvider;
import org.testng.annotations.ITestAnnotation;
-import org.testng.annotations.Test;
/**
* @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
public class MatrixConfigurator extends TestMethodSelector implements IAnnotationTransformer, IInvokedMethodListener,
- IMethodInterceptor {
+ IMethodInterceptor, ITestListener {
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 List<IMethodInstance> intercept(List<IMethodInstance> methodInstances, ITestContext context) {
for (IMethodInstance methodInstance : methodInstances) {
- int parameterCount = 1;
- Test testAnnotation = methodInstance.getMethod().getMethod().getAnnotation(Test.class);
- if (!"".equals(testAnnotation.dataProvider())) {
- Object testInstance = methodInstance.getMethod().getInstances()[0];
- try {
- Method method = getProvidingMethod(testAnnotation.dataProvider(), testInstance.getClass());
- boolean isAccessible = method.isAccessible();
- if (!isAccessible) {
- method.setAccessible(true);
- }
- Object[][] result = (Object[][]) method.invoke(testInstance);
- method.setAccessible(isAccessible);
- parameterCount = result.length;
- } catch (Exception e) {
- throw new IllegalStateException("Cannot obtain data from dataProvider", e);
- }
- }
-
- for (int i = 0; i < (parameterCount * methodInstance.getMethod().getInvocationCount()); i++) {
+ for (int i = 0; i < methodInstance.getMethod().getInvocationCount(); i++) {
methods.add(methodInstance.getMethod().getMethod());
}
}
return methodInstances;
}
- private Method getProvidingMethod(String providerName, Class<?> testInstanceClass) {
- for (Method method : getAllMethods(testInstanceClass)) {
- DataProvider dataProvider = method.getAnnotation(DataProvider.class);
- if (dataProvider != null) {
- if (providerName.equals(dataProvider.name())) {
- return method;
- }
- }
- }
-
- throw new IllegalStateException("For provider name '" + providerName + "' doesn't exists associated provider");
- }
-
public void beforeInvocation(IInvokedMethod invokedMethod, ITestResult testResult) {
if (!methodConfigured) {
if (isAfterConfiguration(invokedMethod.getTestMethod())) {
@@ -122,6 +93,10 @@
}
}
+ public void onTestStart(ITestResult result) {
+ result.setAttribute("matrix-configuration", currentConfiguration);
+ }
+
private boolean isAfterConfiguration(ITestNGMethod m) {
return m.isAfterClassConfiguration() || m.isAfterGroupsConfiguration() || m.isAfterMethodConfiguration()
|| m.isAfterSuiteConfiguration() || m.isAfterTestConfiguration();
@@ -130,39 +105,25 @@
private void configureMethod(ITestResult testResult) {
Method realMethod = ((Queue<Method>) methods).poll();
+ if (realMethod == null) {
+ throw new IllegalStateException("can't find more configured methods");
+ }
+
Class<?> realClass = realMethod.getDeclaringClass();
- if (!configurations.get(realClass).get(realMethod).hasNext()) {
- return;
+ final Object testInstance = testResult.getInstance();
+ Configuration configuration = configurations.get(realClass).get(realMethod);
+ if (!configuration.hasNext()) {
+ throw new IllegalStateException("can't find more configurations");
}
+ currentConfiguration = configuration.next();
- final Object testInstance = testResult.getInstance();
- Map<Field, Object> configuration = configurations.get(realClass).get(realMethod).next();
-
try {
- for (Entry<Field, Object> entry : configuration.entrySet()) {
+ for (Entry<Field, Object> entry : currentConfiguration.entrySet()) {
final Field field = entry.getKey();
- final Object parameter = entry.getValue();
+ final Object assignment = entry.getValue();
- Object assignment;
- if (parameter instanceof String && !parameter.getClass().isAssignableFrom(field.getType())) {
- Field parameterField = realClass.getDeclaredField((String) parameter);
- boolean isAccessible = parameterField.isAccessible();
- if (!isAccessible) {
- parameterField.setAccessible(true);
- }
- assignment = parameterField.get(testInstance);
- parameterField.setAccessible(isAccessible);
- } else {
- assignment = parameter;
- }
-
- boolean isAccessible = field.isAccessible();
- if (!isAccessible) {
- field.setAccessible(true);
- }
- field.set(testInstance, assignment);
- field.setAccessible(isAccessible);
+ setDeclaredFieldValue(testInstance, field, assignment);
}
} catch (Exception e) {
throw new IllegalStateException("Cannot configure method", e);
@@ -197,23 +158,19 @@
parameters.put(field,
getTemplatesParameter(realClass, field.getType(), field.getAnnotation(Templates.class)));
} else {
+ parameters.put(field, null);
unsatisfied.add(field);
}
}
}
- for (Annotation annotation : realMethod.getAnnotations()) {
- if (annotation.annotationType() == Use.class) {
- Use use = (Use) annotation;
- for (Field field : parameters.keySet()) {
- if (field.getName().equals(use.field())) {
- parameters.put(field, getUseParameter(realClass, field.getType(), use));
- unsatisfied.remove(field);
- }
- }
- }
- }
+ // fulfill parameters by super classes' annotations
+ fulfillParametersFromAnnotations(realClass, parameters, unsatisfied,
+ getAnnotationsForAllSuperClasses(realClass));
+ // fulfill parameters by method annotations
+ fulfillParametersFromAnnotations(realClass, parameters, unsatisfied, realMethod.getAnnotations());
+
if (!unsatisfied.isEmpty()) {
throw new IllegalStateException("cannot satisfy following injection points: " + unsatisfied.toString());
}
@@ -232,6 +189,29 @@
return Math.max(1, count);
}
+ private void fulfillParametersFromAnnotations(Class<?> testClass, Map<Field, List<? extends Object>> parameters,
+ List<Field> unsatisfied, Annotation... annotations) {
+ for (Annotation annotation : annotations) {
+ Use[] useAnnotations = null;
+ if (annotation.annotationType() == Uses.class) {
+ useAnnotations = ((Uses) annotation).value();
+ }
+ if (annotation.annotationType() == Use.class) {
+ useAnnotations = new Use[] { (Use) annotation };
+ }
+ if (useAnnotations != null) {
+ for (Use useAnnotation : useAnnotations) {
+ for (Field field : parameters.keySet()) {
+ if (field.getName().equals(useAnnotation.field())) {
+ parameters.put(field, getUseParameter(testClass, field.getType(), useAnnotation));
+ unsatisfied.remove(field);
+ }
+ }
+ }
+ }
+ }
+ }
+
private Field[] getAllFields(Class<?> testClass) {
List<Field> fields = new ArrayList<Field>();
@@ -247,19 +227,22 @@
return fields.toArray(new Field[fields.size()]);
}
- private Method[] getAllMethods(Class<?> testClass) {
- List<Method> allMethods = new ArrayList<Method>();
+ private Annotation[] getAnnotationsForAllSuperClasses(Class<?> testClass) {
+ List<Annotation> annotations = new LinkedList<Annotation>();
Class<?> currentClass = testClass;
while (currentClass != Object.class) {
- allMethods.addAll(Arrays.asList(currentClass.getDeclaredMethods()));
+ annotations.addAll(Arrays.asList(currentClass.getAnnotations()));
if (currentClass == AbstractMetamerTest.class) {
break;
}
currentClass = currentClass.getSuperclass();
}
- return allMethods.toArray(new Method[allMethods.size()]);
+ // needs to be returned in reversed order because of the lowel level annnotations needs to be processed first
+ Collections.reverse(annotations);
+
+ return annotations.toArray(new Annotation[annotations.size()]);
}
private Map<Method, Configuration> getClassConfigurations(Class<?> realClass) {
@@ -270,12 +253,19 @@
}
private List<? extends Object> getUseParameter(Class<?> testClass, Class<?> parameterType, Use useAnnotation) {
- if (parameterType == int.class || parameterType == Integer.class) {
- return Arrays.asList(ArrayUtils.toObject(useAnnotation.ints()));
+ if (useAnnotation.empty()) {
+ return Arrays.asList(new Object[] { null });
}
+ if (useAnnotation.ints().length > 0) {
+ if (parameterType == int.class || parameterType == Integer.class) {
+ return Arrays.asList(ArrayUtils.toObject(useAnnotation.ints()));
+ }
+ }
+
// tries satisfy parameter from fields
List<Object> result = new LinkedList<Object>();
+ Object testInstance = getTestInstance(testClass);
for (int i = 0; i < useAnnotation.value().length; i++) {
boolean satisfied = false;
for (Field field : testClass.getDeclaredFields()) {
@@ -284,9 +274,22 @@
name = StringUtils.replace(name, "?", ".");
Pattern pattern = Pattern.compile(name);
if (pattern.matcher(field.getName()).matches()) {
- if (parameterType.isAssignableFrom(field.getType())) {
- result.add(field.getName());
+ boolean isArray = field.getType().isArray();
+ Class<?> representedType;
+ if (isArray) {
+ representedType = field.getType().getComponentType();
+ } else {
+ representedType = field.getType();
+ }
+ if (parameterType.isAssignableFrom(representedType)) {
+ Object[] assignments = getDeclaredFieldValues(testInstance, field);
+ for (Object assignment : assignments) {
+ result.add(assignment);
+ }
satisfied = true;
+ } else {
+ throw new IllegalStateException("cannot satisfy parameter with declared field"
+ + field.getName());
}
}
}
@@ -298,6 +301,43 @@
return result;
}
+ private Object getTestInstance(Class<?> testClass) {
+ try {
+ return testClass.newInstance();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void setDeclaredFieldValue(Object testInstance, Field field, Object assignment)
+ throws IllegalArgumentException, IllegalAccessException {
+ boolean isAccessible = field.isAccessible();
+ if (!isAccessible) {
+ field.setAccessible(true);
+ }
+ field.set(testInstance, assignment);
+ field.setAccessible(isAccessible);
+ }
+
+ private Object[] getDeclaredFieldValues(Object testInstance, Field field) {
+ try {
+ boolean isAccessible = field.isAccessible();
+ if (!isAccessible) {
+ field.setAccessible(true);
+ }
+ Object[] result;
+ if (field.getType().isArray()) {
+ result = (Object[]) field.get(testInstance);
+ } else {
+ result = new Object[] { field.get(testInstance) };
+ }
+ field.setAccessible(isAccessible);
+ return result;
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
private List<TemplatesList> getTemplatesParameter(Class<?> testClass, Class<?> parameterType,
Templates templatesAnnotation) {
if (parameterType != TemplatesList.class) {
@@ -314,7 +354,7 @@
return templates;
}
- private class Configuration implements Iterator<Map<Field, Object>> {
+ public class Configuration implements Iterator<Map<Field, Object>> {
Map<Field, List<? extends Object>> parameters;
Map<Field, Queue<? extends Object>> queues;
Queue<? extends Object> lastQueue;
@@ -374,4 +414,34 @@
throw new UnsupportedOperationException();
}
}
+
+ public void onTestSuccess(ITestResult result) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onTestFailure(ITestResult result) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onTestSkipped(ITestResult result) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onStart(ITestContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onFinish(ITestContext context) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-28 13:41:42 UTC (rev 18257)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -36,7 +36,9 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.DataProvider;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.annotations.Uses;
import org.testng.annotations.Test;
/**
@@ -47,6 +49,19 @@
*/
public class TestA4JOutputPanel extends AbstractMetamerTest {
+ Event[] events = new Event[] { CLICK, DBLCLICK, KEYDOWN, KEYPRESS, KEYUP, MOUSEDOWN, MOUSEMOVE, MOUSEOUT,
+ MOUSEOVER, MOUSEUP };
+
+ String[] layouts = new String[] { "block", "inline" };
+
+ @Inject
+ @Use(empty = true)
+ Event event;
+
+ @Inject
+ @Use(empty = true)
+ String layout;
+
private JQueryLocator increaseCounterButton = pjq("input[id$=button]");
private JQueryLocator outputDiv = pjq("div[id$=outputPanel]");
private JQueryLocator outputSpan = pjq("span[id$=outputPanel]");
@@ -58,39 +73,12 @@
return buildUrl(contextPath, "faces/components/a4jOutputPanel/simple.xhtml");
}
- /**
- * Data provider for templates, events and layout of output panel.
- *
- * @return array containing templates that should be used (defined in testng.xml) or default array (containing only
- * plain template) if nothing is defined, JavaScript events that are defined for output panel and layout of
- * panel (block or inline)
- */
- @SuppressWarnings("unused")
- @DataProvider(name = "eventsLayouts")
- private Object[][] getEventsLayouts() {
- final int layoutsCount = 2;
- // list of events that will be tested
- Event[] events = new Event[] { CLICK, DBLCLICK, KEYDOWN, KEYPRESS, KEYUP, MOUSEDOWN, MOUSEMOVE, MOUSEOUT,
- MOUSEOVER, MOUSEUP };
-
- Object[][] result = new Object[events.length * layoutsCount][];
- int index = 0;
-
- for (int i = 0; i < events.length; i++) {
- for (int j = 0; j < layoutsCount; j++) {
- index = i * layoutsCount + j;
- result[index] = new Object[] { events[i], j == 0 ? "block" : "inline" };
- }
- }
-
- return result;
- }
-
- @Test(dataProvider = "eventsLayouts")
- public void testEvent(Event event, String type) {
+ @Uses({ @Use(field = "event", value = "events"), @Use(field = "layout", value = "layouts") })
+ @Test
+ public void testEvent() {
JQueryLocator element = null;
- if ("inline".equals(type)) {
+ if ("inline".equals(layout)) {
// for inline layout set background to blue
selenium.click(pjq("input[name$=layoutInput][value=inline]"));
selenium.waitForPageToLoad(TIMEOUT);
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Inject.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Inject.java 2010-07-28 13:41:42 UTC (rev 18257)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Inject.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * 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.annotations;
import java.lang.annotation.Retention;
@@ -5,6 +26,10 @@
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
+/**
+ * @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
@Target({ TYPE, FIELD, METHOD, PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
public @interface Inject {
Deleted: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Named.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Named.java 2010-07-28 13:41:42 UTC (rev 18257)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Named.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -1,12 +0,0 @@
-package org.richfaces.tests.metamer.ftest.annotations;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import static java.lang.annotation.ElementType.*;
-
-@Target({ PARAMETER })
-(a)Retention(RetentionPolicy.RUNTIME)
-public @interface Named {
- String value();
-}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Templates.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Templates.java 2010-07-28 13:41:42 UTC (rev 18257)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Templates.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * 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.annotations;
import java.lang.annotation.Retention;
@@ -6,6 +27,10 @@
import static java.lang.annotation.ElementType.*;
+/**
+ * @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
@Target({ TYPE, FIELD, METHOD, PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
public @interface Templates {
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java 2010-07-28 13:41:42 UTC (rev 18257)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * 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.annotations;
import java.lang.annotation.Retention;
@@ -5,7 +26,11 @@
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
-@Target({ FIELD, METHOD })
+/**
+ * @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+@Target({ TYPE, FIELD, METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Use {
String field() default "";
@@ -13,4 +38,6 @@
String[] value() default {};
int[] ints() default {};
+
+ boolean empty() default false;
}
Added: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Uses.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Uses.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Uses.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -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.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.*;
+
+/**
+ * @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+@Target({ TYPE, METHOD })
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Uses {
+ Use[] value() default {};
+}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-28 13:41:42 UTC (rev 18257)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-28 13:42:37 UTC (rev 18258)
@@ -31,7 +31,6 @@
import org.jboss.test.selenium.locator.IdLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
-import org.richfaces.tests.metamer.ftest.annotations.Named;
import org.richfaces.tests.metamer.ftest.annotations.Use;
import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
import org.richfaces.tests.metamer.ftest.model.DataTable;
@@ -70,13 +69,6 @@
public TestPagination() {
}
- public TestPagination(AssertingDataScroller dataScroller, @Named("fastStep") int fastStep,
- @Named("maxPages") int maxPages) {
- this.dataScroller = dataScroller;
- this.fastStep = fastStep;
- this.maxPages = maxPages;
- }
-
@Override
public URL getTestUrl() {
return buildUrl(contextPath, "faces/components/richDataScroller/simple.xhtml");
14 years, 5 months
JBoss Rich Faces SVN: r18257 - in root/tests/metamer/trunk/ftest-source: src/main/java/org/richfaces/tests/metamer/ftest and 10 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-28 09:41:42 -0400 (Wed, 28 Jul 2010)
New Revision: 18257
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerProperties.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Templates.java
Removed:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/
Modified:
root/tests/metamer/trunk/ftest-source/pom.xml
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
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/a4jActionListener/TestA4JActionListener.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
Log:
added support for Templates configured by MatrixConfigurator
Modified: root/tests/metamer/trunk/ftest-source/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest-source/pom.xml 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/pom.xml 2010-07-28 13:41:42 UTC (rev 18257)
@@ -54,6 +54,11 @@
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.tests</groupId>
+ <artifactId>metamer</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -32,12 +32,12 @@
import org.jboss.test.selenium.encapsulated.JavaScript;
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.TemplatesList;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Templates;
import org.testng.SkipException;
-import org.testng.annotations.BeforeClass;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Optional;
-import org.testng.annotations.Parameters;
/**
* Abstract test case used as a basis for majority of test cases.
@@ -51,10 +51,11 @@
* timeout in miliseconds
*/
public static final long TIMEOUT = 5000;
- private String[][] templates;
- public AbstractMetamerTest() {
- }
+ @Inject
+ @Templates(include = { "plain", "richDataTable1,redDiv", "richDataTable2,redDiv", "a4jRepeat1", "a4jRepeat2",
+ "hDataTable1", "hDataTable2", "uiRepeat1", "uiRepeat2" })
+ private TemplatesList template;
/**
* Returns the url to test page to be opened by Selenium
@@ -64,42 +65,6 @@
public abstract URL getTestUrl();
/**
- * Data provider for templates.
- *
- * @return array containing templates that should be used (defined in testng.xml) or default array (containing only
- * plain template) if nothing is defined
- */
- @DataProvider(name = "templates")
- protected Object[][] getTemplates() {
- if (templates != null && templates.length > 0) {
- return templates;
- }
-
- return new Object[][] { { "plain" } };
- }
-
- /**
- * Loads and parses attribute "templates" from testng.xml.
- *
- * @param urlParams
- */
- @BeforeClass(alwaysRun = true)
- @Parameters({ "templates" })
- public void initTemplates(@Optional String urlParams) {
- if (urlParams == null) {
- return;
- }
-
- String[] array = urlParams.split(" ");
- templates = new String[array.length][];
-
- for (int i = 0; i < array.length; i++) {
- templates[i] = new String[1];
- templates[i][0] = array[i];
- }
- }
-
- /**
* Opens the tested page. If templates is not empty nor null, it appends url parameter with templates.
*
* @param templates
@@ -110,17 +75,14 @@
if (selenium == null) {
new SkipException("selenium isn't initialized");
}
- String urlParams = "";
- if (templates != null && templates.length != 0) {
- urlParams = "?templates=" + templates[0];
- }
- selenium.open(buildUrl(getTestUrl() + urlParams));
+ selenium.open(buildUrl(getTestUrl() + "?templates=" + template.toString()));
selenium.waitForPageToLoad(TIMEOUT);
}
/**
* Invalidates session by clicking on a button on tested page.
*/
+ @AfterMethod(alwaysRun = true)
public void invalidateSession() {
selenium.deleteAllVisibleCookies();
}
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-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -25,6 +25,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@@ -39,51 +40,80 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
+import org.jboss.test.selenium.listener.TestMethodSelector;
+import org.richfaces.tests.metamer.Template;
+import org.richfaces.tests.metamer.TemplatesList;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Templates;
import org.richfaces.tests.metamer.ftest.annotations.Use;
-import org.richfaces.tests.metamer.ftest.internal.NamedType;
import org.testng.IAnnotationTransformer;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.IMethodInstance;
import org.testng.IMethodInterceptor;
import org.testng.ITestContext;
+import org.testng.ITestNGMethod;
import org.testng.ITestResult;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.AfterTest;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.ITestAnnotation;
+import org.testng.annotations.Test;
/**
* @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class MatrixConfigurator implements IAnnotationTransformer, IInvokedMethodListener, IMethodInterceptor {
+public class MatrixConfigurator extends TestMethodSelector implements IAnnotationTransformer, IInvokedMethodListener,
+ IMethodInterceptor {
- private static final Class<? extends Annotation>[] AFTER_ANNOTATION = new Class[] { AfterMethod.class,
- AfterClass.class, AfterTest.class, AfterSuite.class };
-
Map<Class<?>, Map<Method, Configuration>> configurations = new HashMap<Class<?>, Map<Method, Configuration>>();
LinkedList<Method> methods = new LinkedList<Method>();
boolean methodConfigured = false;
public List<IMethodInstance> intercept(List<IMethodInstance> methodInstances, ITestContext context) {
for (IMethodInstance methodInstance : methodInstances) {
- for (int i = 0; i < methodInstance.getMethod().getInvocationCount(); i++) {
+ int parameterCount = 1;
+ Test testAnnotation = methodInstance.getMethod().getMethod().getAnnotation(Test.class);
+
+ if (!"".equals(testAnnotation.dataProvider())) {
+ Object testInstance = methodInstance.getMethod().getInstances()[0];
+ try {
+ Method method = getProvidingMethod(testAnnotation.dataProvider(), testInstance.getClass());
+ boolean isAccessible = method.isAccessible();
+ if (!isAccessible) {
+ method.setAccessible(true);
+ }
+ Object[][] result = (Object[][]) method.invoke(testInstance);
+ method.setAccessible(isAccessible);
+ parameterCount = result.length;
+ } catch (Exception e) {
+ throw new IllegalStateException("Cannot obtain data from dataProvider", e);
+ }
+ }
+
+ for (int i = 0; i < (parameterCount * methodInstance.getMethod().getInvocationCount()); i++) {
methods.add(methodInstance.getMethod().getMethod());
}
}
return methodInstances;
}
+ private Method getProvidingMethod(String providerName, Class<?> testInstanceClass) {
+ for (Method method : getAllMethods(testInstanceClass)) {
+ DataProvider dataProvider = method.getAnnotation(DataProvider.class);
+ if (dataProvider != null) {
+ if (providerName.equals(dataProvider.name())) {
+ return method;
+ }
+ }
+ }
+
+ throw new IllegalStateException("For provider name '" + providerName + "' doesn't exists associated provider");
+ }
+
public void beforeInvocation(IInvokedMethod invokedMethod, ITestResult testResult) {
if (!methodConfigured) {
- Method method = invokedMethod.getTestMethod().getMethod();
- for (Class<? extends Annotation> annotationClass : AFTER_ANNOTATION) {
- if (method.getAnnotation(annotationClass) != null) {
- return;
- }
+ if (isAfterConfiguration(invokedMethod.getTestMethod())) {
+ return;
}
configureMethod(testResult);
@@ -92,23 +122,28 @@
}
}
+ private boolean isAfterConfiguration(ITestNGMethod m) {
+ return m.isAfterClassConfiguration() || m.isAfterGroupsConfiguration() || m.isAfterMethodConfiguration()
+ || m.isAfterSuiteConfiguration() || m.isAfterTestConfiguration();
+ }
+
private void configureMethod(ITestResult testResult) {
Method realMethod = ((Queue<Method>) methods).poll();
+
Class<?> realClass = realMethod.getDeclaringClass();
-
+
if (!configurations.get(realClass).get(realMethod).hasNext()) {
return;
}
-
+
final Object testInstance = testResult.getInstance();
- Map<NamedType, Object> configuration = configurations.get(realClass).get(realMethod).next();
+ Map<Field, Object> configuration = configurations.get(realClass).get(realMethod).next();
try {
- for (Entry<NamedType, Object> entry : configuration.entrySet()) {
- final NamedType namedType = entry.getKey();
+ for (Entry<Field, Object> entry : configuration.entrySet()) {
+ final Field field = entry.getKey();
final Object parameter = entry.getValue();
- Field field = realClass.getDeclaredField(namedType.getName());
Object assignment;
if (parameter instanceof String && !parameter.getClass().isAssignableFrom(field.getType())) {
Field parameterField = realClass.getDeclaredField((String) parameter);
@@ -141,26 +176,28 @@
}
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
+ super.transform(annotation, testClass, testConstructor, testMethod);
int invocationCount = createConfiguration(testMethod.getDeclaringClass(), testMethod);
annotation.setInvocationCount(invocationCount);
}
public int createConfiguration(Class<?> realClass, Method realMethod) {
- Map<NamedType, List<? extends Object>> parameters = new LinkedHashMap<NamedType, List<? extends Object>>();
+ Map<Field, List<? extends Object>> parameters = new LinkedHashMap<Field, List<? extends Object>>();
- List<NamedType> unsatisfied = new LinkedList<NamedType>();
+ List<Field> unsatisfied = new LinkedList<Field>();
// get a list of satisfied and unsatisfied parameters/injections
- for (Field field : realClass.getDeclaredFields()) {
+ Field[] allFields = getAllFields(realClass);
+ for (Field field : allFields) {
if (field.getAnnotation(Inject.class) != null) {
- final NamedType namedType = new NamedType(field.getType(), field.getName());
- if (field.getAnnotation(Use.class) != null || field.getAnnotation(Use.class) != null) {
- parameters.put(namedType,
- getUseParameter(realClass, field.getType(), field.getAnnotation(Use.class)));
+ 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)));
} else {
- parameters.put(namedType, null);
- unsatisfied.add(namedType);
+ unsatisfied.add(field);
}
}
}
@@ -168,10 +205,10 @@
for (Annotation annotation : realMethod.getAnnotations()) {
if (annotation.annotationType() == Use.class) {
Use use = (Use) annotation;
- for (NamedType namedType : parameters.keySet()) {
- if (namedType.getName().equals(use.field())) {
- parameters.put(namedType, getUseParameter(realClass, namedType.getParameterType(), use));
- unsatisfied.remove(namedType);
+ for (Field field : parameters.keySet()) {
+ if (field.getName().equals(use.field())) {
+ parameters.put(field, getUseParameter(realClass, field.getType(), use));
+ unsatisfied.remove(field);
}
}
}
@@ -195,6 +232,36 @@
return Math.max(1, count);
}
+ private Field[] getAllFields(Class<?> testClass) {
+ List<Field> fields = new ArrayList<Field>();
+
+ Class<?> currentClass = testClass;
+ while (currentClass != Object.class) {
+ fields.addAll(Arrays.asList(currentClass.getDeclaredFields()));
+ if (currentClass == AbstractMetamerTest.class) {
+ break;
+ }
+ currentClass = currentClass.getSuperclass();
+ }
+
+ return fields.toArray(new Field[fields.size()]);
+ }
+
+ private Method[] getAllMethods(Class<?> testClass) {
+ List<Method> allMethods = new ArrayList<Method>();
+
+ Class<?> currentClass = testClass;
+ while (currentClass != Object.class) {
+ allMethods.addAll(Arrays.asList(currentClass.getDeclaredMethods()));
+ if (currentClass == AbstractMetamerTest.class) {
+ break;
+ }
+ currentClass = currentClass.getSuperclass();
+ }
+
+ return allMethods.toArray(new Method[allMethods.size()]);
+ }
+
private Map<Method, Configuration> getClassConfigurations(Class<?> realClass) {
if (!configurations.containsKey(realClass)) {
configurations.put(realClass, new HashMap<Method, Configuration>());
@@ -202,17 +269,17 @@
return configurations.get(realClass);
}
- private List<? extends Object> getUseParameter(Class<?> testClass, Class<?> parameterType, Use use) {
+ private List<? extends Object> getUseParameter(Class<?> testClass, Class<?> parameterType, Use useAnnotation) {
if (parameterType == int.class || parameterType == Integer.class) {
- return Arrays.asList(ArrayUtils.toObject(use.ints()));
+ return Arrays.asList(ArrayUtils.toObject(useAnnotation.ints()));
}
// tries satisfy parameter from fields
List<Object> result = new LinkedList<Object>();
- for (int i = 0; i < use.value().length; i++) {
+ for (int i = 0; i < useAnnotation.value().length; i++) {
boolean satisfied = false;
for (Field field : testClass.getDeclaredFields()) {
- String name = use.value()[i];
+ String name = useAnnotation.value()[i];
name = StringUtils.replace(name, "*", ".+");
name = StringUtils.replace(name, "?", ".");
Pattern pattern = Pattern.compile(name);
@@ -231,50 +298,66 @@
return result;
}
- private class Configuration implements Iterator<Map<NamedType, Object>> {
- Map<NamedType, List<? extends Object>> parameters;
- Map<NamedType, Queue<? extends Object>> queues;
+ private List<TemplatesList> getTemplatesParameter(Class<?> testClass, Class<?> parameterType,
+ Templates templatesAnnotation) {
+ if (parameterType != TemplatesList.class) {
+ throw new IllegalStateException("only " + Template.class.getName()
+ + " fields can be annotated with @Inject @Templates");
+ }
+
+ List<TemplatesList> templates = MetamerProperties.getTemplates();
+
+ if (templates == null) {
+ templates = MetamerProperties.parseTemplates(templatesAnnotation.include());
+ }
+
+ return templates;
+ }
+
+ private class Configuration implements Iterator<Map<Field, Object>> {
+ Map<Field, List<? extends Object>> parameters;
+ Map<Field, Queue<? extends Object>> queues;
Queue<? extends Object> lastQueue;
- public Configuration(Map<NamedType, List<? extends Object>> parameters) {
+ public Configuration(Map<Field, List<? extends Object>> parameters) {
this.parameters = parameters;
reset();
}
public void reset() {
- queues = new LinkedHashMap<NamedType, Queue<? extends Object>>();
- for (Entry<NamedType, List<? extends Object>> entry : parameters.entrySet()) {
- final NamedType namedType = entry.getKey();
+ queues = new LinkedHashMap<Field, Queue<? extends Object>>();
+ for (Entry<Field, List<? extends Object>> entry : parameters.entrySet()) {
+ final Field field = entry.getKey();
List<? extends Object> parameter = entry.getValue();
lastQueue = new LinkedList<Object>(parameter);
- queues.put(namedType, lastQueue);
+ queues.put(field, lastQueue);
}
}
- public Map<NamedType, Object> next() {
+ public Map<Field, Object> next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
- Map<NamedType, Object> pass = new HashMap<NamedType, Object>();
+ Map<Field, Object> pass = new HashMap<Field, Object>();
- for (Entry<NamedType, Queue<? extends Object>> entry : queues.entrySet()) {
- final NamedType namedType = entry.getKey();
+ for (Entry<Field, Queue<? extends Object>> entry : queues.entrySet()) {
+ final Field field = entry.getKey();
final Queue<? extends Object> queue = entry.getValue();
- pass.put(namedType, queue.peek());
+ pass.put(field, queue.peek());
}
- for (Entry<NamedType, Queue<? extends Object>> entry : queues.entrySet()) {
- final NamedType namedType = entry.getKey();
+ for (Entry<Field, Queue<? extends Object>> entry : queues.entrySet()) {
+ final Field field = entry.getKey();
final Queue<? extends Object> queue = entry.getValue();
queue.poll();
if (queue.isEmpty() && hasNext()) {
- List<? extends Object> parameter = parameters.get(namedType);
- queues.put(namedType, new LinkedList<Object>(parameter));
+ List<? extends Object> parameter = parameters.get(field);
+ queues.put(field, new LinkedList<Object>(parameter));
} else {
break;
}
Added: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerProperties.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerProperties.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MetamerProperties.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.richfaces.tests.metamer.TemplatesList;
+import org.richfaces.tests.metamer.TemplatesListConverter;
+
+/**
+ * @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public final class MetamerProperties {
+
+ private MetamerProperties() {
+ }
+
+ public static List<TemplatesList> getTemplates() {
+ final String templatesString = System.getProperty("templates");
+
+ if (templatesString == null) {
+ return null;
+ }
+
+ String[] templatesArray = StringUtils.split(templatesString, ";");
+
+ return parseTemplates(templatesArray);
+ }
+
+ public static List<TemplatesList> parseTemplates(String[] templatesArray) {
+ final TemplatesListConverter convertor = new TemplatesListConverter();
+ List<TemplatesList> templates = new LinkedList<TemplatesList>();
+
+ for (String template : templatesArray) {
+ templates.add((TemplatesList) convertor.getAsObject(null, null, template));
+ }
+
+ return templates;
+ }
+}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -29,7 +29,6 @@
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.selenium.SeleniumCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
/**
@@ -51,14 +50,8 @@
return buildUrl(contextPath, "faces/components/a4jActionListener/all.xhtml");
}
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerByType(String templates) {
+ @Test
+ public void testInvokeListenerByType() {
final String hashCodeRegExp = "@[0-9a-fA-F]{1,}$";
final String msg = "Implementation of ActionListener created and called: "
+ "org.richfaces.tests.metamer.bean.A4JActionListenerBean$ActionListenerImpl";
@@ -89,8 +82,8 @@
}
- @Test(dataProvider = "templates")
- public void testInvokeListenerByBinding(String templates) {
+ @Test
+ public void testInvokeListenerByBinding() {
final String msg = "Bound listener called";
selenium.click(invokeButtonBinding);
@@ -103,8 +96,8 @@
assertEquals(count, 1, "Only one message should be displayed on the page.");
}
- @Test(dataProvider = "templates")
- public void testInvokeListenerMethod(String templates) {
+ @Test
+ public void testInvokeListenerMethod() {
final String msg = "Method expression listener called";
selenium.click(invokeButtonMethod);
@@ -117,8 +110,8 @@
assertEquals(count, 1, "Only one message should be displayed on the page.");
}
- @Test(dataProvider = "templates")
- public void testInvokeListenerMethodCC(String templates) {
+ @Test
+ public void testInvokeListenerMethodCC() {
final String msg = "Method expression listener called from composite component";
selenium.click(invokeButtonCC);
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -34,7 +34,6 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
/**
@@ -56,14 +55,8 @@
return buildUrl(contextPath, "faces/components/a4jCommandButton/simple.xhtml");
}
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testSimpleClick(String templates) {
+ @Test(groups = "client-side-perf")
+ public void testSimpleClick() {
selenium.typeKeys(input, "RichFaces 4");
selenium.click(button);
@@ -79,8 +72,8 @@
assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces 4' in input");
}
- @Test(dataProvider = "templates")
- public void testSimpleClickUnicode(String templates) {
+ @Test
+ public void testSimpleClickUnicode() {
selenium.typeKeys(input, "ľščťžýáíéňô");
selenium.click(button);
@@ -96,8 +89,8 @@
assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when 'ľščťžýáíéňô' in input");
}
- @Test(dataProvider = "templates")
- public void testAction(String templates) {
+ @Test
+ public void testAction() {
JQueryLocator doubleStringAction = pjq("input[value=doubleStringAction]");
JQueryLocator first6CharsAction = pjq("input[value=first6CharsAction]");
JQueryLocator toUpperCaseAction = pjq("input[value=toUpperCaseAction]");
@@ -128,8 +121,8 @@
assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces 4ě' in input and toUpperCaseAction selected");
}
- @Test(dataProvider = "templates")
- public void testActionListener(String templates) {
+ @Test
+ public void testActionListener() {
JQueryLocator doubleStringActionListener = pjq("input[value=doubleStringActionListener]");
JQueryLocator first6CharsActionListener = pjq("input[value=first6CharsActionListener]");
JQueryLocator toUpperCaseActionListener = pjq("input[value=toUpperCaseActionListener]");
@@ -161,8 +154,8 @@
"output2 when 'RichFaces 4ě' in input and toUpperCaseActionListener selected");
}
- @Test(dataProvider = "templates")
- public void testDisabled(String templates) {
+ @Test
+ public void testDisabled() {
JQueryLocator disabledChecbox = pjq("input[id$=disabledInput]");
AttributeLocator<?> disabledAttribute = button.getAttribute(new Attribute("disabled"));
@@ -173,58 +166,58 @@
assertEquals(isDisabled.toLowerCase(), "disabled", "The value of attribute disabled");
}
- @Test(dataProvider = "templates")
- public void testOnclick(String templates) {
+ @Test
+ public void testOnclick() {
testFireEvent(Event.CLICK, button);
}
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
+ @Test
+ public void testOndblclick() {
testFireEvent(Event.DBLCLICK, button);
}
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
+ @Test
+ public void testOnkeydown() {
testFireEvent(Event.KEYDOWN, button);
}
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
+ @Test
+ public void testOnkeypress() {
testFireEvent(Event.KEYPRESS, button);
}
- @Test(dataProvider = "templates")
- public void testOneyup(String templates) {
+ @Test
+ public void testOneyup() {
testFireEvent(Event.KEYUP, button);
}
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
+ @Test
+ public void testOnmousedown() {
testFireEvent(Event.MOUSEDOWN, button);
}
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
+ @Test
+ public void testOnmousemove() {
testFireEvent(Event.MOUSEMOVE, button);
}
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
+ @Test
+ public void testOnmouseout() {
testFireEvent(Event.MOUSEOUT, button);
}
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
+ @Test
+ public void testOnmouseover() {
testFireEvent(Event.MOUSEOVER, button);
}
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
+ @Test
+ public void testOnmouseup() {
testFireEvent(Event.MOUSEUP, button);
}
- @Test(dataProvider = "templates")
- public void testRender(String templates) {
+ @Test
+ public void testRender() {
JQueryLocator renderInput = pjq("input[name$=renderInput]");
selenium.type(renderInput, "output1");
@@ -263,8 +256,8 @@
}
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
+ @Test
+ public void testRendered() {
JQueryLocator renderedCheckbox = pjq("input[name$=renderedInput]");
selenium.click(renderedCheckbox);
@@ -272,8 +265,8 @@
assertFalse(selenium.isElementPresent(button), "Button should not be displayed");
}
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
+ @Test
+ public void testStyleClass() {
JQueryLocator wide = pjq("input[name$=styleClassInput][value=wide]");
JQueryLocator big = pjq("input[name$=styleClassInput][value=big]");
JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
@@ -293,8 +286,8 @@
assertFalse(selenium.isAttributePresent(classAttribute), "Button's class was not removed.");
}
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
+ @Test
+ public void testStyle() {
JQueryLocator styleInput = pjq("input[id$=styleInput]");
final AttributeLocator<?> attribute = button.getAttribute(new Attribute("style"));
final String value = "font-size: 20px;";
@@ -305,8 +298,8 @@
assertEquals(selenium.getAttribute(attribute), value, "Style of the button did not change");
}
- @Test(dataProvider = "templates")
- public void testValue(String templates) {
+ @Test
+ public void testValue() {
JQueryLocator valueInput = pjq("input[id$=valueInput]");
final AttributeLocator<?> attribute = button.getAttribute(new Attribute("value"));
final String value = "new label";
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -34,7 +34,6 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
/**
@@ -56,14 +55,8 @@
return buildUrl(contextPath, "faces/components/a4jCommandLink/simple.xhtml");
}
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testSimpleClick(String templates) {
+ @Test(groups = "client-side-perf")
+ public void testSimpleClick() {
selenium.typeKeys(input, "RichFaces 4");
selenium.click(link);
@@ -79,8 +72,8 @@
assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces 4' in input");
}
- @Test(dataProvider = "templates")
- public void testSimpleClickUnicode(String templates) {
+ @Test
+ public void testSimpleClickUnicode() {
selenium.typeKeys(input, "ľščťžýáíéňô");
selenium.click(link);
@@ -96,8 +89,8 @@
assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when 'ľščťžýáíéňô' in input");
}
- @Test(dataProvider = "templates")
- public void testAction(String templates) {
+ @Test
+ public void testAction() {
JQueryLocator doubleStringAction = pjq("input[value=doubleStringAction]");
JQueryLocator first6CharsAction = pjq("input[value=first6CharsAction]");
JQueryLocator toUpperCaseAction = pjq("input[value=toUpperCaseAction]");
@@ -128,8 +121,8 @@
assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces 4ě' in input and toUpperCaseAction selected");
}
- @Test(dataProvider = "templates")
- public void testActionListener(String templates) {
+ @Test
+ public void testActionListener() {
JQueryLocator doubleStringActionListener = pjq("input[value=doubleStringActionListener]");
JQueryLocator first6CharsActionListener = pjq("input[value=first6CharsActionListener]");
JQueryLocator toUpperCaseActionListener = pjq("input[value=toUpperCaseActionListener]");
@@ -161,8 +154,8 @@
"output2 when 'RichFaces 4ě' in input and toUpperCaseActionListener selected");
}
- @Test(dataProvider = "templates")
- public void testDisabled(String templates) {
+ @Test
+ public void testDisabled() {
JQueryLocator disabledChecbox = pjq("input[id$=disabledInput]");
JQueryLocator newLink = pjq("span[id$=a4jCommandLink]");
@@ -176,58 +169,58 @@
}
- @Test(dataProvider = "templates")
- public void testOnclick(String templates) {
+ @Test
+ public void testOnclick() {
testFireEvent(Event.CLICK, link);
}
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
+ @Test
+ public void testOndblclick() {
testFireEvent(Event.DBLCLICK, link);
}
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
+ @Test
+ public void testOnkeydown() {
testFireEvent(Event.KEYDOWN, link);
}
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
+ @Test
+ public void testOnkeypress() {
testFireEvent(Event.KEYPRESS, link);
}
- @Test(dataProvider = "templates")
- public void testOneyup(String templates) {
+ @Test
+ public void testOneyup() {
testFireEvent(Event.KEYUP, link);
}
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
+ @Test
+ public void testOnmousedown() {
testFireEvent(Event.MOUSEDOWN, link);
}
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
+ @Test
+ public void testOnmousemove() {
testFireEvent(Event.MOUSEMOVE, link);
}
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
+ @Test
+ public void testOnmouseout() {
testFireEvent(Event.MOUSEOUT, link);
}
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
+ @Test
+ public void testOnmouseover() {
testFireEvent(Event.MOUSEOVER, link);
}
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
+ @Test
+ public void testOnmouseup() {
testFireEvent(Event.MOUSEUP, link);
}
- @Test(dataProvider = "templates")
- public void testRender(String templates) {
+ @Test
+ public void testRender() {
JQueryLocator renderInput = pjq("input[name$=renderInput]");
selenium.type(renderInput, "output1");
@@ -266,8 +259,8 @@
}
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
+ @Test
+ public void testRendered() {
JQueryLocator renderedCheckbox = pjq("input[name$=renderedInput]");
selenium.click(renderedCheckbox);
@@ -275,8 +268,8 @@
assertFalse(selenium.isElementPresent(link), "Button should not be displayed");
}
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
+ @Test
+ public void testStyleClass() {
JQueryLocator bold = pjq("input[name$=styleClassInput][value=bold]");
JQueryLocator strike = pjq("input[name$=styleClassInput][value=strike]");
JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
@@ -296,8 +289,8 @@
assertFalse(selenium.isAttributePresent(classAttribute), "Button's class was not removed.");
}
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
+ @Test
+ public void testStyle() {
JQueryLocator styleInput = pjq("input[id$=styleInput]");
final AttributeLocator<?> attribute = link.getAttribute(new Attribute("style"));
final String value = "font-size: 20px;";
@@ -308,8 +301,8 @@
assertEquals(selenium.getAttribute(attribute), value, "Style of the button did not change");
}
- @Test(dataProvider = "templates")
- public void testValue(String templates) {
+ @Test
+ public void testValue() {
JQueryLocator valueInput = pjq("input[id$=valueInput]");
final String value = "new label";
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -32,7 +32,6 @@
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
/**
@@ -63,14 +62,8 @@
return buildUrl(contextPath, "faces/components/a4jLog/simple.xhtml");
}
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates")
- public void testSubmit(String templates) {
+ @Test
+ public void testSubmit() {
selenium.typeKeys(input, "RichFaces 4");
selenium.click(submitButton);
@@ -80,8 +73,8 @@
assertTrue(count > 0, "There should be at least one message in log after submit button was clicked.");
}
- @Test(dataProvider = "templates")
- public void testSubmitUnicode(String templates) {
+ @Test
+ public void testSubmitUnicode() {
selenium.typeKeys(input, "ľščťžýáíéôúäň");
selenium.click(submitButton);
@@ -91,8 +84,8 @@
assertTrue(count > 0, "There should be at least one message in log after submit button was clicked.");
}
- @Test(dataProvider = "templates")
- public void testClearButton(String templates) {
+ @Test
+ public void testClearButton() {
JQueryLocator clearButton = pjq("div.rich-log button");
selenium.typeKeys(input, "RichFaces 4");
@@ -109,8 +102,8 @@
assertEquals(count, 0, "There should be no messages in log after clear button was clicked.");
}
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
+ @Test
+ public void testRendered() {
JQueryLocator renderedInput = pjq("input[id$=renderedInput]");
selenium.click(renderedInput);
@@ -119,83 +112,83 @@
assertFalse(selenium.isElementPresent(log), "Log should not be displayed.");
}
- @Test(dataProvider = "templates")
- public void testDebugFilterDebug(String templates) {
+ @Test
+ public void testDebugFilterDebug() {
testLogging(LogLevel.DEBUG, LogLevel.DEBUG);
}
- @Test(dataProvider = "templates")
- public void testDebugFilterInfo(String templates) {
+ @Test
+ public void testDebugFilterInfo() {
testLogging(LogLevel.DEBUG, LogLevel.INFO);
}
- @Test(dataProvider = "templates")
- public void testDebugFilterWarn(String templates) {
+ @Test
+ public void testDebugFilterWarn() {
testLogging(LogLevel.DEBUG, LogLevel.WARN);
}
- @Test(dataProvider = "templates")
- public void testDebugFilterError(String templates) {
+ @Test
+ public void testDebugFilterError() {
testLogging(LogLevel.DEBUG, LogLevel.ERROR);
}
- @Test(dataProvider = "templates")
- public void testInfoFilterDebug(String templates) {
+ @Test
+ public void testInfoFilterDebug() {
testLogging(LogLevel.INFO, LogLevel.DEBUG);
}
- @Test(dataProvider = "templates")
- public void testInfoFilterInfo(String templates) {
+ @Test
+ public void testInfoFilterInfo() {
testLogging(LogLevel.INFO, LogLevel.INFO);
}
- @Test(dataProvider = "templates")
- public void testInfoFilterWarn(String templates) {
+ @Test
+ public void testInfoFilterWarn() {
testLogging(LogLevel.INFO, LogLevel.WARN);
}
- @Test(dataProvider = "templates")
- public void testInfoFilterError(String templates) {
+ @Test
+ public void testInfoFilterError() {
testLogging(LogLevel.INFO, LogLevel.ERROR);
}
- @Test(dataProvider = "templates")
- public void testWarnFilterDebug(String templates) {
+ @Test
+ public void testWarnFilterDebug() {
testLogging(LogLevel.WARN, LogLevel.DEBUG);
}
- @Test(dataProvider = "templates")
- public void testWarnFilterInfo(String templates) {
+ @Test
+ public void testWarnFilterInfo() {
testLogging(LogLevel.WARN, LogLevel.INFO);
}
- @Test(dataProvider = "templates")
- public void testWarnFilterWarn(String templates) {
+ @Test
+ public void testWarnFilterWarn() {
testLogging(LogLevel.WARN, LogLevel.WARN);
}
- @Test(dataProvider = "templates")
- public void testWarnFilterError(String templates) {
+ @Test
+ public void testWarnFilterError() {
testLogging(LogLevel.WARN, LogLevel.ERROR);
}
- @Test(dataProvider = "templates")
- public void testErrorFilterDebug(String templates) {
+ @Test
+ public void testErrorFilterDebug() {
testLogging(LogLevel.ERROR, LogLevel.DEBUG);
}
- @Test(dataProvider = "templates")
- public void testErrorFilterInfo(String templates) {
+ @Test
+ public void testErrorFilterInfo() {
testLogging(LogLevel.ERROR, LogLevel.INFO);
}
- @Test(dataProvider = "templates")
- public void testErrorFilterWarn(String templates) {
+ @Test
+ public void testErrorFilterWarn() {
testLogging(LogLevel.ERROR, LogLevel.WARN);
}
- @Test(dataProvider = "templates")
- public void testErrorFilterError(String templates) {
+ @Test
+ public void testErrorFilterError() {
testLogging(LogLevel.ERROR, LogLevel.ERROR);
}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -27,6 +27,7 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import static org.jboss.test.selenium.dom.Event.*;
import java.net.URL;
@@ -35,7 +36,6 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -58,12 +58,6 @@
return buildUrl(contextPath, "faces/components/a4jOutputPanel/simple.xhtml");
}
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
/**
* Data provider for templates, events and layout of output panel.
*
@@ -72,32 +66,28 @@
* panel (block or inline)
*/
@SuppressWarnings("unused")
- @DataProvider(name = "templatesEventsLayouts")
- private Object[][] getTemplatesEventsLayouts() {
+ @DataProvider(name = "eventsLayouts")
+ private Object[][] getEventsLayouts() {
final int layoutsCount = 2;
- // list of templates, e.g. {{"plain"}, {"richDataTable1,redDiv"}}
- Object[][] templates = getTemplates();
// list of events that will be tested
- Event[] events = new Event[]{Event.CLICK, Event.DBLCLICK, Event.KEYDOWN, Event.KEYPRESS, Event.KEYUP,
- Event.MOUSEDOWN, Event.MOUSEMOVE, Event.MOUSEOUT, Event.MOUSEOVER, Event.MOUSEUP};
+ Event[] events = new Event[] { CLICK, DBLCLICK, KEYDOWN, KEYPRESS, KEYUP, MOUSEDOWN, MOUSEMOVE, MOUSEOUT,
+ MOUSEOVER, MOUSEUP };
- Object[][] result = new Object[templates.length * events.length * layoutsCount][];
+ Object[][] result = new Object[events.length * layoutsCount][];
int index = 0;
- for (int i = 0; i < templates.length; i++) {
- for (int j = 0; j < events.length; j++) {
- for (int k = 0; k < layoutsCount; k++) {
- index = i * events.length * layoutsCount + j * layoutsCount + k;
- result[index] = new Object[]{templates[i][0], events[j], k == 0 ? "block" : "inline"};
- }
+ for (int i = 0; i < events.length; i++) {
+ for (int j = 0; j < layoutsCount; j++) {
+ index = i * layoutsCount + j;
+ result[index] = new Object[] { events[i], j == 0 ? "block" : "inline" };
}
}
return result;
}
- @Test(dataProvider = "templatesEventsLayouts")
- public void testEvent(String templates, Event event, String type) {
+ @Test(dataProvider = "eventsLayouts")
+ public void testEvent(Event event, String type) {
JQueryLocator element = null;
if ("inline".equals(type)) {
@@ -120,8 +110,8 @@
testFireEvent(event, element);
}
- @Test(dataProvider = "templates")
- public void testClick(String templates) {
+ @Test
+ public void testClick() {
selenium.click(increaseCounterButton);
waitGui.until(textEquals.locator(outputDiv).text("1"));
@@ -129,8 +119,8 @@
waitGui.until(textEquals.locator(outputDiv).text("2"));
}
- @Test(dataProvider = "templates")
- public void testAjaxRendered(String templates) {
+ @Test
+ public void testAjaxRendered() {
JQueryLocator ajaxRenderedCheckbox = pjq("input[id$=ajaxRenderedInput]");
JQueryLocator reRenderAllImage = jq("div.header img[id$=reRenderAllImage]");
@@ -147,8 +137,8 @@
waitGui.until(textEquals.locator(outputDiv).text("2"));
}
- @Test(dataProvider = "templates")
- public void testDir(String templates) {
+ @Test
+ public void testDir() {
JQueryLocator optionLtr = pjq("input[name$=dirInput][value=ltr]");
JQueryLocator optionRtl = pjq("input[name$=dirInput][value=rtl]");
JQueryLocator optionNone = pjq("input[name$=dirInput][value=]");
@@ -175,8 +165,8 @@
}
}
- @Test(dataProvider = "templates")
- public void testLang(String templates) {
+ @Test
+ public void testLang() {
JQueryLocator langInput = pjq("input[id$=langInput]");
AttributeLocator<?> attributeLang = outputDiv.getAttribute(new Attribute("lang"));
@@ -193,8 +183,8 @@
assertEquals(attributeValue, "sk", "Lang attribute");
}
- @Test(dataProvider = "templates")
- public void testLayout(String templates) {
+ @Test
+ public void testLayout() {
JQueryLocator optionBlock = pjq("input[name$=layoutInput][value=block]");
JQueryLocator optionInline = pjq("input[name$=layoutInput][value=inline]");
JQueryLocator optionNone = pjq("input[name$=layoutInput][value=none]");
@@ -218,8 +208,8 @@
assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered when none is set.");
}
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
+ @Test
+ public void testRendered() {
JQueryLocator renderedInput = pjq("input[id$=renderedInput]");
selenium.click(renderedInput);
@@ -237,8 +227,8 @@
assertEquals(counter, "2", "Counter after two clicks on button.");
}
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
+ @Test
+ public void testStyle() {
String style = "background-color: magenta; color: white; font-weight: bold;";
JQueryLocator styleInput = pjq("input[id$=styleInput]");
AttributeLocator<?> attributeStyle = outputDiv.getAttribute(Attribute.STYLE);
@@ -258,8 +248,8 @@
}
}
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
+ @Test
+ public void testStyleClass() {
JQueryLocator optionNone = pjq("input[name$=styleClassInput][value=]");
AttributeLocator<?> attributeClass = outputDiv.getAttribute(Attribute.CLASS);
@@ -285,8 +275,8 @@
}
}
- @Test(dataProvider = "templates")
- public void testTitle(String templates) {
+ @Test
+ public void testTitle() {
String title = "a4j:outputPanel title";
JQueryLocator titleInput = pjq("input[id$=titleInput]");
AttributeLocator<?> attributeTitle = outputDiv.getAttribute(new Attribute("title"));
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -29,7 +29,6 @@
import org.jboss.test.selenium.locator.IdLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
@@ -63,11 +62,6 @@
return buildUrl(contextPath, "faces/components/a4jPoll/simple.xhtml");
}
- @AfterMethod(alwaysRun = true)
- public void clearSession() {
- invalidateSession();
- }
-
/**
* <p>
* Test the progress of polling for 3 different values from client side.
@@ -92,8 +86,8 @@
* deviations isn't greater than {@link #MAX_AVERAGE_DEVIATION}.
* </p>
*/
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testIntervalFromClientPerspective(String templates) {
+ @Test(groups = "client-side-perf")
+ public void testIntervalFromClientPerspective() {
long total = 0;
long count = 0;
Copied: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Templates.java (from rev 18256, root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java)
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Templates.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Templates.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -0,0 +1,14 @@
+package org.richfaces.tests.metamer.ftest.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+
+@Target({ TYPE, FIELD, METHOD, PARAMETER })
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Templates {
+ String[] include() default {};
+ String[] exclude() default {};
+}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -5,7 +5,7 @@
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
-@Target({ TYPE, FIELD, METHOD, PARAMETER })
+@Target({ FIELD, METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Use {
String field() default "";
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -34,7 +34,6 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
/**
@@ -56,14 +55,8 @@
return buildUrl(contextPath, "faces/components/commandButton/simple.xhtml");
}
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testSimpleClick(String templates) {
+ @Test(groups = "client-side-perf")
+ public void testSimpleClick() {
selenium.typeKeys(input, "RichFaces 4");
selenium.click(button);
@@ -79,8 +72,8 @@
assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces 4' in input");
}
- @Test(dataProvider = "templates")
- public void testSimpleClickUnicode(String templates) {
+ @Test
+ public void testSimpleClickUnicode() {
selenium.typeKeys(input, "ľščťžýáíéňô");
selenium.click(button);
@@ -96,8 +89,8 @@
assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when 'ľščťžýáíéňô' in input");
}
- @Test(dataProvider = "templates")
- public void testAction(String templates) {
+ @Test
+ public void testAction() {
JQueryLocator doubleStringAction = pjq("input[value=doubleStringAction]");
JQueryLocator first6CharsAction = pjq("input[value=first6CharsAction]");
JQueryLocator toUpperCaseAction = pjq("input[value=toUpperCaseAction]");
@@ -128,8 +121,8 @@
assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces 4ě' in input and toUpperCaseAction selected");
}
- @Test(dataProvider = "templates")
- public void testActionListener(String templates) {
+ @Test
+ public void testActionListener() {
JQueryLocator doubleStringActionListener = pjq("input[value=doubleStringActionListener]");
JQueryLocator first6CharsActionListener = pjq("input[value=first6CharsActionListener]");
JQueryLocator toUpperCaseActionListener = pjq("input[value=toUpperCaseActionListener]");
@@ -161,8 +154,8 @@
"output2 when 'RichFaces 4ě' in input and toUpperCaseActionListener selected");
}
- @Test(dataProvider = "templates")
- public void testDisabled(String templates) {
+ @Test
+ public void testDisabled() {
JQueryLocator disabledChecbox = pjq("input[id$=disabledInput]");
AttributeLocator<?> disabledAttribute = button.getAttribute(new Attribute("disabled"));
@@ -174,75 +167,75 @@
}
// not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnblur(String templates) {
+ // @Test
+ public void testOnblur() {
testFireEvent(Event.BLUR, button);
}
// not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnchange(String templates) {
+ // @Test
+ public void testOnchange() {
testFireEvent(Event.CHANGE, button);
}
- @Test(dataProvider = "templates")
- public void testOnclick(String templates) {
+ @Test
+ public void testOnclick() {
testFireEvent(Event.CLICK, button);
}
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
+ @Test
+ public void testOndblclick() {
testFireEvent(Event.DBLCLICK, button);
}
// not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnfocus(String templates) {
+ // @Test
+ public void testOnfocus() {
testFireEvent(Event.FOCUS, button);
}
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
+ @Test
+ public void testOnkeydown() {
testFireEvent(Event.KEYDOWN, button);
}
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
+ @Test
+ public void testOnkeypress() {
testFireEvent(Event.KEYPRESS, button);
}
- @Test(dataProvider = "templates")
- public void testOnkeyup(String templates) {
+ @Test
+ public void testOnkeyup() {
testFireEvent(Event.KEYUP, button);
}
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
+ @Test
+ public void testOnmousedown() {
testFireEvent(Event.MOUSEDOWN, button);
}
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
+ @Test
+ public void testOnmousemove() {
testFireEvent(Event.MOUSEMOVE, button);
}
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
+ @Test
+ public void testOnmouseout() {
testFireEvent(Event.MOUSEOUT, button);
}
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
+ @Test
+ public void testOnmouseover() {
testFireEvent(Event.MOUSEOVER, button);
}
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
+ @Test
+ public void testOnmouseup() {
testFireEvent(Event.MOUSEUP, button);
}
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
+ @Test
+ public void testStyleClass() {
JQueryLocator wide = pjq("input[name$=styleClassInput][value=wide]");
JQueryLocator big = pjq("input[name$=styleClassInput][value=big]");
@@ -263,27 +256,27 @@
assertFalse(selenium.isAttributePresent(classAttribute), "Button's class was not removed.");
}
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
+ @Test
+ public void testStyle() {
JQueryLocator styleInput = pjq("input[id$=styleInput]");
final AttributeLocator<?> attribute = button.getAttribute(new Attribute("style"));
final String value = "font-size: 20px;";
selenium.type(styleInput, value);
selenium.waitForPageToLoad(TIMEOUT);
-
+
assertEquals(selenium.getAttribute(attribute), value, "Style of the button did not change");
}
- @Test(dataProvider = "templates")
- public void testValue(String templates) {
+ @Test
+ public void testValue() {
JQueryLocator valueInput = pjq("input[id$=valueInput]");
final AttributeLocator<?> attribute = button.getAttribute(new Attribute("value"));
final String value = "new label";
selenium.type(valueInput, value);
selenium.waitForPageToLoad(TIMEOUT);
-
+
assertEquals(selenium.getAttribute(attribute), value, "Value of the button did not change");
}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -35,7 +35,6 @@
import org.richfaces.tests.metamer.ftest.annotations.Use;
import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
import org.richfaces.tests.metamer.ftest.model.DataTable;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -101,10 +100,4 @@
assertEquals(maxPages, dataScroller.getCountOfVisiblePages());
}
}
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-28 13:40:23 UTC (rev 18256)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-28 13:41:42 UTC (rev 18257)
@@ -60,8 +60,8 @@
*
* @see {@link #testRowCount(DataScroller)}
*/
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testRowCountFooterScroller(String templates) {
+ @Test(groups = "client-side-perf")
+ public void testRowCountFooterScroller() {
testRowCount(dataScroller2);
}
@@ -70,8 +70,8 @@
*
* @see {@link #testRowCount(DataScroller)}
*/
- @Test(dataProvider = "templates")
- public void testRowCountOutsideTable(String templates) {
+ @Test
+ public void testRowCountOutsideTable() {
testRowCount(dataScroller1);
}
14 years, 5 months
JBoss Rich Faces SVN: r18256 - in root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: model and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-28 09:40:23 -0400 (Wed, 28 Jul 2010)
New Revision: 18256
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AssertingDataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
Removed:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
Log:
moved DataTable, DataScroller and AssertingDataScroller to separata package ftest.model
Copied: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AssertingDataScroller.java (from rev 18255, root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java)
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AssertingDataScroller.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AssertingDataScroller.java 2010-07-28 13:40:23 UTC (rev 18256)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.model;
+
+import static junit.framework.Assert.*;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+
+/**
+ * Provides DataScroller control methods with assertions about scroller state.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class AssertingDataScroller extends DataScroller {
+
+ public AssertingDataScroller(JQueryLocator root) {
+ super(root);
+ }
+
+ @Override
+ public void gotoPage(int pageNumber) {
+ int startCount = this.getCountOfVisiblePages();
+ super.gotoPage(pageNumber);
+
+ int currentPage = this.getCurrentPage();
+ assertEquals(this.getCountOfVisiblePages(), startCount);
+ assertEquals(currentPage, pageNumber);
+
+ assertEquals(isFirstPageButtonDisabled(), this.isFirstPage());
+ assertEquals(isLastPageButtonDisabled(), this.isLastPage());
+
+ if (fastStep != null) {
+ assertEquals(isFastRewindDisabled(), currentPage - fastStep < 1);
+ if (lastPage != null) {
+ assertEquals(isFastForwardDisabled(), currentPage + fastStep > lastPage);
+ }
+ }
+ }
+
+ @Override
+ public void gotoFirstPage() {
+ super.gotoFirstPage();
+ assertTrue(isFastRewindDisabled());
+ assertTrue(isFirstPageButtonDisabled());
+ }
+
+ @Override
+ public void gotoLastPage() {
+ super.gotoLastPage();
+ assertTrue(isFastForwardDisabled());
+ assertTrue(isLastPageButtonDisabled());
+ }
+
+ public boolean isFastForwardDisabled() {
+ return selenium.belongsClass(fastForwardButton, CLASS_DISABLED);
+ }
+
+ public boolean isFastRewindDisabled() {
+ return selenium.belongsClass(fastRewindButton, CLASS_DISABLED);
+ }
+
+ public boolean isLastPageButtonDisabled() {
+ return selenium.belongsClass(lastPageButton, CLASS_DISABLED);
+ }
+
+ public boolean isFirstPageButtonDisabled() {
+ return selenium.belongsClass(firstPageButton, CLASS_DISABLED);
+ }
+}
Copied: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java (from rev 18255, root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java)
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-07-28 13:40:23 UTC (rev 18256)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * 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.model;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.reference.LocatorReference;
+import org.jboss.test.selenium.locator.reference.ReferencedLocator;
+
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
+
+/**
+ * Provides DataScroller control methods.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataScroller {
+
+ protected static final String CLASS_DISABLED = "rf-ds-dis";
+
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
+
+ ReferencedLocator<JQueryLocator> numberedPages = ref(root, "> .rf-ds-dtl");
+ ReferencedLocator<JQueryLocator> specificNumberedPage = ref(root, "> .rf-ds-dtl:textEquals('{0}')");
+
+ ReferencedLocator<JQueryLocator> firstPageButton = ref(root, "> .rf-ds-l[id$=ds_f]");
+ ReferencedLocator<JQueryLocator> fastRewindButton = ref(root, "> .rf-ds-l[id$=ds_fr]");
+ ReferencedLocator<JQueryLocator> fastForwardButton = ref(root, "> .rf-ds-r[id$=ds_ff]");
+ ReferencedLocator<JQueryLocator> lastPageButton = ref(root, "> .rf-ds-r[id$=ds_l]");
+
+ ReferencedLocator<JQueryLocator> firstVisiblePage = ref(root, "> .rf-ds-dtl:first");
+ ReferencedLocator<JQueryLocator> lastVisiblePage = ref(root, "> .rf-ds-dtl:last");
+ ReferencedLocator<JQueryLocator> currentPage = ref(root, "> .rf-ds-cur");
+
+ Integer fastStep = null;
+ Integer lastPage = null;
+
+ public DataScroller(JQueryLocator root) {
+ setRoot(root);
+ }
+
+ public JQueryLocator getRoot() {
+ return root.getLocator();
+ }
+
+ public void setRoot(JQueryLocator root) {
+ this.root.setLocator(root);
+ }
+
+ public void setFastStep(int fastStep) {
+ this.fastStep = fastStep;
+ }
+
+ public void setLastPage(int pageNumber) {
+ this.lastPage = pageNumber;
+ }
+
+ public void gotoFirstPage() {
+ if (!isFirstPage()) {
+ clickFirstPageButton();
+ }
+ }
+
+ public void gotoLastPage() {
+ if (!isLastPage()) {
+ clickLastPageButton();
+ }
+ }
+
+ public void gotoPage(int pageNumber) {
+ while (pageNumber > getLastVisiblePage()) {
+ fastForward();
+ }
+
+ while (pageNumber < getFirstVisiblePage()) {
+ fastRewind();
+ }
+
+ clickPageButton(pageNumber);
+ }
+
+ public void fastForward() {
+ if (selenium.belongsClass(fastForwardButton, CLASS_DISABLED)) {
+ if (fastStep != null && lastPage != null) {
+ if (getCurrentPage() + fastStep > lastPage) {
+ gotoPage(getLastVisiblePage());
+ } else {
+ throw new AssertionError("fast forward button disabled");
+ }
+ } else {
+ gotoPage(getLastVisiblePage());
+ }
+ } else {
+ clickFastForward();
+ }
+ }
+
+ public void fastRewind() {
+ if (selenium.belongsClass(fastRewindButton, CLASS_DISABLED)) {
+ if (fastStep != null) {
+ if (getCurrentPage() - fastStep <= 0) {
+ gotoPage(getFirstVisiblePage());
+ } else {
+ throw new AssertionError("fast forward button disabled");
+ }
+ } else {
+ gotoPage(getFirstVisiblePage());
+ }
+ } else {
+ clickFastRewind();
+ }
+ }
+
+ public int getCountOfVisiblePages() {
+ return selenium.getCount(numberedPages);
+ }
+
+ public boolean hasPages() {
+ return selenium.isElementPresent(lastVisiblePage);
+ }
+
+ public int getFirstVisiblePage() {
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(firstVisiblePage));
+ }
+
+ public int getLastVisiblePage() {
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(lastVisiblePage));
+ }
+
+ public int getLastPage() {
+ int startPage = getCurrentPage();
+ clickLastPageButton();
+ int lastPage = getCurrentPage();
+ if (startPage == 1) {
+ clickFirstPageButton();
+ } else {
+ gotoPage(startPage);
+ }
+ return lastPage;
+ }
+
+ public int getCurrentPage() {
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(currentPage));
+ }
+
+ public boolean isFirstPage() {
+ return getCurrentPage() == 1;
+ }
+
+ public boolean isLastPage() {
+ return getCurrentPage() == getLastVisiblePage();
+ }
+
+ public static int integer(String string) {
+ return Integer.valueOf(string);
+ }
+
+ public void clickLastPageButton() {
+ guardXhr(selenium).click(lastPageButton);
+ }
+
+ public void clickFirstPageButton() {
+ guardXhr(selenium).click(firstPageButton);
+ }
+
+ public void clickPageButton(int pageNumber) {
+ guardXhr(selenium).click(specificNumberedPage.format(pageNumber));
+ }
+
+ public void clickFastForward() {
+ guardXhr(selenium).click(fastForwardButton);
+ }
+
+ public void clickFastRewind() {
+ guardXhr(selenium).click(fastRewindButton);
+ }
+
+
+}
Copied: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java (from rev 18255, root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java)
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java 2010-07-28 13:40:23 UTC (rev 18256)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.model;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.reference.LocatorReference;
+import org.jboss.test.selenium.locator.reference.ReferencedLocator;
+
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
+
+/**
+ * Provides methods to control DataTable
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataTable {
+
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
+
+ ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b table table tr");
+
+ public DataTable(JQueryLocator tableRoot) {
+ root.setLocator(tableRoot);
+ }
+
+ public int getCountOfTableRows() {
+ return selenium.getCount(tableRows);
+ }
+
+ public String getTableText() {
+ return selenium.getText(root.getLocator());
+ }
+}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-28 13:39:25 UTC (rev 18255)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-28 13:40:23 UTC (rev 18256)
@@ -33,8 +33,8 @@
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Named;
import org.richfaces.tests.metamer.ftest.annotations.Use;
-import org.richfaces.tests.metamer.ftest.richExtendedDataTable.AssertingDataScroller;
-import org.richfaces.tests.metamer.ftest.richExtendedDataTable.DataTable;
+import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Deleted: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java 2010-07-28 13:39:25 UTC (rev 18255)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java 2010-07-28 13:40:23 UTC (rev 18256)
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * 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.richExtendedDataTable;
-
-import static junit.framework.Assert.*;
-
-import org.jboss.test.selenium.locator.JQueryLocator;
-
-/**
- * Provides DataScroller control methods with assertions about scroller state.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class AssertingDataScroller extends DataScroller {
-
- public AssertingDataScroller(JQueryLocator root) {
- super(root);
- }
-
- @Override
- public void gotoPage(int pageNumber) {
- int startCount = this.getCountOfVisiblePages();
- super.gotoPage(pageNumber);
-
- int currentPage = this.getCurrentPage();
- assertEquals(this.getCountOfVisiblePages(), startCount);
- assertEquals(currentPage, pageNumber);
-
- assertEquals(isFirstPageButtonDisabled(), this.isFirstPage());
- assertEquals(isLastPageButtonDisabled(), this.isLastPage());
-
- if (fastStep != null) {
- assertEquals(isFastRewindDisabled(), currentPage - fastStep < 1);
- if (lastPage != null) {
- assertEquals(isFastForwardDisabled(), currentPage + fastStep > lastPage);
- }
- }
- }
-
- @Override
- public void gotoFirstPage() {
- super.gotoFirstPage();
- assertTrue(isFastRewindDisabled());
- assertTrue(isFirstPageButtonDisabled());
- }
-
- @Override
- public void gotoLastPage() {
- super.gotoLastPage();
- assertTrue(isFastForwardDisabled());
- assertTrue(isLastPageButtonDisabled());
- }
-
- public boolean isFastForwardDisabled() {
- return selenium.belongsClass(fastForwardButton, CLASS_DISABLED);
- }
-
- public boolean isFastRewindDisabled() {
- return selenium.belongsClass(fastRewindButton, CLASS_DISABLED);
- }
-
- public boolean isLastPageButtonDisabled() {
- return selenium.belongsClass(lastPageButton, CLASS_DISABLED);
- }
-
- public boolean isFirstPageButtonDisabled() {
- return selenium.belongsClass(firstPageButton, CLASS_DISABLED);
- }
-}
Deleted: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-28 13:39:25 UTC (rev 18255)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-28 13:40:23 UTC (rev 18256)
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * 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.richExtendedDataTable;
-
-import org.jboss.test.selenium.framework.AjaxSelenium;
-import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.reference.LocatorReference;
-import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
-import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
-
-/**
- * Provides DataScroller control methods.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class DataScroller {
-
- protected static final String CLASS_DISABLED = "rf-ds-dis";
-
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
- LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
-
- ReferencedLocator<JQueryLocator> numberedPages = ref(root, "> .rf-ds-dtl");
- ReferencedLocator<JQueryLocator> specificNumberedPage = ref(root, "> .rf-ds-dtl:textEquals('{0}')");
-
- ReferencedLocator<JQueryLocator> firstPageButton = ref(root, "> .rf-ds-l[id$=ds_f]");
- ReferencedLocator<JQueryLocator> fastRewindButton = ref(root, "> .rf-ds-l[id$=ds_fr]");
- ReferencedLocator<JQueryLocator> fastForwardButton = ref(root, "> .rf-ds-r[id$=ds_ff]");
- ReferencedLocator<JQueryLocator> lastPageButton = ref(root, "> .rf-ds-r[id$=ds_l]");
-
- ReferencedLocator<JQueryLocator> firstVisiblePage = ref(root, "> .rf-ds-dtl:first");
- ReferencedLocator<JQueryLocator> lastVisiblePage = ref(root, "> .rf-ds-dtl:last");
- ReferencedLocator<JQueryLocator> currentPage = ref(root, "> .rf-ds-cur");
-
- Integer fastStep = null;
- Integer lastPage = null;
-
- public DataScroller(JQueryLocator root) {
- setRoot(root);
- }
-
- public JQueryLocator getRoot() {
- return root.getLocator();
- }
-
- public void setRoot(JQueryLocator root) {
- this.root.setLocator(root);
- }
-
- public void setFastStep(int fastStep) {
- this.fastStep = fastStep;
- }
-
- public void setLastPage(int pageNumber) {
- this.lastPage = pageNumber;
- }
-
- public void gotoFirstPage() {
- if (!isFirstPage()) {
- clickFirstPageButton();
- }
- }
-
- public void gotoLastPage() {
- if (!isLastPage()) {
- clickLastPageButton();
- }
- }
-
- public void gotoPage(int pageNumber) {
- while (pageNumber > getLastVisiblePage()) {
- fastForward();
- }
-
- while (pageNumber < getFirstVisiblePage()) {
- fastRewind();
- }
-
- clickPageButton(pageNumber);
- }
-
- public void fastForward() {
- if (selenium.belongsClass(fastForwardButton, CLASS_DISABLED)) {
- if (fastStep != null && lastPage != null) {
- if (getCurrentPage() + fastStep > lastPage) {
- gotoPage(getLastVisiblePage());
- } else {
- throw new AssertionError("fast forward button disabled");
- }
- } else {
- gotoPage(getLastVisiblePage());
- }
- } else {
- clickFastForward();
- }
- }
-
- public void fastRewind() {
- if (selenium.belongsClass(fastRewindButton, CLASS_DISABLED)) {
- if (fastStep != null) {
- if (getCurrentPage() - fastStep <= 0) {
- gotoPage(getFirstVisiblePage());
- } else {
- throw new AssertionError("fast forward button disabled");
- }
- } else {
- gotoPage(getFirstVisiblePage());
- }
- } else {
- clickFastRewind();
- }
- }
-
- public int getCountOfVisiblePages() {
- return selenium.getCount(numberedPages);
- }
-
- public boolean hasPages() {
- return selenium.isElementPresent(lastVisiblePage);
- }
-
- public int getFirstVisiblePage() {
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(firstVisiblePage));
- }
-
- public int getLastVisiblePage() {
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(lastVisiblePage));
- }
-
- public int getLastPage() {
- int startPage = getCurrentPage();
- clickLastPageButton();
- int lastPage = getCurrentPage();
- if (startPage == 1) {
- clickFirstPageButton();
- } else {
- gotoPage(startPage);
- }
- return lastPage;
- }
-
- public int getCurrentPage() {
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(currentPage));
- }
-
- public boolean isFirstPage() {
- return getCurrentPage() == 1;
- }
-
- public boolean isLastPage() {
- return getCurrentPage() == getLastVisiblePage();
- }
-
- public static int integer(String string) {
- return Integer.valueOf(string);
- }
-
- public void clickLastPageButton() {
- guardXhr(selenium).click(lastPageButton);
- }
-
- public void clickFirstPageButton() {
- guardXhr(selenium).click(firstPageButton);
- }
-
- public void clickPageButton(int pageNumber) {
- guardXhr(selenium).click(specificNumberedPage.format(pageNumber));
- }
-
- public void clickFastForward() {
- guardXhr(selenium).click(fastForwardButton);
- }
-
- public void clickFastRewind() {
- guardXhr(selenium).click(fastRewindButton);
- }
-
-
-}
Deleted: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-28 13:39:25 UTC (rev 18255)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-28 13:40:23 UTC (rev 18256)
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * 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.richExtendedDataTable;
-
-import org.jboss.test.selenium.framework.AjaxSelenium;
-import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.reference.LocatorReference;
-import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-
-import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
-
-/**
- * Provides methods to control DataTable
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class DataTable {
-
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
- LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
-
- ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b table table tr");
-
- public DataTable(JQueryLocator tableRoot) {
- root.setLocator(tableRoot);
- }
-
- public int getCountOfTableRows() {
- return selenium.getCount(tableRows);
- }
-
- public String getTableText() {
- return selenium.getText(root.getLocator());
- }
-}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-28 13:39:25 UTC (rev 18255)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-28 13:40:23 UTC (rev 18256)
@@ -29,6 +29,9 @@
import org.jboss.test.selenium.locator.IdLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
+import org.richfaces.tests.metamer.ftest.model.DataScroller;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
import org.testng.annotations.Test;
/**
14 years, 5 months
JBoss Rich Faces SVN: r18255 - root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-28 09:39:25 -0400 (Wed, 28 Jul 2010)
New Revision: 18255
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java
Log:
support for not parametrized test classes
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-28 13:38:50 UTC (rev 18254)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/MatrixConfigurator.java 2010-07-28 13:39:25 UTC (rev 18255)
@@ -56,7 +56,7 @@
import org.testng.annotations.ITestAnnotation;
/**
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @author <a href="mailto:ppitonak@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
public class MatrixConfigurator implements IAnnotationTransformer, IInvokedMethodListener, IMethodInterceptor {
@@ -94,14 +94,12 @@
private void configureMethod(ITestResult testResult) {
Method realMethod = ((Queue<Method>) methods).poll();
- Class<?> realClass;
- try {
- realClass = realMethod.getDeclaringClass();
- } catch (NullPointerException e) {
- System.out.println(e);
+ Class<?> realClass = realMethod.getDeclaringClass();
+
+ if (!configurations.get(realClass).get(realMethod).hasNext()) {
return;
}
-
+
final Object testInstance = testResult.getInstance();
Map<NamedType, Object> configuration = configurations.get(realClass).get(realMethod).next();
@@ -147,22 +145,8 @@
annotation.setInvocationCount(invocationCount);
}
- // public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
- // for (IMethodInstance methodInstance : methods) {
- // int count = createConfiguration(methodInstance);
- // for (int i = 0; i < count; i++) {
- // methodInstances.add(methodInstance);
- // }
- // }
- //
- // return methodInstances;
- // }
-
public int createConfiguration(Class<?> realClass, Method realMethod) {
- // Class<?> realClass = method.getRealClass();
- // String methodName = method.getName();
-
Map<NamedType, List<? extends Object>> parameters = new LinkedHashMap<NamedType, List<? extends Object>>();
List<NamedType> unsatisfied = new LinkedList<NamedType>();
@@ -181,13 +165,6 @@
}
}
- // get a injections from method level
- // Method realMethod;
- // try {
- // realMethod = realClass.getMethod(methodName);
- // } catch (Exception e) {
- // throw new IllegalStateException(e);
- // }
for (Annotation annotation : realMethod.getAnnotations()) {
if (annotation.annotationType() == Use.class) {
Use use = (Use) annotation;
@@ -215,7 +192,7 @@
getClassConfigurations(realClass).put(realMethod, configuration);
- return count;
+ return Math.max(1, count);
}
private Map<Method, Configuration> getClassConfigurations(Class<?> realClass) {
@@ -307,7 +284,7 @@
}
public boolean hasNext() {
- return !lastQueue.isEmpty();
+ return !parameters.isEmpty() && !lastQueue.isEmpty();
}
public void remove() {
14 years, 5 months