Author: alexsmirnov
Date: 2007-06-29 15:32:26 -0400 (Fri, 29 Jun 2007)
New Revision: 1422
Added:
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.jav
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockComponentState.java
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockDataAdaptor.java
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockDataModel.java
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockRange.java
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockSerializableDataModel.java
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.jav
branches/refactor1/ui/core/src/test/
branches/refactor1/ui/core/src/test/java/
branches/refactor1/ui/core/src/test/java/org/
branches/refactor1/ui/core/src/test/java/org/ajax4jsf/
branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/
branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java
branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/RepeatTestCase.java
Removed:
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/AllUIRepeatTests.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockComponentState.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataAdaptor.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataModel.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockRange.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockSerializableDataModel.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/RepeatTestCase.java
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java
Modified:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceComponent.java
branches/refactor1/framework/impl/pom.xml
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/AbstractThreadedAjax4JsfTestCase.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/DataAdaptorTestCase.java
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java
Log:
continue refactoring. Implementation & test projects are restored
Modified:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceComponent.java
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceComponent.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceComponent.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.ajax.resource;
+package org.ajax4jsf.framework.resource;
import java.util.Date;
Modified: branches/refactor1/framework/impl/pom.xml
===================================================================
--- branches/refactor1/framework/impl/pom.xml 2007-06-29 19:07:21 UTC (rev 1421)
+++ branches/refactor1/framework/impl/pom.xml 2007-06-29 19:32:26 UTC (rev 1422)
@@ -1,292 +1,306 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
- <parent>
- <artifactId>framework</artifactId>
- <groupId>org.richfaces</groupId>
- <version>3.1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.framework</groupId>
- <artifactId>impl</artifactId>
- <name>Java Server Faces AJAX framework implementation</name>
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <directory>target/javascript</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-resources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <ant>
- <target />
- <property />
- </ant>
- </tasks>
-
<resourceRoot>${project.build.directory}/javascript</resourceRoot>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-source</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <java>
- <arg />
- <arg />
- </java>
- </tasks>
-
<sourceRoot>${project.build.directory}/generated-sources/antlr</sourceRoot>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr</artifactId>
- <version>3.0</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- <profiles>
- <profile>
- <id>jsf1_1</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- <property>
- <name>jsfVersion</name>
- <value>1.1</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>1.1_02</version>
- <exclusions>
- <exclusion>
- <artifactId>jsp-api</artifactId>
- <groupId>javax.servlet.jsp</groupId>
- </exclusion>
- <exclusion>
- <artifactId>jstl</artifactId>
- <groupId>javax.servlet.jsp.jstl</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>1.1_02</version>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <artifactId>jsp-api</artifactId>
- <groupId>javax.servlet.jsp</groupId>
- </exclusion>
- <exclusion>
- <artifactId>jstl</artifactId>
- <groupId>javax.servlet.jsp.jstl</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>jsf1_2</id>
- <activation>
- <property>
- <name>jsfVersion</name>
- <value>1.2</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>process-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>src/main/jsf12</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>1.2_03</version>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>1.2_03</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>opensymphony</groupId>
- <artifactId>oscache</artifactId>
- <version>2.3</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>com.sun.facelets</groupId>
- <artifactId>jsf-facelets</artifactId>
- <version>1.1.11</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>nekohtml</groupId>
- <artifactId>nekohtml</artifactId>
- <version>0.9.5</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.7.0</version>
- </dependency>
- <dependency>
- <groupId>commons-digester</groupId>
- <artifactId>commons-digester</artifactId>
- <version>1.8</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.framework</groupId>
- <artifactId>api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr</artifactId>
- <version>3.0</version>
- </dependency>
- </dependencies>
- <properties>
- <jsfVersion>1.1</jsfVersion>
- </properties>
-</project>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <parent>
+ <artifactId>framework</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>impl</artifactId>
+ <name>Java Server Faces AJAX framework implementation</name>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>target/javascript</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-source</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!--
+ <execution>
+ <id>antlr</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <java classname="org.antlr.Tool"
+ classpathref="maven.plugin.classpath"
+ fork="true"
+ dir="src/main/antlr">
+ <arg value="RichMacroDefinition.g"/>
+ <arg line="-o
${project.build.directory}/generated-sources/antlr/org/richfaces"/>
+ </java>
+ </tasks>
+ <sourceRoot>${project.build.directory}/generated-sources/antlr</sourceRoot>
+ </configuration>
+ </execution>
+ -->
+ <execution>
+ <id>javascript</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant
+ antfile="${basedir}/generatescript.xml"
inheritRefs="true">
+ <target name="assembly" />
+ <property name="target-dir"
+ value="${project.build.directory}/javascript">
+ </property>
+ </ant>
+ </tasks>
+ <resourceRoot>
+ ${project.build.directory}/javascript
+ </resourceRoot>
+ </configuration>
+ </execution>
+ </executions>
+ <!--
+ <dependencies>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.0</version>
+ </dependency>
+ </dependencies>
+ -->
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>jsf1_1</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ <property>
+ <name>jsfVersion</name>
+ <value>1.1</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.1_02</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>jsp-api</artifactId>
+ <groupId>javax.servlet.jsp</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jstl</artifactId>
+ <groupId>javax.servlet.jsp.jstl</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.1_02</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>jsp-api</artifactId>
+ <groupId>javax.servlet.jsp</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jstl</artifactId>
+ <groupId>javax.servlet.jsp.jstl</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>jsf1_2</id>
+ <activation>
+ <property>
+ <name>jsfVersion</name>
+ <value>1.2</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>
+ build-helper-maven-plugin
+ </artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/main/jsf12</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.2_03</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_03</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>oscache</artifactId>
+ <version>2.3</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ <version>1.1.11</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>nekohtml</groupId>
+ <artifactId>nekohtml</artifactId>
+ <version>0.9.5</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.0</version>
+ </dependency>
+ -->
+ </dependencies>
+ <properties>
+ <jsfVersion>1.1</jsfVersion>
+ </properties>
+</project>
+
Copied:
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.jav
(from rev 1418,
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java)
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.jav
(rev 0)
+++
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.jav 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,168 @@
+/**
+ *
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+
+import org.richfaces.json.JSContentHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com created 21.06.2007
+ *
+ */
+public class MacroDefinitionJSContentHandler extends JSContentHandler {
+ private String prolog;
+ private String epilog;
+
+ public MacroDefinitionJSContentHandler(Writer writer, String prolog,
+ String epilog) {
+ super(writer);
+ this.prolog = prolog;
+ this.epilog = epilog;
+ }
+
+ private List parseExpressiion(String expressionString) throws SAXException {
+ ANTLRStringStream stream = new ANTLRStringStream(expressionString);
+ RichMacroDefinitionLexer lexer = new RichMacroDefinitionLexer(stream);
+ RichMacroDefinitionParser macroParser = new RichMacroDefinitionParser(
+ new CommonTokenStream(lexer));
+ try {
+ expression_return expression = macroParser.expression();
+ List result = expression.result;
+
+ return result;
+ } catch (RecognitionException e) {
+ throw new SAXException(e.getMessage(), e);
+ }
+ }
+
+ private void encodeExpressionString(String string) throws IOException,
+ SAXException {
+ List parsedExpressiion = parseExpressiion(string);
+
+ boolean isExpression = false;
+ for (Iterator iterator = parsedExpressiion.iterator(); iterator
+ .hasNext();) {
+ Object next = (Object) iterator.next();
+ if (next instanceof Expression) {
+ isExpression = true;
+ break;
+ }
+ }
+
+ if (isExpression) {
+ this.outputWriter.write("function (context) { return ");
+ }
+
+ boolean first = true;
+ for (Iterator iterator = parsedExpressiion.iterator(); iterator
+ .hasNext();) {
+ Object next = (Object) iterator.next();
+
+ if (next == null) {
+ continue;
+ }
+
+ if (!first) {
+ this.outputWriter.write('+');
+ }
+
+ if (next instanceof Expression) {
+ Expression macroExpression = (Expression) next;
+
+ this.outputWriter.write(prolog);
+ this.encode(macroExpression.getExpression().toString());
+ this.outputWriter.write(epilog);
+ } else {
+ this.outputWriter.write('\'');
+ this.encode(next.toString());
+ this.outputWriter.write('\'');
+ }
+
+ first = false;
+ }
+
+ if (isExpression) {
+ this.outputWriter.write(";}");
+ }
+ }
+
+ protected void encodeAttributeValue(Attributes attributes, int idx)
+ throws SAXException, IOException {
+
+ String value = attributes.getValue(idx);
+ encodeExpressionString(value);
+ }
+
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
+ if (isProcessingCdata()) {
+ super.characters(ch, start, length);
+ } else {
+ List parsedExpression = parseExpressiion(new String(ch, start, length));
+ for (Iterator iterator = parsedExpression.iterator(); iterator
+ .hasNext();) {
+
+ Object next = iterator.next();
+
+ if (next instanceof Expression) {
+ Expression expression = (Expression) next;
+
+ if (this.isBeforeDocumentStart() || level < 0)
+ return;
+ try {
+ if (level != 0 && !this.closeElement(false) &&
this.isProcessingCdata() == false) {
+ this.outputWriter.write(',');
+ }
+
+ if (this.isProcessingCdata() == false) {
+ this.outputWriter.write("new ET(");
+ }
+
+ this.outputWriter.write("function (context) { return ");
+ this.outputWriter.write(prolog);
+ this.encode(expression.getExpression().toString());
+ this.outputWriter.write(epilog);
+ this.outputWriter.write("}");
+
+ if (this.isProcessingCdata() == false) {
+ this.outputWriter.write(")");
+ }
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+
+ } else {
+ char[] cs = next.toString().toCharArray();
+ super.characters(cs, 0, cs.length);
+ }
+
+ if (iterator.hasNext()) {
+ try {
+ this.outputWriter.write(',');
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ protected void encodeText(char[] chars, int start, int length)
+ throws SAXException, IOException {
+ if (!isProcessingCdata()) {
+ String str = new String(chars, start, length);
+ encodeExpressionString(str);
+ } else {
+ super.encodeText(chars, start, length);
+ }
+ }
+
+}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,168 +0,0 @@
-/**
- *
- */
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.List;
-
-import org.richfaces.json.JSContentHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com created 21.06.2007
- *
- */
-public class MacroDefinitionJSContentHandler extends JSContentHandler {
- private String prolog;
- private String epilog;
-
- public MacroDefinitionJSContentHandler(Writer writer, String prolog,
- String epilog) {
- super(writer);
- this.prolog = prolog;
- this.epilog = epilog;
- }
-
- private List parseExpressiion(String expressionString) throws SAXException {
- ANTLRStringStream stream = new ANTLRStringStream(expressionString);
- RichMacroDefinitionLexer lexer = new RichMacroDefinitionLexer(stream);
- RichMacroDefinitionParser macroParser = new RichMacroDefinitionParser(
- new CommonTokenStream(lexer));
- try {
- expression_return expression = macroParser.expression();
- List result = expression.result;
-
- return result;
- } catch (RecognitionException e) {
- throw new SAXException(e.getMessage(), e);
- }
- }
-
- private void encodeExpressionString(String string) throws IOException,
- SAXException {
- List parsedExpressiion = parseExpressiion(string);
-
- boolean isExpression = false;
- for (Iterator iterator = parsedExpressiion.iterator(); iterator
- .hasNext();) {
- Object next = (Object) iterator.next();
- if (next instanceof Expression) {
- isExpression = true;
- break;
- }
- }
-
- if (isExpression) {
- this.outputWriter.write("function (context) { return ");
- }
-
- boolean first = true;
- for (Iterator iterator = parsedExpressiion.iterator(); iterator
- .hasNext();) {
- Object next = (Object) iterator.next();
-
- if (next == null) {
- continue;
- }
-
- if (!first) {
- this.outputWriter.write('+');
- }
-
- if (next instanceof Expression) {
- Expression macroExpression = (Expression) next;
-
- this.outputWriter.write(prolog);
- this.encode(macroExpression.getExpression().toString());
- this.outputWriter.write(epilog);
- } else {
- this.outputWriter.write('\'');
- this.encode(next.toString());
- this.outputWriter.write('\'');
- }
-
- first = false;
- }
-
- if (isExpression) {
- this.outputWriter.write(";}");
- }
- }
-
- protected void encodeAttributeValue(Attributes attributes, int idx)
- throws SAXException, IOException {
-
- String value = attributes.getValue(idx);
- encodeExpressionString(value);
- }
-
- public void characters(char[] ch, int start, int length)
- throws SAXException {
- if (isProcessingCdata()) {
- super.characters(ch, start, length);
- } else {
- List parsedExpression = parseExpressiion(new String(ch, start, length));
- for (Iterator iterator = parsedExpression.iterator(); iterator
- .hasNext();) {
-
- Object next = iterator.next();
-
- if (next instanceof Expression) {
- Expression expression = (Expression) next;
-
- if (this.isBeforeDocumentStart() || level < 0)
- return;
- try {
- if (level != 0 && !this.closeElement(false) &&
this.isProcessingCdata() == false) {
- this.outputWriter.write(',');
- }
-
- if (this.isProcessingCdata() == false) {
- this.outputWriter.write("new ET(");
- }
-
- this.outputWriter.write("function (context) { return ");
- this.outputWriter.write(prolog);
- this.encode(expression.getExpression().toString());
- this.outputWriter.write(epilog);
- this.outputWriter.write("}");
-
- if (this.isProcessingCdata() == false) {
- this.outputWriter.write(")");
- }
- } catch (IOException e) {
- throw new SAXException("Write error",e);
- }
-
- } else {
- char[] cs = next.toString().toCharArray();
- super.characters(cs, 0, cs.length);
- }
-
- if (iterator.hasNext()) {
- try {
- this.outputWriter.write(',');
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- }
-
- protected void encodeText(char[] chars, int start, int length)
- throws SAXException, IOException {
- if (!isProcessingCdata()) {
- String str = new String(chars, start, length);
- encodeExpressionString(str);
- } else {
- super.encodeText(chars, start, length);
- }
- }
-
-}
Modified:
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -67,29 +67,29 @@
writer.write("[");
- try {
- Transformer transformer;
+// try {
+// Transformer transformer;
+//
+// synchronized (transformerFactory) {
+// transformer = transformerFactory.newTransformer();
+// }
+//
+// transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+// transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+//
+// JSContentHandler contentHandler = new MacroDefinitionJSContentHandler(writer,
"Richfaces.eval(\"", "\", context)");
+// Result result = new SAXResult(contentHandler);
+//
+// for (int i = 0; i < bodyChildrenLength; i++) {
+// if (i != 0) {
+// writer.write(", ");
+// }
+// transformer.transform(new DOMSource(bodyChildren.item(i)), result);
+// }
+// } catch (TransformerException e) {
+// throw new IOException(e.getMessage());
+// }
- synchronized (transformerFactory) {
- transformer = transformerFactory.newTransformer();
- }
-
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
-
- JSContentHandler contentHandler = new MacroDefinitionJSContentHandler(writer,
"Richfaces.eval(\"", "\", context)");
- Result result = new SAXResult(contentHandler);
-
- for (int i = 0; i < bodyChildrenLength; i++) {
- if (i != 0) {
- writer.write(", ");
- }
- transformer.transform(new DOMSource(bodyChildren.item(i)), result);
- }
- } catch (TransformerException e) {
- throw new IOException(e.getMessage());
- }
-
writer.write("];\n");
}
Modified:
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
---
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -49,6 +49,7 @@
import javax.servlet.http.HttpServletResponse;
import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxContextImpl;
import org.ajax4jsf.framework.renderer.AjaxViewRootRenderer;
import org.ajax4jsf.framework.renderer.ChameleonRenderKitImpl;
import org.ajax4jsf.framework.resource.InternetResource;
@@ -113,7 +114,7 @@
// setup nessesary components.
application.addComponent("javax.faces.ViewRoot",
MockViewRoot.class.getName());
// setup AjaxContext.
- ajaxContext = new AjaxContext();
+ ajaxContext = new AjaxContextImpl();
request.setAttribute(AjaxContext.AJAX_CONTEXT_KEY, ajaxContext);
// Setup ViewHandler / ViewRoot.
application.setViewHandler(new MockViewHandler(application.getViewHandler()));
Modified:
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/AbstractThreadedAjax4JsfTestCase.java
===================================================================
---
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/AbstractThreadedAjax4JsfTestCase.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/AbstractThreadedAjax4JsfTestCase.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -27,6 +27,7 @@
import junit.framework.TestResult;
import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxContextImpl;
import org.apache.shale.test.mock.MockFacesContext;
import org.apache.shale.test.mock.MockHttpServletRequest;
import org.apache.shale.test.mock.MockHttpServletResponse;
@@ -220,7 +221,7 @@
protected FacesContext createFacesContext() {
MockHttpSession tsession = new MockHttpSession();
MockHttpServletRequest trequest = new MockHttpServletRequest(tsession);
- trequest.setAttribute(AjaxContext.AJAX_CONTEXT_KEY, new AjaxContext());
+ trequest.setAttribute(AjaxContext.AJAX_CONTEXT_KEY, new AjaxContextImpl());
MockHttpServletResponse tresponse = new MockHttpServletResponse();
MockFacesContext tfacesContext = (MockFacesContext)
facesContextFactory.getFacesContext(servletContext,
Copied:
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockComponentState.java
(from rev 1395,
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockComponentState.java)
===================================================================
---
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockComponentState.java
(rev 0)
+++
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockComponentState.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,96 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests;
+
+import java.io.Serializable;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.repeat.DataComponentState;
+import org.ajax4jsf.ajax.repeat.Range;
+
+/**
+ * @author shura
+ *
+ */
+public class MockComponentState implements DataComponentState,Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4278697745017092414L;
+ private int _count = 2;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.DataComponentState#getRange()
+ */
+ public Range getRange() {
+ // TODO Auto-generated method stub
+ return new MockRange(_count);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.StateHolder#isTransient()
+ */
+ public boolean isTransient() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ _count = ((Integer)state).intValue();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ // TODO Auto-generated method stub
+ return new Integer(_count);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.StateHolder#setTransient(boolean)
+ */
+ public void setTransient(boolean newTransientValue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @return the count
+ */
+ public int getCount() {
+ return _count;
+ }
+
+ /**
+ * @param count the count to set
+ */
+ public void setCount(int count) {
+ _count = count;
+ }
+
+}
Copied:
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockDataAdaptor.java
(from rev 1395,
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataAdaptor.java)
===================================================================
---
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockDataAdaptor.java
(rev 0)
+++
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockDataAdaptor.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,68 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests;
+
+import java.util.Iterator;
+
+import org.ajax4jsf.ajax.repeat.DataComponentState;
+import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
+import org.ajax4jsf.ajax.repeat.UIDataAdaptor;
+
+/**
+ * @author shura
+ *
+ */
+public class MockDataAdaptor extends UIDataAdaptor {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createComponentState()
+ */
+ protected DataComponentState createComponentState() {
+ // TODO Auto-generated method stub
+ return new MockComponentState();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createDataModel()
+ */
+ protected ExtendedDataModel createDataModel() {
+ // TODO Auto-generated method stub
+ return new MockDataModel();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#dataChildren()
+ */
+ protected Iterator dataChildren() {
+ // TODO Auto-generated method stub
+ return getChildren().iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#fixedChildren()
+ */
+ protected Iterator fixedChildren() {
+ // TODO Auto-generated method stub
+ return getFacets().values().iterator();
+ }
+
+}
Copied:
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockDataModel.java
(from rev 1395,
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataModel.java)
===================================================================
--- branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockDataModel.java
(rev 0)
+++
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockDataModel.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,171 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
+import org.ajax4jsf.ajax.repeat.Range;
+import org.ajax4jsf.ajax.repeat.SequenceRange;
+
+/**
+ * @author shura
+ *
+ */
+public class MockDataModel extends ExtendedDataModel {
+
+ public static final int ROWS = 10;
+
+ private int rowIndex = 0;
+
+ private int minRow = 0;
+
+ private int maxRow = ROWS;
+
+ /**
+ * @return the maxRow
+ */
+ public int getMaxRow() {
+ return maxRow;
+ }
+
+ /**
+ * @param maxRow the maxRow to set
+ */
+ public void setMaxRow(int maxRow) {
+ this.maxRow = maxRow;
+ }
+
+ /**
+ * @return the minRow
+ */
+ public int getMinRow() {
+ return minRow;
+ }
+
+ /**
+ * @param minRow the minRow to set
+ */
+ public void setMinRow(int minRow) {
+ this.minRow = minRow;
+ }
+
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) throws IOException {
+ int first=0;
+ int count=ROWS;
+ if (range instanceof MockRange) {
+ MockRange mockRange = (MockRange) range;
+ count = mockRange.getCount();
+ } else if (range instanceof SequenceRange) {
+ SequenceRange seqRange = (SequenceRange) range;
+ first = seqRange.getFirstRow();
+ int rows = seqRange.getRows();
+ if(rows>0){
+ count = rows+first;
+ }
+ }
+ for(int row = first; row < count && row < ROWS;row++){
+ visitor.process(context, new Integer(row), argument);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ // TODO Auto-generated method stub
+ return rowIndex<0?null:new Integer(rowIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ public void setRowKey(Object key) {
+ if(null == key){
+ rowIndex = -1;
+ } else {
+ rowIndex = ((Integer) key).intValue();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ public int getRowCount() {
+ // TODO Auto-generated method stub
+ return getMaxRow();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ public Object getRowData() {
+ // TODO Auto-generated method stub
+ return isRowAvailable()?String.valueOf(rowIndex):null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ public int getRowIndex() {
+ // TODO Auto-generated method stub
+ return rowIndex;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ public Object getWrappedData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ public boolean isRowAvailable() {
+ // TODO Auto-generated method stub
+ return rowIndex>=getMinRow() && rowIndex<getMaxRow();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ public void setRowIndex(int rowIndex) {
+ this.rowIndex = rowIndex;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ public void setWrappedData(Object data) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Copied: branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockRange.java
(from rev 1395,
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockRange.java)
===================================================================
--- branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockRange.java
(rev 0)
+++
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockRange.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests;
+
+import org.ajax4jsf.ajax.repeat.Range;
+
+/**
+ * @author shura
+ *
+ */
+public class MockRange implements Range {
+
+ private int count;
+
+ public MockRange(int count) {
+ this.count = count;
+ }
+
+ public int getCount(){
+ return count;
+ }
+}
Copied:
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockSerializableDataModel.java
(from rev 1395,
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockSerializableDataModel.java)
===================================================================
---
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockSerializableDataModel.java
(rev 0)
+++
branches/refactor1/framework/test/src/main/java/org/ajax4jsf/tests/MockSerializableDataModel.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,100 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.tests;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.Range;
+import org.ajax4jsf.ajax.repeat.SerializableDataModel;
+
+/**
+ * @author shura
+ *
+ */
+public class MockSerializableDataModel extends MockDataModel {
+
+ public SerializableDataModel getSerializableModel(Range range) {
+ MockRange mockRange = (MockRange) range;
+ SerializableDataModel model = new SerializableDataModel(){
+
+ public void update() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object getRowKey() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setRowKey(Object key) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public int getRowCount() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Object getRowData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getRowIndex() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Object getWrappedData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isRowAvailable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setRowIndex(int arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setWrappedData(Object arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+ return model;
+ }
+}
Deleted:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,154 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.Serializable;
-
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.IntegerConverter;
-import javax.faces.event.ActionEvent;
-
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-import junit.framework.TestCase;
-
-/**
- * @author shura
- *
- */
-public class ActionListenerTest extends AbstractAjax4JsfTestCase {
-
- /**
- * @param name
- */
- public ActionListenerTest(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.ajax4jsf.ajax.UIActionParameter#getValue()}.
- */
- public void testGetValue() {
- Bean bean = new Bean();
- bean.setFirst(1);
- bean.setSecond(2.0);
- UIActionParameter param = new UIActionParameter();
- param.setConverter(new TestConverter());
- param.setValue(bean);
- assertEquals("1;2.0", param.getValue());
- }
-
- public void testGetIntValue() throws Exception {
- UIActionParameter param = new UIActionParameter();
- application.addConverter(Integer.class, IntegerConverter.class.getName());
- param.setValue(new Integer(1));
- assertEquals("1", param.getValue());
- }
-
- static class TestConverter implements Converter {
-
- /* (non-Javadoc)
- * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String)
- */
- public Object getAsObject(FacesContext context, UIComponent comp, String str) {
- Bean bean = new Bean();
- String[] values = str.split(";");
- bean.setFirst(Integer.parseInt(values[0]));
- bean.setSecond(Double.parseDouble(values[1]));
- return bean;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.Object)
- */
- public String getAsString(FacesContext context, UIComponent comp, Object value) {
- Bean bean = (Bean) value;
- return
String.valueOf(bean.getFirst())+";"+String.valueOf(bean.getSecond());
- }
-
- }
-
- public static class Bean implements Serializable {
- int _first;
- double _second;
- /**
- * @return the first
- */
- public int getFirst() {
- return this._first;
- }
- /**
- * @param first the first to set
- */
- public void setFirst(int first) {
- this._first = first;
- }
- /**
- * @return the second
- */
- public double getSecond() {
- return this._second;
- }
- /**
- * @param second the second to set
- */
- public void setSecond(double second) {
- this._second = second;
- }
- }
-
- /**
- * Test method for {@link
org.ajax4jsf.ajax.UIActionParameter#processAction(javax.faces.event.ActionEvent)}.
- */
- public void testProcessAction() {
- UICommand command = new UICommand();
- UIActionParameter param = new UIActionParameter();
- param.setConverter(new IntegerConverter());
- param.setName("param");
- param.setAssignToBinding(application.createValueBinding("#{bean.first}"));
- Bean bean = new Bean();
- request.setAttribute("bean", bean);
- request.addParameter("param", "123");
- externalContext.getRequestParameterMap().put("param", "123");
- command.addActionListener(param);
- command.broadcast(new ActionEvent(command));
- assertEquals(123, bean.getFirst());
- }
-
-}
Deleted:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/AllUIRepeatTests.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/AllUIRepeatTests.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/AllUIRepeatTests.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllUIRepeatTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Test for org.ajax4jsf.ajax.repeat");
- //$JUnit-BEGIN$
- suite.addTestSuite(DataAdaptorTestCase.class);
- suite.addTestSuite(RepeatTestCase.class);
- //$JUnit-END$
- return suite;
- }
-
-}
Modified:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/DataAdaptorTestCase.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/DataAdaptorTestCase.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/DataAdaptorTestCase.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -32,6 +32,9 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.tests.MockComponentState;
+import org.ajax4jsf.tests.MockDataAdaptor;
+import org.ajax4jsf.tests.MockDataModel;
import org.ajax4jsf.tests.MockUIInputRenderer;
/**
Deleted:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockComponentState.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockComponentState.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockComponentState.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,93 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.Serializable;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author shura
- *
- */
-public class MockComponentState implements DataComponentState,Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -4278697745017092414L;
- private int _count = 2;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.DataComponentState#getRange()
- */
- public Range getRange() {
- // TODO Auto-generated method stub
- return new MockRange(_count);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.component.StateHolder#isTransient()
- */
- public boolean isTransient() {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- _count = ((Integer)state).intValue();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- // TODO Auto-generated method stub
- return new Integer(_count);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.component.StateHolder#setTransient(boolean)
- */
- public void setTransient(boolean newTransientValue) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @return the count
- */
- public int getCount() {
- return _count;
- }
-
- /**
- * @param count the count to set
- */
- public void setCount(int count) {
- _count = count;
- }
-
-}
Deleted:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataAdaptor.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataAdaptor.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataAdaptor.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,64 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.util.Iterator;
-
-/**
- * @author shura
- *
- */
-public class MockDataAdaptor extends UIDataAdaptor {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createComponentState()
- */
- protected DataComponentState createComponentState() {
- // TODO Auto-generated method stub
- return new MockComponentState();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createDataModel()
- */
- protected ExtendedDataModel createDataModel() {
- // TODO Auto-generated method stub
- return new MockDataModel();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#dataChildren()
- */
- protected Iterator dataChildren() {
- // TODO Auto-generated method stub
- return getChildren().iterator();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#fixedChildren()
- */
- protected Iterator fixedChildren() {
- // TODO Auto-generated method stub
- return getFacets().values().iterator();
- }
-
-}
Deleted:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataModel.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataModel.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockDataModel.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,166 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author shura
- *
- */
-public class MockDataModel extends ExtendedDataModel {
-
- public static final int ROWS = 10;
-
- private int rowIndex = 0;
-
- private int minRow = 0;
-
- private int maxRow = ROWS;
-
- /**
- * @return the maxRow
- */
- public int getMaxRow() {
- return maxRow;
- }
-
- /**
- * @param maxRow the maxRow to set
- */
- public void setMaxRow(int maxRow) {
- this.maxRow = maxRow;
- }
-
- /**
- * @return the minRow
- */
- public int getMinRow() {
- return minRow;
- }
-
- /**
- * @param minRow the minRow to set
- */
- public void setMinRow(int minRow) {
- this.minRow = minRow;
- }
-
-
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) throws IOException {
- int first=0;
- int count=ROWS;
- if (range instanceof MockRange) {
- MockRange mockRange = (MockRange) range;
- count = mockRange.getCount();
- } else if (range instanceof SequenceRange) {
- SequenceRange seqRange = (SequenceRange) range;
- first = seqRange.getFirstRow();
- int rows = seqRange.getRows();
- if(rows>0){
- count = rows+first;
- }
- }
- for(int row = first; row < count && row < ROWS;row++){
- visitor.process(context, new Integer(row), argument);
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- // TODO Auto-generated method stub
- return rowIndex<0?null:new Integer(rowIndex);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- if(null == key){
- rowIndex = -1;
- } else {
- rowIndex = ((Integer) key).intValue();
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- public int getRowCount() {
- // TODO Auto-generated method stub
- return getMaxRow();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- public Object getRowData() {
- // TODO Auto-generated method stub
- return isRowAvailable()?String.valueOf(rowIndex):null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return rowIndex;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- // TODO Auto-generated method stub
- return rowIndex>=getMinRow() && rowIndex<getMaxRow();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- this.rowIndex = rowIndex;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockRange.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockRange.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockRange.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,39 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-/**
- * @author shura
- *
- */
-public class MockRange implements Range {
-
- private int count;
-
- public MockRange(int count) {
- this.count = count;
- }
-
- public int getCount(){
- return count;
- }
-}
Deleted:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockSerializableDataModel.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockSerializableDataModel.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/MockSerializableDataModel.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,96 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author shura
- *
- */
-public class MockSerializableDataModel extends MockDataModel {
-
- public SerializableDataModel getSerializableModel(Range range) {
- MockRange mockRange = (MockRange) range;
- SerializableDataModel model = new SerializableDataModel(){
-
- public void update() {
- // TODO Auto-generated method stub
-
- }
-
- public Object getRowKey() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setRowKey(Object key) {
- // TODO Auto-generated method stub
-
- }
-
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- public int getRowCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Object getRowData() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Object getWrappedData() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isRowAvailable() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void setRowIndex(int arg0) {
- // TODO Auto-generated method stub
-
- }
-
- public void setWrappedData(Object arg0) {
- // TODO Auto-generated method stub
-
- }
-
- };
- return model;
- }
-}
Deleted:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/RepeatTestCase.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/RepeatTestCase.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/RepeatTestCase.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,246 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UIColumn;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIData;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.renderkit.html.RepeatRenderer;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.ajax4jsf.tests.MockUIInputRenderer;
-
-/**
- * @author shura
- *
- */
-public class RepeatTestCase extends AbstractAjax4JsfTestCase {
-
- private UIRepeat repeater;
-
- private UIInput child;
-
- private int childInvoked;
-
- private UIInput facetChild;
-
- private int facetInvoked;
-
- private UIInput childChild;
-
- private int childChildInvoked;
-
- private UIInput childChildFacet;
-
- private int childChildFacetInvoked;
-
- private UIRepeat enclosedRepeater;
- /**
- * @param name
- */
- public RepeatTestCase(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
- // Create mock DataAdaptor and childs.
- repeater = new UIRepeat();
- child = new UIInput(){
- public void processDecodes(FacesContext context) {
- childInvoked++;
- super.processDecodes(context);
- }
- };
- childInvoked = 0;
- child.setId("child");
- repeater.getChildren().add(child);
- facetChild = new UIInput(){
- public void processDecodes(FacesContext context) {
- facetInvoked++;
- super.processDecodes(context);
- }
- };
- facetInvoked = 0;
- facetChild.setId("facetChild");
- repeater.getFacets().put("facet", facetChild);
- childChild = new UIInput(){
- public void processDecodes(FacesContext context) {
- childChildInvoked++;
- super.processDecodes(context);
- }
- };;
- childChildInvoked = 0;
- childChild.setId("childChild");
- child.getChildren().add(childChild);
- childChildFacet = new UIInput(){
- public void processDecodes(FacesContext context) {
- childChildFacetInvoked++;
- super.processDecodes(context);
- }
- };;
- childChildFacetInvoked = 0;
- childChildFacet.setId("childChildFacet");
- childChild.getFacets().put("facet", childChildFacet);
- enclosedRepeater = new UIRepeat();
- renderKit.addRenderer(child.getFamily(), child.getRendererType(), new
MockUIInputRenderer(){
- public void decode(FacesContext context, UIComponent component) {
- super.decode(context, component);
- UIInput input = (UIInput) component;
- String submittedValie =
enclosedRepeater.getRowKey()+":"+repeater.getRowKey();
- input.setSubmittedValue(submittedValie);
- System.out.println("decode component
"+component.getClientId(facesContext)+" with value "+submittedValie);
- }
- });
- renderKit.addRenderer(repeater.getFamily(), repeater.getRendererType(), new
RepeatRenderer());
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- repeater = null;
- child = null;
- childChild = null;
- childChildFacet = null;
- facetChild = null;
- enclosedRepeater = null;
- }
-
-
- private void createDataTree(){
- enclosedRepeater.setId("data");
- repeater.setId("adaptor");
- repeater.setVar("row");
- ArrayList value = new ArrayList(2);
- value.add("first");
- value.add("second");
- enclosedRepeater.setValue(value);
- enclosedRepeater.setVar("var");
- UIColumn column = new UIColumn();
- enclosedRepeater.getChildren().add(column);
- column.getChildren().add(repeater);
- facesContext.getViewRoot().getChildren().add(enclosedRepeater);
- }
-
- private void printChildMap(Map childrenState){
- System.out.println("{");
- for (Iterator iter = childrenState.keySet().iterator(); iter.hasNext();) {
- Object key = iter.next();
- System.out.println(" "+key+" : "+childrenState.get(key));
- }
- System.out.println("}");
- }
- /**
- * Test method for {@link
javax.faces.component.UIData#processDecodes(javax.faces.context.FacesContext)}.
- */
- public void testProcessDecodesFacesContext() {
- createDataTree();
- repeater.setValue(new MockDataModel());
-// enclosedRepeater.setValue(new MockDataModel());
- enclosedRepeater.processDecodes(facesContext);
- enclosedRepeater.setRowIndex(1);
- repeater.setRowIndex(1);
- System.out.println("Saved child state for external repeater ");
- printChildMap(enclosedRepeater.getChildState(facesContext));
- System.out.println("Saved child state" );
- printChildMap(repeater.getChildState(facesContext));
- assertEquals("1:1", child.getSubmittedValue());
- }
-
- /**
- * Test method for {@link
javax.faces.component.UIData#processUpdates(javax.faces.context.FacesContext)}.
- */
- public void testProcessUpdatesFacesContext() {
- createDataTree();
- repeater.setValue(new MockDataModel());
-// enclosedRepeater.setValue(new MockDataModel());
- enclosedRepeater.processDecodes(facesContext);
- enclosedRepeater.processValidators(facesContext);
- enclosedRepeater.processUpdates(facesContext);
- enclosedRepeater.setRowIndex(1);
- repeater.setRowIndex(1);
- assertEquals("1:1", child.getValue());
- enclosedRepeater.setRowIndex(0);
- repeater.setRowIndex(2);
- assertEquals("0:2", child.getValue());
- }
-
- /**
- * Test method for {@link
javax.faces.component.UIData#processUpdates(javax.faces.context.FacesContext)}.
- */
- public void testProcessValidatorsFacesContext() {
- createDataTree();
- repeater.setValue(new MockDataModel());
-// enclosedRepeater.setValue(new MockDataModel());
- enclosedRepeater.processDecodes(facesContext);
- enclosedRepeater.processValidators(facesContext);
- enclosedRepeater.setRowIndex(1);
- repeater.setRowIndex(1);
- assertEquals("1:1", child.getLocalValue());
- enclosedRepeater.setRowIndex(0);
- repeater.setRowIndex(2);
- assertEquals("0:2", child.getLocalValue());
- }
-
- public void testSetRowIndex() throws Exception {
- createDataTree();
- repeater.setValue(new MockDataModel());
- enclosedRepeater.setRowIndex(1);
- repeater.setRowIndex(1);
- child.setValue("1:1");
- repeater.setRowIndex(-1);
- enclosedRepeater.setRowIndex(-1);
- // -----------------------------
- enclosedRepeater.setRowIndex(0);
- repeater.setRowIndex(2);
- child.setValue("0:2");
- // -----------------------------
- repeater.setRowIndex(-1);
- enclosedRepeater.setRowIndex(-1);
- System.out.println("Saved child state for external repeater ");
- printChildMap(enclosedRepeater.getChildState(facesContext));
- System.out.println("Saved child state" );
- printChildMap(repeater.getChildState(facesContext));
- // -----------------------------
- enclosedRepeater.setRowIndex(1);
- repeater.setRowIndex(1);
- assertEquals("1:1", child.getValue());
- repeater.setRowIndex(-1);
- enclosedRepeater.setRowIndex(-1);
- // -----------------------------
- enclosedRepeater.setRowIndex(0);
- repeater.setRowIndex(2);
- assertEquals("0:2", child.getValue());
-
- }
-}
Modified:
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -29,7 +29,7 @@
import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
-import org.ajax4jsf.renderkit.html.CommandButtonRenderer;
+
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
/**
@@ -69,8 +69,8 @@
public void testAfterPhase() throws Exception {
PhaseListener listener = new AjaxPhaseListener();
PhaseEvent event = new PhaseEvent(facesContext,PhaseId.RENDER_RESPONSE,lifecycle);
- UIComponent ajaxButton = createComponent("org.ajax4jsf.ajax.AjaxButton",
"org.ajax4jsf.ajax.html.HtmlAjaxCommandButton",
"org.ajax4jsf.ajax.AjaxButton", CommandButtonRenderer.class, null);
- facesContext.getViewRoot().getChildren().add(ajaxButton);
+// UIComponent ajaxButton = createComponent("org.ajax4jsf.ajax.AjaxButton",
"org.ajax4jsf.ajax.html.HtmlAjaxCommandButton",
"org.ajax4jsf.ajax.AjaxButton", CommandButtonRenderer.class, null);
+// facesContext.getViewRoot().getChildren().add(ajaxButton);
AjaxContext.getCurrentInstance(facesContext).setAjaxRequest(true);
// TODO Must be used different StateManager !
// listener.afterPhase(event);
Copied:
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.jav
(from rev 1396,
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java)
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.jav
(rev 0)
+++
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.jav 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.tree.Tree;
+import org.richfaces.RichMacroDefinitionLexer;
+import org.richfaces.RichMacroDefinitionParser;
+import org.richfaces.RichMacroDefinitionParser.expression_return;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 17.06.2007
+ *
+ */
+public class TemplateUtilTest extends TestCase {
+
+ private String doWrite(String in) throws IOException {
+ return in;
+ }
+
+ private void printTree(Tree tree, int indent) {
+ int childCount = tree.getChildCount();
+ for (int i = 0; i < indent; i++) {
+ System.out.print('\t');
+ System.out.print(tree.getText() + " : " + tree.getType());
+ System.out.println();
+ }
+ for (int j = 1; j < childCount; j++) {
+ printTree(tree.getChild(j), ++indent);
+ }
+ }
+
+
+ public void testAntlr() throws Exception {
+ ANTLRStringStream stream = new ANTLRStringStream("{aa{b\\}}a}\\\\
a\\}b\\{c");
+ RichMacroDefinitionLexer lexer = new RichMacroDefinitionLexer(stream);
+ RichMacroDefinitionParser macroParser = new RichMacroDefinitionParser(new
CommonTokenStream(lexer));
+ expression_return expression = macroParser.expression();
+ List result = expression.result;
+ Expression holder = (Expression) result.get(0);
+ assertEquals("aa{b}}a", holder.getExpression());
+ assertEquals("\\ a}b{c", result.get(1));
+ }
+}
Deleted:
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java
===================================================================
---
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java 2007-06-29
19:07:21 UTC (rev 1421)
+++
branches/refactor1/framework/test/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -1,70 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.tree.Tree;
-import org.richfaces.RichMacroDefinitionLexer;
-import org.richfaces.RichMacroDefinitionParser;
-import org.richfaces.RichMacroDefinitionParser.expression_return;
-
-/**
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com
- * created 17.06.2007
- *
- */
-public class TemplateUtilTest extends TestCase {
-
- private String doWrite(String in) throws IOException {
- return in;
- }
-
- private void printTree(Tree tree, int indent) {
- int childCount = tree.getChildCount();
- for (int i = 0; i < indent; i++) {
- System.out.print('\t');
- System.out.print(tree.getText() + " : " + tree.getType());
- System.out.println();
- }
- for (int j = 1; j < childCount; j++) {
- printTree(tree.getChild(j), ++indent);
- }
- }
-
-
- public void testAntlr() throws Exception {
- ANTLRStringStream stream = new ANTLRStringStream("{aa{b\\}}a}\\\\
a\\}b\\{c");
- RichMacroDefinitionLexer lexer = new RichMacroDefinitionLexer(stream);
- RichMacroDefinitionParser macroParser = new RichMacroDefinitionParser(new
CommonTokenStream(lexer));
- expression_return expression = macroParser.expression();
- List result = expression.result;
- Expression holder = (Expression) result.get(0);
- assertEquals("aa{b}}a", holder.getExpression());
- assertEquals("\\ a}b{c", result.get(1));
- }
-}
Copied: branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java
(from rev 1395,
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java)
===================================================================
--- branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java
(rev 0)
+++
branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/ActionListenerTest.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,154 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.Serializable;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.IntegerConverter;
+import javax.faces.event.ActionEvent;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import junit.framework.TestCase;
+
+/**
+ * @author shura
+ *
+ */
+public class ActionListenerTest extends AbstractAjax4JsfTestCase {
+
+ /**
+ * @param name
+ */
+ public ActionListenerTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.ajax.UIActionParameter#getValue()}.
+ */
+ public void testGetValue() {
+ Bean bean = new Bean();
+ bean.setFirst(1);
+ bean.setSecond(2.0);
+ UIActionParameter param = new UIActionParameter();
+ param.setConverter(new TestConverter());
+ param.setValue(bean);
+ assertEquals("1;2.0", param.getValue());
+ }
+
+ public void testGetIntValue() throws Exception {
+ UIActionParameter param = new UIActionParameter();
+ application.addConverter(Integer.class, IntegerConverter.class.getName());
+ param.setValue(new Integer(1));
+ assertEquals("1", param.getValue());
+ }
+
+ static class TestConverter implements Converter {
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String)
+ */
+ public Object getAsObject(FacesContext context, UIComponent comp, String str) {
+ Bean bean = new Bean();
+ String[] values = str.split(";");
+ bean.setFirst(Integer.parseInt(values[0]));
+ bean.setSecond(Double.parseDouble(values[1]));
+ return bean;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.Object)
+ */
+ public String getAsString(FacesContext context, UIComponent comp, Object value) {
+ Bean bean = (Bean) value;
+ return
String.valueOf(bean.getFirst())+";"+String.valueOf(bean.getSecond());
+ }
+
+ }
+
+ public static class Bean implements Serializable {
+ int _first;
+ double _second;
+ /**
+ * @return the first
+ */
+ public int getFirst() {
+ return this._first;
+ }
+ /**
+ * @param first the first to set
+ */
+ public void setFirst(int first) {
+ this._first = first;
+ }
+ /**
+ * @return the second
+ */
+ public double getSecond() {
+ return this._second;
+ }
+ /**
+ * @param second the second to set
+ */
+ public void setSecond(double second) {
+ this._second = second;
+ }
+ }
+
+ /**
+ * Test method for {@link
org.ajax4jsf.ajax.UIActionParameter#processAction(javax.faces.event.ActionEvent)}.
+ */
+ public void testProcessAction() {
+ UICommand command = new UICommand();
+ UIActionParameter param = new UIActionParameter();
+ param.setConverter(new IntegerConverter());
+ param.setName("param");
+ param.setAssignToBinding(application.createValueBinding("#{bean.first}"));
+ Bean bean = new Bean();
+ request.setAttribute("bean", bean);
+ request.addParameter("param", "123");
+ externalContext.getRequestParameterMap().put("param", "123");
+ command.addActionListener(param);
+ command.broadcast(new ActionEvent(command));
+ assertEquals(123, bean.getFirst());
+ }
+
+}
Copied: branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/RepeatTestCase.java
(from rev 1395,
branches/refactor1/framework/test/src/test/java/org/ajax4jsf/ajax/repeat/RepeatTestCase.java)
===================================================================
--- branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/RepeatTestCase.java
(rev 0)
+++
branches/refactor1/ui/core/src/test/java/org/ajax4jsf/ajax/RepeatTestCase.java 2007-06-29
19:32:26 UTC (rev 1422)
@@ -0,0 +1,247 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.html.RepeatRenderer;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.tests.MockDataModel;
+import org.ajax4jsf.tests.MockUIInputRenderer;
+
+/**
+ * @author shura
+ *
+ */
+public class RepeatTestCase extends AbstractAjax4JsfTestCase {
+
+ private UIRepeat repeater;
+
+ private UIInput child;
+
+ private int childInvoked;
+
+ private UIInput facetChild;
+
+ private int facetInvoked;
+
+ private UIInput childChild;
+
+ private int childChildInvoked;
+
+ private UIInput childChildFacet;
+
+ private int childChildFacetInvoked;
+
+ private UIRepeat enclosedRepeater;
+ /**
+ * @param name
+ */
+ public RepeatTestCase(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ // Create mock DataAdaptor and childs.
+ repeater = new UIRepeat();
+ child = new UIInput(){
+ public void processDecodes(FacesContext context) {
+ childInvoked++;
+ super.processDecodes(context);
+ }
+ };
+ childInvoked = 0;
+ child.setId("child");
+ repeater.getChildren().add(child);
+ facetChild = new UIInput(){
+ public void processDecodes(FacesContext context) {
+ facetInvoked++;
+ super.processDecodes(context);
+ }
+ };
+ facetInvoked = 0;
+ facetChild.setId("facetChild");
+ repeater.getFacets().put("facet", facetChild);
+ childChild = new UIInput(){
+ public void processDecodes(FacesContext context) {
+ childChildInvoked++;
+ super.processDecodes(context);
+ }
+ };;
+ childChildInvoked = 0;
+ childChild.setId("childChild");
+ child.getChildren().add(childChild);
+ childChildFacet = new UIInput(){
+ public void processDecodes(FacesContext context) {
+ childChildFacetInvoked++;
+ super.processDecodes(context);
+ }
+ };;
+ childChildFacetInvoked = 0;
+ childChildFacet.setId("childChildFacet");
+ childChild.getFacets().put("facet", childChildFacet);
+ enclosedRepeater = new UIRepeat();
+ renderKit.addRenderer(child.getFamily(), child.getRendererType(), new
MockUIInputRenderer(){
+ public void decode(FacesContext context, UIComponent component) {
+ super.decode(context, component);
+ UIInput input = (UIInput) component;
+ String submittedValie =
enclosedRepeater.getRowKey()+":"+repeater.getRowKey();
+ input.setSubmittedValue(submittedValie);
+ System.out.println("decode component
"+component.getClientId(facesContext)+" with value "+submittedValie);
+ }
+ });
+ renderKit.addRenderer(repeater.getFamily(), repeater.getRendererType(), new
RepeatRenderer());
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ repeater = null;
+ child = null;
+ childChild = null;
+ childChildFacet = null;
+ facetChild = null;
+ enclosedRepeater = null;
+ }
+
+
+ private void createDataTree(){
+ enclosedRepeater.setId("data");
+ repeater.setId("adaptor");
+ repeater.setVar("row");
+ ArrayList value = new ArrayList(2);
+ value.add("first");
+ value.add("second");
+ enclosedRepeater.setValue(value);
+ enclosedRepeater.setVar("var");
+ UIColumn column = new UIColumn();
+ enclosedRepeater.getChildren().add(column);
+ column.getChildren().add(repeater);
+ facesContext.getViewRoot().getChildren().add(enclosedRepeater);
+ }
+
+ private void printChildMap(Map childrenState){
+ System.out.println("{");
+ for (Iterator iter = childrenState.keySet().iterator(); iter.hasNext();) {
+ Object key = iter.next();
+ System.out.println(" "+key+" : "+childrenState.get(key));
+ }
+ System.out.println("}");
+ }
+ /**
+ * Test method for {@link
javax.faces.component.UIData#processDecodes(javax.faces.context.FacesContext)}.
+ */
+ public void testProcessDecodesFacesContext() {
+ createDataTree();
+ repeater.setValue(new MockDataModel());
+// enclosedRepeater.setValue(new MockDataModel());
+ enclosedRepeater.processDecodes(facesContext);
+ enclosedRepeater.setRowIndex(1);
+ repeater.setRowIndex(1);
+ System.out.println("Saved child state for external repeater ");
+ printChildMap(enclosedRepeater.getChildState(facesContext));
+ System.out.println("Saved child state" );
+ printChildMap(repeater.getChildState(facesContext));
+ assertEquals("1:1", child.getSubmittedValue());
+ }
+
+ /**
+ * Test method for {@link
javax.faces.component.UIData#processUpdates(javax.faces.context.FacesContext)}.
+ */
+ public void testProcessUpdatesFacesContext() {
+ createDataTree();
+ repeater.setValue(new MockDataModel());
+// enclosedRepeater.setValue(new MockDataModel());
+ enclosedRepeater.processDecodes(facesContext);
+ enclosedRepeater.processValidators(facesContext);
+ enclosedRepeater.processUpdates(facesContext);
+ enclosedRepeater.setRowIndex(1);
+ repeater.setRowIndex(1);
+ assertEquals("1:1", child.getValue());
+ enclosedRepeater.setRowIndex(0);
+ repeater.setRowIndex(2);
+ assertEquals("0:2", child.getValue());
+ }
+
+ /**
+ * Test method for {@link
javax.faces.component.UIData#processUpdates(javax.faces.context.FacesContext)}.
+ */
+ public void testProcessValidatorsFacesContext() {
+ createDataTree();
+ repeater.setValue(new MockDataModel());
+// enclosedRepeater.setValue(new MockDataModel());
+ enclosedRepeater.processDecodes(facesContext);
+ enclosedRepeater.processValidators(facesContext);
+ enclosedRepeater.setRowIndex(1);
+ repeater.setRowIndex(1);
+ assertEquals("1:1", child.getLocalValue());
+ enclosedRepeater.setRowIndex(0);
+ repeater.setRowIndex(2);
+ assertEquals("0:2", child.getLocalValue());
+ }
+
+ public void testSetRowIndex() throws Exception {
+ createDataTree();
+ repeater.setValue(new MockDataModel());
+ enclosedRepeater.setRowIndex(1);
+ repeater.setRowIndex(1);
+ child.setValue("1:1");
+ repeater.setRowIndex(-1);
+ enclosedRepeater.setRowIndex(-1);
+ // -----------------------------
+ enclosedRepeater.setRowIndex(0);
+ repeater.setRowIndex(2);
+ child.setValue("0:2");
+ // -----------------------------
+ repeater.setRowIndex(-1);
+ enclosedRepeater.setRowIndex(-1);
+ System.out.println("Saved child state for external repeater ");
+ printChildMap(enclosedRepeater.getChildState(facesContext));
+ System.out.println("Saved child state" );
+ printChildMap(repeater.getChildState(facesContext));
+ // -----------------------------
+ enclosedRepeater.setRowIndex(1);
+ repeater.setRowIndex(1);
+ assertEquals("1:1", child.getValue());
+ repeater.setRowIndex(-1);
+ enclosedRepeater.setRowIndex(-1);
+ // -----------------------------
+ enclosedRepeater.setRowIndex(0);
+ repeater.setRowIndex(2);
+ assertEquals("0:2", child.getValue());
+
+ }
+}