JBoss Rich Faces SVN: r17247 - in root/ui/dist/trunk: richfaces-components-ui and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-05-26 06:48:57 -0400 (Wed, 26 May 2010)
New Revision: 17247
Modified:
root/ui/dist/trunk/pom.xml
root/ui/dist/trunk/richfaces-components-ui/pom.xml
Log:
RF-8461
add misc to richfaces-ui
Modified: root/ui/dist/trunk/pom.xml
===================================================================
--- root/ui/dist/trunk/pom.xml 2010-05-26 09:29:00 UTC (rev 17246)
+++ root/ui/dist/trunk/pom.xml 2010-05-26 10:48:57 UTC (rev 17247)
@@ -37,6 +37,7 @@
<modules>
<module>../../core/trunk</module>
+ <module>../../misc/trunk</module>
<module>../../../ui-sandbox/tables/trunk</module>
<!-- aggregate modules -->
Modified: root/ui/dist/trunk/richfaces-components-ui/pom.xml
===================================================================
--- root/ui/dist/trunk/richfaces-components-ui/pom.xml 2010-05-26 09:29:00 UTC (rev 17246)
+++ root/ui/dist/trunk/richfaces-components-ui/pom.xml 2010-05-26 10:48:57 UTC (rev 17247)
@@ -60,6 +60,10 @@
<artifactId>richfaces-ui-core-api</artifactId>
</dependency>
<dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui-misc-ui</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.richfaces.ui-sandbox</groupId>
<artifactId>tables-ui</artifactId>
</dependency>
15 years, 7 months
JBoss Rich Faces SVN: r17245 - management/design-4x/boxes.
by richfaces-svn-commits@lists.jboss.org
Author: admitriev
Date: 2010-05-26 05:26:01 -0400 (Wed, 26 May 2010)
New Revision: 17245
Added:
management/design-4x/boxes/combo_box.html
management/design-4x/boxes/suggestion_box.html
Log:
Added: management/design-4x/boxes/combo_box.html
===================================================================
--- management/design-4x/boxes/combo_box.html (rev 0)
+++ management/design-4x/boxes/combo_box.html 2010-05-26 09:26:01 UTC (rev 17245)
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
+
+<html>
+<head>
+ <title>Untitled</title>
+<style>
+* {font-size : 11px; font-family : verdana; color : #000000}
+
+.cb_field_width{ width : 150px;}
+.cb_list_width{ width : 250px;}
+.cb_list_height{ height : 100px;}
+
+.cb_font{color : #000000/*generalTextColor*/}
+.cb_input {border : 0px; background : none; width : 100%;}
+
+.cb_field{ position : inline-block; border : 1px solid #A6A6A6/*panelBorderColor*/; display : inline-block; background : url(images/bg_field.png) top left repeat-x/*gradient - from additionalBackgroundColor to controlBackgroundColor, background-color - controlBackgroundColor*/; }
+
+.cb_button{ background : url(images/bg_btn.png) top left repeat-x #C0D1E7/*gradient - from headerGradientColor to headerBackgroundColor, background-color - headerBackgroundColor*/; text-align : center; border-left : 1px solid #A6A6A6/*panelBorderColor*/; width : 15px; position : absolute; top : 0px; right : 0px; height : 200px; padding-top : 1px }
+.cb_button_arrow{ background : url(images/down.gif) center no-repeat; cursor : pointer;}
+
+.cb_list_cord{ position : relative; font-size : 0px;d@isplay : none}/*DDL is hidden!!!!!*/
+.cb_list_position{ position : absolute; top: 0px; left: -1px; }
+.cb_list_decoration{ border : 1px solid #A6A6A6 /*panelBorderColor*/; padding : 0px; background : #FFFFFF; /*tableBackgroundColor*/}
+.cb_list_scroll{ overflow : auto; overflow-x : hidden;}
+.cb_option{ padding : 2px; white-space : nowrap; cursor : default;}
+.cb_select{ padding : 1px; width : 100%; background-color: #DFE8F6; border : 1px dotted #a3bae9;/*generalTextColor*/}
+
+.cb_list_shadow{ position : absolute; width : 260px; height : 109px; margin-left : -4px; margin-top : -2px;}
+
+</style>
+</head>
+
+<body style="margin : 30px">
+
+
+Text block text block text block text block text block text block text block text block
+<div class=" cb_field_width cb_field">
+ <div style=" position : relative; overflow : hidden; text-align : left; padding-right : 21px;">
+ <input type="Text" class="cb_font cb_input">
+ <div class="cb_button">
+ <img src="images/down.gif" width="15" height="15" alt="" border="0">
+ </div>
+ </div>
+
+ <div class="cb_list_cord">
+ <img src="images/bg_shadow.png" class="cb_list_shadow">
+ <div class="cb_list_position cb_list_width">
+ <div class="cb_list_decoration">
+ <div class="cb_list_scroll cb_list_height">
+ <div class="cb_option cb_font">Option 1</div>
+ <div class="cb_option cb_font">Option 2</div>
+ <div class="cb_option cb_font">Option 3</div>
+ <div class="cb_option cb_font">Option 4</div>
+ <div class="cb_option cb_font cb_select">Option 6</div>
+ <div class="cb_option cb_font">Option 7</div>
+ <div class="cb_option cb_font">Option 8</div>
+ <div class="cb_option cb_font">Option 9</div>
+ <div class="cb_option cb_font">Option 0</div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+</div>
+ text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block
+
+
+</body>
+</html>
Added: management/design-4x/boxes/suggestion_box.html
===================================================================
--- management/design-4x/boxes/suggestion_box.html (rev 0)
+++ management/design-4x/boxes/suggestion_box.html 2010-05-26 09:26:01 UTC (rev 17245)
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
+
+<html>
+<head>
+ <title>Untitled</title>
+<style>
+* {font-size : 11px; font-family : verdana; color : #000000}
+
+.sb_shell{ display : inline-block;}
+
+.sb_list_width{ width : 250px;}
+.sb_list_height{ height : 100px;}
+
+.sb_font{color : #000000/*generalTextColor*/}
+
+.sb_list_cord{ position : relative; font-size : 0px;d@isplay : none;}/*DDL is not hidden!!!!!*/
+.sb_list_position{ position : absolute; top: 0px; left: -1px; }
+.sb_list_decoration{ border : 1px solid #A6A6A6 /*panelBorderColor*/; position : absolute; padding : 0px; background : #FFFFFF; /*tableBackgroundColor*/}
+.sb_list_scroll{ overflow : auto; overflow-x : hidden;}
+.sb_option{ padding : 2px; white-space : nowrap; cursor : default;}
+.sb_select{ padding : 1px; width : 100%; background-color: #DFE8F6; border : 1px dotted #a3bae9;/*generalTextColor*/}
+
+.sb_shadow{ position : absolute; width : 260px; height : 109px; margin-left : -4px; margin-top : -2px;}
+
+</style>
+</head>
+
+<body style="margin : 30px">
+
+
+Text block text block text block text block text block text block text block text block text block
+<div class="sb_shell">
+ <input type="Text" value="Parent element">
+
+ <div class="sb_list_cord">
+ <div class="sb_list_position sb_list_width">
+ <img src="images/bg_shadow.png" class="sb_shadow">
+ <div class="sb_list_decoration">
+ <div class="sb_list_scroll sb_list_height sb_list_width">
+ <div class="sb_option sb_font">Option 1</div>
+ <div class="sb_option sb_font">Option 2</div>
+ <div class="sb_option sb_font">Option 3</div>
+ <div class="sb_option sb_font">Option 4</div>
+ <div class="sb_option sb_font sb_select">Option 6</div>
+ <div class="sb_option sb_font">Option 7</div>
+ <div class="sb_option sb_font">Option 8</div>
+ <div class="sb_option sb_font">Option 9</div>
+ <div class="sb_option sb_font">Option 0</div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+</div>
+ text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block
+
+
+</body>
+</html>
15 years, 7 months
JBoss Rich Faces SVN: r17244 - in root/examples: misc-demo and 9 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-25 20:44:13 -0400 (Tue, 25 May 2010)
New Revision: 17244
Added:
root/examples/misc-demo/
root/examples/misc-demo/branches/
root/examples/misc-demo/tags/
root/examples/misc-demo/trunk/
root/examples/misc-demo/trunk/pom.xml
root/examples/misc-demo/trunk/src/
root/examples/misc-demo/trunk/src/main/java/
root/examples/misc-demo/trunk/src/main/java/org/
root/examples/misc-demo/trunk/src/main/java/org/richfaces/
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/TestIdentityFilter.java
root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/UserBean.java
Removed:
root/examples/misc-demo/trunk/src/main/webapp/pages/error.html
root/examples/misc-demo/trunk/src/main/webapp/pages/index.jsp
root/examples/misc-demo/trunk/src/main/webapp/pages/login.html
Modified:
root/examples/misc-demo/trunk/src/main/webapp/WEB-INF/web.xml
root/examples/misc-demo/trunk/src/main/webapp/index.jsp
root/examples/misc-demo/trunk/src/main/webapp/pages/index.xhtml
root/examples/pom.xml
Log:
https://jira.jboss.org/browse/RF-7983
Copied: root/examples/misc-demo/trunk/pom.xml (from rev 16894, branches/community/3.3.X/samples/functions-demo/pom.xml)
===================================================================
--- root/examples/misc-demo/trunk/pom.xml (rev 0)
+++ root/examples/misc-demo/trunk/pom.xml 2010-05-26 00:44:13 UTC (rev 17244)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of
+ individual contributors. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software is distributed in the
+ hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not,
+ write to the Free Software Foundation, Inc., 51 Franklin St,
+ Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
+ http://www.fsf.org.
+-->
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces.examples</groupId>
+ <artifactId>examples-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.richfaces.examples</groupId>
+ <artifactId>misc-demo</artifactId>
+ <packaging>war</packaging>
+ <name>RichFaces Examples: Miscellanous</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui-misc-ui</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Copied: root/examples/misc-demo/trunk/src (from rev 16894, branches/community/3.3.X/samples/functions-demo/src)
Added: root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/TestIdentityFilter.java
===================================================================
--- root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/TestIdentityFilter.java (rev 0)
+++ root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/TestIdentityFilter.java 2010-05-26 00:44:13 UTC (rev 17244)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TestIdentityFilter implements Filter {
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException {
+
+ HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper((HttpServletRequest) request) {
+
+ private UserBean getUserBean() {
+ HttpSession session = getSession(false);
+ if (session != null) {
+ return (UserBean) session.getAttribute("userBean");
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean isUserInRole(String role) {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.isUserInRole(role);
+ }
+
+ return false;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.getPrincipal();
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getRemoteUser() {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.getRolename();
+ }
+ return null;
+ }
+ };
+
+ chain.doFilter(wrapper, response);
+ }
+
+}
Added: root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/UserBean.java
===================================================================
--- root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/UserBean.java (rev 0)
+++ root/examples/misc-demo/trunk/src/main/java/org/richfaces/demo/UserBean.java 2010-05-26 00:44:13 UTC (rev 17244)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.security.Principal;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class UserBean {
+
+ private String rolename;
+
+ public String getRolename() {
+ return rolename;
+ }
+
+ public void setRolename(String username) {
+ this.rolename = username;
+ }
+
+ public Principal getPrincipal() {
+ if (rolename != null) {
+ return new PrincipalImpl(rolename);
+ }
+
+ return null;
+ }
+
+ public boolean isUserInRole(String role) {
+ Principal principal = getPrincipal();
+ if (principal != null) {
+ //username & principal's name & role name are considered the same
+ return principal.getName().equals(role);
+ }
+
+ return false;
+ }
+}
+
+class PrincipalImpl implements Principal {
+
+ private String name;
+
+ public PrincipalImpl(String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
Modified: root/examples/misc-demo/trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/community/3.3.X/samples/functions-demo/src/main/webapp/WEB-INF/web.xml 2010-05-05 09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/WEB-INF/web.xml 2010-05-26 00:44:13 UTC (rev 17244)
@@ -1,83 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
-<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <display-name>Archetype Created Web Application</display-name>
- <context-param>
- <param-name>javax.faces.CONFIG_FILES</param-name>
- <param-value>/WEB-INF/faces-config.xml</param-value>
- </context-param>
- <context-param>
- <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
- <param-value>server</param-value>
- </context-param>
- <!-- Use Documents Saved as *.xhtml -->
- <context-param>
- <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
- <param-value>.jsp</param-value>
- </context-param>
+<web-app id="WebApp_ID" version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>misc-demo</display-name>
- <!-- Facelets pages will use the .xhtml extension -->
- <context-param>
- <param-name>facelets.VIEW_MAPPINGS</param-name>
- <param-value>*xhtml</param-value>
- </context-param>
-
- <context-param>
- <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
- <param-value>com.sun.facelets.FaceletViewHandler</param-value>
- </context-param>
-
- <!--
- -->
<filter>
- <display-name>Ajax4jsf Filter</display-name>
- <filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.Filter</filter-class>
+ <filter-name>Test Identity Filter</filter-name>
+ <filter-class>org.richfaces.demo.TestIdentityFilter</filter-class>
</filter>
+
<filter-mapping>
- <filter-name>ajax4jsf</filter-name>
+ <filter-name>Test Identity Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>FORWARD</dispatcher>
- <dispatcher>INCLUDE</dispatcher>
- <dispatcher>ERROR</dispatcher>
</filter-mapping>
- <!-- Faces Servlet -->
+
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
</servlet>
- <!--
- Use prefix mapping for Facelets pages, e.g.
- http://localhost:8080/webapp/faces/mypage.xhtml
- -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
- <url-pattern>/faces/*</url-pattern>
+ <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
-
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>/faces-auth/*</url-pattern>
- </servlet-mapping>
-
- <login-config>
- <auth-method>FORM</auth-method>
- <form-login-config>
- <form-login-page>/pages/login.html</form-login-page>
- <form-error-page>/pages/error.html</form-error-page>
- </form-login-config>
- </login-config>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>faces-auth</web-resource-name>
- <url-pattern>/faces-auth/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>user</role-name>
- <role-name>admin</role-name>
- </auth-constraint>
- </security-constraint>
</web-app>
Modified: root/examples/misc-demo/trunk/src/main/webapp/index.jsp
===================================================================
--- branches/community/3.3.X/samples/functions-demo/src/main/webapp/index.jsp 2010-05-05 09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/index.jsp 2010-05-26 00:44:13 UTC (rev 17244)
@@ -5,10 +5,7 @@
<head></head>
<body>
- <a href="faces/pages/index.jsp">JSP</a><br/>
- <a href="faces-auth/pages/index.jsp">JSP authenticated</a><br/>
- <a href="faces/pages/index.xhtml">Facelets</a><br />
- <a href="faces-auth/pages/index.xhtml">Facelets authenticated</a>
+ <a href="pages/index.jsf">Facelets</a><br />
</body>
</html>
\ No newline at end of file
Deleted: root/examples/misc-demo/trunk/src/main/webapp/pages/error.html
===================================================================
--- branches/community/3.3.X/samples/functions-demo/src/main/webapp/pages/error.html 2010-05-05 09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/pages/error.html 2010-05-26 00:44:13 UTC (rev 17244)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>Login failed</title>
-</head>
-<body>
-Login failed
-</body>
-</html>
\ No newline at end of file
Deleted: root/examples/misc-demo/trunk/src/main/webapp/pages/index.jsp
===================================================================
--- branches/community/3.3.X/samples/functions-demo/src/main/webapp/pages/index.jsp 2010-05-05 09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/pages/index.jsp 2010-05-26 00:44:13 UTC (rev 17244)
@@ -1,36 +0,0 @@
-<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
-<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
-<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/functions" prefix="fn" %>
-<html>
- <head>
- <title></title>
- </head>
- <body>
- <f:view>
- <f:subview id="view">
- <h:form id="myForm">
- <h:inputText id="input" value="abc" />
- </h:form>
- </f:subview>
-
- <h:outputText value="#{fn:clientId('input')}" />
- <br />
- <h:outputText value="#{fn:element('input')}" />
- <br />
- <h:outputText value="#{fn:component('input')}" />
- <br />
- <h:outputText value="#{fn:findComponent('input').value}" />
- <br />
-
- Roles:
- <h:outputText rendered="#{fn:isUserInRole('admin, user')}" value="admin/user" />
- <br />
- <h:outputText rendered="#{fn:isUserInRole('admin')}" value="admin" />
- <br />
- <h:outputText rendered="#{fn:isUserInRole('user')}" value="user" />
- <br />
-
-
- </f:view>
- </body>
-</html>
Modified: root/examples/misc-demo/trunk/src/main/webapp/pages/index.xhtml
===================================================================
--- branches/community/3.3.X/samples/functions-demo/src/main/webapp/pages/index.xhtml 2010-05-05 09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/pages/index.xhtml 2010-05-26 00:44:13 UTC (rev 17244)
@@ -1,33 +1,40 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:fn="http://labs.jboss.com/jbossrichfaces/ui/functions"
- >
- <f:view>
- <f:subview id="view">
- <h:form id="myForm">
- <h:inputText id="input" value="abc"/>
- </h:form>
- </f:subview>
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:fn="http://richfaces.org/misc">
+<f:view>
+ <h:form>
+ <h:outputLabel value="Role name:" for="roleName" />
+ <h:inputText value="#{userBean.rolename}" id="roleName" />
+ <br />
+ <h:commandLink value="Apply role name" />
+ </h:form>
- <h:outputText value="#{fn:clientId('input')}" />
- <br />
- <h:outputText value="#{fn:element('input')}" />
- <br />
- <h:outputText value="#{fn:component('input')}" />
- <br />
- <h:outputText value="#{fn:findComponent('input').value}" />
- <br />
+ <f:subview id="view">
+ <h:form id="myForm">
+ <h:inputText id="input" value="abc" />
+ </h:form>
+ </f:subview>
+
+ <h:outputText value="#{fn:clientId('input')}" />
+ <br />
+ <h:outputText value="#{fn:element('input')}" />
+ <br />
+ <h:outputText value="#{fn:component('input')}" />
+ <br />
+ <h:outputText value="#{fn:findComponent('input').value}" />
+ <br />
- Roles:
- <h:outputText rendered="#{fn:isUserInRole('admin, user')}" value="admin/user" />
- <br />
- <h:outputText rendered="#{fn:isUserInRole('admin')}" value="admin" />
- <br />
- <h:outputText rendered="#{fn:isUserInRole('user')}" value="user" />
- <br />
-
- </f:view>
-</html>
\ No newline at end of file
+ Roles:
+ <h:outputText rendered="#{fn:isUserInRole('admin, user')}"
+ value="admin or user" />
+ <br />
+ <h:outputText rendered="#{fn:isUserInRole('admin')}" value="admin" />
+ <br />
+ <h:outputText rendered="#{fn:isUserInRole('user')}" value="user" />
+ <br />
+
+</f:view>
+</html>
Deleted: root/examples/misc-demo/trunk/src/main/webapp/pages/login.html
===================================================================
--- branches/community/3.3.X/samples/functions-demo/src/main/webapp/pages/login.html 2010-05-05 09:47:34 UTC (rev 16894)
+++ root/examples/misc-demo/trunk/src/main/webapp/pages/login.html 2010-05-26 00:44:13 UTC (rev 17244)
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>Insert title here</title>
-</head>
-<body>
- <form action="j_security_check" method="post">
- <input type="text" name="j_username" />
- <br />
- <input type="password" name="j_password" />
- <br />
- <input type="submit" value="Login" />
- </form>
-</body>
-</html>
\ No newline at end of file
Modified: root/examples/pom.xml
===================================================================
--- root/examples/pom.xml 2010-05-25 23:55:03 UTC (rev 17243)
+++ root/examples/pom.xml 2010-05-26 00:44:13 UTC (rev 17244)
@@ -37,6 +37,7 @@
<modules>
<module>core-demo/trunk</module>
+ <module>misc-demo/trunk</module>
<module>repeater-demo/trunk</module>
<!--<module>richfaces-showcase/trunk</module>-->
<!--<module>dist/trunk</module>-->
@@ -60,6 +61,14 @@
<type>pom</type>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui-misc-bom</artifactId>
+ <version>${project.version}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+
<!-- simple logger binding: only messages of level INFO and higher are printed-->
<dependency>
<groupId>org.slf4j</groupId>
15 years, 7 months
JBoss Rich Faces SVN: r17243 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/apt and 9 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-05-25 19:55:03 -0400 (Tue, 25 May 2010)
New Revision: 17243
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManagerImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManagerImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagWithModel.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/EventSourceInterfaceGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/ListenerTagHandlerGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
Log:
CODING IN PROGRESS - issue RF-8568: Improve FreeMarker generator.
https://jira.jboss.org/browse/RF-8568
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -25,6 +25,8 @@
package org.richfaces.cdk;
+import org.richfaces.cdk.model.ComponentLibrary;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -32,5 +34,5 @@
*/
public interface CdkWriter {
- public void render() throws CdkException;
+ public void render(ComponentLibrary library) throws CdkException;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -35,12 +35,33 @@
*/
public interface FileManager {
+ /**
+ * <p class="changed_added_4_0">Get existing file or directory.</p>
+ * @param path
+ * @return
+ * @throws FileNotFoundException
+ */
public File getFile(String path) throws FileNotFoundException;
+ /**
+ * <p class="changed_added_4_0">Get collection of all source files for this manager.</p>
+ * @return collection of files explicitly included for processing.
+ */
public Iterable<File> getFiles();
+ /**
+ * <p class="changed_added_4_0">Create new file in output folder.</p>
+ * @param path relative path to output file.
+ * @param lastModified time of last modification of model.
+ * @return file descriptor or null if file exists and its modification time is later then <code>lastModified</code> parameter.
+ * @throws IOException
+ */
public Writer createOutput(String path, long lastModified) throws IOException;
+ /**
+ * <p class="changed_added_4_0">Return collection of all folders included in this manager instance.</p>
+ * @return
+ */
public abstract Iterable<File> getFolders();
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -99,11 +99,11 @@
}
public void addOutputFolder(Outputs type, File outputFolder) {
- this.outputFolders.put(type, new OutputFileManager(outputFolder));
+ this.outputFolders.put(type, new OutputFileManagerImpl(outputFolder));
}
public void addSources(Sources type, Iterable<File> files, Iterable<File> folders) {
- this.sources.put(type, new SourceFileManager(files, folders));
+ this.sources.put(type, new SourceFileManagerImpl(files, folders));
}
public void setOptions(Map<String, String> options) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -23,6 +23,8 @@
package org.richfaces.cdk;
+import org.richfaces.cdk.model.ComponentLibrary;
+
/**
* <p class="changed_added_4_0">
* That class builds JSF library model from different sources. It acts as
@@ -44,9 +46,10 @@
/**
* Generate all types of files from library model.
+ * @param library TODO
*
* @throws CdkException
*/
- public void generate() throws CdkException;
+ public void generate(ComponentLibrary library) throws CdkException;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -23,106 +23,11 @@
package org.richfaces.cdk;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Collections;
-
/**
- * <p class="changed_added_4_0">
- * </p>
- *
+ * <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public class OutputFileManager implements FileManager {
+public interface OutputFileManager extends FileManager {
- private final Iterable<File> folders;
- private final File folder;
-
- public OutputFileManager(File folder) {
- this.folder = folder;
- this.folders = Collections.singleton(folder);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.FileManager#createFile(java.lang.String)
- */
- @Override
- public Writer createOutput(String path, long lastModified) throws IOException {
- if (null == path) {
- throw new NullPointerException();
- }
-
-
- if (null == folder) {
- throw new FileNotFoundException("No output folder set for file " + path);
- }
-
- if (folder.exists() && !folder.isDirectory()) {
- throw new IOException("Output folder " + folder + " not is directory.");
- }
-
- // Strip leading '/'
- if (path.startsWith(File.separator)) {
- path = path.substring(1);
- }
-
- File outputFile = new File(folder, path);
-
- if (outputFile.exists()) {
- if (lastModified > 0 && outputFile.lastModified() > lastModified) {
- return null;
- } else {
- outputFile.delete();
- }
- }
-
- // Create file folder.
- outputFile.getParentFile().mkdirs();
- outputFile.createNewFile();
-
- return new FileWriter(outputFile);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.FileManager#getFile(java.lang.String)
- */
- @Override
- public File getFile(String path) throws FileNotFoundException {
- File file = new File(folder, path);
- if (file.exists()) {
- return file;
- }
- throw new FileNotFoundException(path);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.FileManager#getFiles()
- */
- @Override
- public Iterable<File> getFiles() {
- // TODO - list all files in folder.
- return Collections.emptySet();
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the folders
- */
- @Override
- public Iterable<File> getFolders() {
- return this.folders;
- }
-
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManagerImpl.java (from rev 17238, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManagerImpl.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManagerImpl.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -0,0 +1,127 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - 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.richfaces.cdk;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collections;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class OutputFileManagerImpl implements OutputFileManager {
+
+ private final Iterable<File> folders;
+ private final File folder;
+
+ public OutputFileManagerImpl(File folder) {
+ this.folder = folder;
+ this.folders = Collections.singleton(folder);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#createFile(java.lang.String)
+ */
+ @Override
+ public Writer createOutput(String path, long lastModified) throws IOException {
+ if (null == path) {
+ throw new NullPointerException("Output file path is null");
+ }
+
+ if (null == folder) {
+ throw new FileNotFoundException("No output folder set for file " + path);
+ }
+
+ if (folder.exists() && !folder.isDirectory()) {
+ throw new IOException("Output folder " + folder + " not is directory.");
+ }
+
+ // Strip leading '/'
+ if (path.startsWith(File.separator)) {
+ path = path.substring(1);
+ }
+
+ File outputFile = new File(folder, path);
+
+ if (outputFile.exists()) {
+ if (lastModified > 0 && outputFile.lastModified() > lastModified) {
+ return null;
+ } else {
+ outputFile.delete();
+ }
+ }
+
+ // Create file folder.
+ outputFile.getParentFile().mkdirs();
+ outputFile.createNewFile();
+
+ return new FileWriter(outputFile);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#getFile(java.lang.String)
+ */
+ @Override
+ public File getFile(String path) throws FileNotFoundException {
+ File file = new File(folder, path);
+ if (file.exists()) {
+ return file;
+ }
+ throw new FileNotFoundException(path);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#getFiles()
+ */
+ @Override
+ public Iterable<File> getFiles() {
+ // TODO - list all files in folder.
+ return Collections.emptySet();
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the folders
+ */
+ @Override
+ public Iterable<File> getFolders() {
+ return this.folders;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManagerImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -23,93 +23,11 @@
package org.richfaces.cdk;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.Writer;
-
/**
- * <p class="changed_added_4_0">
- * </p>
- *
+ * <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
+ *
*/
-public class SourceFileManager implements FileManager {
+public interface SourceFileManager extends FileManager {
- private final Iterable<File> sources;
- private final Iterable<File> folders;
-
- public SourceFileManager(Iterable<File> sources, Iterable<File> folders) {
- this.sources = sources;
- this.folders = folders;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.FileManager#createFile(java.lang.String)
- */
-
- @Override
- public Writer createOutput(String path, long lastModified) throws IOException {
- throw new UnsupportedOperationException("Cannot create file in source folder");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.FileManager#getFile(java.lang.String)
- */
-
- @Override
- public File getFile(String path) throws FileNotFoundException {
- String platformPath;
-
- if (File.separatorChar == '/') {
- platformPath = path;
- } else {
- platformPath = path.replace('/', File.separatorChar);
- }
-
- if (null != folders) {
- for (File folder : folders) {
- if (folder.exists() && folder.isDirectory()) {
- File configFile = new File(folder, platformPath);
- if (configFile.exists()) {
- return configFile;
- }
- }
- }
- }
- if (null != sources) {
- for (File file : sources) {
- if (file.getAbsolutePath().endsWith(platformPath)) {
- return file;
- }
- }
- }
- throw new FileNotFoundException(path);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.FileManager#getFiles()
- */
-
- @Override
- public Iterable<File> getFiles() {
- return sources;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the folders
- */
- @Override
- public Iterable<File> getFolders() {
- return this.folders;
- }
-
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManagerImpl.java (from rev 17238, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManagerImpl.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManagerImpl.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -0,0 +1,115 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - 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.richfaces.cdk;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ */
+public class SourceFileManagerImpl implements SourceFileManager,FileManager {
+
+ private final Iterable<File> sources;
+ private final Iterable<File> folders;
+
+ public SourceFileManagerImpl(Iterable<File> sources, Iterable<File> folders) {
+ this.sources = sources;
+ this.folders = folders;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#createFile(java.lang.String)
+ */
+
+ @Override
+ public Writer createOutput(String path, long lastModified) throws IOException {
+ throw new UnsupportedOperationException("Cannot create file in source folder");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#getFile(java.lang.String)
+ */
+
+ @Override
+ public File getFile(String path) throws FileNotFoundException {
+ String platformPath;
+
+ if (File.separatorChar == '/') {
+ platformPath = path;
+ } else {
+ platformPath = path.replace('/', File.separatorChar);
+ }
+
+ if (null != folders) {
+ for (File folder : folders) {
+ if (folder.exists() && folder.isDirectory()) {
+ File configFile = new File(folder, platformPath);
+ if (configFile.exists()) {
+ return configFile;
+ }
+ }
+ }
+ }
+ if (null != sources) {
+ for (File file : sources) {
+ if (file.getAbsolutePath().endsWith(platformPath)) {
+ return file;
+ }
+ }
+ }
+ throw new FileNotFoundException(path);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#getFiles()
+ */
+
+ @Override
+ public Iterable<File> getFiles() {
+ return sources;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the folders
+ */
+ @Override
+ public Iterable<File> getFolders() {
+ return this.folders;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManagerImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -33,6 +33,7 @@
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.LibraryBuilder;
import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.model.ComponentLibrary;
import com.google.inject.Inject;
@@ -63,11 +64,11 @@
}
@Override
- public void generate() throws CdkException {
+ public void generate(ComponentLibrary library) throws CdkException {
if (0 == log.getErrorCount()) {
// processing over, generate files.
for (CdkWriter generator : generators) {
- generator.render();
+ generator.render(library);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -107,7 +107,7 @@
} else if (0 == log.getErrorCount()) {
// processing over, generate files.
log.debug("Generate output files");
- builder.generate();
+ builder.generate(library);
}
return false;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMarkerRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMarkerRenderer.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMarkerRenderer.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -32,12 +32,12 @@
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.Trackable;
import freemarker.template.Configuration;
-import freemarker.template.Template;
import freemarker.template.TemplateException;
/**
@@ -47,32 +47,23 @@
*/
public abstract class FreeMarkerRenderer<C> implements CdkWriter {
- protected final ComponentLibrary library;
private final Configuration configuration;
- private final Template template;
-
private final FileManager output;
- public FreeMarkerRenderer(Configuration configuration, ComponentLibrary library, FileManager output) {
+ public FreeMarkerRenderer(Configuration configuration, FileManager output) {
this.configuration = configuration;
- this.library = library;
this.output = output;
-
- try {
- template = configuration.getTemplate(getTemplateName());
- } catch (IOException e) {
- throw new CdkException(e);
- }
}
- public void generate(C c) throws CdkException {
+ public void generate(ComponentLibrary library,C c) throws CdkException {
try {
- Writer out = getOutput(c);
-
- template.process(c, out);
- out.close();
+ Writer out = getOutput(library, c);
+ if(null != out){
+ configuration.getTemplate(getTemplateName()).process(c, out);
+ out.close();
+ }
} catch (IOException e) {
throw new CdkException(e);
} catch (TemplateException e) {
@@ -80,23 +71,22 @@
}
}
- protected Writer getOutput(C c) throws CdkException {
+ protected Writer getOutput(ComponentLibrary library, C c) throws CdkException {
long lastModified = Long.MIN_VALUE;
if (c instanceof Trackable) {
Trackable trackuble = (Trackable) c;
-
lastModified = trackuble.lastModified();
}
try {
- return output.createOutput(getOutputFile(c), lastModified);
+ return output.createOutput(getOutputFileName(c), lastModified);
} catch (IOException e) {
throw new CdkException(e);
}
}
- protected String getOutputFile(C c) throws CdkException {
+ protected String getOutputFileName(C c) throws CdkException {
if (c instanceof ModelElementBase) {
ModelElementBase modelElement = (ModelElementBase) c;
return modelElement.getTargetClass().getName().replace('.', File.separatorChar) + ".java";
@@ -104,6 +94,10 @@
throw new CdkException("Unknown model object " + c);
}
}
+
+ protected String getJavaFileName(ClassName targetClass){
+ return targetClass.getName().replace('.', File.separatorChar) + ".java";
+ }
protected abstract String getTemplateName();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -44,17 +44,17 @@
public class BehaviorClassGenerator extends FreeMarkerRenderer<BehaviorModel> implements CdkWriter {
@Inject
- public BehaviorClassGenerator(Configuration configuration, ComponentLibrary library,
+ public BehaviorClassGenerator(Configuration configuration,
@Output(Outputs.JAVA_CLASSES) FileManager output) {
- super(configuration, library, output);
+ super(configuration, output);
}
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
Collection<BehaviorModel> models = library.getBehaviors();
for (BehaviorModel model : models) {
if (model.isGenerate()) {
- this.generate(model);
+ this.generate(library, model);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -48,16 +48,16 @@
public class ComponentClassGenerator extends FreeMarkerRenderer<ComponentModel> implements CdkWriter {
@Inject
- public ComponentClassGenerator(Configuration configuration, ComponentLibrary library, @Output(Outputs.JAVA_CLASSES) FileManager output) {
- super(configuration, library, output);
+ public ComponentClassGenerator(Configuration configuration, @Output(Outputs.JAVA_CLASSES) FileManager output) {
+ super(configuration, output);
}
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
Collection<ComponentModel> models = library.getComponents();
for (ComponentModel model : models) {
if (model.isGenerate()) {
- this.generate(model);
+ this.generate(library, model);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -44,17 +44,17 @@
public class ConverterClassGenerator extends FreeMarkerRenderer<ConverterModel> implements CdkWriter {
@Inject
- public ConverterClassGenerator(Configuration configuration, ComponentLibrary library,
+ public ConverterClassGenerator(Configuration configuration,
@Output(Outputs.JAVA_CLASSES) FileManager output) {
- super(configuration, library, output);
+ super(configuration, output);
}
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
Collection<ConverterModel> models = library.getConverters();
for (ConverterModel model : models) {
if (model.isGenerate()) {
- this.generate(model);
+ this.generate(library, model);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/EventSourceInterfaceGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/EventSourceInterfaceGenerator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/EventSourceInterfaceGenerator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -45,23 +45,23 @@
public class EventSourceInterfaceGenerator extends FreeMarkerRenderer<EventModel> implements CdkWriter {
@Inject
- public EventSourceInterfaceGenerator(Configuration configuration, ComponentLibrary library,
+ public EventSourceInterfaceGenerator(Configuration configuration,
@Output(Outputs.JAVA_CLASSES) FileManager output) {
- super(configuration, library, output);
+ super(configuration, output);
}
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
Collection<EventModel> models = library.getEvents();
for (EventModel model : models) {
if (model.isGenerateSource()) {
- this.generate(model);
+ this.generate(library, model);
}
}
}
@Override
- protected String getOutputFile(EventModel c) throws CdkException {
+ protected String getOutputFileName(EventModel c) throws CdkException {
return c.getSourceInterface().getName().replace('.', File.separatorChar) + ".java";
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -44,16 +44,16 @@
public class ValidatorClassGenerator extends FreeMarkerRenderer<ValidatorModel> implements CdkWriter {
@Inject
- public ValidatorClassGenerator(Configuration configuration, ComponentLibrary library, @Output(Outputs.JAVA_CLASSES) FileManager output) {
- super(configuration, library, output);
+ public ValidatorClassGenerator(Configuration configuration, @Output(Outputs.JAVA_CLASSES) FileManager output) {
+ super(configuration, output);
}
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
Collection<ValidatorModel> models = library.getValidators();
for (ValidatorModel model : models) {
if (model.isGenerate()) {
- this.generate(model);
+ this.generate(library, model);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/ListenerTagHandlerGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/ListenerTagHandlerGenerator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/ListenerTagHandlerGenerator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -44,33 +44,30 @@
* @author akolonitsky
* @since Jan 20, 2010
*/
-public class ListenerTagHandlerGenerator extends FreeMarkerRenderer<TagModel> implements CdkWriter {
+public class ListenerTagHandlerGenerator extends FreeMarkerRenderer<TagWithModel<EventModel>> implements CdkWriter {
@Inject
- public ListenerTagHandlerGenerator(Configuration configuration, ComponentLibrary library,
+ public ListenerTagHandlerGenerator(Configuration configuration,
@Output(Outputs.JAVA_CLASSES) FileManager output) {
- super(configuration, library, output);
+ super(configuration, output);
}
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
Collection<EventModel> models = library.getEvents();
for (EventModel model : models) {
for (TagModel tag : model.getTags()) {
if ((TagType.All.equals(tag.getType()) || TagType.Facelets.equals(tag.getType())) && tag.isGenerate()) {
- process(model,tag);
+ generate(library,new TagWithModel<EventModel>(tag, model));
}
}
}
}
- protected void process(EventModel model, TagModel tag) {
-
- }
@Override
- protected String getOutputFile(TagModel c) throws CdkException {
- return c.getTargetClass().getName().replace('.', File.separatorChar) + ".java";
+ protected String getOutputFileName(TagWithModel<EventModel> c) throws CdkException {
+ return c.getTag().getTargetClass().getName().replace('.', File.separatorChar) + ".java";
}
@Override
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerWriter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerWriter.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerWriter.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -48,7 +48,7 @@
private TagHandlerGeneratorVisitor tagHandlerGeneratorVisitor;
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
library.accept(tagHandlerGeneratorVisitor,null);
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagWithModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagWithModel.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagWithModel.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -0,0 +1,65 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - 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.richfaces.cdk.generate.java.taghandler;
+
+import org.richfaces.cdk.model.TagModel;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class TagWithModel<M> {
+
+ private final TagModel tag;
+
+ private final M model;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param tag
+ * @param model
+ */
+ public TagWithModel(TagModel tag, M model) {
+ this.tag = tag;
+ this.model = model;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tag
+ */
+ public TagModel getTag() {
+ return this.tag;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the model
+ */
+ public M getModel() {
+ return this.model;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagWithModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -31,7 +31,6 @@
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Generator;
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -44,18 +43,14 @@
*/
public class TaglibWriter implements CdkWriter {
- @Inject
- private ComponentLibrary library;
@Inject
@Output(Outputs.RESOURCES)
private FileManager output;
- @Inject
- private Generator generator;
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor();
library.accept(visitor,library);
@@ -68,7 +63,7 @@
OutputFormat format1 = OutputFormat.createPrettyPrint();
format1.setIndentSize(4);
- XMLWriter writer = new XMLWriter(getOutput(), format1);
+ XMLWriter writer = new XMLWriter(getOutput(library), format1);
writer.write(document);
writer.close();
} catch (IOException e) {
@@ -76,7 +71,7 @@
}
}
- protected Writer getOutput() throws CdkException {
+ protected Writer getOutput(ComponentLibrary library) throws CdkException {
try {
return output.createOutput("META-INF/" + library.getTaglib().getShortName() + ".taglib.xml", library.lastModified());
} catch (IOException e) {
@@ -84,14 +79,7 @@
}
}
- public ComponentLibrary getLibrary() {
- return library;
- }
- public void setLibrary(ComponentLibrary library) {
- this.library = library;
- }
-
public void setOutput(FileManager output) {
this.output = output;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -53,7 +53,6 @@
* @author asmirnov(a)exadel.com
*/
public class RendererClassGenerator implements CdkWriter {
- private ComponentLibrary library;
private FileManager output;
private Logger log;
private TemplateVisitorFactory<RendererClassVisitor> visitorFactory;
@@ -69,17 +68,15 @@
* @param visitorFactory
*/
@Inject
- public RendererClassGenerator(ComponentLibrary library,
- @Output(Outputs.JAVA_CLASSES) FileManager output, Logger log,
+ public RendererClassGenerator((a)Output(Outputs.JAVA_CLASSES) FileManager output, Logger log,
TemplateVisitorFactory<RendererClassVisitor> visitorFactory, FreeMarkerRenderer renderer) {
- this.library = library;
this.output = output;
this.log = log;
this.visitorFactory = visitorFactory;
this.renderer = renderer;
}
-
- private ComponentModel findComponentByRenderer(RendererModel renderer) {
+
+ private ComponentModel findComponentByRenderer(RendererModel renderer, ComponentLibrary library) {
return library.getComponentModel(renderer.getFamily());
}
@@ -89,14 +86,14 @@
* @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary )
*/
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
for (RenderKitModel renderKit : library.getRenderKits()) {
for (RendererModel renderer : renderKit.getRenderers()) {
Template template = renderer.getTemplate();
if (null != template) {
- Collection<PropertyBase> attributes = ModelSet.<PropertyBase>create();
+ Collection<PropertyBase> attributes = ModelSet.<PropertyBase> create();
- ComponentModel component = findComponentByRenderer(renderer);
+ ComponentModel component = findComponentByRenderer(renderer, library);
if (component != null) {
attributes.addAll(component.getAttributes());
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -54,8 +54,6 @@
@Inject
private JAXB jaxbBinding;
- @Inject
- private ComponentLibrary library;
@Inject @Output(Outputs.RESOURCES)
private FileManager outputFileManager;
@@ -74,7 +72,7 @@
* )
*/
@Override
- public void render() throws CdkException {
+ public void render(ComponentLibrary library) throws CdkException {
// TODO - check modification time.
try {
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -151,7 +151,7 @@
expect(log.getErrorCount()).andReturn(0);
log.debug((CharSequence) anyObject());
expectLastCall().asStub();
- builder.generate();
+ builder.generate(library);
expectLastCall();
replay(log, element, roundEnv, builder, validator, cdkProcessor);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -36,7 +36,7 @@
import org.richfaces.cdk.LibraryBuilder;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.Source;
-import org.richfaces.cdk.SourceFileManager;
+import org.richfaces.cdk.SourceFileManagerImpl;
import org.richfaces.cdk.SourceImpl;
import org.richfaces.cdk.Sources;
import org.richfaces.cdk.annotations.JsfComponent;
@@ -111,7 +111,7 @@
sourceFiles.add(getJavaFile(src));
}
binder.bind(FileManager.class).annotatedWith(new SourceImpl(Sources.JAVA_SOURCES)).toInstance(
- new SourceFileManager(sourceFiles, this.testSourceDirectory));
+ new SourceFileManagerImpl(sourceFiles, this.testSourceDirectory));
} catch (Exception e) {
throw new RuntimeException(e);
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -72,7 +72,7 @@
ComponentLibrary library = new ComponentLibrary();
library.getBehaviors().add(behavior);
- generator.generate(behavior);
+ generator.generate(library,behavior);
log.debug(outputWriter.toString());
verify(output);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -145,7 +145,7 @@
library.getComponents().add(component);
- generator.generate(component);
+ generator.generate(library,component);
log.debug(outputWriter.toString());
verify(output);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -73,7 +73,7 @@
ComponentLibrary library = new ComponentLibrary();
library.getConverters().add(converter);
- generator.generate(converter);
+ generator.generate(library,converter);
log.debug(outputWriter.toString());
verify(output);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-05-25 23:49:09 UTC (rev 17242)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-05-25 23:55:03 UTC (rev 17243)
@@ -72,7 +72,7 @@
ComponentLibrary library = new ComponentLibrary();
library.getValidators().add(validator);
- generator.generate(validator);
+ generator.generate(library,validator);
log.debug(outputWriter.toString());
verify(output);
15 years, 7 months
JBoss Rich Faces SVN: r17242 - in root/ui/misc/trunk/ui/src: main/java/org/richfaces/function and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-25 19:49:09 -0400 (Tue, 25 May 2010)
New Revision: 17242
Added:
root/ui/misc/trunk/ui/src/test/
root/ui/misc/trunk/ui/src/test/java/
root/ui/misc/trunk/ui/src/test/java/org/
root/ui/misc/trunk/ui/src/test/java/org/richfaces/
root/ui/misc/trunk/ui/src/test/java/org/richfaces/function/
root/ui/misc/trunk/ui/src/test/java/org/richfaces/function/RichFunctionTest.java
Modified:
root/ui/misc/trunk/ui/src/main/java/org/richfaces/function/RichFunction.java
root/ui/misc/trunk/ui/src/main/java/org/richfaces/function/package-info.java
Log:
https://jira.jboss.org/browse/RF-7983
Modified: root/ui/misc/trunk/ui/src/main/java/org/richfaces/function/RichFunction.java
===================================================================
--- root/ui/misc/trunk/ui/src/main/java/org/richfaces/function/RichFunction.java 2010-05-25 22:58:22 UTC (rev 17241)
+++ root/ui/misc/trunk/ui/src/main/java/org/richfaces/function/RichFunction.java 2010-05-25 23:49:09 UTC (rev 17242)
@@ -39,64 +39,81 @@
public final class RichFunction {
+ //EasyMock requires at least protected access for the interface for calls to be delegated to
+ protected static interface ComponentLocator {
+
+ UIComponent findComponent(FacesContext facesContext, UIComponent contextComponent, String id);
+
+ }
+
+ private static ComponentLocator locator = new ComponentLocator() {
+
+ private final RendererUtils utils = RendererUtils.getInstance();
+
+ public UIComponent findComponent(FacesContext context, UIComponent contextComponent, String id) {
+ return utils.findComponentFor(context, contextComponent, id);
+ }
+ };
+
private RichFunction() {
//utility class constructor
}
-
- private static UIComponent findComponent(FacesContext context, String id) {
- if (id != null) {
- if (context != null) {
- UIComponent contextComponent = UIComponent.getCurrentComponent(context);
- if (contextComponent == null) {
- contextComponent = context.getViewRoot();
- }
- if (contextComponent != null) {
- UIComponent component = RendererUtils.getInstance().findComponentFor(contextComponent, id);
+ //used by unit tests
+ static void setComponentLocator(ComponentLocator mockLocator) {
+ locator = mockLocator;
+ }
- if (component != null) {
- return component;
- }
- }
- }
- }
+ private static UIComponent findComponent(FacesContext context, String id) {
+ if (id != null) {
+ UIComponent contextComponent = UIComponent.getCurrentComponent(context);
+ if (contextComponent == null) {
+ contextComponent = context.getViewRoot();
+ }
- return null;
- }
-
+ UIComponent component = locator.findComponent(context, contextComponent, id);
+
+ if (component != null) {
+ return component;
+ }
+ }
+
+ return null;
+ }
+
@Function
public static String clientId(String id) {
- FacesContext context = FacesContext.getCurrentInstance();
- UIComponent component = findComponent(context, id);
- return component != null ? component.getClientId(context) : null;
+ FacesContext context = FacesContext.getCurrentInstance();
+ UIComponent component = findComponent(context, id);
+ return component != null ? component.getClientId(context) : null;
}
-
+
@Function
public static String component(String id) {
- String element = element(id);
- if (element != null) {
+ String clientId = clientId(id);
+ if (clientId != null) {
//TODO nick - what if jQuery.RichFaces doesn't exist?
- return "RichFaces.$(" + clientId(id) + ")";
- }
+ return "RichFaces.$('" + clientId + "')";
+ }
- return null;
+ return null;
}
@Function
public static String element(String id) {
- String clientId = clientId(id);
- if (clientId != null) {
- return "document.getElementById('" + clientId + "')";
- }
+ String clientId = clientId(id);
+ if (clientId != null) {
+ return "document.getElementById('" + clientId + "')";
+ }
- return null;
+ return null;
}
@Function
public static UIComponent findComponent(String id) {
- return findComponent(FacesContext.getCurrentInstance(), id);
+ return findComponent(FacesContext.getCurrentInstance(), id);
}
-
+
/**
* @since 3.3.1
* @param rolesObject
@@ -105,18 +122,18 @@
@Function
public static boolean isUserInRole(Object rolesObject) {
//TODO nick - AjaxRendererUtils split text by commas and whitespace, what is the right variant?
- Set<String> rolesSet = AjaxRendererUtils.asSet(rolesObject);
- if (rolesSet != null) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ExternalContext externalContext = facesContext.getExternalContext();
+ Set<String> rolesSet = AjaxRendererUtils.asSet(rolesObject);
+ if (rolesSet != null) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
- for (String role : rolesSet) {
- if (externalContext.isUserInRole(role)) {
- return true;
- }
- }
- }
-
- return false;
+ for (String role : rolesSet) {
+ if (externalContext.isUserInRole(role)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
}
}
Modified: root/ui/misc/trunk/ui/src/main/java/org/richfaces/function/package-info.java
===================================================================
--- root/ui/misc/trunk/ui/src/main/java/org/richfaces/function/package-info.java 2010-05-25 22:58:22 UTC (rev 17241)
+++ root/ui/misc/trunk/ui/src/main/java/org/richfaces/function/package-info.java 2010-05-25 23:49:09 UTC (rev 17242)
@@ -1,4 +1,6 @@
/**
* Implementation of RichFaces functions library
*/
+@TagLibrary(uri="http://richfaces.org/misc", shortName="misc")
package org.richfaces.function;
+import org.richfaces.cdk.annotations.TagLibrary;
Added: root/ui/misc/trunk/ui/src/test/java/org/richfaces/function/RichFunctionTest.java
===================================================================
--- root/ui/misc/trunk/ui/src/test/java/org/richfaces/function/RichFunctionTest.java (rev 0)
+++ root/ui/misc/trunk/ui/src/test/java/org/richfaces/function/RichFunctionTest.java 2010-05-25 23:49:09 UTC (rev 17242)
@@ -0,0 +1,225 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.function;
+
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.same;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.easymock.EasyMock;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.function.RichFunction.ComponentLocator;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class RichFunctionTest {
+
+ private static final class StubComponentLocator implements ComponentLocator {
+
+ private UIComponent locatedComponent;
+
+ public StubComponentLocator(UIComponent locatedComponent) {
+ super();
+ this.locatedComponent = locatedComponent;
+ }
+
+ public UIComponent findComponent(FacesContext facesContext, UIComponent contextComponent, String id) {
+ if (facesContext == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (contextComponent == null) {
+ throw new NullPointerException("contextComponent");
+ }
+
+ if (EXISTING_TEST_ID.equals(id)) {
+ return locatedComponent;
+ } else if (NONEXISTING_TEST_ID.equals(id)) {
+ return null;
+ } else {
+ fail(id);
+ return null;
+ }
+ }
+ }
+
+ private static final String TEST_CLIENT_ID = "table:0:testId";
+
+ private static final String EXISTING_TEST_ID = "testId";
+
+ private static final String NONEXISTING_TEST_ID = "nonExistent";
+
+ private MockFacesEnvironment environment;
+
+ private ComponentLocator stubComponentLocator;
+
+ private ComponentLocator mockComponentLocator;
+
+ private FacesContext facesContext;
+
+ private ExternalContext externalContext;
+
+ private UIComponent currentComponent;
+
+ private UIComponent locatedComponent;
+
+ private UIViewRoot viewRoot;
+
+ private <T extends UIComponent> T createMockComponent(Class<T> componentClass) {
+ T component = environment.createMock(componentClass);
+ expect(component.getAttributes()).andStubReturn(new HashMap<String, Object>());
+ return component;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ environment = MockFacesEnvironment.createEnvironment();
+
+ facesContext = environment.getFacesContext();
+ expect(facesContext.getAttributes()).andStubReturn(new HashMap<Object, Object>());
+
+ externalContext = environment.createMock(ExternalContext.class);
+ expect(facesContext.getExternalContext()).andStubReturn(externalContext);
+
+ viewRoot = createMockComponent(UIViewRoot.class);
+ expect(facesContext.getViewRoot()).andStubReturn(viewRoot);
+
+ currentComponent = createMockComponent(UIComponent.class);
+
+ locatedComponent = createMockComponent(UIComponent.class);
+ expect(locatedComponent.getClientId(same(facesContext))).andStubReturn(TEST_CLIENT_ID);
+
+ stubComponentLocator = new StubComponentLocator(locatedComponent);
+ mockComponentLocator = environment.createMock(ComponentLocator.class);
+ RichFunction.setComponentLocator(mockComponentLocator);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ facesContext = null;
+ externalContext = null;
+ currentComponent = null;
+ locatedComponent = null;
+ viewRoot = null;
+
+ environment.verify();
+ environment.release();
+ environment = null;
+ }
+
+ @Test
+ public void testFunctionsInCurrentComponentContext() throws Exception {
+ expect(mockComponentLocator.findComponent(same(facesContext), eq(currentComponent),
+ EasyMock.<String>notNull())).andStubDelegateTo(stubComponentLocator);
+
+ environment.replay();
+
+ currentComponent.pushComponentToEL(environment.getFacesContext(), null);
+
+ assertEquals(TEST_CLIENT_ID, RichFunction.clientId(EXISTING_TEST_ID));
+ assertEquals("RichFaces.$('" + TEST_CLIENT_ID + "')", RichFunction.component(EXISTING_TEST_ID));
+ assertEquals("document.getElementById('" + TEST_CLIENT_ID + "')", RichFunction.element(EXISTING_TEST_ID));
+ assertEquals(locatedComponent, RichFunction.findComponent(EXISTING_TEST_ID));
+
+ assertNull(RichFunction.clientId(NONEXISTING_TEST_ID));
+ assertNull(RichFunction.component(NONEXISTING_TEST_ID));
+ assertNull(RichFunction.element(NONEXISTING_TEST_ID));
+ assertNull(RichFunction.findComponent(NONEXISTING_TEST_ID));
+
+ assertNull(RichFunction.clientId(null));
+ assertNull(RichFunction.component(null));
+ assertNull(RichFunction.element(null));
+ assertNull(RichFunction.findComponent(null));
+
+ currentComponent.popComponentFromEL(environment.getFacesContext());
+ }
+
+ @Test
+ public void testFunctionsInViewRootContext() throws Exception {
+ expect(mockComponentLocator.findComponent(same(facesContext), eq(viewRoot),
+ EasyMock.<String>notNull())).andStubDelegateTo(stubComponentLocator);
+
+ environment.replay();
+
+ assertEquals(TEST_CLIENT_ID, RichFunction.clientId(EXISTING_TEST_ID));
+ assertEquals("RichFaces.$('" + TEST_CLIENT_ID + "')", RichFunction.component(EXISTING_TEST_ID));
+ assertEquals("document.getElementById('" + TEST_CLIENT_ID + "')", RichFunction.element(EXISTING_TEST_ID));
+ assertEquals(locatedComponent, RichFunction.findComponent(EXISTING_TEST_ID));
+
+ assertNull(RichFunction.clientId(NONEXISTING_TEST_ID));
+ assertNull(RichFunction.component(NONEXISTING_TEST_ID));
+ assertNull(RichFunction.element(NONEXISTING_TEST_ID));
+ assertNull(RichFunction.findComponent(NONEXISTING_TEST_ID));
+
+ assertNull(RichFunction.clientId(null));
+ assertNull(RichFunction.component(null));
+ assertNull(RichFunction.element(null));
+ assertNull(RichFunction.findComponent(null));
+ }
+
+ @Test
+ public void testIsUserInRole() throws Exception {
+ expect(externalContext.isUserInRole(eq("admin"))).andReturn(false);
+ expect(externalContext.isUserInRole(eq("user"))).andReturn(true);
+
+ expect(externalContext.isUserInRole(eq("manager"))).andReturn(false);
+ expect(externalContext.isUserInRole(eq("guest"))).andReturn(false);
+ expect(externalContext.isUserInRole(eq("supervisor"))).andReturn(true);
+
+ expect(externalContext.isUserInRole(eq("auditor"))).andReturn(false);
+
+ environment.replay();
+
+ assertTrue(RichFunction.isUserInRole("admin, user, root"));
+
+ Set<String> set = new LinkedHashSet<String>();
+ set.add("manager");
+ set.add("guest");
+ set.add("supervisor");
+
+ assertTrue(RichFunction.isUserInRole(set));
+
+ assertFalse(RichFunction.isUserInRole("auditor"));
+
+ assertFalse(RichFunction.isUserInRole(null));
+}
+}
15 years, 7 months
JBoss Rich Faces SVN: r17241 - root/build/resources/trunk.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-05-25 18:58:22 -0400 (Tue, 25 May 2010)
New Revision: 17241
Added:
root/build/resources/trunk/change_version.sh
Log:
Script to change all pom.xml versions from ORIG to NEW, using basic perl script
Added: root/build/resources/trunk/change_version.sh
===================================================================
--- root/build/resources/trunk/change_version.sh (rev 0)
+++ root/build/resources/trunk/change_version.sh 2010-05-25 22:58:22 UTC (rev 17241)
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+usage()
+{
+cat << EOF
+usage: $0 options
+
+This script will search all pom.xml and change <version>ORIG</version> to <version>NEW</version>
+
+BASIC OPTIONS:
+ -h Show this message
+ -d Destination directory, otherwise the PWD is used
+ -o Version to replace - such as 4-SNAPSHOT
+ -n Version to replace with - such as 5
+EOF
+}
+
+work()
+{
+
+if [ -d "$DESTINATION" ]
+then
+ echo "Beginning version update from base directory: $DESTINATION"
+else
+ echo "Base directory does not exist, can not update version from: $DESTINATION"
+ exit 1;
+fi
+
+ echo
+ echo =================================
+ echo "Changing <version>$ORIG_VERSION</version> into <version>$NEW_VERSION</version>
+
+ find . -name "pom.xml" | xargs perl -pi -e "s/<version>$ORIG_VERSION<\/version>/<version>$NEW_VERSION<\/version>/"
+
+ echo =================================
+
+done
+
+}
+
+DESTINATION=`pwd`
+ORIG_VERSION=
+NEW_VERSION=
+
+while getopts "n:o:d:h" OPTION
+do
+ case $OPTION in
+ n)
+ NEW_VERSION=$OPTARG
+ ;;
+ o)
+ ORIG_VERSION=$OPTARG
+ ;;
+ d)
+ DESTINATION=$OPTARG
+ ;;
+ h)
+ usage
+ WORK=0
+ ;;
+ [?])
+ usage;
+ WORK=0
+ ;;
+ esac
+done
+
+if [ "$WORK" -eq "1" ] || [ "$#" -eq "0" ]
+then
+ work;
+fi
\ No newline at end of file
Property changes on: root/build/resources/trunk/change_version.sh
___________________________________________________________________
Name: svn:executable
+ *
15 years, 7 months
JBoss Rich Faces SVN: r17240 - root/build/resources/trunk.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-05-25 18:57:25 -0400 (Tue, 25 May 2010)
New Revision: 17240
Added:
root/build/resources/trunk/clean_install.sh
Log:
Script to mvn clean install every module in 4.0
Added: root/build/resources/trunk/clean_install.sh
===================================================================
--- root/build/resources/trunk/clean_install.sh (rev 0)
+++ root/build/resources/trunk/clean_install.sh 2010-05-25 22:57:25 UTC (rev 17240)
@@ -0,0 +1,198 @@
+#!/bin/sh
+
+usage()
+{
+cat << EOF
+usage: $0 options
+
+This script will execute "mvn clean install" on all modules in RichFaces 4.0. With the the various options below.
+
+MODULE OPTIONS
+ -c Include cdk modules
+ -t Include tests, and docs modules (NOT FUNCTIONAL)
+ -e Include examples, and archetype modules (NOT FUNCTIONAL)
+ -s Include sandbox modules
+ -a Include all of the above
+
+BASIC OPTIONS:
+ -h Show this message
+ -d Root directory, otherwise the PWD is used
+ -x Use mvn -X option
+
+TODO Add options for skip test, skip check style etc...
+
+EOF
+}
+
+work()
+{
+
+if [ "$DEBUG" -eq "0" ]
+then
+ MVNARGS="-X"
+fi
+
+if [ -d "$DESTINATION" ]
+then
+ echo "Beginning build from base directory: $DESTINATION"
+else
+ echo "Base directory does not exist, can not build from: $DESTINATION"
+ exit 1;
+fi
+
+FINAL_LIST=( ${MAIN_MODULE_ARRAY[@]} )
+
+if [ "$INCL_CDK" -eq "1" ]
+then
+ FINAL_LIST=( ${FINAL_LIST[@]} ${CDK_MODULE_ARRAY[@]} )
+fi
+
+if [ "$INCL_DOCS_TESTS" -eq "1" ]
+then
+ FINAL_LIST=( ${FINAL_LIST[@]} ${DOC_QE_MODULE_ARRAY[@]} )
+fi
+
+if [ "$INCL_EXAMPLES_ARCHETYPE" -eq "1" ]
+then
+ FINAL_LIST=( ${FINAL_LIST[@]} ${EXAMPLE_ARCHETYPE_MODULE_ARRAY[@]} )
+fi
+
+if [ "$INCL_SANDBOX" -eq "1" ]
+then
+ FINAL_LIST=( ${FINAL_LIST[@]} ${SANDBOX_MODULE_ARRAY[@]} )
+fi
+
+for module in "${FINAL_LIST[@]}"
+do
+ moduledir=$DESTINATION/$module
+ command="mvn $MVNARGS clean install"
+ echo
+ echo =================================
+ echo "Moving into module directory : $moduledir"
+ if [ -d "$moduledir" ]
+ then
+ echo "Executing command : $command"
+ cd $moduledir
+ $command
+ else
+ echo "Module directory does not exist, can not execute command: $command"
+ echo =================================
+ exit 1;
+ fi
+
+ echo =================================
+
+done
+
+}
+
+DESTINATION=`pwd`
+DEBUG=0
+MVNARGS=
+WORK=1
+INCL_CDK=0
+INCL_DOCS_TESTS=0
+INCL_EXAMPLES_ARCHETYPE=0
+INCL_SANDBOX=0
+
+# Listing of all modules to be checked out
+# $1 = path to module ( before trunk/tag/branch )
+MAIN_MODULE_ARRAY=(
+ "build/parent/trunk"
+ "build/bom/trunk"
+ "build/resources/trunk/checkstyle"
+ "commons/trunk"
+ "core/trunk"
+ "ui/core/trunk"
+ "ui/misc/trunk
+ # other ui modules when in place
+ # TODO NOT SURE WHAT TO DO WITH /DISTS
+ )
+
+CDK_MODULE_ARRAY=(
+ "cdk/trunk"
+ "cdk-sandbox/trunk"
+ )
+
+DOC_QE_MODULE_ARRAY=(
+ # "docs/trunk"
+ # "tests/trunk"
+ )
+
+EXAMPLE_ARCHETYPE_MODULE_ARRAY=(
+ # For each example
+ # "examples/<example>"
+ "examples/core-demo"
+ "examples/repeater-demo"
+ "examples/richfaces-showcase"
+ "examples/dist"
+
+ # For each archetype
+ # "archetype/<archetype>"
+ # TODO - populate after we have archetypes
+ )
+
+SANDBOX_MODULE_ARRAY=(
+ # For each example in sandbox
+ # "examples-sandbox/<example>"
+
+ # For each component in sandbox
+ # "ui-sandbox/<component>"
+ "ui-sandbox/tables/trunk"
+ "ui-sandbox/datascroller/trunk"
+ "ui-sandbox/componentControl/trunk"
+
+ # These exist but are just shells
+ # "ui-sandbox/calendar"
+ # "ui-sandbox/datafilterslider"
+ # "ui-sandbox/drag-drop"
+ # "ui-sandbox/fileupload"
+ # "ui-sandbox/numberinputs"
+ # "ui-sandbox/selects"
+ # "ui-sandbox/togglepanels"
+ # "ui-sandbox/tree"
+ # "ui-sandbox/tree-model"
+ )
+
+while getopts "tecsahd:x" OPTION
+do
+ case $OPTION in
+ t)
+ INCL_DOCS_TESTS=1
+ ;;
+ e)
+ INCL_EXAMPLES_ARCHETYPE=1
+ ;;
+ c)
+ INCL_CDK=1
+ ;;
+ s)
+ INCL_SANDBOX=1
+ ;;
+ a)
+ INCL_CDK=1
+ INCL_DOCS_TESTS=1
+ INCL_EXAMPLES_ARCHETYPE=1
+ INCL_SANDBOX=1
+ ;;
+ h)
+ usage
+ WORK=0
+ ;;
+ d)
+ DESTINATION=$OPTARG
+ ;;
+ x)
+ DEBUG=1
+ ;;
+ [?])
+ usage;
+ WORK=0
+ ;;
+ esac
+done
+
+if [ "$WORK" -eq "1" ] || [ "$#" -eq "0" ]
+then
+ work;
+fi
\ No newline at end of file
Property changes on: root/build/resources/trunk/clean_install.sh
___________________________________________________________________
Name: svn:executable
+ *
15 years, 7 months
JBoss Rich Faces SVN: r17239 - in root/cdk/trunk/plugins/generator: src/main/java/org/richfaces/cdk/generate/freemarker and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-05-25 18:05:22 -0400 (Tue, 25 May 2010)
New Revision: 17239
Added:
root/cdk/trunk/plugins/generator/.checkstyle
Removed:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/CdkConfiguration.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/XhtmlAttributesParsingTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/Bean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/util/ComparatorUtilsTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/ComponentAdapterTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/XmlTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/package-info.java
Log:
Fix CheckStyle violations in tests
Added: root/cdk/trunk/plugins/generator/.checkstyle
===================================================================
--- root/cdk/trunk/plugins/generator/.checkstyle (rev 0)
+++ root/cdk/trunk/plugins/generator/.checkstyle 2010-05-25 22:05:22 UTC (rev 17239)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="false">
+ <fileset name="JavaSource" enabled="true" check-config-name="RichFaces" local="false">
+ <file-match-pattern match-pattern="src/main/java" include-pattern="true"/>
+ </fileset>
+ <fileset name="test sources" enabled="true" check-config-name="RichFaces" local="false">
+ <file-match-pattern match-pattern="src/test/java" include-pattern="true"/>
+ </fileset>
+ <filter name="NonSrcDirs" enabled="true"/>
+</fileset-config>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/CdkConfiguration.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/CdkConfiguration.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/CdkConfiguration.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -46,8 +46,9 @@
super();
this.log = log;
- // TODO set proper template loader.
+ // load templates from this project.
setClassForTemplateLoading(this.getClass(), TEMPLATES);
+ setTemplateUpdateDelay(10000);// Forever...
setObjectWrapper(wrapper);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -23,13 +23,6 @@
package org.richfaces.cdk;
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Binder;
-import com.google.inject.Module;
-import org.junit.After;
-import org.junit.Before;
-import org.richfaces.cdk.annotations.JsfComponent;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -41,6 +34,14 @@
import java.util.Locale;
import java.util.logging.LogManager;
+import org.junit.After;
+import org.junit.Before;
+import org.richfaces.cdk.annotations.JsfComponent;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+
/**
* <p class="changed_added_4_0">
* </p>
@@ -50,9 +51,15 @@
*/
public abstract class CdkTestBase implements Module {
+ protected File tempDir;
+
protected Iterable<File> testSourceDirectory;
- protected File tempDir;
+ @Override
+ public void configure(Binder binder) {
+ binder.bind(Locale.class).toInstance(Locale.getDefault());
+ binder.bind(Charset.class).toInstance(Charset.defaultCharset());
+ }
@Before
public void setUpSourceDirectory() throws Exception {
@@ -84,10 +91,13 @@
testSourceDirectory = null;
}
- @Override
- public void configure(Binder binder) {
- binder.bind(Locale.class).toInstance(Locale.getDefault());
- binder.bind(Charset.class).toInstance(Charset.defaultCharset());
+ protected CdkClassLoader createClassLoader() {
+ try {
+ return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
+ getLibraryFile(JsfComponent.class)), null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
protected File getJavaFile(String name) throws URISyntaxException {
@@ -99,6 +109,10 @@
return classFile;
}
+ protected File getLibraryFile(Class<?> clazz) throws Exception {
+ return getLibraryFile(clazz.getName().replaceAll("\\.", "/") + ".class");
+ }
+
protected File getLibraryFile(String resource) throws Exception {
URL url = this.getClass().getClassLoader().getResource(resource);
if (null != url) {
@@ -120,17 +134,4 @@
throw new Exception("Resource does not exists " + resource);
}
}
-
- protected File getLibraryFile(Class<?> clazz) throws Exception {
- return getLibraryFile(clazz.getName().replaceAll("\\.", "/") + ".class");
- }
-
- protected CdkClassLoader createClassLoader() {
- try {
- return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(JsfComponent.class)), null);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
}
Deleted: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -1,46 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - 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.richfaces.cdk;
-
-/**
- * <p class="changed_added_4_0">
- * This application should create GraphVis .dot file with Cdk dependencies
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public class DependenciesGraph {
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param args
- */
- public static void main(String[] args) {
-
- }
-
-}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -1,40 +1,57 @@
-
/**
*
*/
package org.richfaces.cdk;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.maven.model.FileSet;
-import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.junit.Ignore;
import org.junit.Test;
-import org.junit.Ignore;
-import org.richfaces.cdk.apt.AptBuilder;
-import java.io.File;
-import java.util.*;
-import java.net.MalformedURLException;
-
/**
* @author asmirnov
- *
+ *
*/
public class LibraryBuilderTest extends CdkTestBase {
- private static final String PROJECT_BASE = "E:\\_richfaces\\svn\\richfaces_root\\ui\\components\\core\\";
- private static final String[] JAVA_INCLUDES = new String[]{"**/*.java"};
+ private static final String[] JAVA_INCLUDES = new String[] { "**/*.java" };
private static final String MAIN_CONFIG = "src/main/config";
private static final String MAIN_TEMPLATES = "src/main/templates";
+ private static final String PROJECT_BASE = "E:\\_richfaces\\svn\\richfaces_root\\ui\\components\\core\\";
private static final String[] STRINGS_ARRAY = new String[0];
private static final String XML_INCLUDES = "**/*.xml";
protected File outputJavaDirectory = new File(PROJECT_BASE + "target/generated-sources/main/java");
protected File outputResourcesDirectory = new File(PROJECT_BASE + "target/generated-sources/main/resources");
protected File outputTestDirectory = new File(PROJECT_BASE + "target/generated-sources/test/java");
+
protected File outputTestResourcesDirectory = new File(PROJECT_BASE + "target/generated-sources/test/resources");
+ /**
+ * <p class="changed_added_4_0">
+ * This utility method sets output directory for particular type. I such directory does not exist, it is created.
+ * </p>
+ *
+ * @param generator
+ * @param directory
+ * @param type
+ */
+ private static void setOutput(Generator generator, File directory, Outputs type) {
+ if (!directory.exists()) {
+ directory.mkdirs();
+ }
+
+ generator.addOutputFolder(type, directory);
+ }
+
@Test
@Ignore
public void createInstance() throws Exception {
@@ -53,13 +70,11 @@
}
}
-
generator.addSources(Sources.JAVA_SOURCES, findJavaFiles(), folders);
// TODO - detect templates and configs directories.
generator.addSources(Sources.RENDERER_TEMPLATES, findTemplateFiles(), null);
generator.addSources(Sources.FACES_CONFIGS, findFacesConfigFiles(), null);
-
// Setup output folders.
setOutput(generator, outputJavaDirectory, Outputs.JAVA_CLASSES);
setOutput(generator, outputResourcesDirectory, Outputs.RESOURCES);
@@ -67,7 +82,7 @@
setOutput(generator, outputTestResourcesDirectory, Outputs.TEST_RESOURCES);
// configure CDK workers.
-// setupPlugins(generator);
+ // setupPlugins(generator);
try {
@@ -80,62 +95,84 @@
}
}
+ /**
+ * <p class="changed_added_4_0">
+ * This method checks library configuration and sets default values if necessary.
+ * </p>
+ */
+ protected void checkLibraryConfig() {
+
+ // TODO Auto-generated method stub
+ }
+
+ @Override
protected CdkClassLoader createClassLoader() {
return new CdkClassLoader(this.getClass().getClassLoader());
}
/**
- * <p class="changed_added_4_0">This utility method sets output directory for particular type.
- * I such directory does not exist, it is created.</p>
- *
- * @param generator
- * @param directory
- * @param type
+ * Skan Array of filesets for selected resources.
+ *
+ * @param filesets
+ * @return
+ * @throws MojoExecutionException
*/
- private static void setOutput(Generator generator, File directory, Outputs type) {
- if (!directory.exists()) {
- directory.mkdirs();
+ @SuppressWarnings("unchecked")
+ protected Collection<File> doScan(FileSet[] filesets) throws MojoExecutionException {
+ List<File> files = new ArrayList<File>();
+
+ if (null != filesets) {
+ for (FileSet fileSet : filesets) {
+ String[] includes = (String[]) fileSet.getIncludes().toArray(STRINGS_ARRAY);
+ String[] excludes = (String[]) fileSet.getExcludes().toArray(STRINGS_ARRAY);
+ File fileSetDirectory = resolveRelativePath(new File(fileSet.getDirectory()));
+ String[] scan = doScan(includes, excludes, fileSetDirectory);
+
+ for (String filename : scan) {
+ files.add(resolveRelativePath(new File(fileSetDirectory, filename)));
+ }
+ }
}
- generator.addOutputFolder(type, directory);
+ return files;
}
- /**
- * <p class="changed_added_4_0">This method checks library configuration and sets default values if necessary.</p>
- */
- protected void checkLibraryConfig() {
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder) throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
- // TODO Auto-generated method stub
- }
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+ directoryScanner.scan();
- private File resolveRelativePath(File file) {
- File result = file;
- if (!result.isAbsolute()) {
- result = new File(PROJECT_BASE, result.getPath());
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException("Error scanning source root: \'" + rootFolder + "\'", e);
}
-
- return result;
}
- private Iterable<File> findTemplateFiles() throws MojoExecutionException {
- FileSet[] templates = null;
- File defaultDirectory = resolveRelativePath(new File(MAIN_TEMPLATES));
+ private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
+ FileSet[] facesConfigs = null;
+ File defaultDirectory = resolveRelativePath(new File(MAIN_CONFIG));
if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
FileSet fileSet = new FileSet();
- fileSet.setDirectory(MAIN_TEMPLATES);
+ fileSet.setDirectory(MAIN_CONFIG);
fileSet.addInclude(XML_INCLUDES);
- templates = new FileSet[]{fileSet};
+ facesConfigs = new FileSet[] { fileSet };
}
- return doScan(templates);
+ return doScan(facesConfigs);
}
private Iterable<File> findJavaFiles() throws MojoExecutionException {
Set<File> javaSources = new HashSet<File>();
String[] includes = JAVA_INCLUDES;
- String compileSourceRoots[] = new String[]{PROJECT_BASE + "\\src\\main\\java"};
+ String[] compileSourceRoots = new String[] { PROJECT_BASE + "\\src\\main\\java" };
for (String compileRoot : compileSourceRoots) {
File rootFolder = new File(compileRoot);
String[] sources = doScan(includes, null, rootFolder);
@@ -148,62 +185,27 @@
return javaSources;
}
- private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
- FileSet[] facesConfigs = null;
- File defaultDirectory = resolveRelativePath(new File(MAIN_CONFIG));
+ private Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ FileSet[] templates = null;
+ File defaultDirectory = resolveRelativePath(new File(MAIN_TEMPLATES));
if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
FileSet fileSet = new FileSet();
- fileSet.setDirectory(MAIN_CONFIG);
+ fileSet.setDirectory(MAIN_TEMPLATES);
fileSet.addInclude(XML_INCLUDES);
- facesConfigs = new FileSet[]{fileSet};
+ templates = new FileSet[] { fileSet };
}
- return doScan(facesConfigs);
+ return doScan(templates);
}
- protected String[] doScan(String[] includes, String[] excludes, File rootFolder) throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
-
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
- directoryScanner.scan();
-
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException("Error scanning source root: \'" + rootFolder + "\'", e);
+ private File resolveRelativePath(File file) {
+ File result = file;
+ if (!result.isAbsolute()) {
+ result = new File(PROJECT_BASE, result.getPath());
}
- }
- /**
- * Skan Array of filesets for selected resources.
- *
- * @param filesets
- * @return
- * @throws MojoExecutionException
- */
- @SuppressWarnings("unchecked")
- protected Collection<File> doScan(FileSet[] filesets) throws MojoExecutionException {
- List<File> files = new ArrayList<File>();
-
- if (null != filesets) {
- for (FileSet fileSet : filesets) {
- String[] includes = (String[]) fileSet.getIncludes().toArray(STRINGS_ARRAY);
- String[] excludes = (String[]) fileSet.getExcludes().toArray(STRINGS_ARRAY);
- File fileSetDirectory = resolveRelativePath(new File(fileSet.getDirectory()));
- String[] scan = doScan(includes, excludes, fileSetDirectory);
-
- for (String filename : scan) {
- files.add(resolveRelativePath(new File(fileSetDirectory, filename)));
- }
- }
- }
-
- return files;
+ return result;
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -29,7 +29,6 @@
import org.junit.Before;
import org.junit.Test;
import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.FacesId;
/**
@@ -40,8 +39,8 @@
*
*/
public class NamingConventionsTest {
- private static final FacesId COMPONENT_TYPE = FacesId.parseId("foo.bar.Test");
private static final String BASE = "foo.bar";
+ private static final FacesId COMPONENT_TYPE = FacesId.parseId("foo.bar.Test");
private RichFacesConventions conventions;
@Before
@@ -54,19 +53,7 @@
conventions = null;
}
- /**
- * Test method for
- * {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
- *
- * @throws Exception
- */
@Test
- public void testInferComponentTypeFromUIClass() throws Exception {
- assertEquals(COMPONENT_TYPE, conventions.inferComponentType(new ClassName("foo.bar.component.UITest")));
- }
-
-
- @Test
public void testInferComponentTypeFromAbstractClass() throws Exception {
assertEquals(COMPONENT_TYPE, conventions.inferComponentType(new ClassName("foo.bar.component.AbstractTest")));
}
@@ -78,12 +65,23 @@
@Test
public void testInferComponentTypeFromMarkupClass() throws Exception {
- assertEquals(FacesId.parseId("foo.bar.HtmlTest"), conventions.inferComponentType(new ClassName("foo.bar.component.html.HtmlTest")));
+ assertEquals(FacesId.parseId("foo.bar.HtmlTest"), conventions.inferComponentType(new ClassName(
+ "foo.bar.component.html.HtmlTest")));
}
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String, java.lang.String)}.
+ *
+ * @throws Exception
+ */
@Test
+ public void testInferComponentTypeFromUIClass() throws Exception {
+ assertEquals(COMPONENT_TYPE, conventions.inferComponentType(new ClassName("foo.bar.component.UITest")));
+ }
+
+ @Test
public void testInferUIComponentClassFromType() throws Exception {
- assertEquals(new ClassName("foo.bar.component.UITest"),
- conventions.inferUIComponentClass(COMPONENT_TYPE));
+ assertEquals(new ClassName("foo.bar.component.UITest"), conventions.inferUIComponentClass(COMPONENT_TYPE));
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -69,37 +69,37 @@
private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
- private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
private static final ImmutableSet<String> PROCESS_ANNOTATIONS = ImmutableSet.of(TestAnnotation.class.getName());
+ private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
@Inject
- private CdkProcessor processor;
+ ComponentLibrary library;
- @Stub
- @Output(Outputs.JAVA_CLASSES)
- private FileManager output;
+ @Mock
+ private LibraryBuilder builder;
@Inject
- ComponentLibrary library;
-
- @Inject
private CdkAnnotationProcessor cdkProcessor;
@Mock
- private RoundEnvironment roundEnv;
+ private TypeElement element;
@Mock
- private TypeElement element;
+ private Logger log;
+ @Stub
+ @Output(Outputs.JAVA_CLASSES)
+ private FileManager output;
+
+ @Inject
+ private CdkProcessor processor;
+
@Mock
- private LibraryBuilder builder;
+ private RoundEnvironment roundEnv;
@Mock
private ModelValidator validator;
- @Mock
- private Logger log;
-
@Override
public void configure(Binder binder) {
super.configure(binder);
@@ -113,17 +113,11 @@
}).toInstance(Collections.<ModelBuilder> emptySet());
}
- @Override
- protected Iterable<String> sources() {
- return ImmutableList.of(CLASS_JAVA, INTERFACE_JAVA, SUB_CLASS_JAVA);
- }
-
@Test
public void testProcess() throws Exception {
expect(roundEnv.processingOver()).andReturn(false);
expect((Class<TestAnnotation2>) cdkProcessor.getProcessedAnnotation()).andStubReturn(TestAnnotation2.class);
- expect((Set<TypeElement>) roundEnv.getRootElements()).andReturn(
- Collections.singleton(element));
+ expect((Set<TypeElement>) roundEnv.getRootElements()).andReturn(Collections.singleton(element));
expect(element.getKind()).andReturn(ElementKind.CLASS);
TestAnnotation2 testAnnotation2 = createNiceMock(TestAnnotation2.class);
expect(element.getAnnotation(TestAnnotation2.class)).andReturn(testAnnotation2);
@@ -138,10 +132,25 @@
}
@Test
+ public void testProcess3() throws Exception {
+ expect(roundEnv.processingOver()).andReturn(false);
+ expect((Class<TestAnnotation>) cdkProcessor.getProcessedAnnotation()).andStubReturn(TestAnnotation.class);
+ expect((Set<TypeElement>) roundEnv.getRootElements()).andReturn(Collections.singleton(element));
+ expect(element.getKind()).andReturn(ElementKind.CLASS);
+ expect(element.getAnnotation(TestAnnotation.class)).andReturn(null);
+ validator.verify(library);
+ expectLastCall();
+ replay(element, roundEnv, builder, validator, cdkProcessor);
+ processor.process(Collections.singleton(element), roundEnv);
+ verify(element, roundEnv, builder, validator, cdkProcessor);
+ }
+
+ @Test
public void testProcessOver() throws Exception {
expect(roundEnv.processingOver()).andReturn(true);
expect(log.getErrorCount()).andReturn(0);
- log.debug((CharSequence) anyObject());expectLastCall().asStub();
+ log.debug((CharSequence) anyObject());
+ expectLastCall().asStub();
builder.generate();
expectLastCall();
replay(log, element, roundEnv, builder, validator, cdkProcessor);
@@ -160,19 +169,9 @@
verify(log, element, roundEnv, builder, validator, cdkProcessor);
}
- @Test
- public void testProcess3() throws Exception {
- expect(roundEnv.processingOver()).andReturn(false);
- expect((Class<TestAnnotation>) cdkProcessor.getProcessedAnnotation()).andStubReturn(TestAnnotation.class);
- expect((Set<TypeElement>) roundEnv.getRootElements()).andReturn(
- Collections.singleton(element));
- expect(element.getKind()).andReturn(ElementKind.CLASS);
- expect(element.getAnnotation(TestAnnotation.class)).andReturn(null);
- validator.verify(library);
- expectLastCall();
- replay(element, roundEnv, builder, validator, cdkProcessor);
- processor.process(Collections.singleton(element), roundEnv);
- verify(element, roundEnv, builder, validator, cdkProcessor);
+ @Override
+ protected Iterable<String> sources() {
+ return ImmutableList.of(CLASS_JAVA, INTERFACE_JAVA, SUB_CLASS_JAVA);
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -23,21 +23,22 @@
package org.richfaces.cdk.apt;
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Inject;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+import java.util.Set;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.Processor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaCompiler.CompilationTask;
+
import org.easymock.Capture;
import org.easymock.CaptureType;
import org.easymock.EasyMock;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
@@ -48,14 +49,8 @@
import org.richfaces.cdk.Stub;
import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.Processor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.TypeElement;
-import javax.tools.JavaCompiler.CompilationTask;
-import java.util.Collections;
-import java.util.Set;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -68,15 +63,15 @@
public class TaskFactoryTest extends AnnotationProcessorTest {
private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
- private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
+ private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
- @Inject
- private TaskFactoryImpl factory;
-
@Mock
Processor processor;
+ @Inject
+ private TaskFactoryImpl factory;
+
@Stub
@Output(Outputs.JAVA_CLASSES)
private FileManager output;
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -35,7 +35,6 @@
import org.richfaces.cdk.Generator;
import org.richfaces.cdk.LibraryBuilder;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.Mock;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.SourceFileManager;
import org.richfaces.cdk.SourceImpl;
@@ -55,33 +54,34 @@
public abstract class AnnotationProcessorTest extends CdkTestBase {
protected static final class TestName implements Name {
-
+
private final String name;
-
+
public TestName(String name) {
this.name = name;
}
+
@Override
+ public char charAt(int index) {
+ return name.charAt(index);
+ }
+
+ @Override
public boolean contentEquals(CharSequence cs) {
// TODO Auto-generated method stub
return name.equals(cs);
}
-
+
@Override
- public char charAt(int index) {
- return name.charAt(index);
- }
-
- @Override
public int length() {
return name.length();
}
-
+
@Override
public CharSequence subSequence(int start, int end) {
return name.substring(start, end);
}
-
+
@Override
public String toString() {
return name;
@@ -91,27 +91,15 @@
protected static final String FOO_BAR = "foo.Bar";
@Inject
+ protected Logger log;
+
+ @Inject
@Source(Sources.JAVA_SOURCES)
protected FileManager sources;
@Inject
- protected Logger log;
-
- @Inject
private Injector injector;
- protected void process(String javaFilePath) throws Exception {
- Generator generator = new Generator();
- generator.setLoader(createClassLoader());
- generator.addSources(Sources.JAVA_SOURCES, ImmutableList.of(getJavaFile(javaFilePath)), null);
-
- generator.init();
- injector.injectMembers(new ComponentProcessor());
-
- LibraryBuilder builder = injector.getInstance(LibraryBuilder.class);
- builder.build();
- }
-
@Override
public void configure(Binder binder) {
super.configure(binder);
@@ -130,16 +118,29 @@
}
- protected abstract Iterable<String> sources();
-
@Override
protected CdkClassLoader createClassLoader() {
try {
return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(ComponentModel.class), getLibraryFile(ELContext.class), getLibraryFile(JsfComponent.class),
- getLibraryFile(UIComponent.class)), this.getClass().getClassLoader());
+ getLibraryFile(ComponentModel.class), getLibraryFile(ELContext.class),
+ getLibraryFile(JsfComponent.class), getLibraryFile(UIComponent.class)), this.getClass()
+ .getClassLoader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
+
+ protected void process(String javaFilePath) throws Exception {
+ Generator generator = new Generator();
+ generator.setLoader(createClassLoader());
+ generator.addSources(Sources.JAVA_SOURCES, ImmutableList.of(getJavaFile(javaFilePath)), null);
+
+ generator.init();
+ injector.injectMembers(new ComponentProcessor());
+
+ LibraryBuilder builder = injector.getInstance(LibraryBuilder.class);
+ builder.build();
+ }
+
+ protected abstract Iterable<String> sources();
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -37,7 +37,6 @@
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.MockController;
-import org.richfaces.cdk.Logger;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
@@ -52,9 +51,11 @@
import com.google.inject.Inject;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
@RunWith(CdkTestRunner.class)
public class AttributesProcessorTest extends AnnotationProcessorTest {
@@ -63,23 +64,25 @@
private static final String FOO_XML = "foo.xml";
+ @Mock
+ private DescriptionProcessor descriptionProcessor;
+
@Inject
private MockController mockController;
-
+
@Inject
private AttributesProcessorImpl processor;
@Mock
- private DescriptionProcessor descriptionProcessor;
+ private SourceUtils utils;
@Mock
private JAXB xmlProcessor;
- @Mock
- private SourceUtils utils;
-
/**
- * Test method for {@link org.richfaces.cdk.apt.processors.AttributesProcessorImpl#processType(org.richfaces.cdk.model.BeanModelBase, javax.lang.model.element.TypeElement)}.
+ * Test method for
+ * {@link org.richfaces.cdk.apt.processors.AttributesProcessorImpl#processType(org.richfaces.cdk.model.BeanModelBase, javax.lang.model.element.TypeElement)}
+ * .
*/
@Test
public void testProcessType() {
@@ -88,13 +91,16 @@
utils.visitSupertypes(same(element), EasyMock.isA(SuperTypeVisitor.class));
expectLastCall();
BeanProperty beanProperty = createNiceMock(BeanProperty.class);
- expect(utils.getBeanPropertiesAnnotatedWith(eq(Attribute.class), same(element))).andReturn(Collections.singleton(beanProperty));
+ expect(utils.getBeanPropertiesAnnotatedWith(eq(Attribute.class), same(element))).andReturn(
+ Collections.singleton(beanProperty));
expect(utils.getAbstractBeanProperties(same(element))).andReturn(new HashSet<BeanProperty>(0));
expect(beanProperty.getName()).andReturn(FOO);
expect(beanProperty.getType()).andReturn(ClassName.parseName(String.class.getName()));
- mockController.replay();replay(element,beanProperty);
+ mockController.replay();
+ replay(element, beanProperty);
processor.processType(bean, element);
- mockController.verify();verify(element,beanProperty);
+ mockController.verify();
+ verify(element, beanProperty);
assertEquals(1, bean.getAttributes().size());
}
@@ -104,8 +110,10 @@
Fragment fragment = new Fragment();
PropertyModel propertyModel = new PropertyModel();
propertyModel.setName(FOO);
- fragment.getProperties().add(propertyModel );
- expect(xmlProcessor.unmarshal(eq(CdkEntityResolver.URN_ATTRIBUTES+FOO_XML), (String)anyObject(), eq(Fragment.class))).andReturn(fragment);
+ fragment.getProperties().add(propertyModel);
+ expect(
+ xmlProcessor.unmarshal(eq(CdkEntityResolver.URN_ATTRIBUTES + FOO_XML), (String) anyObject(),
+ eq(Fragment.class))).andReturn(fragment);
mockController.replay();
processor.processXmlFragment(bean, FOO_XML);
mockController.verify();
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -59,30 +59,18 @@
*/
@RunWith(CdkTestRunner.class)
public class BehaviorProcessorTest extends AnnotationProcessorTest {
- private static final String MY_BEHAVIOR = "my_behavior";
-
private static final String BEHAVIOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyBehavior.java";
- @Inject
- private BehaviorProcessor processor;
+ private static final String MY_BEHAVIOR = "my_behavior";
- @Inject
- private ComponentLibrary library;
-
@Mock
- private SourceUtils utils;
+ private JsfBehavior behaviorAnnotation;
@Mock
private TypeElement componentElement;
- @Stub
- private Name name;
-
- @Stub
- private Tag tag;
-
@Mock
- private JsfBehavior behaviorAnnotation;
+ private NamingConventions conventions;
@Mock
private Description description;
@@ -90,8 +78,20 @@
@Mock
private JAXB jaxb;
+ @Inject
+ private ComponentLibrary library;
+
+ @Stub
+ private Name name;
+
+ @Inject
+ private BehaviorProcessor processor;
+
+ @Stub
+ private Tag tag;
+
@Mock
- private NamingConventions conventions;
+ private SourceUtils utils;
@Test
@Ignore
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -23,18 +23,14 @@
package org.richfaces.cdk.apt.processors;
-import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.same;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
@@ -54,9 +50,8 @@
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.xmlconfig.JAXB;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-import java.util.Collections;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -67,65 +62,122 @@
*/
@RunWith(CdkTestRunner.class)
public class ComponentProcessorTest extends AnnotationProcessorTest {
- public static final String SMALL_JPG = "/icons/Small.jpg";
public static final String LARGE_GIF = "/icons/Large.gif";
- private static final String FOO_HTML_BAR = "foo.HtmlBar";
+ public static final String SMALL_JPG = "/icons/Small.jpg";
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
private static final String FACES_COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/UITestCommand.java";
+ private static final String FOO_HTML_BAR = "foo.HtmlBar";
- @Inject
- private ComponentProcessor processor;
+ @Mock
+ private JsfComponent annotation;
@Mock
private AttributesProcessor attributesProcessor;
- @Inject
- private ComponentLibrary library;
+ @Mock
+ private TypeElement componentElement;
- @Inject
- private ComponentModel model;
-
@Mock
- private SourceUtils utils;
+ private NamingConventions conventions;
@Mock
- private TypeElement componentElement;
-
- @Mock
- private JsfComponent annotation;
-
- @Mock
private Description description;
+ @Stub
+ private DescriptionProcessor descriptionProcessor;
+
@Mock
private JAXB jaxb;
-
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ private ComponentModel model;
+
+ @Inject
+ private ComponentProcessor processor;
+
@Mock
private BeanProperty property;
- @Mock
- private NamingConventions conventions;
-
@Stub
@Source(Sources.RENDERER_TEMPLATES)
private FileManager sources;
-
- @Stub
- private DescriptionProcessor descriptionProcessor;
+ @Mock
+ private SourceUtils utils;
+
+ @Test
+ public void testProcessFacetsFromAnnotation() throws Exception {
+ Facet facet = createMock(Facet.class);
+ expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class), same(componentElement))).andReturn(
+ Collections.<BeanProperty> emptySet());
+ expect(annotation.facets()).andReturn(new Facet[] { facet });
+ expect(facet.name()).andReturn("foo");
+ expect(facet.description()).andReturn(this.description);
+ expect(facet.generate()).andReturn(true);
+ // expect(this.description.smallIcon()).andReturn("");
+ // expect(this.description.largeIcon()).andReturn("");
+ // expect(this.description.displayName()).andReturn("fooFacet").times(2);
+ // expect(this.description.value()).andReturn("");
+ replay(utils, componentElement, jaxb, annotation, property, facet, description);
+
+ processor.processFacets(componentElement, model, annotation);
+
+ verify(utils, componentElement, jaxb, annotation, property, facet, description);
+ assertEquals(1, model.getFacets().size());
+ FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
+ assertTrue(facetModel.isGenerate());
+ assertEquals("foo", facetModel.getName());
+ // assertEquals("my comment", facetModel.getDescription());
+ // assertEquals("fooFacet", facetModel.getDisplayname());
+ // assertNull(facetModel.getIcon());
+ }
+
+ @Test
+ public void testProcessFacetsFromProperty() throws Exception {
+ Facet facet = createMock(Facet.class);
+ expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class), same(componentElement))).andReturn(
+ Collections.singleton(property));
+ expect(annotation.facets()).andReturn(new Facet[0]);
+ expect(property.getAnnotation(Facet.class)).andReturn(facet);
+ expect(property.getName()).andReturn("foo");
+ expect(property.getDocComment()).andReturn("my comment").times(2);
+ expect(property.isExists()).andReturn(true);
+ expect(facet.description()).andReturn(description);
+ expect(facet.generate()).andReturn(true);
+ // expect(this.description.smallIcon()).andReturn("");
+ // expect(this.description.largeIcon()).andReturn("");
+ // expect(this.description.displayName()).andReturn("fooFacet").times(2);
+ // expect(this.description.value()).andReturn("");
+ replay(utils, componentElement, jaxb, annotation, property, facet, description);
+
+ processor.processFacets(componentElement, model, annotation);
+
+ verify(utils, componentElement, jaxb, annotation, property, facet, description);
+ assertEquals(1, model.getFacets().size());
+ FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
+ assertTrue(facetModel.isGenerate());
+ assertEquals("foo", facetModel.getName());
+ // assertEquals("my comment", facetModel.getDescription());
+ // assertEquals("fooFacet", facetModel.getDisplayname());
+ // assertNull(facetModel.getIcon());
+ }
+
/**
* Test method for
* {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)} .
*
* @throws Exception
*/
- @Test
+ @Test
public void testSetClassNames() throws Exception {
- expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>emptySet());
+ expect(componentElement.getModifiers()).andReturn(Collections.<Modifier> emptySet());
expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
replay(utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model,"");
- verify(utils, componentElement, jaxb,annotation );
+ processor.setClassNames(componentElement, model, "");
+ verify(utils, componentElement, jaxb, annotation);
assertFalse(model.isGenerate());
assertEquals(FOO_BAR, model.getBaseClass().toString());
assertNull(model.getTargetClass());
@@ -137,57 +189,59 @@
*
* @throws Exception
*/
- @Test
+ @Test
public void testSetClassNames1() throws Exception {
- expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>singleton(Modifier.ABSTRACT));
+ expect(componentElement.getModifiers()).andReturn(Collections.<Modifier> singleton(Modifier.ABSTRACT));
expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
replay(utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model,"");
+ processor.setClassNames(componentElement, model, "");
- verify(utils, componentElement, jaxb,annotation );
+ verify(utils, componentElement, jaxb, annotation);
assertTrue(model.isGenerate());
assertEquals(FOO_BAR, model.getBaseClass().toString());
assertNull(model.getTargetClass());
}
+
/**
* Test method for
* {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)} .
*
* @throws Exception
*/
- @Test
+ @Test
public void testSetClassNames2() throws Exception {
- expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>emptySet());
+ expect(componentElement.getModifiers()).andReturn(Collections.<Modifier> emptySet());
expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
replay(utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model,FOO_HTML_BAR);
+ processor.setClassNames(componentElement, model, FOO_HTML_BAR);
- verify(utils, componentElement, jaxb,annotation );
+ verify(utils, componentElement, jaxb, annotation);
assertTrue(model.isGenerate());
assertEquals(FOO_BAR, model.getBaseClass().toString());
- assertEquals(FOO_HTML_BAR,model.getTargetClass().toString());
+ assertEquals(FOO_HTML_BAR, model.getTargetClass().toString());
}
@Test
public void testSetFamily() throws Exception {
replay(utils, componentElement, jaxb, annotation);
- processor.setComponeneFamily(componentElement, model,FOO_HTML_BAR);
+ processor.setComponeneFamily(componentElement, model, FOO_HTML_BAR);
- verify(utils, componentElement, jaxb,annotation );
+ verify(utils, componentElement, jaxb, annotation);
assertEquals(FOO_HTML_BAR, model.getFamily());
}
-
+
@Test
public void testSetFamily1() throws Exception {
- expect(utils.getConstant(same(componentElement), eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(FOO_HTML_BAR);
+ expect(utils.getConstant(same(componentElement), eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(
+ FOO_HTML_BAR);
replay(utils, componentElement, jaxb, annotation);
- processor.setComponeneFamily(componentElement, model,"");
+ processor.setComponeneFamily(componentElement, model, "");
- verify(utils, componentElement, jaxb,annotation );
+ verify(utils, componentElement, jaxb, annotation);
assertEquals(FOO_HTML_BAR, model.getFamily());
}
@@ -196,69 +250,12 @@
expect(utils.getConstant(same(componentElement), eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(null);
replay(utils, componentElement, jaxb, annotation);
- processor.setComponeneFamily(componentElement, model,"");
+ processor.setComponeneFamily(componentElement, model, "");
- verify(utils, componentElement, jaxb,annotation );
- assertNull( model.getFamily());
+ verify(utils, componentElement, jaxb, annotation);
+ assertNull(model.getFamily());
}
-
-
- @Test
- public void testProcessFacetsFromProperty() throws Exception {
- Facet facet = createMock(Facet.class);
- expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class),same(componentElement))).andReturn(Collections.singleton(property));
- expect(annotation.facets()).andReturn(new Facet[0]);
- expect(property.getAnnotation(Facet.class)).andReturn(facet);
- expect(property.getName()).andReturn("foo");
- expect(property.getDocComment()).andReturn("my comment").times(2);
- expect(property.isExists()).andReturn(true);
- expect(facet.description()).andReturn(description);
- expect(facet.generate()).andReturn(true);
-// expect(this.description.smallIcon()).andReturn("");
-// expect(this.description.largeIcon()).andReturn("");
-// expect(this.description.displayName()).andReturn("fooFacet").times(2);
-// expect(this.description.value()).andReturn("");
- replay(utils, componentElement, jaxb, annotation,property,facet,description);
-
- processor.processFacets(componentElement, model, annotation);
-
- verify(utils, componentElement, jaxb,annotation,property,facet,description);
- assertEquals(1, model.getFacets().size());
- FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
- assertTrue(facetModel.isGenerate());
- assertEquals("foo", facetModel.getName());
-// assertEquals("my comment", facetModel.getDescription());
-// assertEquals("fooFacet", facetModel.getDisplayname());
-// assertNull(facetModel.getIcon());
- }
- @Test
- public void testProcessFacetsFromAnnotation() throws Exception {
- Facet facet = createMock(Facet.class);
- expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class),same(componentElement))).andReturn(Collections.<BeanProperty>emptySet());
- expect(annotation.facets()).andReturn(new Facet[]{facet});
- expect(facet.name()).andReturn("foo");
- expect(facet.description()).andReturn(this.description);
- expect(facet.generate()).andReturn(true);
-// expect(this.description.smallIcon()).andReturn("");
-// expect(this.description.largeIcon()).andReturn("");
-// expect(this.description.displayName()).andReturn("fooFacet").times(2);
-// expect(this.description.value()).andReturn("");
- replay(utils, componentElement, jaxb, annotation,property,facet,description);
-
- processor.processFacets(componentElement, model, annotation);
-
- verify(utils, componentElement, jaxb,annotation,property,facet,description);
- assertEquals(1, model.getFacets().size());
- FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
- assertTrue(facetModel.isGenerate());
- assertEquals("foo", facetModel.getName());
-// assertEquals("my comment", facetModel.getDescription());
-// assertEquals("fooFacet", facetModel.getDisplayname());
-// assertNull(facetModel.getIcon());
- }
-
-
@Override
protected Iterable<String> sources() {
return Collections.singleton(COMPONENT_CLASS_JAVA);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -21,20 +21,21 @@
package org.richfaces.cdk.apt.processors;
-import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+import java.util.Collections;
+
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
-import java.util.Collection;
-import java.util.Collections;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
/**
* @author akolonitsky
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -24,7 +24,6 @@
package org.richfaces.cdk.apt.processors;
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
import java.util.Collections;
@@ -39,41 +38,48 @@
import com.google.inject.Inject;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
@RunWith(CdkTestRunner.class)
public class DescriptionProcessorTest extends AnnotationProcessorTest {
+ private static final String FOO_BAR_ELEMENT = "Foo bar element";
+
private static final String FOO_FACET = "fooFacet";
- private static final String FOO_BAR_ELEMENT = "Foo bar element";
+ @Mock
+ private DescriptionGroup bean;
+ @Mock
+ private Description description;
+
@Inject
+ private DescriptionProcessorImpl descriptionProcessor;
+
+ @Inject
private MockController mockController;
- @Inject
- private DescriptionProcessorImpl descriptionProcessor;
-
- @Mock
- private Description description;
-
- @Mock
- private DescriptionGroup bean;
/**
- * Test method for {@link org.richfaces.cdk.apt.processors.DescriptionProcessorImpl#processDescription(org.richfaces.cdk.model.DescriptionGroup, org.richfaces.cdk.annotations.Description, java.lang.String)}.
+ * Test method for
+ * {@link org.richfaces.cdk.apt.processors.DescriptionProcessorImpl#processDescription(org.richfaces.cdk.model.DescriptionGroup, org.richfaces.cdk.annotations.Description, java.lang.String)}
+ * .
*/
@Test
public void testProcessDescription() {
- bean.setDescription(FOO_BAR_ELEMENT);expectLastCall();
- bean.setDisplayname(FOO_FACET);expectLastCall();
- expect(this.description.smallIcon()).andReturn("");
- expect(this.description.largeIcon()).andReturn("");
- expect(this.description.displayName()).andReturn(FOO_FACET).times(2);
- expect(this.description.value()).andReturn("");
+ bean.setDescription(FOO_BAR_ELEMENT);
+ expectLastCall();
+ bean.setDisplayname(FOO_FACET);
+ expectLastCall();
+ expect(this.description.smallIcon()).andReturn("");
+ expect(this.description.largeIcon()).andReturn("");
+ expect(this.description.displayName()).andReturn(FOO_FACET).times(2);
+ expect(this.description.value()).andReturn("");
mockController.replay();
- descriptionProcessor.processDescription(bean, description,FOO_BAR_ELEMENT);
+ descriptionProcessor.processDescription(bean, description, FOO_BAR_ELEMENT);
mockController.verify();
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -21,28 +21,29 @@
package org.richfaces.cdk.apt.processors;
-import com.google.inject.Inject;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+
import org.easymock.EasyMock;
import org.junit.Assert;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
import org.richfaces.cdk.annotations.JsfValidator;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.ValidatorModel;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import com.google.inject.Inject;
/**
* @author akolonitsky
@@ -50,15 +51,43 @@
*/
@RunWith(CdkTestRunner.class)
public class ValidatorProcessorTest extends AnnotationProcessorTest {
+ private static class MyName implements Name {
+ private final String toString;
+
+ MyName(String toString) {
+ this.toString = toString;
+ }
+
+ @Override
+ public char charAt(int index) {
+ return 0;
+ }
+
+ @Override
+ public boolean contentEquals(CharSequence cs) {
+ return false;
+ }
+
+ @Override
+ public int length() {
+ return 0;
+ }
+
+ @Override
+ public CharSequence subSequence(int start, int end) {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return toString;
+ }
+ }
private static final String VALIDATOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyValidator.java";
+
@Inject
private ComponentLibrary library;
- @Override
- protected Iterable<String> sources() {
- return Collections.singleton(VALIDATOR_CLASS_JAVA);
- }
-
@Test
@Ignore
public void testProcess() throws Exception {
@@ -68,7 +97,7 @@
for (ValidatorModel model : validators) {
FacesId id = model.getId();
- if (id != null ) {
+ if (id != null) {
assertEquals("my_validator", id.toString());
}
}
@@ -76,7 +105,6 @@
// TODO create Test for ProcessorBase
@Test
-
public void testSetNames() {
ValidatorModel model;
@@ -98,37 +126,41 @@
// /////////////////////////////// ABSTRACT ///////////////////////////////////////
// @JsfValidator public abstract class BaseClass { ...
-// checkAbstractWithException(null);
+ // checkAbstractWithException(null);
// @JsfValidator(validatorClass = "") public abstract class BaseClass { ...
-// checkAbstractWithException("");
+ // checkAbstractWithException("");
// @JsfValidator(validatorClass = BaseClass) public abstract class BaseClass { ...
-// checkAbstractWithException("BaseClass");
+ // checkAbstractWithException("BaseClass");
// @JsfValidator(validatorClass = GeneratedClass) public abstract class BaseClass { ...
model = getValidatorModelForSetNames(true, "GeneratedClass", "BaseClass", true);
check("GeneratedClass", "BaseClass", true, model);
}
- private void checkAbstractWithException(String validatorClass) {
- try {
- getValidatorModelForSetNames(true, validatorClass, "BaseClass", true);
- Assert.fail("Abstract class can't be a validator.");
- } catch (IllegalStateException e) {
- // Do nothing.
- }
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(VALIDATOR_CLASS_JAVA);
}
private void check(String validatorClass, String baseClass, boolean generate, ValidatorModel model) {
if (baseClass != null) {
-// assertEquals(model.getBaseClass().toString(), baseClass);
+ // assertEquals(model.getBaseClass().toString(), baseClass);
} else {
assertNull(model.getBaseClass());
}
+ // assertEquals(generate, model.isGenerate());
+ }
-// assertEquals(generate, model.isGenerate());
+ private void checkAbstractWithException(String validatorClass) {
+ try {
+ getValidatorModelForSetNames(true, validatorClass, "BaseClass", true);
+ Assert.fail("Abstract class can't be a validator.");
+ } catch (IllegalStateException e) {
+ // Do nothing.
+ }
}
private ValidatorModel getValidatorModelForSetNames(boolean isAnnotationDefined, String validatorClass,
@@ -154,40 +186,7 @@
}
EasyMock.verify();
-// ValidatorProcessor.setClassNames(element, validatorModel, validator);
+ // ValidatorProcessor.setClassNames(element, validatorModel, validator);
return validatorModel;
}
-
- private static class MyName implements Name {
- private final String toString;
-
- MyName(String toString) {
- this.toString = toString;
- }
-
- @Override
- public int length() {
- return 0;
- }
-
- @Override
- public char charAt(int index) {
- return 0;
- }
-
- @Override
- public CharSequence subSequence(int start, int end) {
- return null;
- }
-
- @Override
- public String toString() {
- return toString;
- }
-
- @Override
- public boolean contentEquals(CharSequence cs) {
- return false;
- }
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -58,44 +58,31 @@
public abstract class AbstractClassGeneratorTest extends CdkTestBase {
@Inject
- protected ComponentLibrary library;
-
- @Inject
@As(CdkConfiguration.class)
protected Configuration configuration;
@Inject
- @As(LibraryModelWrapper.class)
- protected ObjectWrapper wrapper;
+ protected ComponentLibrary library;
+ @Inject
+ protected Logger log;
+
@Mock
@Output(Outputs.RESOURCES)
protected FileManager output;
@Inject
- protected Logger log;
+ @As(LibraryModelWrapper.class)
+ protected ObjectWrapper wrapper;
- protected static PropertyBase addAttribute(ModelElementBase model, String attributeName, Class<?> type, boolean generate) {
+ protected static PropertyBase addAttribute(ModelElementBase model, String attributeName, Class<?> type,
+ boolean generate) {
PropertyBase attribute = model.getOrCreateAttribute(attributeName);
attribute.setType(new ClassName(type));
attribute.setGenerate(generate);
return attribute;
}
- protected static EventName getEvent(String name, boolean defaultEvent) {
- EventName event = new EventName();
- event.setName(name);
- event.setDefaultEvent(defaultEvent);
- return event;
- }
-
- protected void compare(StringWriter writer, String fileName) throws IOException {
- InputStream expectedFacesConfigFile = this.getClass().getResourceAsStream(fileName);
- Assert.assertNotNull("File (" + fileName + ") with expected result wasn't found.", expectedFacesConfigFile);
-
- compareTextFiles(new StringReader(writer.toString()), new InputStreamReader(expectedFacesConfigFile));
- }
-
protected static void compareTextFiles(Reader reference, Reader output) throws IOException {
LineNumberReader ref = new LineNumberReader(reference);
LineNumberReader out = new LineNumberReader(output);
@@ -118,4 +105,18 @@
}
}
}
+
+ protected static EventName getEvent(String name, boolean defaultEvent) {
+ EventName event = new EventName();
+ event.setName(name);
+ event.setDefaultEvent(defaultEvent);
+ return event;
+ }
+
+ protected void compare(StringWriter writer, String fileName) throws IOException {
+ InputStream expectedFacesConfigFile = this.getClass().getResourceAsStream(fileName);
+ Assert.assertNotNull("File (" + fileName + ") with expected result wasn't found.", expectedFacesConfigFile);
+
+ compareTextFiles(new StringReader(writer.toString()), new InputStreamReader(expectedFacesConfigFile));
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -22,12 +22,11 @@
package org.richfaces.cdk.generate.java;
-import com.google.inject.Inject;
-import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.*;
+
+import java.io.StringWriter;
+import java.util.Set;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
@@ -38,8 +37,7 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.PropertyBase;
-import java.io.StringWriter;
-import java.util.Set;
+import com.google.inject.Inject;
/**
* @author akolonitsky
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -28,8 +28,6 @@
import japa.parser.JavaParser;
import japa.parser.ast.CompilationUnit;
import japa.parser.ast.body.MethodDeclaration;
-import japa.parser.ast.visitor.GenericVisitorAdapter;
-import japa.parser.ast.visitor.VoidVisitor;
import japa.parser.ast.visitor.VoidVisitorAdapter;
import java.io.ByteArrayInputStream;
@@ -67,9 +65,10 @@
private final class VoidVisitorAdapterExtension extends VoidVisitorAdapter<String> {
private boolean found = false;
+ @Override
public void visit(MethodDeclaration n, String arg) {
- if(arg.equals(n.getName())){
- this.found =true;
+ if (arg.equals(n.getName())) {
+ this.found = true;
}
}
}
@@ -77,39 +76,6 @@
@Inject
private ComponentClassGenerator generator;
- @Test
- public void testGetOutputFileComponent() throws Exception {
- final StringWriter outputWriter = new StringWriter();
- expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
- replay(output);
-
- ComponentModel component = createComponent();
-
- library.getComponents().add(component);
-
- generator.generate(component);
- log.debug(outputWriter.toString());
-
- verify(output);
-
-// TODO - any change in the template breaks test, make comperison more intellectual ?
- ByteArrayInputStream inputStream = new ByteArrayInputStream(outputWriter.toString().getBytes());
- CompilationUnit compilationUnit = JavaParser.parse(inputStream);
- assertNotNull(compilationUnit);
- VoidVisitorAdapterExtension visitorAdapter = new VoidVisitorAdapterExtension();
- compilationUnit.accept(visitorAdapter , "isTestFlag");
- assertTrue(visitorAdapter.found);
-// compare(outputWriter, "GeneratedComponent.java");
- }
-
- public ComponentClassGenerator getGenerator() {
- return generator;
- }
-
- public void setGenerator(ComponentClassGenerator generator) {
- this.generator = generator;
- }
-
public static ComponentModel createComponent() {
ComponentModel component = new ComponentModel(FacesId.parseId("foo.bar"));
component.setGenerate(true);
@@ -157,7 +123,40 @@
Set<EventName> eventNames = attribute.getEventNames();
eventNames.add(getEvent("id", false));
eventNames.add(getEvent("action", true));
-
+
return component;
}
+
+ public ComponentClassGenerator getGenerator() {
+ return generator;
+ }
+
+ public void setGenerator(ComponentClassGenerator generator) {
+ this.generator = generator;
+ }
+
+ @Test
+ public void testGetOutputFileComponent() throws Exception {
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
+
+ ComponentModel component = createComponent();
+
+ library.getComponents().add(component);
+
+ generator.generate(component);
+ log.debug(outputWriter.toString());
+
+ verify(output);
+
+ // TODO - any change in the template breaks test, make comperison more intellectual ?
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(outputWriter.toString().getBytes());
+ CompilationUnit compilationUnit = JavaParser.parse(inputStream);
+ assertNotNull(compilationUnit);
+ VoidVisitorAdapterExtension visitorAdapter = new VoidVisitorAdapterExtension();
+ compilationUnit.accept(visitorAdapter, "isTestFlag");
+ assertTrue(visitorAdapter.found);
+ // compare(outputWriter, "GeneratedComponent.java");
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -22,12 +22,11 @@
package org.richfaces.cdk.generate.java;
-import com.google.inject.Inject;
-import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.*;
+
+import java.io.StringWriter;
+import java.util.Set;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
@@ -38,8 +37,7 @@
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.FacesId;
-import java.io.StringWriter;
-import java.util.Set;
+import com.google.inject.Inject;
/**
* @author akolonitsky
@@ -80,8 +78,7 @@
log.debug(outputWriter.toString());
verify(output);
// TODO - use source code parser to analyze generated class
-// compare(outputWriter, "GeneratedConverter.java");
+ // compare(outputWriter, "GeneratedConverter.java");
}
-
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -22,12 +22,12 @@
package org.richfaces.cdk.generate.java;
-import com.google.inject.Inject;
-import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.*;
+
+import java.io.StringWriter;
+
+import javax.faces.view.facelets.ComponentHandler;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
@@ -37,8 +37,7 @@
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.TagModel;
-import javax.faces.view.facelets.ComponentHandler;
-import java.io.StringWriter;
+import com.google.inject.Inject;
/**
* @author akolonitsky
@@ -48,11 +47,19 @@
public class TagHandlerClassGeneratorTest extends AbstractClassGeneratorTest {
@Inject
- private Logger log;
-
- @Inject
private TagHandlerClassGenerator generator;
+ @Inject
+ private Logger log;
+
+ public TagHandlerClassGenerator getGenerator() {
+ return generator;
+ }
+
+ public void setGenerator(TagHandlerClassGenerator generator) {
+ this.generator = generator;
+ }
+
@Test
public void testGetOutputFileBehavior() throws Exception {
final StringWriter outputWriter = new StringWriter();
@@ -62,25 +69,16 @@
ComponentModel model = ComponentClassGeneratorTest.createComponent();
library.getComponents().add(model);
-
TagModel tagModel = new TagModel();
tagModel.setName("mytag");
tagModel.setTargetClass(ClassName.parseName("org.richfaces.cdk.generate.java.GeneratedTagHandler"));
tagModel.setBaseClass(ClassName.parseName(ComponentHandler.class.getName()));
-
- generator.process(model,tagModel);
+ generator.process(model, tagModel);
+
log.debug(outputWriter.toString());
verify(output);
compare(outputWriter, "GeneratedTagHandler.java");
}
-
- public TagHandlerClassGenerator getGenerator() {
- return generator;
- }
-
- public void setGenerator(TagHandlerClassGenerator generator) {
- this.generator = generator;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -22,12 +22,11 @@
package org.richfaces.cdk.generate.java;
-import com.google.inject.Inject;
-import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.*;
+
+import java.io.StringWriter;
+import java.util.Set;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
@@ -38,8 +37,7 @@
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.ValidatorModel;
-import java.io.StringWriter;
-import java.util.Set;
+import com.google.inject.Inject;
/**
* @author akolonitsky
@@ -80,7 +78,7 @@
verify(output);
// TODO - use source code parser to analyze generated class
-// compare(outputWriter, "GeneratedValidator.java");
+ // compare(outputWriter, "GeneratedValidator.java");
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -23,15 +23,16 @@
package org.richfaces.cdk.model;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import java.util.Arrays;
-import java.util.Collection;
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -46,6 +47,7 @@
private final String expectedCanonicalName;
private final String expectedTypeParameter;
private final String packageName;
+
private final String simpleName;
public ClassDescriptionTest(String className, String expectedCanonicalName, String expectedBoxedName,
@@ -58,6 +60,13 @@
this.simpleName = simpleName;
}
+ @Parameters
+ public static Collection<String[]> values() {
+ return Arrays.asList(new String[] { int.class.getName(), "int", "java.lang.Integer", null, null, "int" },
+ new String[] { "java.util.List<String>", "java.util.List", "java.util.List<String>", "<String>","java.util", "List" },
+ new String[] { double.class.getName(), "double", "java.lang.Double", null, null,"double" });
+ }
+
/**
* Test method for {@link ClassName#ClassName(java.lang.String)}.
*/
@@ -72,12 +81,4 @@
assertEquals(packageName, description.getPackage());
assertEquals(simpleName, description.getSimpleName());
}
-
- @Parameters
- public static Collection<String[]> values() {
- return Arrays.asList(new String[] { int.class.getName(), "int", "java.lang.Integer", null, null, "int" },
- new String[] { "java.util.List<String>", "java.util.List", "java.util.List<String>", "<String>",
- "java.util", "List" }, new String[] { double.class.getName(), "double", "java.lang.Double", null, null,
- "double" });
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -32,19 +32,27 @@
*/
public class ModelBean implements ModelElement<ModelBean> {
+ public static final class Type extends FacesId {
+ private static final long serialVersionUID = 6227413669285563473L;
+
+ public Type(String type) {
+ super(type);
+ }
+ }
/**
* <p class="changed_added_4_0">
* </p>
*/
private static final long serialVersionUID = -4853397197172488116L;
String readOnly;
+
String writeOnly;
-
- private boolean vizited = false;
private String doNotReplace;
private Object result;
private Type type;
+ private boolean vizited = false;
+
public ModelBean() {
}
@@ -52,136 +60,128 @@
this.type = new Type(name);
}
+ public <R, D> R accept(Visitor<R, D> visitor, D data) {
+ vizited = true;
+
+ return visitor.visit(this, data);
+ }
+
/**
* <p class="changed_added_4_0">
* </p>
*
- * @return the type
+ * @return the doNotReplace
*/
- public Type getType() {
- return this.type;
+ @Merge(false)
+ public String getDoNotReplace() {
+ return doNotReplace;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param type
- * the type to set
+ * @return the readOnly
*/
- public void setType(Type type) {
- this.type = type;
+ @Merge
+ public String getReadOnly() {
+ return readOnly;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @return the vizited
+ * @return the result
*/
@Merge
- public boolean isVizited() {
- return vizited;
+ public Object getResult() {
+ return result;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param vizited
- * the vizited to set
+ * @return the type
*/
- public void setVizited(boolean vizited) {
- this.vizited = vizited;
+ public Type getType() {
+ return this.type;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @return the result
+ * @return the vizited
*/
@Merge
- public Object getResult() {
- return result;
+ public boolean isVizited() {
+ return vizited;
}
+ @Override
+ public void merge(ModelBean other) {
+ ComponentLibrary.merge(this, other);
+ }
+
+ @Override
+ public boolean same(ModelBean other) {
+ return null != getType() && getType().equals(other.getType());
+ }
+
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param result
- * the result to set
+ * @param doNotReplace
+ * the doNotReplace to set
*/
- public void setResult(Object result) {
- this.result = result;
+ public void setDoNotReplace(String doNotReplace) {
+ this.doNotReplace = doNotReplace;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @return the readOnly
+ * @param result
+ * the result to set
*/
- @Merge
- public String getReadOnly() {
- return readOnly;
+ public void setResult(Object result) {
+ this.result = result;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param writeOnly
- * the writeOnly to set
+ * @param type
+ * the type to set
*/
- public void setWriteOnly(String writeOnly) {
- this.writeOnly = writeOnly;
+ public void setType(Type type) {
+ this.type = type;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @return the doNotReplace
+ * @param vizited
+ * the vizited to set
*/
- @Merge(false)
- public String getDoNotReplace() {
- return doNotReplace;
+ public void setVizited(boolean vizited) {
+ this.vizited = vizited;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param doNotReplace
- * the doNotReplace to set
+ * @param writeOnly
+ * the writeOnly to set
*/
- public void setDoNotReplace(String doNotReplace) {
- this.doNotReplace = doNotReplace;
+ public void setWriteOnly(String writeOnly) {
+ this.writeOnly = writeOnly;
}
-
- @Override
- public void merge(ModelBean other) {
- ComponentLibrary.merge(this, other);
- }
-
- public <R,D> R accept(Visitor<R,D> visitor, D data) {
- vizited = true;
-
- return visitor.visit(this,data);
- }
-
- @Override
- public boolean same(ModelBean other) {
- return null != getType() && getType().equals(other.getType());
- }
-
- public static final class Type extends FacesId {
- private static final long serialVersionUID = 6227413669285563473L;
-
- public Type(String type) {
- super(type);
- }
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/NameTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -23,9 +23,9 @@
package org.richfaces.cdk.model;
+import static org.junit.Assert.*;
+
import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
import org.junit.Before;
import org.junit.Test;
@@ -164,21 +164,21 @@
}
/**
- * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String, java.lang.String)}.
+ * Test method for
+ * {@link org.richfaces.cdk.model.Name#create(java.lang.String, org.richfaces.cdk.model.Name.Classifier, java.lang.String)}
+ * .
*/
@Test
- public void testCreateStringString() {
+ public void testCreateStringClassifierString() {
// fail("Not yet implemented");
}
/**
- * Test method for
- * {@link org.richfaces.cdk.model.Name#create(java.lang.String, org.richfaces.cdk.model.Name.Classifier, java.lang.String)}
- * .
+ * Test method for {@link org.richfaces.cdk.model.Name#create(java.lang.String, java.lang.String)}.
*/
@Test
- public void testCreateStringClassifierString() {
+ public void testCreateStringString() {
// fail("Not yet implemented");
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -18,17 +18,13 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ */
package org.richfaces.cdk.model.validator;
-import com.google.inject.Inject;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestBase;
@@ -42,38 +38,43 @@
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.FacesId;
+import com.google.inject.Inject;
+
/**
* @author asmirnov
* @version $Id$
- *
+ *
*/
@RunWith(CdkTestRunner.class)
public class ModelValidatorTest extends CdkTestBase {
@Mock
- private NamingConventions namiingConventions;
-
+ protected Logger log;
+
@Mock
SourceUtils utils;
-
- @Mock
- protected Logger log;
@Inject
+ ValidatorImpl validator;
+
+ @Inject
private ComponentLibrary library;
- @Inject
- ValidatorImpl validator;
+ @Mock
+ private NamingConventions namiingConventions;
+
/**
- * Test method for {@link org.richfaces.cdk.model.validator.ValidatorImpl#verifyComponent(org.richfaces.cdk.model.ComponentModel)}.
+ * Test method for
+ * {@link org.richfaces.cdk.model.validator.ValidatorImpl#verifyComponent(org.richfaces.cdk.model.ComponentModel)}.
*/
@Test
public void testVerifyEmptyComponent() {
ComponentModel component = new ComponentModel();
- log.error((CharSequence) anyObject());expectLastCall();
- replay(log,utils,namiingConventions);
+ log.error((CharSequence) anyObject());
+ expectLastCall();
+ replay(log, utils, namiingConventions);
validator.verifyComponentType(component);
- verify(log,utils,namiingConventions);
+ verify(log, utils, namiingConventions);
}
@Test
@@ -84,10 +85,10 @@
component.setTargetClass(className);
expect(namiingConventions.inferComponentType(className)).andReturn(type);
expect(namiingConventions.inferUIComponentFamily(type)).andReturn("foo.baz");
- replay(log,utils,namiingConventions);
+ replay(log, utils, namiingConventions);
// Validator should set component type from base class.
validator.verifyComponentType(component);
- verify(log,utils,namiingConventions);
+ verify(log, utils, namiingConventions);
assertEquals(type, component.getType());
assertEquals("foo.baz", component.getFamily());
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -68,14 +68,14 @@
public class RendererTemplateParserTest extends CdkTestBase {
@Inject
- private RendererTemplateParser parser;
+ @As(JAXBBinding.class)
+ private JAXB binding;
@Inject
private ComponentLibrary library;
@Inject
- @As(JAXBBinding.class)
- private JAXB binding;
+ private RendererTemplateParser parser;
@Mock
private EntityResolver2 resolver;
@@ -84,24 +84,14 @@
@Source(Sources.RENDERER_TEMPLATES)
private FileManager templatesSource;
- private RenderKitModel getRenderkitFromModel(String renderkitId) {
- RenderKitModel renderKit = library.getRenderKit(new FacesId(renderkitId));
- assertNotNull(renderKit);
-
- return renderKit;
+ private void assertNoDefaultValue(PropertyBase property) {
+ assertNull(property.getDefaultValue());
}
- private RendererModel getFirstRendererFromRenderkit(RenderKitModel renderKit) {
- Collection<RendererModel> renderers = renderKit.getRenderers();
- assertNotNull(renderers);
-
- Iterator<RendererModel> renderersIterator = renderers.iterator();
- assertTrue(renderersIterator.hasNext());
-
- RendererModel renderer = renderersIterator.next();
- assertNotNull(renderer);
-
- return renderer;
+ private void assertNoEventNames(PropertyBase property) {
+ Set<EventName> eventNames = property.getEventNames();
+ assertNotNull(eventNames);
+ assertTrue(eventNames.isEmpty());
}
private void assertNoSignature(PropertyBase property) {
@@ -110,21 +100,89 @@
assertTrue(signature.isEmpty());
}
- private void assertNoEventNames(PropertyBase property) {
- Set<EventName> eventNames = property.getEventNames();
- assertNotNull(eventNames);
- assertTrue(eventNames.isEmpty());
+ private void assertNotRequired(PropertyBase property) {
+ assertFalse(property.isRequired());
}
- private void assertNoDefaultValue(PropertyBase property) {
- assertNull(property.getDefaultValue());
+ @Test
+ public void basicComponentTest() throws Exception {
+ Template template = parser.parseTemplate(getJavaFile("org/richfaces/cdk/templatecompiler/basic.template.xml"));
+ assertNotNull(template);
+
+ parser.mergeTemplateIntoModel(template, null);
+
+ RenderKitModel renderKit = getRenderkitFromModel(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ RendererModel renderer = getFirstRendererFromRenderkit(renderKit);
+
+ assertEquals(new ClassName("org.richfaces.renderkit.html.BasicRendererImpl"), renderer.getRendererClass());
+ assertFalse(renderer.isRendersChildren());
}
- private void assertNotRequired(PropertyBase property) {
- assertFalse(property.isRequired());
+ /**
+ * Checks that method signature satisfies the following declaration: <code>java.lang.String action()</code>
+ *
+ * @param actionProperty
+ */
+ private void checkDummyComponentAction(PropertyBase actionProperty) {
+ assertNotNull(actionProperty);
+ assertNoEventNames(actionProperty);
+
+ assertEquals(Lists.newArrayList(), actionProperty.getSignature());
}
/**
+ * Checks that method signature satisfies the following declaration:
+ * <code>void actionListener(javax.faces.event.ActionEvent)</code>
+ *
+ * @param actionListenerProperty
+ */
+ private void checkDummyComponentActionListener(PropertyBase actionListenerProperty) {
+ assertNotNull(actionListenerProperty);
+ assertNoEventNames(actionListenerProperty);
+
+ assertEquals(Lists.newArrayList(new ClassName(ActionEvent.class)), actionListenerProperty.getSignature());
+ }
+
+ /**
+ * Checks that method signature satisfies the following declaration:
+ * <code>float coolMethod(int, java.lang.String, javax.faces.validator.Validator)</code>
+ *
+ * @param coolMethodProperty
+ */
+ private void checkDummyComponentCoolMethod(PropertyBase coolMethodProperty) {
+ assertNotNull(coolMethodProperty);
+ assertNoEventNames(coolMethodProperty);
+
+ ArrayList<ClassName> expectedSignature =
+ Lists.newArrayList(new ClassName(int.class), new ClassName(String.class), new ClassName(Validator.class));
+
+ assertEquals(expectedSignature, coolMethodProperty.getSignature());
+ }
+
+ private void checkDummyComponentImportedAttribute(PropertyBase importedAttribute, Class<?> type) {
+ assertNotNull(importedAttribute);
+ assertNoEventNames(importedAttribute);
+ assertNoSignature(importedAttribute);
+ assertNoDefaultValue(importedAttribute);
+ assertFalse(importedAttribute.isRequired());
+
+ assertEquals(type.getName(), importedAttribute.getType().getName());
+ }
+
+ /**
+ * @param integerAttribute
+ */
+ private void checkDummyComponentIntegerAttribute(PropertyBase integerAttribute) {
+ assertNotNull(integerAttribute);
+ assertNoEventNames(integerAttribute);
+ assertNoSignature(integerAttribute);
+ assertNotRequired(integerAttribute);
+
+ assertEquals(new ClassName(Integer.class), integerAttribute.getType());
+ assertEquals("-1", integerAttribute.getDefaultValue());
+ }
+
+ /**
* Checks the following conditions for attribute:<br />
* - signature is empty<br />
* - There's a single "change" event name that is not a default event<br />
@@ -183,61 +241,6 @@
}
/**
- * Checks that method signature satisfies the following declaration: <code>java.lang.String action()</code>
- *
- * @param actionProperty
- */
- private void checkDummyComponentAction(PropertyBase actionProperty) {
- assertNotNull(actionProperty);
- assertNoEventNames(actionProperty);
-
- assertEquals(Lists.newArrayList(), actionProperty.getSignature());
- }
-
- /**
- * Checks that method signature satisfies the following declaration:
- * <code>void actionListener(javax.faces.event.ActionEvent)</code>
- *
- * @param actionListenerProperty
- */
- private void checkDummyComponentActionListener(PropertyBase actionListenerProperty) {
- assertNotNull(actionListenerProperty);
- assertNoEventNames(actionListenerProperty);
-
- assertEquals(Lists.newArrayList(new ClassName(ActionEvent.class)), actionListenerProperty.getSignature());
- }
-
- /**
- * Checks that method signature satisfies the following declaration:
- * <code>float coolMethod(int, java.lang.String, javax.faces.validator.Validator)</code>
- *
- * @param coolMethodProperty
- */
- private void checkDummyComponentCoolMethod(PropertyBase coolMethodProperty) {
- assertNotNull(coolMethodProperty);
- assertNoEventNames(coolMethodProperty);
-
- ArrayList<ClassName> expectedSignature =
- Lists.newArrayList(new ClassName(int.class), new ClassName(String.class),
- new ClassName(Validator.class));
-
- assertEquals(expectedSignature, coolMethodProperty.getSignature());
- }
-
- /**
- * @param integerAttribute
- */
- private void checkDummyComponentIntegerAttribute(PropertyBase integerAttribute) {
- assertNotNull(integerAttribute);
- assertNoEventNames(integerAttribute);
- assertNoSignature(integerAttribute);
- assertNotRequired(integerAttribute);
-
- assertEquals(new ClassName(Integer.class), integerAttribute.getType());
- assertEquals("-1", integerAttribute.getDefaultValue());
- }
-
- /**
* @param requiredAttribute
*/
private void checkDummyComponentRequiredAttribute(PropertyBase requiredAttribute) {
@@ -251,40 +254,19 @@
assertEquals("Required Attribute", requiredAttribute.getDisplayname());
}
- private void checkDummyComponentImportedAttribute(PropertyBase importedAttribute, Class<?> type) {
- assertNotNull(importedAttribute);
- assertNoEventNames(importedAttribute);
- assertNoSignature(importedAttribute);
- assertNoDefaultValue(importedAttribute);
- assertFalse(importedAttribute.isRequired());
-
- assertEquals(type.getName(), importedAttribute.getType().getName());
- }
-
@Test
- public void basicComponentTest() throws Exception {
- Template template = parser.parseTemplate(getJavaFile("org/richfaces/cdk/templatecompiler/basic.template.xml"));
- assertNotNull(template);
-
- parser.mergeTemplateIntoModel(template, null);
-
- RenderKitModel renderKit = getRenderkitFromModel(RenderKitFactory.HTML_BASIC_RENDER_KIT);
- RendererModel renderer = getFirstRendererFromRenderkit(renderKit);
-
- assertEquals(new ClassName("org.richfaces.renderkit.html.BasicRendererImpl"), renderer
- .getRendererClass());
- assertFalse(renderer.isRendersChildren());
- }
-
- @Test
-
// TODO - fix import-attributes.
public void dummyComponentTest() throws Exception {
- expect(resolver.getExternalSubset(EasyMock.<String> eq("cdk:root"), (String)anyObject())).andReturn(null);
- expect(resolver.resolveEntity((String)isNull(), (String)eq("urn:resource:org/richfaces/cdk/templatecompiler/dummy-attributes.xml"))).andReturn(new InputSource(this.getClass().getResourceAsStream("/org/richfaces/cdk/templatecompiler/dummy-attributes.xml")));
- expect(resolver.getExternalSubset(EasyMock.<String> eq("cdk:properties"), (String)isNull())).andReturn(null);
- expect(resolver.resolveEntity((String)isNull(), (String)eq("urn:attributes:dummy-template-props.xml"))).andReturn(new InputSource(this.getClass().getResourceAsStream("/META-INF/cdk/attributes/dummy-template-props.xml")));
- expect(resolver.getExternalSubset(EasyMock.<String>eq("cdk:properties"), (String)isNull())).andReturn(null);
+ expect(resolver.getExternalSubset(EasyMock.<String> eq("cdk:root"), (String) anyObject())).andReturn(null);
+ expect(
+ resolver.resolveEntity((String) isNull(),
+ eq("urn:resource:org/richfaces/cdk/templatecompiler/dummy-attributes.xml"))).andReturn(
+ new InputSource(this.getClass().getResourceAsStream(
+ "/org/richfaces/cdk/templatecompiler/dummy-attributes.xml")));
+ expect(resolver.getExternalSubset(EasyMock.<String> eq("cdk:properties"), (String) isNull())).andReturn(null);
+ expect(resolver.resolveEntity((String) isNull(), eq("urn:attributes:dummy-template-props.xml"))).andReturn(
+ new InputSource(this.getClass().getResourceAsStream("/META-INF/cdk/attributes/dummy-template-props.xml")));
+ expect(resolver.getExternalSubset(EasyMock.<String> eq("cdk:properties"), (String) isNull())).andReturn(null);
replay(resolver, templatesSource);
Template template = parser.parseTemplate(getJavaFile("org/richfaces/cdk/templatecompiler/dummy.template.xml"));
@@ -296,8 +278,7 @@
RenderKitModel renderKit = getRenderkitFromModel("org.richfaces.CUSTOM_RENDERKIT");
RendererModel renderer = getFirstRendererFromRenderkit(renderKit);
- assertEquals(new ClassName("org.richfaces.renderkit.html.DummyRendererImpl"), renderer
- .getRendererClass());
+ assertEquals(new ClassName("org.richfaces.renderkit.html.DummyRendererImpl"), renderer.getRendererClass());
assertTrue(renderer.isRendersChildren());
assertEquals("org.richfaces.Dummy", renderer.getFamily());
@@ -306,29 +287,49 @@
Collection<PropertyBase> attributes = renderer.getAttributes();
assertNotNull(attributes);
- checkDummyComponentOnclick(getAttribute(attributes,"onclick"));
- checkDummyComponentOnchange(getAttribute(attributes,"onchange"));
- checkDummyComponentAction(getAttribute(attributes,"action"));
- checkDummyComponentActionListener(getAttribute(attributes,"actionListener"));
- checkDummyComponentCoolMethod(getAttribute(attributes,"coolMethod"));
- checkDummyComponentIntegerAttribute(getAttribute(attributes,"integerAttribute"));
- checkDummyComponentRequiredAttribute(getAttribute(attributes,"requiredAttribute"));
+ checkDummyComponentOnclick(getAttribute(attributes, "onclick"));
+ checkDummyComponentOnchange(getAttribute(attributes, "onchange"));
+ checkDummyComponentAction(getAttribute(attributes, "action"));
+ checkDummyComponentActionListener(getAttribute(attributes, "actionListener"));
+ checkDummyComponentCoolMethod(getAttribute(attributes, "coolMethod"));
+ checkDummyComponentIntegerAttribute(getAttribute(attributes, "integerAttribute"));
+ checkDummyComponentRequiredAttribute(getAttribute(attributes, "requiredAttribute"));
- checkDummyComponentImportedAttribute(getAttribute(attributes,"anotherImportedStringProperty"), String.class);
- checkDummyComponentImportedAttribute(getAttribute(attributes,"anotherImportedProperty"), Object.class);
- checkDummyComponentImportedAttribute(getAttribute(attributes,"importedBooleanProperty"), boolean.class);
- checkDummyComponentImportedAttribute(getAttribute(attributes,"importedIntegerProperty"), Integer.class);
+ checkDummyComponentImportedAttribute(getAttribute(attributes, "anotherImportedStringProperty"), String.class);
+ checkDummyComponentImportedAttribute(getAttribute(attributes, "anotherImportedProperty"), Object.class);
+ checkDummyComponentImportedAttribute(getAttribute(attributes, "importedBooleanProperty"), boolean.class);
+ checkDummyComponentImportedAttribute(getAttribute(attributes, "importedIntegerProperty"), Integer.class);
assertEquals(11, attributes.size());
}
private PropertyBase getAttribute(Collection<PropertyBase> attributes, String string) {
for (PropertyBase property : attributes) {
- if(string.equals(property.getName())){
+ if (string.equals(property.getName())) {
return property;
}
}
return null;
}
+ private RendererModel getFirstRendererFromRenderkit(RenderKitModel renderKit) {
+ Collection<RendererModel> renderers = renderKit.getRenderers();
+ assertNotNull(renderers);
+
+ Iterator<RendererModel> renderersIterator = renderers.iterator();
+ assertTrue(renderersIterator.hasNext());
+
+ RendererModel renderer = renderersIterator.next();
+ assertNotNull(renderer);
+
+ return renderer;
+ }
+
+ private RenderKitModel getRenderkitFromModel(String renderkitId) {
+ RenderKitModel renderKit = library.getRenderKit(new FacesId(renderkitId));
+ assertNotNull(renderKit);
+
+ return renderKit;
+ }
+
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/XhtmlAttributesParsingTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/XhtmlAttributesParsingTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/XhtmlAttributesParsingTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -51,14 +51,46 @@
*/
public class XhtmlAttributesParsingTest {
- private Schema xhtmlSchema;
+ private static final class AttributeKindPredicate implements Predicate<Attribute> {
- private void verifyAttributesByPredicate(Collection<Attribute> attributes, Predicate<Attribute> predicate) {
- for (Attribute attribute : attributes) {
- Assert.assertTrue(attribute.getName(), predicate.apply(attribute));
+ private Kind kind;
+
+ public AttributeKindPredicate(Kind kind) {
+ super();
+ this.kind = kind;
}
+
+ @Override
+ public boolean apply(Attribute attribute) {
+ return kind.equals(attribute.getKind());
+ }
}
+ private static final class AttributeNamePredicate implements Predicate<Attribute> {
+
+ private String name;
+
+ public AttributeNamePredicate(String name) {
+ super();
+ this.name = name;
+ }
+
+ @Override
+ public boolean apply(Attribute attribute) {
+ return name.equals(attribute.getName());
+ }
+ }
+
+ private static final class AttributeNullDataPredicate implements Predicate<Attribute> {
+
+ @Override
+ public boolean apply(Attribute attribute) {
+ return attribute.getName() == null || attribute.getKind() == null;
+ }
+ }
+
+ private Schema xhtmlSchema;
+
private Collection<Attribute> findAttributesByPredicate(Predicate<Attribute> predicate) {
List<Attribute> result = new ArrayList<Attribute>();
@@ -86,44 +118,6 @@
return result;
}
- private static final class AttributeNullDataPredicate implements Predicate<Attribute> {
-
- @Override
- public boolean apply(Attribute attribute) {
- return attribute.getName() == null || attribute.getKind() == null;
- }
- }
-
- private static final class AttributeNamePredicate implements Predicate<Attribute> {
-
- public AttributeNamePredicate(String name) {
- super();
- this.name = name;
- }
-
- private String name;
-
- @Override
- public boolean apply(Attribute attribute) {
- return name.equals(attribute.getName());
- }
- }
-
- private static final class AttributeKindPredicate implements Predicate<Attribute> {
-
- private Kind kind;
-
- public AttributeKindPredicate(Kind kind) {
- super();
- this.kind = kind;
- }
-
- @Override
- public boolean apply(Attribute attribute) {
- return kind.equals(attribute.getKind());
- }
- }
-
@Before
public void setUp() throws Exception {
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
@@ -199,4 +193,10 @@
Collection<String> requiredAttributeNames = getNamesCollection(requiredAttributes);
System.out.println("XhtmlAttributesParsingTest.testRequiredAttributes(): " + requiredAttributeNames);
}
+
+ private void verifyAttributesByPredicate(Collection<Attribute> attributes, Predicate<Attribute> predicate) {
+ for (Attribute attribute : attributes) {
+ Assert.assertTrue(attribute.getName(), predicate.apply(attribute));
+ }
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -39,139 +39,13 @@
*/
public class TemplateTest extends JaxbTestBase {
- private static final String TEMPLATE_EPILOG = "</cc:implementation></cdk:root>";
- private static final String TEMPLATE_MIDDLE = "</cc:interface><cc:implementation>";
public static final String TEMPLATE_PROLOG =
"<cdk:root xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:cdk=\"http://richfaces.org/cdk/core\" xmlns:c=\"http://richfaces.org/cdk/jstl/core\" xmlns:cc=\"http://richfaces.org/cdk/jsf/composite\"><cc:interface>";
private static final Object DEFAULT_ATTRIBUTE_TYPE = Object.class.getName();
+ private static final String TEMPLATE_EPILOG = "</cc:implementation></cdk:root>";
+ private static final String TEMPLATE_MIDDLE = "</cc:interface><cc:implementation>";
@Test
- public void testTemplate() throws Exception {
- Template template = unmarshal(Template.class, TEMPLATE_PROLOG + TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
- assertNotNull(template.getInterface());
- assertNotNull(template.getImplementation());
- }
-
- @Test
- public void testImpl() throws Exception {
- Template template =
- unmarshal(
- Template.class,
- TEMPLATE_PROLOG
- + TEMPLATE_MIDDLE
- + "<cdk:call expression=\"#{cc.clientId}\"/><table width=\"200\"><tbody><cdk:call expression=\"#{cc.fooMethod(clientId)}\"/></tbody></table>Header<div class='bar'>foo</div>"
- + TEMPLATE_EPILOG);
-
- CompositeImplementation implementation = template.getImplementation();
- assertNotNull(implementation);
- List<Object> children = implementation.getChildren();
- assertNotNull(children);
- assertEquals(4, children.size());
- assertEquals(CdkCallElement.class, children.get(0).getClass());
- assertEquals(AnyElement.class, children.get(1).getClass());
- assertEquals(String.class, children.get(2).getClass());
- }
-
- @Test
- public void testJstlCoreElements() throws Exception {
- Template template =
- unmarshal(Template.class, TEMPLATE_PROLOG + TEMPLATE_MIDDLE + "start"
- + "<c:if test=\"#{someTest}\">if content</c:if>" + "<c:choose>"
- + "<c:when test=\"#{anotherTest}\">when content</c:when>" + "<c:when test=\"#{coolTest}\">"
- + "<c:if test=\"#{nestedIfTest}\">nested if content</c:if>" + "</c:when>"
- + "<c:otherwise>otherwise content</c:otherwise>" + "</c:choose>"
- + "<c:forEach items=\"#{someCollection}\" var=\"iterationVar\">" + "forEach content" + "</c:forEach>"
- + "finish" + TEMPLATE_EPILOG);
-
- CompositeImplementation implementation = template.getImplementation();
- assertNotNull(implementation);
-
- List<Object> children = implementation.getChildren();
- assertNotNull(children);
- assertEquals(5, children.size());
- assertEquals("start", children.get(0));
- assertEquals(CdkIfElement.class, children.get(1).getClass());
- CdkIfElement ifElement = (CdkIfElement) children.get(1);
- assertEquals("#{someTest}", ifElement.getTest());
- List<Object> ifChildren = ifElement.getChildren();
- assertNotNull(ifChildren);
- assertEquals(1, ifChildren.size());
- assertEquals("if content", ifChildren.get(0));
-
- assertEquals(CdkChooseElement.class, children.get(2).getClass());
- CdkChooseElement chooseElement = (CdkChooseElement) children.get(2);
- List<Object> chooseChildren = chooseElement.getChildren();
- assertNotNull(chooseChildren);
- assertEquals(3, chooseChildren.size());
-
- assertEquals(CdkWhenElement.class, chooseChildren.get(0).getClass());
- CdkWhenElement firstWhen = (CdkWhenElement) chooseChildren.get(0);
- assertEquals("#{anotherTest}", firstWhen.getTest());
- List<Object> childrenOfFirstWhen = firstWhen.getChildren();
- assertNotNull(childrenOfFirstWhen);
- assertEquals(1, childrenOfFirstWhen.size());
- assertEquals("when content", childrenOfFirstWhen.get(0));
-
- assertEquals(CdkWhenElement.class, chooseChildren.get(1).getClass());
- CdkWhenElement secondWhen = (CdkWhenElement) chooseChildren.get(1);
- assertEquals("#{coolTest}", secondWhen.getTest());
-
- List<Object> childrenOfSecondWhen = secondWhen.getChildren();
- assertNotNull(childrenOfSecondWhen);
- assertEquals(1, childrenOfSecondWhen.size());
-
- assertEquals(CdkIfElement.class, childrenOfSecondWhen.get(0).getClass());
- CdkIfElement nestedIf = (CdkIfElement) childrenOfSecondWhen.get(0);
- assertEquals("#{nestedIfTest}", nestedIf.getTest());
- List<Object> childrenOfNestedIf = nestedIf.getChildren();
- assertNotNull(childrenOfNestedIf);
- assertEquals(1, childrenOfNestedIf.size());
- assertEquals("nested if content", childrenOfNestedIf.get(0));
-
- assertEquals(CdkOtherwiseElement.class, chooseChildren.get(2).getClass());
- CdkOtherwiseElement otherwiseElement = (CdkOtherwiseElement) chooseChildren.get(2);
- List<Object> childrenOfOtherwiseElement = otherwiseElement.getChildren();
- assertNotNull(childrenOfOtherwiseElement);
- assertEquals(1, childrenOfOtherwiseElement.size());
- assertEquals("otherwise content", childrenOfOtherwiseElement.get(0));
-
- assertEquals(CdkForEachElement.class, children.get(3).getClass());
- CdkForEachElement forEachElement = (CdkForEachElement) children.get(3);
- assertEquals("#{someCollection}", forEachElement.getItems());
- assertEquals("iterationVar", forEachElement.getVar());
-
- List<Object> forEachChildren = forEachElement.getChildren();
- assertNotNull(forEachChildren);
- assertEquals(1, forEachChildren.size());
- assertEquals("forEach content", forEachChildren.get(0));
-
- assertEquals("finish", children.get(4));
- }
-
- @Test
- public void testInterface() throws Exception {
- Template template =
- unmarshal(Template.class, TEMPLATE_PROLOG
- + "<cdk:class>org.richfaces.renderkit.html.TreeRenderer</cdk:class>"
- + "<cdk:superclass>org.richfaces.renderkit.TreeRendererBase</cdk:superclass>"
- + "<cdk:component-family>org.richfaces.TreeFamily</cdk:component-family>"
- + "<cdk:renderer-type>org.richfaces.TreeRenderer</cdk:renderer-type>"
- + "<cdk:renderkit-id>RF4_XHTML</cdk:renderkit-id>"
- + "<cdk:renders-children>false</cdk:renders-children>" + TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
-
- CompositeInterface interfaceSection = template.getInterface();
- assertNotNull(interfaceSection);
-
- assertEquals("org.richfaces.renderkit.html.TreeRenderer", interfaceSection.getJavaClass());
- assertEquals("org.richfaces.renderkit.TreeRendererBase", interfaceSection.getBaseClass());
- assertEquals("org.richfaces.TreeFamily", interfaceSection.getComponentFamily());
- assertEquals("org.richfaces.TreeRenderer", interfaceSection.getRendererType());
- assertEquals("RF4_XHTML", interfaceSection.getRenderKitId());
- assertEquals(Boolean.FALSE, interfaceSection.getRendersChildren());
-
- }
-
- @Test
public void testAttributes() throws Exception {
Template template =
unmarshal(
@@ -326,44 +200,122 @@
}
@Test
- public void testResourceDependencies() throws Exception {
+ public void testImpl() throws Exception {
Template template =
- unmarshal(Template.class, TEMPLATE_PROLOG + "<cdk:resource-dependencies>"
- + "<cdk:resource-dependency name=\"jquery.js\" />"
- + "<cdk:resource-dependency name=\"richfaces.css\" library=\"org.richfaces\" />"
- + "<cdk:resource-dependency name=\"richfaces.js\" library=\"org.richfaces\" target=\"body\" /> "
- + "</cdk:resource-dependencies> " +
+ unmarshal(
+ Template.class,
+ TEMPLATE_PROLOG
+ + TEMPLATE_MIDDLE
+ + "<cdk:call expression=\"#{cc.clientId}\"/><table width=\"200\"><tbody><cdk:call expression=\"#{cc.fooMethod(clientId)}\"/></tbody></table>Header<div class='bar'>foo</div>"
+ + TEMPLATE_EPILOG);
- TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+ CompositeImplementation implementation = template.getImplementation();
+ assertNotNull(implementation);
+ List<Object> children = implementation.getChildren();
+ assertNotNull(children);
+ assertEquals(4, children.size());
+ assertEquals(CdkCallElement.class, children.get(0).getClass());
+ assertEquals(AnyElement.class, children.get(1).getClass());
+ assertEquals(String.class, children.get(2).getClass());
+ }
+ @Test
+ public void testInterface() throws Exception {
+ Template template =
+ unmarshal(Template.class, TEMPLATE_PROLOG
+ + "<cdk:class>org.richfaces.renderkit.html.TreeRenderer</cdk:class>"
+ + "<cdk:superclass>org.richfaces.renderkit.TreeRendererBase</cdk:superclass>"
+ + "<cdk:component-family>org.richfaces.TreeFamily</cdk:component-family>"
+ + "<cdk:renderer-type>org.richfaces.TreeRenderer</cdk:renderer-type>"
+ + "<cdk:renderkit-id>RF4_XHTML</cdk:renderkit-id>"
+ + "<cdk:renders-children>false</cdk:renders-children>" + TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+
CompositeInterface interfaceSection = template.getInterface();
assertNotNull(interfaceSection);
- assertNull(interfaceSection.getRendersChildren());
+ assertEquals("org.richfaces.renderkit.html.TreeRenderer", interfaceSection.getJavaClass());
+ assertEquals("org.richfaces.renderkit.TreeRendererBase", interfaceSection.getBaseClass());
+ assertEquals("org.richfaces.TreeFamily", interfaceSection.getComponentFamily());
+ assertEquals("org.richfaces.TreeRenderer", interfaceSection.getRendererType());
+ assertEquals("RF4_XHTML", interfaceSection.getRenderKitId());
+ assertEquals(Boolean.FALSE, interfaceSection.getRendersChildren());
- List<ResourceDependency> resourceDependencies = interfaceSection.getResourceDependencies();
- assertNotNull(resourceDependencies);
- assertEquals(3, resourceDependencies.size());
+ }
- ResourceDependency resourceDependency;
+ @Test
+ public void testJstlCoreElements() throws Exception {
+ Template template =
+ unmarshal(Template.class, TEMPLATE_PROLOG + TEMPLATE_MIDDLE + "start"
+ + "<c:if test=\"#{someTest}\">if content</c:if>" + "<c:choose>"
+ + "<c:when test=\"#{anotherTest}\">when content</c:when>" + "<c:when test=\"#{coolTest}\">"
+ + "<c:if test=\"#{nestedIfTest}\">nested if content</c:if>" + "</c:when>"
+ + "<c:otherwise>otherwise content</c:otherwise>" + "</c:choose>"
+ + "<c:forEach items=\"#{someCollection}\" var=\"iterationVar\">" + "forEach content" + "</c:forEach>"
+ + "finish" + TEMPLATE_EPILOG);
- resourceDependency = resourceDependencies.get(0);
- assertNotNull(resourceDependency);
- assertEquals("jquery.js", resourceDependency.getName());
- assertNull(resourceDependency.getLibrary());
- assertEquals("head", resourceDependency.getTarget());
+ CompositeImplementation implementation = template.getImplementation();
+ assertNotNull(implementation);
- resourceDependency = resourceDependencies.get(1);
- assertNotNull(resourceDependency);
- assertEquals("richfaces.css", resourceDependency.getName());
- assertEquals("org.richfaces", resourceDependency.getLibrary());
- assertEquals("head", resourceDependency.getTarget());
+ List<Object> children = implementation.getChildren();
+ assertNotNull(children);
+ assertEquals(5, children.size());
+ assertEquals("start", children.get(0));
+ assertEquals(CdkIfElement.class, children.get(1).getClass());
+ CdkIfElement ifElement = (CdkIfElement) children.get(1);
+ assertEquals("#{someTest}", ifElement.getTest());
+ List<Object> ifChildren = ifElement.getChildren();
+ assertNotNull(ifChildren);
+ assertEquals(1, ifChildren.size());
+ assertEquals("if content", ifChildren.get(0));
- resourceDependency = resourceDependencies.get(2);
- assertNotNull(resourceDependency);
- assertEquals("richfaces.js", resourceDependency.getName());
- assertEquals("org.richfaces", resourceDependency.getLibrary());
- assertEquals("body", resourceDependency.getTarget());
+ assertEquals(CdkChooseElement.class, children.get(2).getClass());
+ CdkChooseElement chooseElement = (CdkChooseElement) children.get(2);
+ List<Object> chooseChildren = chooseElement.getChildren();
+ assertNotNull(chooseChildren);
+ assertEquals(3, chooseChildren.size());
+
+ assertEquals(CdkWhenElement.class, chooseChildren.get(0).getClass());
+ CdkWhenElement firstWhen = (CdkWhenElement) chooseChildren.get(0);
+ assertEquals("#{anotherTest}", firstWhen.getTest());
+ List<Object> childrenOfFirstWhen = firstWhen.getChildren();
+ assertNotNull(childrenOfFirstWhen);
+ assertEquals(1, childrenOfFirstWhen.size());
+ assertEquals("when content", childrenOfFirstWhen.get(0));
+
+ assertEquals(CdkWhenElement.class, chooseChildren.get(1).getClass());
+ CdkWhenElement secondWhen = (CdkWhenElement) chooseChildren.get(1);
+ assertEquals("#{coolTest}", secondWhen.getTest());
+
+ List<Object> childrenOfSecondWhen = secondWhen.getChildren();
+ assertNotNull(childrenOfSecondWhen);
+ assertEquals(1, childrenOfSecondWhen.size());
+
+ assertEquals(CdkIfElement.class, childrenOfSecondWhen.get(0).getClass());
+ CdkIfElement nestedIf = (CdkIfElement) childrenOfSecondWhen.get(0);
+ assertEquals("#{nestedIfTest}", nestedIf.getTest());
+ List<Object> childrenOfNestedIf = nestedIf.getChildren();
+ assertNotNull(childrenOfNestedIf);
+ assertEquals(1, childrenOfNestedIf.size());
+ assertEquals("nested if content", childrenOfNestedIf.get(0));
+
+ assertEquals(CdkOtherwiseElement.class, chooseChildren.get(2).getClass());
+ CdkOtherwiseElement otherwiseElement = (CdkOtherwiseElement) chooseChildren.get(2);
+ List<Object> childrenOfOtherwiseElement = otherwiseElement.getChildren();
+ assertNotNull(childrenOfOtherwiseElement);
+ assertEquals(1, childrenOfOtherwiseElement.size());
+ assertEquals("otherwise content", childrenOfOtherwiseElement.get(0));
+
+ assertEquals(CdkForEachElement.class, children.get(3).getClass());
+ CdkForEachElement forEachElement = (CdkForEachElement) children.get(3);
+ assertEquals("#{someCollection}", forEachElement.getItems());
+ assertEquals("iterationVar", forEachElement.getVar());
+
+ List<Object> forEachChildren = forEachElement.getChildren();
+ assertNotNull(forEachChildren);
+ assertEquals(1, forEachChildren.size());
+ assertEquals("forEach content", forEachChildren.get(0));
+
+ assertEquals("finish", children.get(4));
}
@Test
@@ -397,4 +349,52 @@
assertEquals("java.lang.String", secondObject.getType());
assertEquals("\"test expression\" +\n\"second line\"", secondObject.getBodyValue());
}
+
+ @Test
+ public void testResourceDependencies() throws Exception {
+ Template template =
+ unmarshal(Template.class, TEMPLATE_PROLOG + "<cdk:resource-dependencies>"
+ + "<cdk:resource-dependency name=\"jquery.js\" />"
+ + "<cdk:resource-dependency name=\"richfaces.css\" library=\"org.richfaces\" />"
+ + "<cdk:resource-dependency name=\"richfaces.js\" library=\"org.richfaces\" target=\"body\" /> "
+ + "</cdk:resource-dependencies> " +
+
+ TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+
+ CompositeInterface interfaceSection = template.getInterface();
+ assertNotNull(interfaceSection);
+
+ assertNull(interfaceSection.getRendersChildren());
+
+ List<ResourceDependency> resourceDependencies = interfaceSection.getResourceDependencies();
+ assertNotNull(resourceDependencies);
+ assertEquals(3, resourceDependencies.size());
+
+ ResourceDependency resourceDependency;
+
+ resourceDependency = resourceDependencies.get(0);
+ assertNotNull(resourceDependency);
+ assertEquals("jquery.js", resourceDependency.getName());
+ assertNull(resourceDependency.getLibrary());
+ assertEquals("head", resourceDependency.getTarget());
+
+ resourceDependency = resourceDependencies.get(1);
+ assertNotNull(resourceDependency);
+ assertEquals("richfaces.css", resourceDependency.getName());
+ assertEquals("org.richfaces", resourceDependency.getLibrary());
+ assertEquals("head", resourceDependency.getTarget());
+
+ resourceDependency = resourceDependencies.get(2);
+ assertNotNull(resourceDependency);
+ assertEquals("richfaces.js", resourceDependency.getName());
+ assertEquals("org.richfaces", resourceDependency.getLibrary());
+ assertEquals("body", resourceDependency.getTarget());
+ }
+
+ @Test
+ public void testTemplate() throws Exception {
+ Template template = unmarshal(Template.class, TEMPLATE_PROLOG + TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+ assertNotNull(template.getInterface());
+ assertNotNull(template.getImplementation());
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/Bean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/Bean.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/Bean.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -45,33 +45,18 @@
components.add(value);
}
- public Bean2 getTestBean2() {
- return testBean2;
+ public Integer count(Integer i) {
+ return null;
}
- public void setTestBean2(Bean2 testBean2) {
- this.testBean2 = testBean2;
- }
-
- public void test(UIComponent comp, boolean test) {
- }
-
public UIComponent[] getArray() {
return array;
}
- public void setArray(UIComponent[] array) {
- this.array = array;
- }
-
public List<UIComponent> getComponents() {
return components;
}
- public void setComponents(List<UIComponent> components) {
- this.components = components;
- }
-
public UIComponent getFacet(String name) {
return facets.get(name);
}
@@ -80,27 +65,42 @@
return facets;
}
- public void setFacets(Map<String, UIComponent> facets) {
- this.facets = facets;
- }
-
public Map getRawMap() {
return rawMap;
}
- public void setRawMap(Map rawMap) {
- this.rawMap = rawMap;
+ public Bean2 getTestBean2() {
+ return testBean2;
}
public boolean isReadOnly() {
return readOnly;
}
+ public void setArray(UIComponent[] array) {
+ this.array = array;
+ }
+
+ public void setComponents(List<UIComponent> components) {
+ this.components = components;
+ }
+
+ public void setFacets(Map<String, UIComponent> facets) {
+ this.facets = facets;
+ }
+
+ public void setRawMap(Map rawMap) {
+ this.rawMap = rawMap;
+ }
+
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
- public Integer count(Integer i) {
- return null;
+ public void setTestBean2(Bean2 testBean2) {
+ this.testBean2 = testBean2;
}
+
+ public void test(UIComponent comp, boolean test) {
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -21,30 +21,43 @@
package org.richfaces.cdk.templatecompiler.parser.el.test;
+import static org.junit.Assert.*;
+import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.Test;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.EMPTINESS_CHECK;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.EQUALS_CHECK;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.TO_BOOLEAN_CONVERSION;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.TO_STRING_CONVERSION;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class ELParserTest {
private ELVisitor visitor;
+ private void parseExpression(String expression) throws ParsingException {
+ parseExpression(expression, Object.class);
+ }
+
+ private void parseExpression(String expression, Class<?> returnType) throws ParsingException {
+ Map<String, Type> contextMap = new HashMap<String, Type>();
+
+ contextMap.put("action", TypesFactory.getType(org.richfaces.cdk.templatecompiler.parser.el.test.Bean.class));
+ contextMap.put("clientId", TypesFactory.getType(String.class));
+ contextMap.put("test", TypesFactory.getType(boolean.class));
+ contextMap.put("otherTest", TypesFactory.getType(boolean.class));
+ contextMap.put("this", TypesFactory.getType(Object.class));
+ contextMap.put("super", TypesFactory.getType(Object.class));
+ contextMap.put("objectVar", TypesFactory.getType(Object.class));
+
+ visitor.parse(expression, contextMap, TypesFactory.getType(returnType));
+ }
+
@Before
public void setUp() {
visitor = new ELVisitor();
@@ -56,126 +69,58 @@
}
@Test
- public void testNull() throws Exception {
- parseExpression("#{null}");
- assertEquals("null", visitor.getParsedExpression());
- assertTrue(visitor.getExpressionType().isNullType());
- }
+ public void testAnd() throws Exception {
+ parseExpression("#{test and otherTest}");
+ assertEquals("(test && otherTest)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- @Test
- public void testTrue() throws Exception {
- parseExpression("#{true}");
- assertEquals("true", visitor.getParsedExpression());
+ parseExpression("#{otherTest && test}");
+ assertEquals("(otherTest && test)", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- }
- @Test
- public void testFalse() throws Exception {
- parseExpression("#{false}");
- assertEquals("false", visitor.getParsedExpression());
+ parseExpression("#{action and otherTest}");
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ assertEquals("(convertToBoolean(action) && otherTest)", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- }
- @Test
- public void testFloat() throws Exception {
- parseExpression("#{5.0}");
- assertEquals("Double.valueOf(5.0)", visitor.getParsedExpression());
- assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{5.012e+34}");
- assertEquals("Double.valueOf(5.012e+34)", visitor.getParsedExpression());
- assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
+ parseExpression("#{test && action}");
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ assertEquals("(test && convertToBoolean(action))", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
- public void testNegative() throws Exception {
- parseExpression("#{-5}");
- assertEquals("-5", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
- }
+ public void testBooleanReturnType() throws Exception {
+ parseExpression("#{clientId}", Boolean.TYPE);
- @Test
- public void testNegativeFloat() throws Exception {
- parseExpression("#{-5.0}");
- assertEquals("-Double.valueOf(5.0)", visitor.getParsedExpression());
- assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
- }
-
- @Test
- public void testNotEqual() throws Exception {
- parseExpression("#{1 ne 3}");
- assertEquals("(1 != 3)", visitor.getParsedExpression());
+ assertEquals("convertToBoolean(clientId)", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- parseExpression("#{2 != 3}");
- assertEquals("(2 != 3)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+ parseExpression("#{test}", Boolean.TYPE);
- parseExpression("#{action != 2}");
- assertEquals("!isEqual(action,2)", visitor.getParsedExpression());
+ assertEquals("test", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
-
- parseExpression("#{2 ne action}");
- assertEquals("!isEqual(2,action)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
-
- parseExpression("#{action != clientId}");
- assertEquals("!isEqual(action,clientId)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
-
- parseExpression("#{action ne clientId}");
- assertEquals("!isEqual(action,clientId)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
-
- parseExpression("#{action ne null}");
- assertEquals("(action != null)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
-
- parseExpression("#{2 != null}");
- assertEquals("!isEqual(2,null)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+ assertFalse(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
}
@Test
- public void testNot() throws Exception {
- parseExpression("#{not test}");
- assertEquals("(!test)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ public void testChoice() throws Exception {
+ parseExpression("#{test ? 2 : 3}");
+ assertEquals("(test ? 2 : 3)", visitor.getParsedExpression());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
- parseExpression("#{!otherTest}");
- assertEquals("(!otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ parseExpression("#{test ? null : 'string'}");
+ assertEquals("(test ? null : \"string\")", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
- parseExpression("#{!action}");
- assertEquals("(!convertToBoolean(action))", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ parseExpression("#{action ? null : 'string'}");
+ assertEquals("(convertToBoolean(action) ? null : \"string\")", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
}
@Test
- public void testPlus() throws Exception {
- // TODO: tests involving double values
- parseExpression("#{1+2}");
- assertEquals("(1 + 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
- }
-
- @Test
- public void testMinus() throws Exception {
- parseExpression("#{1-2}");
- assertEquals("(1 - 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
- }
-
- @Test
public void testDiv() throws Exception {
parseExpression("#{1/2}");
assertEquals("(1 / 2)", visitor.getParsedExpression());
@@ -183,59 +128,18 @@
}
@Test
- public void testMult() throws Exception {
- parseExpression("#{1*2}");
- assertEquals("(1 * 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
- }
-
- @Test
- public void testMod() throws Exception {
- parseExpression("#{1%2}");
- assertEquals("(1 % 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
- }
-
- @Test
- public void testAnd() throws Exception {
- parseExpression("#{test and otherTest}");
- assertEquals("(test && otherTest)", visitor.getParsedExpression());
+ public void testEmpty() throws Exception {
+ parseExpression("#{empty action.array}");
+ assertEquals("isEmpty(action.getArray())", visitor.getParsedExpression());
+ assertTrue(visitor.getUsedHelperMethods().contains(EMPTINESS_CHECK));
assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{otherTest && test}");
- assertEquals("(otherTest && test)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{action and otherTest}");
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- assertEquals("(convertToBoolean(action) && otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{test && action}");
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- assertEquals("(test && convertToBoolean(action))", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
- public void testOr() throws Exception {
- parseExpression("#{test or otherTest}");
- assertEquals("(test || otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{otherTest || test}");
- assertEquals("(otherTest || test)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{action or otherTest}");
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- assertEquals("(convertToBoolean(action) || otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{test || action}");
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- assertEquals("(test || convertToBoolean(action))", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ public void testEmptyString() throws Exception {
+ parseExpression("");
+ assertEquals("\"\"", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
@@ -254,7 +158,7 @@
assertEquals("isEqual(action,2)", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
-
+
parseExpression("#{2 eq action}");
assertEquals("isEqual(2,action)", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
@@ -282,6 +186,31 @@
}
@Test
+ public void testFalse() throws Exception {
+ parseExpression("#{false}");
+ assertEquals("false", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ }
+
+ @Test
+ public void testFloat() throws Exception {
+ parseExpression("#{5.0}");
+ assertEquals("Double.valueOf(5.0)", visitor.getParsedExpression());
+ assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{5.012e+34}");
+ assertEquals("Double.valueOf(5.012e+34)", visitor.getParsedExpression());
+ assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
+ }
+
+ @Test
+ public void testFunction() throws Exception {
+ parseExpression("#{super:getType()}");
+ assertEquals("super.getType()", visitor.getParsedExpression());
+ Type variableType = visitor.getExpressionType();
+ }
+
+ @Test
public void testGreatThen() throws Exception {
parseExpression("#{1 gt 2}");
assertEquals("(1 > 2)", visitor.getParsedExpression());
@@ -293,6 +222,31 @@
}
@Test
+ public void testGreatThenEquals() throws Exception {
+ parseExpression("#{1 ge 2}");
+ assertEquals("(1 >= 2)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{3 >= 2}");
+ assertEquals("(3 >= 2)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ }
+
+ @Test
+ public void testIdentifier() throws Exception {
+ parseExpression("#{clientId}");
+ assertEquals("clientId", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+ }
+
+ @Test
+ public void testInteger() throws Exception {
+ parseExpression("#{152}");
+ assertEquals("152", visitor.getParsedExpression());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
+ }
+
+ @Test
public void testLessThen() throws Exception {
parseExpression("#{1 lt 2}");
assertEquals("(1 < 2)", visitor.getParsedExpression());
@@ -315,80 +269,79 @@
}
@Test
- public void testGreatThenEquals() throws Exception {
- parseExpression("#{1 ge 2}");
- assertEquals("(1 >= 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{3 >= 2}");
- assertEquals("(3 >= 2)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ public void testLiteral() throws Exception {
+ parseExpression("clientId");
+ assertEquals("\"clientId\"", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
- public void testChoice() throws Exception {
- parseExpression("#{test ? 2 : 3}");
- assertEquals("(test ? 2 : 3)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
+ public void testLiteralWithDeferred() throws Exception {
+ parseExpression("#{1}#{2}");
+ assertEquals("convertToString(1) + convertToString(2)", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
- parseExpression("#{test ? null : 'string'}");
- assertEquals("(test ? null : \"string\")", visitor.getParsedExpression());
+ parseExpression("abs #{getType()}");
+ assertEquals("\"abs \" + convertToString(this.getType())", visitor.getParsedExpression());
assertEquals(String.class, visitor.getExpressionType().getRawType());
+ }
- parseExpression("#{action ? null : 'string'}");
- assertEquals("(convertToBoolean(action) ? null : \"string\")", visitor.getParsedExpression());
+ @Test
+ public void testLiteralWithDeferred2() throws Exception {
+ parseExpression("#{getType()} abs ");
+ assertEquals("convertToString(this.getType()) + \" abs \"", visitor.getParsedExpression());
assertEquals(String.class, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
}
@Test
- public void testInteger() throws Exception {
- parseExpression("#{152}");
- assertEquals("152", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
+ public void testMethod() throws Exception {
+ parseExpression("#{action.readOnly}");
+ assertEquals("action.isReadOnly()", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
- public void testString() throws Exception {
- parseExpression("#{\"nabc\"}");
- assertEquals("\"nabc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ public void testMethodReturnArray() throws Exception {
+ parseExpression("#{action.array}");
+ assertEquals("action.getArray()", visitor.getParsedExpression());
+ assertEquals(UIComponent[].class, visitor.getExpressionType().getRawType());
+ }
- parseExpression("#{'nabc'}");
- assertEquals("\"nabc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ @Test
+ public void testMethodReturnArrayElement() throws Exception {
+ parseExpression("#{action.array[0]}");
+ assertEquals("action.getArray()[0]", visitor.getParsedExpression());
+ assertEquals(UIComponent.class, visitor.getExpressionType().getRawType());
+ }
- parseExpression("#{'\tabc'}");
- assertEquals("\"\\tabc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
-
- parseExpression("#{'/nabc'}");
- assertEquals("\"/nabc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
-
- parseExpression("#{'na\"bc'}");
- assertEquals("\"na\\\"bc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
-
- parseExpression("#{'na\\\\bc'}");
- assertEquals("\"na\\\\bc\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ @Test
+ public void testMethodReturnList() throws Exception {
+ parseExpression("#{action.components}");
+ assertEquals("action.getComponents()", visitor.getParsedExpression());
+ Type variableType = visitor.getExpressionType();
+ assertEquals(List.class, variableType.getRawType());
+ assertEquals(UIComponent.class, variableType.getContainerType().getRawType());
}
@Test
- public void testIdentifier() throws Exception {
- parseExpression("#{clientId}");
- assertEquals("clientId", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ public void testMethodReturnListElement() throws Exception {
+ parseExpression("#{action.components[0]}");
+ assertEquals("action.getComponents().get(0)", visitor.getParsedExpression());
+ assertEquals(UIComponent.class, visitor.getExpressionType().getRawType());
}
@Test
- public void testLiteral() throws Exception {
- parseExpression("clientId");
- assertEquals("\"clientId\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ public void testMethodReturnListElement2() throws Exception {
+ parseExpression("#{action.components[0].rendered}");
+ assertEquals("action.getComponents().get(0).isRendered()", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
+ // @Test
+ // public void testMethodReturnMapElement1() throws Exception {
+ // assertEquals("action.getFacets().get(\"header\")", resolveExpression("#{action.facets.header}"));
+ // }
+
@Test
public void testMethodReturnMap() throws Exception {
parseExpression("#{action.facets}");
@@ -416,11 +369,6 @@
assertEquals(Object.class, visitor.getExpressionType().getRawType());
}
- // @Test
- // public void testMethodReturnMapElement1() throws Exception {
- // assertEquals("action.getFacets().get(\"header\")", resolveExpression("#{action.facets.header}"));
- // }
-
@Test
public void testMethodReturnMapElement2() throws Exception {
parseExpression("#{action.facets.toString()}");
@@ -438,104 +386,206 @@
}
@Test
- public void testMethod() throws Exception {
- parseExpression("#{action.readOnly}");
- assertEquals("action.isReadOnly()", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ public void testMethodWithParam() throws Exception {
+ parseExpression("#{getType(action.array[0].rendered, action.readOnly, true)}");
+ assertEquals("this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)", visitor
+ .getParsedExpression());
+
+ Type variableType = visitor.getExpressionType();
+
+ parseExpression("#{action.count(123)}");
+ assertEquals("action.count(123)", visitor.getParsedExpression());
+ assertEquals(Integer.class, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{action.count(clientId)}");
+ assertEquals("action.count(clientId)", visitor.getParsedExpression());
+ assertEquals(Object.class, visitor.getExpressionType().getRawType());
}
@Test
- public void testNestedMethod() throws Exception {
- parseExpression("#{action.testBean2.string}");
- assertEquals("action.getTestBean2().getString()", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ public void testMinus() throws Exception {
+ parseExpression("#{1-2}");
+ assertEquals("(1 - 2)", visitor.getParsedExpression());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
- public void testMethodReturnList() throws Exception {
- parseExpression("#{action.components}");
- assertEquals("action.getComponents()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
- assertEquals(List.class, variableType.getRawType());
- assertEquals(UIComponent.class, variableType.getContainerType().getRawType());
+ public void testMod() throws Exception {
+ parseExpression("#{1%2}");
+ assertEquals("(1 % 2)", visitor.getParsedExpression());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
- public void testMethodReturnListElement() throws Exception {
- parseExpression("#{action.components[0]}");
- assertEquals("action.getComponents().get(0)", visitor.getParsedExpression());
- assertEquals(UIComponent.class, visitor.getExpressionType().getRawType());
+ public void testMult() throws Exception {
+ parseExpression("#{1*2}");
+ assertEquals("(1 * 2)", visitor.getParsedExpression());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
- public void testMethodReturnListElement2() throws Exception {
- parseExpression("#{action.components[0].rendered}");
- assertEquals("action.getComponents().get(0).isRendered()", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ public void testNegative() throws Exception {
+ parseExpression("#{-5}");
+ assertEquals("-5", visitor.getParsedExpression());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
}
@Test
- public void testMethodReturnArray() throws Exception {
- parseExpression("#{action.array}");
- assertEquals("action.getArray()", visitor.getParsedExpression());
- assertEquals(UIComponent[].class, visitor.getExpressionType().getRawType());
+ public void testNegativeFloat() throws Exception {
+ parseExpression("#{-5.0}");
+ assertEquals("-Double.valueOf(5.0)", visitor.getParsedExpression());
+ assertEquals(Double.TYPE, visitor.getExpressionType().getRawType());
}
@Test
- public void testMethodReturnArrayElement() throws Exception {
- parseExpression("#{action.array[0]}");
- assertEquals("action.getArray()[0]", visitor.getParsedExpression());
- assertEquals(UIComponent.class, visitor.getExpressionType().getRawType());
+ public void testNestedMethod() throws Exception {
+ parseExpression("#{action.testBean2.string}");
+ assertEquals("action.getTestBean2().getString()", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
- public void testMethodWithParam() throws Exception {
- parseExpression("#{getType(action.array[0].rendered, action.readOnly, true)}");
- assertEquals("this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)", visitor
- .getParsedExpression());
+ public void testNonExistingMethod() throws Exception {
+ parseExpression("#{action.doSomething(clientId, 123)}");
+ assertEquals("action.doSomething(clientId,123)", visitor.getParsedExpression());
+ assertEquals(Object.class, visitor.getExpressionType().getRawType());
+ }
- Type variableType = visitor.getExpressionType();
+ @Test
+ public void testNot() throws Exception {
+ parseExpression("#{not test}");
+ assertEquals("(!test)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- parseExpression("#{action.count(123)}");
- assertEquals("action.count(123)", visitor.getParsedExpression());
- assertEquals(Integer.class, visitor.getExpressionType().getRawType());
+ parseExpression("#{!otherTest}");
+ assertEquals("(!otherTest)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- parseExpression("#{action.count(clientId)}");
- assertEquals("action.count(clientId)", visitor.getParsedExpression());
- assertEquals(Object.class, visitor.getExpressionType().getRawType());
+ parseExpression("#{!action}");
+ assertEquals("(!convertToBoolean(action))", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
}
@Test
- public void testEmpty() throws Exception {
- parseExpression("#{empty action.array}");
- assertEquals("isEmpty(action.getArray())", visitor.getParsedExpression());
- assertTrue(visitor.getUsedHelperMethods().contains(EMPTINESS_CHECK));
+ public void testNotEqual() throws Exception {
+ parseExpression("#{1 ne 3}");
+ assertEquals("(1 != 3)", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+
+ parseExpression("#{2 != 3}");
+ assertEquals("(2 != 3)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+
+ parseExpression("#{action != 2}");
+ assertEquals("!isEqual(action,2)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+
+ parseExpression("#{2 ne action}");
+ assertEquals("!isEqual(2,action)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+
+ parseExpression("#{action != clientId}");
+ assertEquals("!isEqual(action,clientId)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+
+ parseExpression("#{action ne clientId}");
+ assertEquals("!isEqual(action,clientId)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+
+ parseExpression("#{action ne null}");
+ assertEquals("(action != null)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
+
+ parseExpression("#{2 != null}");
+ assertEquals("!isEqual(2,null)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(EQUALS_CHECK));
}
@Test
- public void testFunction() throws Exception {
- parseExpression("#{super:getType()}");
- assertEquals("super.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ public void testNull() throws Exception {
+ parseExpression("#{null}");
+ assertEquals("null", visitor.getParsedExpression());
+ assertTrue(visitor.getExpressionType().isNullType());
}
@Test
- public void testLiteralWithDeferred() throws Exception {
- parseExpression("#{1}#{2}");
- assertEquals("convertToString(1) + convertToString(2)", visitor.getParsedExpression());
+ public void testOr() throws Exception {
+ parseExpression("#{test or otherTest}");
+ assertEquals("(test || otherTest)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{otherTest || test}");
+ assertEquals("(otherTest || test)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{action or otherTest}");
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ assertEquals("(convertToBoolean(action) || otherTest)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{test || action}");
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ assertEquals("(test || convertToBoolean(action))", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ }
+
+ @Test
+ public void testPlus() throws Exception {
+ // TODO: tests involving double values
+ parseExpression("#{1+2}");
+ assertEquals("(1 + 2)", visitor.getParsedExpression());
+ assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
+ }
+
+ @Test
+ public void testString() throws Exception {
+ parseExpression("#{\"nabc\"}");
+ assertEquals("\"nabc\"", visitor.getParsedExpression());
assertEquals(String.class, visitor.getExpressionType().getRawType());
- parseExpression("abs #{getType()}");
- assertEquals("\"abs \" + convertToString(this.getType())", visitor.getParsedExpression());
+ parseExpression("#{'nabc'}");
+ assertEquals("\"nabc\"", visitor.getParsedExpression());
assertEquals(String.class, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{'\tabc'}");
+ assertEquals("\"\\tabc\"", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{'/nabc'}");
+ assertEquals("\"/nabc\"", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{'na\"bc'}");
+ assertEquals("\"na\\\"bc\"", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+
+ parseExpression("#{'na\\\\bc'}");
+ assertEquals("\"na\\\\bc\"", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
}
@Test
- public void testLiteralWithDeferred2() throws Exception {
- parseExpression("#{getType()} abs ");
- assertEquals("convertToString(this.getType()) + \" abs \"", visitor.getParsedExpression());
+ public void testStringReturnType() throws Exception {
+ parseExpression("#{clientId}", String.class);
+
+ assertEquals("clientId", visitor.getParsedExpression());
assertEquals(String.class, visitor.getExpressionType().getRawType());
+ assertFalse(visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION));
+
+ parseExpression("#{test}", String.class);
+
+ assertEquals("convertToString(test)", visitor.getParsedExpression());
+ assertEquals(String.class, visitor.getExpressionType().getRawType());
+ assertTrue(visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION));
}
@Test
@@ -549,6 +599,13 @@
}
@Test
+ public void testTrue() throws Exception {
+ parseExpression("#{true}");
+ assertEquals("true", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ }
+
+ @Test
public void testVariableFunction() throws Exception {
parseExpression("#{objectVar.getType()}");
assertEquals("objectVar.getType()", visitor.getParsedExpression());
@@ -556,13 +613,6 @@
}
@Test
- public void testNonExistingMethod() throws Exception {
- parseExpression("#{action.doSomething(clientId, 123)}");
- assertEquals("action.doSomething(clientId,123)", visitor.getParsedExpression());
- assertEquals(Object.class, visitor.getExpressionType().getRawType());
- }
-
- @Test
public void testWrongExpression() throws Exception {
try {
parseExpression("#{bean.property}");
@@ -579,59 +629,4 @@
assertEquals("action.getProperty()", visitor.getParsedExpression());
assertEquals(Object.class, visitor.getExpressionType().getRawType());
}
-
- @Test
- public void testEmptyString() throws Exception {
- parseExpression("");
- assertEquals("\"\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
- }
-
- @Test
- public void testBooleanReturnType() throws Exception {
- parseExpression("#{clientId}", Boolean.TYPE);
-
- assertEquals("convertToBoolean(clientId)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
-
- parseExpression("#{test}", Boolean.TYPE);
-
- assertEquals("test", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertFalse(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- }
-
- @Test
- public void testStringReturnType() throws Exception {
- parseExpression("#{clientId}", String.class);
-
- assertEquals("clientId", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
- assertFalse(visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION));
-
- parseExpression("#{test}", String.class);
-
- assertEquals("convertToString(test)", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION));
- }
-
- private void parseExpression(String expression) throws ParsingException {
- parseExpression(expression, Object.class);
- }
-
- private void parseExpression(String expression, Class<?> returnType) throws ParsingException {
- Map<String, Type> contextMap = new HashMap<String, Type>();
-
- contextMap.put("action", TypesFactory.getType(org.richfaces.cdk.templatecompiler.parser.el.test.Bean.class));
- contextMap.put("clientId", TypesFactory.getType(String.class));
- contextMap.put("test", TypesFactory.getType(boolean.class));
- contextMap.put("otherTest", TypesFactory.getType(boolean.class));
- contextMap.put("this", TypesFactory.getType(Object.class));
- contextMap.put("super", TypesFactory.getType(Object.class));
- contextMap.put("objectVar", TypesFactory.getType(Object.class));
-
- visitor.parse(expression, contextMap, TypesFactory.getType(returnType));
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -40,40 +40,58 @@
private static final class ParameterizedTypesHolder {
@SuppressWarnings("unused")
- public Map<String, Object> getMap() {
+ public List<String>[] getArray() {
return null;
}
@SuppressWarnings("unused")
- public List<String>[] getArray() {
+ public Map<String, Object> getMap() {
return null;
}
@SuppressWarnings("unused")
- public List<? extends String> getWildcardList() {
+ public <Abc> Abc getTypeVariableList() {
return null;
}
@SuppressWarnings("unused")
- public <Abc> Abc getTypeVariableList() {
+ public List<? extends String> getWildcardList() {
return null;
}
}
+ private java.lang.reflect.Type getParameterizedArrayType() throws Exception {
+ return ParameterizedTypesHolder.class.getMethod("getArray").getGenericReturnType();
+ }
+
private java.lang.reflect.Type getParameterizedMapType() throws Exception {
return ParameterizedTypesHolder.class.getMethod("getMap").getGenericReturnType();
}
- private java.lang.reflect.Type getParameterizedArrayType() throws Exception {
- return ParameterizedTypesHolder.class.getMethod("getArray").getGenericReturnType();
+ private java.lang.reflect.Type getTypeVariableType() throws Exception {
+ return ParameterizedTypesHolder.class.getMethod("getTypeVariableList").getGenericReturnType();
}
private java.lang.reflect.Type getWildcardType() throws Exception {
return ParameterizedTypesHolder.class.getMethod("getWildcardList").getGenericReturnType();
}
- private java.lang.reflect.Type getTypeVariableType() throws Exception {
- return ParameterizedTypesHolder.class.getMethod("getTypeVariableList").getGenericReturnType();
+ @Test
+ public void testCaching() throws Exception {
+ Type objectType = TypesFactory.getType(Object.class);
+ Type objectType2 = TypesFactory.getType(Object.class);
+
+ assertNotNull(objectType);
+ assertNotNull(objectType2);
+
+ assertSame(objectType, objectType2);
+
+ TypesFactory.clearCaches();
+
+ Type objectType3 = TypesFactory.getType(Object.class);
+ assertNotNull(objectType3);
+
+ assertNotSame(objectType, objectType3);
}
@Test
@@ -204,24 +222,6 @@
}
@Test
- public void testCaching() throws Exception {
- Type objectType = TypesFactory.getType(Object.class);
- Type objectType2 = TypesFactory.getType(Object.class);
-
- assertNotNull(objectType);
- assertNotNull(objectType2);
-
- assertSame(objectType, objectType2);
-
- TypesFactory.clearCaches();
-
- Type objectType3 = TypesFactory.getType(Object.class);
- assertNotNull(objectType3);
-
- assertNotSame(objectType, objectType3);
- }
-
- @Test
public void testReferencedType() throws Exception {
ClassLoader classLoader = getClass().getClassLoader();
String className = "some.not.available.Class";
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/util/ComparatorUtilsTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/util/ComparatorUtilsTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/util/ComparatorUtilsTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -26,7 +26,6 @@
import org.junit.Test;
-
/**
* @author Nick Belaevski
*
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -1,27 +1,68 @@
package org.richfaces.cdk.xmlconfig;
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Binder;
-import com.google.inject.Inject;
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.assertNotNull;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.richfaces.cdk.*;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.xml.sax.InputSource;
+import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
-import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
-import java.net.MalformedURLException;
+import java.net.URLConnection;
import java.net.URLStreamHandler;
-import java.net.URLConnection;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.Sources;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.xml.sax.InputSource;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+
@RunWith(CdkTestRunner.class)
public class CdkResolverTest extends CdkTestBase {
+ private class MyURLConnection extends URLConnection {
+
+ private InputStream inputStream;
+
+ MyURLConnection(URL u, InputStream inputStream) {
+ super(u);
+ this.inputStream = inputStream;
+ }
+
+ @Override
+ public void connect() throws IOException {
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return this.inputStream;
+ }
+ }
+
+ private class MyURLStreamHandler extends URLStreamHandler {
+
+ private InputStream inputStream;
+
+ MyURLStreamHandler(InputStream inputStream) {
+ this.inputStream = inputStream;
+ }
+
+ @Override
+ protected URLConnection openConnection(URL u) throws IOException {
+ return new MyURLConnection(u, inputStream);
+ }
+ }
+
private static final String TEST_HTML = "org/richfaces/cdk/apt/test.html";
@Inject
@@ -43,14 +84,6 @@
new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
getLibraryFile(JsfComponent.class)), null) {
@Override
- public InputStream getResourceAsStream(String name) {
- if ("foo/bar.xml".equals(name)) {
- return getBarXmlStream();
- } else {
- return super.getResourceAsStream(name);
- }
- }
-
public URL getResource(String name) {
if ("foo/bar.xml".equals(name)) {
try {
@@ -65,6 +98,15 @@
}
}
+ @Override
+ public InputStream getResourceAsStream(String name) {
+ if ("foo/bar.xml".equals(name)) {
+ return getBarXmlStream();
+ } else {
+ return super.getResourceAsStream(name);
+ }
+ }
+
};
binder.bind(CdkClassLoader.class).toInstance(classLoader);
} catch (Exception e) {
@@ -72,16 +114,20 @@
}
}
- private ByteArrayInputStream getBarXmlStream() {
- return new ByteArrayInputStream("baz".getBytes());
+ @Test
+ public void testGetProjectInputSource() throws Exception {
+ expect(facesConfigSource.getFile(TEST_HTML)).andReturn(getJavaFile(TEST_HTML));
+ replay(facesConfigSource, templatesSource);
+ InputSource input = entityResolver.getProjectInputSource(facesConfigSource, TEST_HTML);
+ verify(facesConfigSource, templatesSource);
+ assertNotNull(input);
}
@Test
- public void testResolveSystemIdSystem() throws Exception {
+ public void testResolveSystemIdAttributes() throws Exception {
replay(facesConfigSource, templatesSource);
-
- InputSource input = entityResolver.resolveSystemId("http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd");
+ InputSource input = entityResolver.resolveSystemId("urn:attributes:test-props.xml");
verify(facesConfigSource, templatesSource);
assertNotNull(input);
}
@@ -95,54 +141,16 @@
}
@Test
- public void testResolveSystemIdAttributes() throws Exception {
+ public void testResolveSystemIdSystem() throws Exception {
replay(facesConfigSource, templatesSource);
- InputSource input = entityResolver.resolveSystemId("urn:attributes:test-props.xml");
- verify(facesConfigSource, templatesSource);
- assertNotNull(input);
- }
- @Test
- public void testGetProjectInputSource() throws Exception {
- expect(facesConfigSource.getFile(TEST_HTML)).andReturn(getJavaFile(TEST_HTML));
- replay(facesConfigSource, templatesSource);
- InputSource input = entityResolver.getProjectInputSource(facesConfigSource, TEST_HTML);
+ InputSource input = entityResolver.resolveSystemId("http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd");
verify(facesConfigSource, templatesSource);
assertNotNull(input);
}
-
- private class MyURLConnection extends URLConnection {
-
- private InputStream inputStream;
-
- @Override
- public void connect() throws IOException {
- }
-
- MyURLConnection(URL u, InputStream inputStream) {
- super(u);
- this.inputStream = inputStream;
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- return this.inputStream;
- }
+ private ByteArrayInputStream getBarXmlStream() {
+ return new ByteArrayInputStream("baz".getBytes());
}
-
- private class MyURLStreamHandler extends URLStreamHandler {
-
- private InputStream inputStream;
-
- MyURLStreamHandler(InputStream inputStream) {
- this.inputStream = inputStream;
- }
-
- @Override
- protected URLConnection openConnection(URL u) throws IOException {
- return new MyURLConnection(u, inputStream);
- }
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/ComponentAdapterTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/ComponentAdapterTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/ComponentAdapterTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -1,8 +1,9 @@
package org.richfaces.cdk.xmlconfig;
-import com.google.common.collect.Iterables;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
import org.junit.Test;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentModel;
@@ -12,7 +13,7 @@
import org.richfaces.cdk.xmlconfig.model.ComponentBean;
import org.richfaces.cdk.xmlconfig.model.ComponentBean.ComponentExtension;
-import java.util.Collection;
+import com.google.common.collect.Iterables;
public class ComponentAdapterTest {
private static final String BAZ = "baz";
@@ -22,7 +23,6 @@
private static final String FOO_UI_BAR = "foo.UIBar";
@Test
-
public void testComponentAdapter() throws Exception {
ComponentModel component = new ComponentModel(FacesId.parseId(FOO_BAR));
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -23,11 +23,11 @@
package org.richfaces.cdk.xmlconfig;
-import com.google.common.collect.Iterables;
-import com.google.inject.Binder;
-import com.google.inject.Inject;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+import java.util.List;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.As;
@@ -45,11 +45,11 @@
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
-import org.richfaces.cdk.xmlconfig.model.RenderKitBean;
import org.xml.sax.ext.EntityResolver2;
-import java.util.Collection;
-import java.util.List;
+import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -62,24 +62,24 @@
public class FacesConfigTest extends CdkTestBase {
@Inject
+ @As(JAXBBinding.class)
+ JAXB jaxbBinding;
+
+ @Inject
FragmentParser parser;
@Inject
@As(CdkEntityResolver.class)
EntityResolver2 resolver;
- @Inject
- @As(JAXBBinding.class)
- JAXB jaxbBinding;
+ @Mock
+ @Source(Sources.FACES_CONFIGS)
+ private FileManager configSource;
@Mock
@Source(Sources.RENDERER_TEMPLATES)
private FileManager templatesSource;
- @Mock
- @Source(Sources.FACES_CONFIGS)
- private FileManager configSource;
-
@Override
public void configure(Binder binder) {
super.configure(binder);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -23,11 +23,11 @@
package org.richfaces.cdk.xmlconfig;
-import com.google.common.collect.Iterables;
-import com.google.inject.Binder;
-import com.google.inject.Inject;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+import java.util.List;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.As;
@@ -42,9 +42,9 @@
import org.richfaces.cdk.model.PropertyBase;
import org.xml.sax.ext.EntityResolver2;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
+import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -57,24 +57,24 @@
public class FragmentParserTest extends CdkTestBase {
@Inject
+ @As(JAXBBinding.class)
+ JAXB binder;
+
+ @Inject
FragmentParser parser;
@Inject
@As(CdkEntityResolver.class)
EntityResolver2 resolver;
- @Inject
- @As(JAXBBinding.class)
- JAXB binder;
+ @Mock
+ @Source(Sources.FACES_CONFIGS)
+ private FileManager configSource;
@Mock
@Source(Sources.RENDERER_TEMPLATES)
private FileManager templatesSource;
- @Mock
- @Source(Sources.FACES_CONFIGS)
- private FileManager configSource;
-
@Override
public void configure(Binder binder) {
super.configure(binder);
@@ -82,30 +82,21 @@
}
@Test
- public void parserTest() throws Exception {
+ public void nestedXincludeTest() throws Exception {
Collection<PropertyBase> properties =
- parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
+ parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
- assertEquals(3, properties.size());
- }
-
- @Test
- public void xincludeTest() throws Exception {
-
- Collection<PropertyBase> properties =
- parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
-
assertEquals(2, properties.size());
}
@Test
- public void nestedXincludeTest() throws Exception {
+ public void parserTest() throws Exception {
Collection<PropertyBase> properties =
- parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
+ parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
- assertEquals(2, properties.size());
+ assertEquals(3, properties.size());
}
@Test
@@ -117,7 +108,7 @@
assertEquals(1, properties.size());
PropertyBase property = Iterables.getOnlyElement(properties);
- assertEquals("ontest2",property.getName());
+ assertEquals("ontest2", property.getName());
assertEquals("int", property.getType().getName());
assertEquals("test2 property", property.getDescription());
@@ -137,8 +128,17 @@
assertEquals(2, signature.size());
- String alias = property.getAliasFor();
+ String alias = property.getAliasFor();
assertEquals("bar", alias);
}
+
+ @Test
+ public void xincludeTest() throws Exception {
+
+ Collection<PropertyBase> properties =
+ parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
+
+ assertEquals(2, properties.size());
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbTestBase.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -10,6 +10,14 @@
public abstract class JaxbTestBase extends CdkTestBase {
protected static final String XML_PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ protected <T> String marshal(T root) {
+ ByteArrayOutputStream xml = new ByteArrayOutputStream();
+
+ JAXB.marshal(root, xml);
+
+ return new String(xml.toByteArray());
+ }
+
protected <T> T unmarshal(Class<T> type, String src) {
StringBuilder xml = new StringBuilder(XML_PROLOG);
@@ -20,12 +28,4 @@
return result;
}
-
- protected <T> String marshal(T root) {
- ByteArrayOutputStream xml = new ByteArrayOutputStream();
-
- JAXB.marshal(root, xml);
-
- return new String(xml.toByteArray());
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbUnmarshalTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -40,26 +40,27 @@
*/
public class JaxbUnmarshalTest extends JaxbTestBase {
@Test
- public void testRootElement() throws Exception {
+ public void testExtensions() throws Exception {
Root root =
unmarshal(
Root.class,
- "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>");
+ "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value><extension><e:myExtension xmlns:e=\"http://foo.bar/extensions\">eee</e:myExtension><s:foo xmlns:s=\"urn:foo\">foo</s:foo></extension></children></root-config>");
+ Set<Child> children = root.getChildren();
- assertEquals("foo", root.getName());
+ assertEquals(1, children.size());
- Set<Child> children = root.getChildren();
+ Child child = children.iterator().next();
- assertEquals(1, children.size());
- assertEquals("xxx", children.iterator().next().getId());
+ assertEquals(1, child.getExtension().getExtensions().size());
+ assertEquals("eee", child.getWrapped());
}
@Test
- public void testUniqueElement() throws Exception {
+ public void testRootElement() throws Exception {
Root root =
unmarshal(
Root.class,
- "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>");
+ "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>");
assertEquals("foo", root.getName());
@@ -70,18 +71,17 @@
}
@Test
- public void testExtensions() throws Exception {
+ public void testUniqueElement() throws Exception {
Root root =
unmarshal(
Root.class,
- "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value><extension><e:myExtension xmlns:e=\"http://foo.bar/extensions\">eee</e:myExtension><s:foo xmlns:s=\"urn:foo\">foo</s:foo></extension></children></root-config>");
+ "<root-config xmlns='http://foo.bar/schema' ><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>");
+
+ assertEquals("foo", root.getName());
+
Set<Child> children = root.getChildren();
assertEquals(1, children.size());
-
- Child child = children.iterator().next();
-
- assertEquals(1, child.getExtension().getExtensions().size());
- assertEquals("eee", child.getWrapped());
+ assertEquals("xxx", children.iterator().next().getId());
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -22,6 +22,8 @@
package org.richfaces.cdk.xmlconfig;
+import java.util.Set;
+
import org.junit.Test;
import org.richfaces.cdk.generate.taglib.TaglibGeneratorVisitor;
import org.richfaces.cdk.model.ClassName;
@@ -32,8 +34,6 @@
import org.richfaces.cdk.model.Taglib;
import org.richfaces.cdk.model.ValidatorModel;
-import java.util.Set;
-
/**
* @author akolonitsky
* @since Feb 3, 2010
@@ -61,23 +61,23 @@
taglib.setUri("http://foo.bar/a4j");
library.setTaglib(taglib);
TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor();
- library.accept(visitor,library);
-// visitor.generate();
+ library.accept(visitor, library);
+ // visitor.generate();
// TODO validate result
}
+ private PropertyBase addAttribute(ValidatorModel validator, String attributeName, Class<?> type, boolean generate) {
+ PropertyBase attribute = validator.getOrCreateAttribute(attributeName);
+ attribute.setType(new ClassName(type));
+ attribute.setGenerate(generate);
+ return attribute;
+ }
+
private EventName getEvent(String name, boolean defaultEvent) {
EventName event = new EventName();
event.setName(name);
event.setDefaultEvent(defaultEvent);
return event;
}
-
- private PropertyBase addAttribute(ValidatorModel validator, String attributeName, Class<?> type, boolean generate) {
- PropertyBase attribute = validator.getOrCreateAttribute(attributeName);
- attribute.setType(new ClassName(type));
- attribute.setGenerate(generate);
- return attribute;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/XmlTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/XmlTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/XmlTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -21,21 +21,26 @@
package org.richfaces.cdk.xmlconfig;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.transform.stream.StreamResult;
+
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Validator;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Assert;
import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.CdkTestRunner;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import javax.xml.transform.stream.StreamResult;
-import java.io.*;
-
import com.google.inject.Inject;
/**
@@ -45,32 +50,13 @@
@RunWith(CdkTestRunner.class)
public abstract class XmlTest extends JaxbTestBase {
- static {
- XMLUnit.setControlEntityResolver(new CdkEntityResolver());
- }
-
@Inject
protected Logger log;
- protected void validateXml(StringWriter facesConfig, String schemaLocation) throws SAXException, IOException {
- InputSource is = new InputSource(new StringReader(facesConfig.toString()));
- Validator validator = new Validator(is);
- validator.useXMLSchema(true);
- InputSource source = new CdkEntityResolver()
- .resolveEntity(null, schemaLocation);
- validator.setJAXP12SchemaSource(source);
-
- validator.assertIsValid();
+ static {
+ XMLUnit.setControlEntityResolver(new CdkEntityResolver());
}
- protected void validateXml(StringWriter facesConfig) throws SAXException, IOException {
- validateXml(facesConfig, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION);
- }
-
- protected void validateTaglib(StringWriter facesConfig) throws SAXException, IOException {
- validateXml(facesConfig, ComponentLibrary.TAGLIB_SCHEMA_LOCATION);
- }
-
protected void checkXmlStructure(StringWriter writer) throws SAXException, IOException {
Class<?> testClass = this.getClass();
InputStream expectedFacesConfigFile = testClass.getResourceAsStream(testClass.getSimpleName() + ".xml");
@@ -78,9 +64,7 @@
return;
}
XMLUnit.setNormalizeWhitespace(true);
- Diff xmlDiff = new Diff(
- new StringReader(writer.toString()),
- new InputStreamReader(expectedFacesConfigFile));
+ Diff xmlDiff = new Diff(new StringReader(writer.toString()), new InputStreamReader(expectedFacesConfigFile));
Assert.assertTrue("XML was not similar:" + xmlDiff.toString(), xmlDiff.similar());
}
@@ -90,8 +74,26 @@
StreamResult result = new StreamResult(writer);
JAXBBinding jaxbBinding = new JAXBBinding();
- jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION,
- new FacesConfigAdapter().marshal(library));
+ jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION, new FacesConfigAdapter()
+ .marshal(library));
return writer;
}
+
+ protected void validateTaglib(StringWriter facesConfig) throws SAXException, IOException {
+ validateXml(facesConfig, ComponentLibrary.TAGLIB_SCHEMA_LOCATION);
+ }
+
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException {
+ validateXml(facesConfig, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION);
+ }
+
+ protected void validateXml(StringWriter facesConfig, String schemaLocation) throws SAXException, IOException {
+ InputSource is = new InputSource(new StringReader(facesConfig.toString()));
+ Validator validator = new Validator(is);
+ validator.useXMLSchema(true);
+ InputSource source = new CdkEntityResolver().resolveEntity(null, schemaLocation);
+ validator.setJAXP12SchemaSource(source);
+
+ validator.assertIsValid();
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -22,17 +22,17 @@
package org.richfaces.cdk.xmlconfig.testmodel;
+import java.io.StringWriter;
+
import org.junit.Test;
+import org.richfaces.cdk.model.AttributeModel;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
-import org.richfaces.cdk.model.AttributeModel;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.xmlconfig.XmlTest;
-import java.io.StringWriter;
-
/**
* @author akolonitsky
* @since Jan 21, 2010
@@ -58,7 +58,7 @@
// Jaxb marshaling
StringWriter facesConfig = generateFacesConfig(library);
log.debug(facesConfig.toString());
-
+
// Checks
checkXmlStructure(facesConfig);
validateXml(facesConfig);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -42,53 +42,108 @@
*/
@XmlType(name = "ChildType", namespace = Root.HTTP_FOO_BAR_SCHEMA)
public class Child implements Id {
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class Extension {
+ private List<Element> extensions = new ArrayList<Element>();
+ private Child parent;
+
+ // This method is called after all the properties (except IDREF) are unmarshalled for this object,
+ // but before this object is set to the parent object.
+ void afterUnmarshal(Unmarshaller u, Object parent) {
+ }
+
+ // This method is called immediately after the object is created and before the unmarshalling of this
+ // object begins. The callback provides an opportunity to initialize JavaBean properties prior to unmarshalling.
+ void beforeUnmarshal(Unmarshaller u, Object parent) {
+ this.parent = (Child) parent;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the extensions
+ */
+ @XmlAnyElement
+ public List<Element> getExtensions() {
+ return extensions;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the myExtension
+ */
+ @XmlElement(namespace = Root.EXTENSIONS_NAMESPACE)
+ public String getMyExtension() {
+ return parent.getWrapped();
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param extensions
+ * the extensions to set
+ */
+ public void setExtensions(List<Element> extensions) {
+ this.extensions = extensions;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param myExtension
+ * the myExtension to set
+ */
+ public void setMyExtension(String myExtension) {
+ parent.setWrapped(myExtension);
+ }
+ }
private Extension extension;
private String id;
private String value;
+
private String wrapped;
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.xmlconfig.testmodel.Id#getId()
+ * @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
- public String getId() {
- return id;
- }
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param id
- * the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
+ if (obj == null) {
+ return false;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the value
- */
- @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
- public String getValue() {
- return value;
- }
+ if (!(obj instanceof Child)) {
+ return false;
+ }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param value
- * the value to set
- */
- public void setValue(String value) {
- this.value = value;
+ Child other = (Child) obj;
+
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+
+ return true;
}
@XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
@@ -100,29 +155,36 @@
return extension;
}
- public void setExtension(Extension extension) {
- this.extension = extension;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.xmlconfig.testmodel.Id#getId()
+ */
+ @Override
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getId() {
+ return id;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @return the wrapped
+ * @return the value
*/
- public String getWrapped() {
- return wrapped;
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
+ public String getValue() {
+ return value;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param wrapped
- * the wrapped to set
+ * @return the wrapped
*/
- public void setWrapped(String wrapped) {
- this.wrapped = wrapped;
+ public String getWrapped() {
+ return wrapped;
}
/*
@@ -140,102 +202,40 @@
return result;
}
- /*
- * (non-Javadoc)
+ public void setExtension(Extension extension) {
+ this.extension = extension;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
*
- * @see java.lang.Object#equals(java.lang.Object)
+ * @param id
+ * the id to set
*/
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
+ public void setId(String id) {
+ this.id = id;
+ }
- if (obj == null) {
- return false;
- }
-
- if (!(obj instanceof Child)) {
- return false;
- }
-
- Child other = (Child) obj;
-
- if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
-
- return true;
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param value
+ * the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @author asmirnov(a)exadel.com
- *
+ * @param wrapped
+ * the wrapped to set
*/
- public static class Extension {
- private List<Element> extensions = new ArrayList<Element>();
- private Child parent;
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the myExtension
- */
- @XmlElement(namespace = Root.EXTENSIONS_NAMESPACE)
- public String getMyExtension() {
- return parent.getWrapped();
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param myExtension
- * the myExtension to set
- */
- public void setMyExtension(String myExtension) {
- parent.setWrapped(myExtension);
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the extensions
- */
- @XmlAnyElement
- public List<Element> getExtensions() {
- return extensions;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param extensions
- * the extensions to set
- */
- public void setExtensions(List<Element> extensions) {
- this.extensions = extensions;
- }
-
- // This method is called immediately after the object is created and before the unmarshalling of this
- // object begins. The callback provides an opportunity to initialize JavaBean properties prior to unmarshalling.
- void beforeUnmarshal(Unmarshaller u, Object parent) {
- this.parent = (Child) parent;
- }
-
- // This method is called after all the properties (except IDREF) are unmarshalled for this object,
- // but before this object is set to the parent object.
- void afterUnmarshal(Unmarshaller u, Object parent) {
- }
+ public void setWrapped(String wrapped) {
+ this.wrapped = wrapped;
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -21,6 +21,8 @@
package org.richfaces.cdk.xmlconfig.testmodel;
+import java.io.StringWriter;
+
import org.junit.Test;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -28,8 +30,6 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.xmlconfig.XmlTest;
-import java.io.StringWriter;
-
/**
* @author akolonitsky
* @since Jan 10, 2010
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -66,6 +66,10 @@
@As(JAXBBinding.class)
JAXB binding;
+ @Mock
+ @Source(Sources.FACES_CONFIGS)
+ FileManager configSource;
+
@Inject
@As(CdkEntityResolver.class)
EntityResolver2 resolver;
@@ -74,26 +78,6 @@
@Source(Sources.RENDERER_TEMPLATES)
FileManager templatesSource;
- @Mock
- @Source(Sources.FACES_CONFIGS)
- FileManager configSource;
-
- @Override
- public void configure(Binder binder) {
- super.configure(binder);
- binder.bind(CdkClassLoader.class).toInstance(createClassLoader());
- }
-
- protected void validateXml(StringWriter facesConfig) throws SAXException, IOException, URISyntaxException {
- InputSource is = new InputSource(new StringReader(facesConfig.toString()));
- Validator validator = new Validator(is);
- validator.useXMLSchema(true);
- InputSource source = new InputSource(getJavaFile("META-INF/schema/web-facesconfig_2_0.xsd").toURI().toString());
- validator.setJAXP12SchemaSource(source);
-
- validator.assertIsValid();
- }
-
protected void checkXmlStructure(StringWriter writer) throws SAXException, IOException {
Class<?> testClass = this.getClass();
InputStream expectedFacesConfigFile = testClass.getResourceAsStream(testClass.getSimpleName() + ".xml");
@@ -106,6 +90,12 @@
Assert.assertTrue("XML was not similar", xmlDiff.similar());
}
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkClassLoader.class).toInstance(createClassLoader());
+ }
+
protected StringWriter generateFacesConfig(ComponentLibrary library) throws Exception {
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
@@ -113,4 +103,14 @@
binding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION, new FacesConfigAdapter().marshal(library));
return writer;
}
+
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException, URISyntaxException {
+ InputSource is = new InputSource(new StringReader(facesConfig.toString()));
+ Validator validator = new Validator(is);
+ validator.useXMLSchema(true);
+ InputSource source = new InputSource(getJavaFile("META-INF/schema/web-facesconfig_2_0.xsd").toURI().toString());
+ validator.setJAXP12SchemaSource(source);
+
+ validator.assertIsValid();
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Root.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -48,43 +48,43 @@
* <p class="changed_added_4_0">
* </p>
*
- * @return the name
+ * @return the children
*/
@XmlElement(namespace = HTTP_FOO_BAR_SCHEMA)
- public String getName() {
- return name;
+ public Set<Child> getChildren() {
+ return children;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param name
- * the name to set
+ * @return the name
*/
- public void setName(String name) {
- this.name = name;
+ @XmlElement(namespace = HTTP_FOO_BAR_SCHEMA)
+ public String getName() {
+ return name;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @return the children
+ * @param children
+ * the children to set
*/
- @XmlElement(namespace = HTTP_FOO_BAR_SCHEMA)
- public Set<Child> getChildren() {
- return children;
+ public void setChildren(Set<Child> children) {
+ this.children = children;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param children
- * the children to set
+ * @param name
+ * the name to set
*/
- public void setChildren(Set<Child> children) {
- this.children = children;
+ public void setName(String name) {
+ this.name = name;
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -49,6 +49,6 @@
// Checks
checkXmlStructure(facesConfig);
- validateXml(facesConfig);
+ validateXml(facesConfig);
}
}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/package-info.java 2010-05-25 18:17:01 UTC (rev 17238)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/package-info.java 2010-05-25 22:05:22 UTC (rev 17239)
@@ -14,8 +14,8 @@
*/
@XmlAccessorType(XmlAccessType.NONE)
@javax.xml.bind.annotation.XmlSchema(namespace = Root.HTTP_FOO_BAR_SCHEMA, xmlns = {
- @javax.xml.bind.annotation.XmlNs(prefix = "", namespaceURI = Root.HTTP_FOO_BAR_SCHEMA),
- @javax.xml.bind.annotation.XmlNs(prefix = "ext", namespaceURI = Root.EXTENSIONS_NAMESPACE) })
+ @javax.xml.bind.annotation.XmlNs(prefix = "", namespaceURI = Root.HTTP_FOO_BAR_SCHEMA),
+ @javax.xml.bind.annotation.XmlNs(prefix = "ext", namespaceURI = Root.EXTENSIONS_NAMESPACE) })
package org.richfaces.cdk.xmlconfig.testmodel;
import javax.xml.bind.annotation.XmlAccessType;
15 years, 7 months
JBoss Rich Faces SVN: r17238 - in root/core/trunk/impl/src: test/java/org/richfaces/context and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-25 14:17:01 -0400 (Tue, 25 May 2010)
New Revision: 17238
Removed:
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java
Modified:
root/core/trunk/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java
Log:
https://jira.jboss.org/browse/RF-8682
Deleted: root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2010-05-25 18:10:36 UTC (rev 17237)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2010-05-25 18:17:01 UTC (rev 17238)
@@ -1,197 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - 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.component;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
-import javax.faces.el.ValueBinding;
-
-/**
- * Inner class for build event string for parent component.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:38 $ Disadvantages -
- * not rebuild event string setted as EL expression. TODO - save
- * expressions for build event string at render phase.
- */
-public class EventValueBinding extends ValueBinding implements StateHolder {
- private static final long serialVersionUID = -6583167387542332290L;
-
- /**
- * current update component. transient since saved state as component.
- */
- private transient AjaxSupport component = null;
- private String componentId;
-
- /**
- * Default constructor for restoreState.
- */
- public EventValueBinding() {
- }
-
- /**
- * Constructor for build from AjaxComponent.
- *
- * @param update
- */
- public EventValueBinding(AjaxSupport update) {
- component = update;
-
- // _componentId = string;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getType(javax.faces.context.FacesContext)
- */
- @Override
- public Class getType(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException {
- return String.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getValue(javax.faces.context.FacesContext)
- */
- @Override
- public Object getValue(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException {
- if (((UIComponent) getComponent(facesContext)).isRendered()) {
- return getComponent(facesContext).getEventString();
- } else {
- return null;
- }
- }
-
- private AjaxSupport getComponent(FacesContext facesContext) throws EvaluationException {
- if (component == null) {
- UIComponent uiComponent = facesContext.getViewRoot().findComponent(componentId);
-
- if ((null != uiComponent) && (uiComponent instanceof AjaxSupport)) {
- component = (AjaxSupport) uiComponent;
- } else {
- throw new EvaluationException(Messages.getMessage(Messages.COMPONENT_NOT_FOUND, componentId));
- }
- }
-
- return component;
- }
-
- /**
- * @param component the component to set
- */
- public void setComponent(AjaxSupport component) {
- this.component = component;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#isReadOnly(javax.faces.context.FacesContext)
- */
- @Override
- public boolean isReadOnly(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException {
-
- // TODO Auto-generated method stub
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#setValue(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- @Override
- public void setValue(FacesContext facesContext, Object value)
- throws EvaluationException, PropertyNotFoundException {
-
- throw new EvaluationException(Messages.getMessage(Messages.EVENT_IS_READ_ONLY));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- if (null == component) {
- return componentId;
- } else {
- return AjaxRendererUtils.getAbsoluteId((UIComponent) getComponent(context));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
-
- // TODO Auto-generated method stub
- componentId = (String) state;
- }
-
- /*
- * (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#setTransient(boolean)
- */
- public void setTransient(boolean newTransientValue) {
-
- // TODO Auto-generated method stub
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getExpressionString()
- */
- @Override
- public String getExpressionString() {
-
- // FacesContext context = FacesContext.getCurrentInstance();
- // UIComponent component = (UIComponent) getComponent(context);
- // return "#{ajaxSupport["+component.getClientId(context)+"]}";
- return null;
- }
-}
Deleted: root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java 2010-05-25 18:10:36 UTC (rev 17237)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java 2010-05-25 18:17:01 UTC (rev 17238)
@@ -1,207 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - 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.component;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Maksim Kaszynski
- */
-public class EventValueExpression extends ValueExpression implements StateHolder {
- private static final long serialVersionUID = -6583167387542332290L;
-
- /**
- * current update component. transient since saved state as component.
- */
- private transient AjaxSupport component = null;
- private String componentId;
-
- public EventValueExpression() {
-
- // TODO Auto-generated constructor stub
- }
-
- public EventValueExpression(AjaxSupport component) {
- super();
- this.component = component;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.Expression#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
-
- // TODO Auto-generated method stub
- return false;
- }
-
- private AjaxSupport getComponent(FacesContext facesContext) throws ELException {
- if (component == null) {
- UIComponent uiComponent = facesContext.getViewRoot().findComponent(componentId);
-
- if ((null != uiComponent) && (uiComponent instanceof AjaxSupport)) {
- component = (AjaxSupport) uiComponent;
- } else {
- throw new ELException(Messages.getMessage(Messages.COMPONENT_NOT_FOUND, componentId));
- }
- }
-
- return component;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#getExpectedType()
- */
- @Override
- public Class<?> getExpectedType() {
- return String.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.Expression#getExpressionString()
- */
- @Override
- public String getExpressionString() {
-
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#getType(javax.el.ELContext)
- */
- @Override
- public Class<?> getType(ELContext context) {
- return String.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
- */
- @Override
- public Object getValue(ELContext context) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- AjaxSupport component = getComponent(facesContext);
-
- if (((UIComponent) component).isRendered()) {
- return component.getEventString();
- } else {
- return null;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.Expression#hashCode()
- */
- @Override
- public int hashCode() {
-
- // TODO Auto-generated method stub
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.Expression#isLiteralText()
- */
- @Override
- public boolean isLiteralText() {
-
- // TODO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
- */
- @Override
- public boolean isReadOnly(ELContext context) {
- return true;
- }
-
- public boolean isTransient() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- componentId = (String) state;
- }
-
- public Object saveState(FacesContext context) {
- if (null == component) {
- return componentId;
- } else {
- return AjaxRendererUtils.getAbsoluteId((UIComponent) getComponent(context));
- }
- }
-
- /**
- * @param component the component to set
- */
- public void setComponent(AjaxSupport component) {
- this.component = component;
- }
-
- public void setTransient(boolean newTransientValue) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#setValue(javax.el.ELContext,
- * java.lang.Object)
- */
- @Override
- public void setValue(ELContext context, Object value) {
- throw new ELException(Messages.getMessage(Messages.EVENT_IS_READ_ONLY));
- }
-}
Modified: root/core/trunk/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java
===================================================================
--- root/core/trunk/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java 2010-05-25 18:10:36 UTC (rev 17237)
+++ root/core/trunk/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java 2010-05-25 18:17:01 UTC (rev 17238)
@@ -44,9 +44,7 @@
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.application.Application;
-import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIData;
import javax.faces.component.UIForm;
import javax.faces.component.UIOutput;
import javax.faces.component.UIViewRoot;
@@ -66,29 +64,30 @@
/**
* Tested view structure:
+ * <ul>
+ * <li>a4j:table is AjaxTableComponentImpl</li>
+ * </ul>
* <pre>
* <h:form id="myForm">
* <a4j:outputText id="outerOutput" />
*
- * <h:dataTable id="table" var="item" value="['Item 0',... ,'Item 1']">
+ * <a4j:table id="table" var="item" value="['Item 0',... ,'Item 1']">
* <f:facet name="header">
* <h:outputText id="theHeader" />
* </f:facet>
*
- * <h:column id="col">
- * <a4j:outputText id="nestedOutput" value="#{item}" />
+ * <a4j:outputText id="nestedOutput" value="#{item}" />
*
- * <h:outputText id="nestedText" value="#{item}" />
+ * <h:outputText id="nestedText" value="#{item}" />
*
- * <a4j:table id="nestedTable" value="['Nested item 0',... ,'Nested item 2']" var="nestedItem">
- * <f:facet name="footer">
- * <h:outputText id="nestedTableFooter" value="#{item}" />
- * </f:facet>
+ * <a4j:table id="nestedTable" value="['Nested item 0',... ,'Nested item 2']" var="nestedItem">
+ * <f:facet name="footer">
+ * <h:outputText id="nestedTableFooter" value="#{item}" />
+ * </f:facet>
*
- * <h:outputText id="nestedTableText" value="#{nestedItem}" />
- * </a4j:table>
- * </h:column>
- * </h:dataTable>
+ * <h:outputText id="nestedTableText" value="#{nestedItem}" />
+ * </a4j:table>
+ * </a4j:table>
* </h:form>
* </pre>
*
@@ -136,10 +135,8 @@
private AjaxOutputComponentImpl outerOutput;
- private UIData table;
+ private AjaxTableComponentImpl table;
- private UIColumn column;
-
private UIOutput dataHeader;
private AjaxOutputComponentImpl nestedOutput;
@@ -223,7 +220,7 @@
nestedText.setId("nestedText");
nestedText.setValueExpression("value", createTableVarValueExpression());
- column.getChildren().add(nestedText);
+ table.getChildren().add(nestedText);
}
private void createNestedOutput() {
@@ -232,7 +229,7 @@
nestedOutput.setId("nestedOutput");
nestedOutput.setValueExpression("value", createTableVarValueExpression());
- column.getChildren().add(nestedOutput);
+ table.getChildren().add(nestedOutput);
}
private void createOuterOutput() {
@@ -250,16 +247,6 @@
table.getFacets().put("header", dataHeader);
}
- private void createTableColumn() {
- column = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
- column.setId("col");
-
- table.getChildren().add(column);
- createNestedOutput();
- createNestedText();
- createNestedTable();
- }
-
private void createNestedTable() {
nestedTable = new AjaxTableComponentImpl();
nestedTable.setId("nestedTable");
@@ -268,7 +255,7 @@
createNestedTableData();
nestedTable.setValue(nestedTableData);
- column.getChildren().add(nestedTable);
+ table.getChildren().add(nestedTable);
createNestedTableText();
createNestedTableFooter();
@@ -291,7 +278,7 @@
}
private void createTable() {
- table = (UIData) application.createComponent(UIData.COMPONENT_TYPE);
+ table = new AjaxTableComponentImpl();
table.setId("table");
table.setVar("item");
@@ -299,7 +286,9 @@
table.setValue(tableData);
form.getChildren().add(table);
- createTableColumn();
+ createNestedOutput();
+ createNestedText();
+ createNestedTable();
createTableHeader();
}
@@ -343,7 +332,6 @@
facesContext = null;
application = null;
- column = null;
table = null;
dataHeader = null;
form = null;
@@ -490,7 +478,7 @@
assertEqualSets(tableClientIds, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(tableIds, renderingContext.getDirectSubtreeIdsToVisit(table));
- table.setRowIndex(0);
+ table.setRowKey(Integer.valueOf(0));
Set<String> nestedTableClientIds = asSet("myForm:table:0:nestedTable:1",
"myForm:table:0:nestedTable:nestedFooter");
@@ -499,7 +487,7 @@
assertEqualSets(nestedTableClientIds, renderingContext.getSubtreeIdsToVisit(nestedTable));
assertEqualSets(nestedTableIds, renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
- table.setRowIndex(-1);
+ table.setRowKey(null);
}
@Test
@@ -515,7 +503,7 @@
assertSame(VisitContext.ALL_IDS, renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowIndex(i);
+ table.setRowKey(Integer.valueOf(i));
assertSame(VisitContext.ALL_IDS, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedText", "nestedTable", "nestedOutput"),
@@ -525,7 +513,7 @@
assertEqualSets(asSet("0"), renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
}
- table.setRowIndex(-1);
+ table.setRowKey(null);
}
@Test
@@ -541,7 +529,7 @@
assertSame(VisitContext.ALL_IDS, renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowIndex(i);
+ table.setRowKey(Integer.valueOf(i));
assertSame(VisitContext.ALL_IDS, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedText", "nestedTable"), renderingContext.getDirectSubtreeIdsToVisit(table));
@@ -550,7 +538,7 @@
assertEqualSets(asSet("0"), renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
}
- table.setRowIndex(-1);
+ table.setRowKey(null);
}
@Test
@@ -565,7 +553,7 @@
assertSame(VisitContext.ALL_IDS, renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowIndex(i);
+ table.setRowKey(Integer.valueOf(i));
assertSame(VisitContext.ALL_IDS, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedTable"), renderingContext.getDirectSubtreeIdsToVisit(table));
@@ -574,7 +562,7 @@
assertTrue(renderingContext.getDirectSubtreeIdsToVisit(nestedTable).isEmpty());
}
- table.setRowIndex(-1);
+ table.setRowKey(null);
}
@Test
15 years, 7 months
JBoss Rich Faces SVN: r17237 - root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-25 14:10:36 -0400 (Tue, 25 May 2010)
New Revision: 17237
Added:
root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component/EventValueBinding.java
root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component/EventValueExpression.java
Log:
https://jira.jboss.org/browse/RF-8682
Copied: root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component/EventValueBinding.java (from rev 17230, root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java)
===================================================================
--- root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component/EventValueBinding.java (rev 0)
+++ root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2010-05-25 18:10:36 UTC (rev 17237)
@@ -0,0 +1,197 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - 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.component;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+
+/**
+ * Inner class for build event string for parent component.
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:38 $ Disadvantages -
+ * not rebuild event string setted as EL expression. TODO - save
+ * expressions for build event string at render phase.
+ */
+public class EventValueBinding extends ValueBinding implements StateHolder {
+ private static final long serialVersionUID = -6583167387542332290L;
+
+ /**
+ * current update component. transient since saved state as component.
+ */
+ private transient AjaxSupport component = null;
+ private String componentId;
+
+ /**
+ * Default constructor for restoreState.
+ */
+ public EventValueBinding() {
+ }
+
+ /**
+ * Constructor for build from AjaxComponent.
+ *
+ * @param update
+ */
+ public EventValueBinding(AjaxSupport update) {
+ component = update;
+
+ // _componentId = string;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#getType(javax.faces.context.FacesContext)
+ */
+ @Override
+ public Class getType(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException {
+ return String.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#getValue(javax.faces.context.FacesContext)
+ */
+ @Override
+ public Object getValue(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException {
+ if (((UIComponent) getComponent(facesContext)).isRendered()) {
+ return getComponent(facesContext).getEventString();
+ } else {
+ return null;
+ }
+ }
+
+ private AjaxSupport getComponent(FacesContext facesContext) throws EvaluationException {
+ if (component == null) {
+ UIComponent uiComponent = facesContext.getViewRoot().findComponent(componentId);
+
+ if ((null != uiComponent) && (uiComponent instanceof AjaxSupport)) {
+ component = (AjaxSupport) uiComponent;
+ } else {
+ throw new EvaluationException(Messages.getMessage(Messages.COMPONENT_NOT_FOUND, componentId));
+ }
+ }
+
+ return component;
+ }
+
+ /**
+ * @param component the component to set
+ */
+ public void setComponent(AjaxSupport component) {
+ this.component = component;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#isReadOnly(javax.faces.context.FacesContext)
+ */
+ @Override
+ public boolean isReadOnly(FacesContext facesContext) throws EvaluationException, PropertyNotFoundException {
+
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#setValue(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ @Override
+ public void setValue(FacesContext facesContext, Object value)
+ throws EvaluationException, PropertyNotFoundException {
+
+ throw new EvaluationException(Messages.getMessage(Messages.EVENT_IS_READ_ONLY));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ if (null == component) {
+ return componentId;
+ } else {
+ return AjaxRendererUtils.getAbsoluteId((UIComponent) getComponent(context));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+
+ // TODO Auto-generated method stub
+ componentId = (String) state;
+ }
+
+ /*
+ * (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#setTransient(boolean)
+ */
+ public void setTransient(boolean newTransientValue) {
+
+ // TODO Auto-generated method stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.el.ValueBinding#getExpressionString()
+ */
+ @Override
+ public String getExpressionString() {
+
+ // FacesContext context = FacesContext.getCurrentInstance();
+ // UIComponent component = (UIComponent) getComponent(context);
+ // return "#{ajaxSupport["+component.getClientId(context)+"]}";
+ return null;
+ }
+}
Copied: root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component/EventValueExpression.java (from rev 17230, root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java)
===================================================================
--- root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component/EventValueExpression.java (rev 0)
+++ root/ui-sandbox/core/trunk/src/main/java/org/ajax4jsf/component/EventValueExpression.java 2010-05-25 18:10:36 UTC (rev 17237)
@@ -0,0 +1,207 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - 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.component;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Maksim Kaszynski
+ */
+public class EventValueExpression extends ValueExpression implements StateHolder {
+ private static final long serialVersionUID = -6583167387542332290L;
+
+ /**
+ * current update component. transient since saved state as component.
+ */
+ private transient AjaxSupport component = null;
+ private String componentId;
+
+ public EventValueExpression() {
+
+ // TODO Auto-generated constructor stub
+ }
+
+ public EventValueExpression(AjaxSupport component) {
+ super();
+ this.component = component;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ private AjaxSupport getComponent(FacesContext facesContext) throws ELException {
+ if (component == null) {
+ UIComponent uiComponent = facesContext.getViewRoot().findComponent(componentId);
+
+ if ((null != uiComponent) && (uiComponent instanceof AjaxSupport)) {
+ component = (AjaxSupport) uiComponent;
+ } else {
+ throw new ELException(Messages.getMessage(Messages.COMPONENT_NOT_FOUND, componentId));
+ }
+ }
+
+ return component;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getExpectedType()
+ */
+ @Override
+ public Class<?> getExpectedType() {
+ return String.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#getExpressionString()
+ */
+ @Override
+ public String getExpressionString() {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getType(javax.el.ELContext)
+ */
+ @Override
+ public Class<?> getType(ELContext context) {
+ return String.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
+ */
+ @Override
+ public Object getValue(ELContext context) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ AjaxSupport component = getComponent(facesContext);
+
+ if (((UIComponent) component).isRendered()) {
+ return component.getEventString();
+ } else {
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#hashCode()
+ */
+ @Override
+ public int hashCode() {
+
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.Expression#isLiteralText()
+ */
+ @Override
+ public boolean isLiteralText() {
+
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
+ */
+ @Override
+ public boolean isReadOnly(ELContext context) {
+ return true;
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ componentId = (String) state;
+ }
+
+ public Object saveState(FacesContext context) {
+ if (null == component) {
+ return componentId;
+ } else {
+ return AjaxRendererUtils.getAbsoluteId((UIComponent) getComponent(context));
+ }
+ }
+
+ /**
+ * @param component the component to set
+ */
+ public void setComponent(AjaxSupport component) {
+ this.component = component;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.el.ValueExpression#setValue(javax.el.ELContext,
+ * java.lang.Object)
+ */
+ @Override
+ public void setValue(ELContext context, Object value) {
+ throw new ELException(Messages.getMessage(Messages.EVENT_IS_READ_ONLY));
+ }
+}
15 years, 7 months