Author: alexsmirnov
Date: 2010-11-16 19:13:58 -0500 (Tue, 16 Nov 2010)
New Revision: 20062
Added:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
Removed:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
Log:
CODING IN PROGRESS - issue RF-9799: CSV code review
https://jira.jboss.org/browse/RF-9799
Copied:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java
(from rev 20061,
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java)
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ * 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.javascript;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * <p class="changed_added_4_0">This interface describes service that
determines JavaScript module and function
+ * for Java corresponded version ( both Converter and Validator )</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface ClientScriptService {
+
+ /**
+ * <p class="changed_added_4_0">Get description for client-side
version of Java implementation</p>
+ * @param facesContext TODO
+ * @param javaClass either Converter or Validator class.
+ * @return description of client-side script.
+ * @throws ScriptNotFoundException if no JavaScript code associated with Java class.
+ */
+ LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass) throws
ScriptNotFoundException;
+
+}
Property changes on:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java
(from rev 20061,
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java)
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,26 @@
+/**
+ *
+ */
+package org.richfaces.javascript;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation describes client-side version of Converter/validator.
+ * @author asmirnov
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.TYPE)
+public @interface ClientSideScript {
+
+ String library() default "";
+
+ String resource();
+
+ String function();
+
+}
Property changes on:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java
(from rev 20061,
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java)
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,39 @@
+/*
+ * $Id$
+ * 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.javascript;
+
+/**
+ * <p class="changed_added_4_0">
+ * This class contains information about JavaScript function in external library (
resource )
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface LibraryFunction extends LibraryScript {
+
+
+ String getName();
+
+}
Property changes on:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java
(from rev 20061,
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java)
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,103 @@
+package org.richfaces.javascript;
+
+import java.util.LinkedHashSet;
+
+
+import com.google.common.collect.Sets;
+
+/**
+ * This class represent information about external JavaScript library as JSF resource
+ *
+ * @author asmirnov
+ *
+ */
+public class LibraryResource {
+
+ private final String library;
+
+ private final String resourceName;
+
+ /**
+ * @param library
+ * @param resourceName
+ */
+ public LibraryResource(String library, String resourceName) {
+ this.library = library;
+ this.resourceName = resourceName;
+ }
+
+ /**
+ * @return the library
+ */
+ public String getLibrary() {
+ return library;
+ }
+
+ /**
+ * @return the resourceName
+ */
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((library == null) ? 0 : library.hashCode());
+ result = prime * result + ((resourceName == null) ? 0 :
resourceName.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ LibraryResource other = (LibraryResource) obj;
+ if (library == null) {
+ if (other.library != null) {
+ return false;
+ }
+ } else if (!library.equals(other.library)) {
+ return false;
+ }
+ if (resourceName == null) {
+ if (other.resourceName != null) {
+ return false;
+ }
+ } else if (!resourceName.equals(other.resourceName)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return getLibrary()+':'+getResourceName();
+ }
+
+ public static Iterable<LibraryResource> of(Iterable<LibraryScriptString>
scripts){
+ LinkedHashSet<LibraryResource> resources = Sets.newLinkedHashSet();
+ for (LibraryScriptString scriptString : scripts) {
+ resources.add(scriptString.getResource());
+ }
+ return resources;
+ }
+}
\ No newline at end of file
Property changes on:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
(from rev 20061,
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java)
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,38 @@
+/*
+ * $Id$
+ * 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.javascript;
+
+/**
+ * <p class="changed_added_4_0">
+ * This class contains information about JavaScript associated with JSF object (
converter or validator )
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface LibraryScript {
+
+ LibraryResource getResource();
+
+}
Property changes on:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
(from rev 20061,
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java)
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,13 @@
+package org.richfaces.javascript;
+
+import org.ajax4jsf.javascript.ScriptString;
+
+/**
+ * This interface describes JavaScript object with possible dependent resource.
+ * @author asmirnov
+ *
+ */
+public interface LibraryScriptString extends LibraryScript, ScriptString {
+
+
+}
\ No newline at end of file
Property changes on:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java
(from rev 20061,
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java)
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,24 @@
+package org.richfaces.javascript;
+
+public class ScriptNotFoundException extends Exception {
+
+ public ScriptNotFoundException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public ScriptNotFoundException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ScriptNotFoundException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ScriptNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Property changes on:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,45 +0,0 @@
-/*
- * $Id$
- * 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.validator;
-
-import javax.faces.context.FacesContext;
-
-/**
- * <p class="changed_added_4_0">This interface describes service that
determines JavaScript module and function
- * for Java corresponded version ( both Converter and Validator )</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface ClientScriptService {
-
- /**
- * <p class="changed_added_4_0">Get description for client-side
version of Java implementation</p>
- * @param facesContext TODO
- * @param javaClass either Converter or Validator class.
- * @return description of client-side script.
- * @throws ScriptNotFoundException if no JavaScript code associated with Java class.
- */
- LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass) throws
ScriptNotFoundException;
-
-}
Deleted:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,26 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation describes client-side version of Converter/validator.
- * @author asmirnov
- *
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-public @interface ClientSideScript {
-
- String library() default "";
-
- String resource();
-
- String function();
-
-}
Deleted:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,39 +0,0 @@
-/*
- * $Id$
- * 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.validator;
-
-/**
- * <p class="changed_added_4_0">
- * This class contains information about JavaScript function in external library (
resource )
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public interface LibraryFunction extends LibraryScript {
-
-
- String getName();
-
-}
Deleted:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,103 +0,0 @@
-package org.richfaces.validator;
-
-import java.util.LinkedHashSet;
-
-
-import com.google.common.collect.Sets;
-
-/**
- * This class represent information about external JavaScript library as JSF resource
- *
- * @author asmirnov
- *
- */
-public class LibraryResource {
-
- private final String library;
-
- private final String resourceName;
-
- /**
- * @param library
- * @param resourceName
- */
- public LibraryResource(String library, String resourceName) {
- this.library = library;
- this.resourceName = resourceName;
- }
-
- /**
- * @return the library
- */
- public String getLibrary() {
- return library;
- }
-
- /**
- * @return the resourceName
- */
- public String getResourceName() {
- return resourceName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((library == null) ? 0 : library.hashCode());
- result = prime * result + ((resourceName == null) ? 0 :
resourceName.hashCode());
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- LibraryResource other = (LibraryResource) obj;
- if (library == null) {
- if (other.library != null) {
- return false;
- }
- } else if (!library.equals(other.library)) {
- return false;
- }
- if (resourceName == null) {
- if (other.resourceName != null) {
- return false;
- }
- } else if (!resourceName.equals(other.resourceName)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return getLibrary()+':'+getResourceName();
- }
-
- public static Iterable<LibraryResource> of(Iterable<LibraryScriptString>
scripts){
- LinkedHashSet<LibraryResource> resources = Sets.newLinkedHashSet();
- for (LibraryScriptString scriptString : scripts) {
- resources.add(scriptString.getResource());
- }
- return resources;
- }
-}
\ No newline at end of file
Deleted:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,38 +0,0 @@
-/*
- * $Id$
- * 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.validator;
-
-/**
- * <p class="changed_added_4_0">
- * This class contains information about JavaScript associated with JSF object (
converter or validator )
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public interface LibraryScript {
-
- LibraryResource getResource();
-
-}
Deleted:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,13 +0,0 @@
-package org.richfaces.validator;
-
-import org.ajax4jsf.javascript.ScriptString;
-
-/**
- * This interface describes JavaScript object with possible dependent resource.
- * @author asmirnov
- *
- */
-public interface LibraryScriptString extends LibraryScript, ScriptString {
-
-
-}
\ No newline at end of file
Deleted:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java
===================================================================
---
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,24 +0,0 @@
-package org.richfaces.validator;
-
-public class ScriptNotFoundException extends Exception {
-
- public ScriptNotFoundException() {
- // TODO Auto-generated constructor stub
- }
-
- public ScriptNotFoundException(String message) {
- super(message);
- // TODO Auto-generated constructor stub
- }
-
- public ScriptNotFoundException(Throwable cause) {
- super(cause);
- // TODO Auto-generated constructor stub
- }
-
- public ScriptNotFoundException(String message, Throwable cause) {
- super(message, cause);
- // TODO Auto-generated constructor stub
- }
-
-}
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -28,19 +28,19 @@
import javax.validation.ValidationException;
import org.richfaces.el.ValueExpressionAnalayserImpl;
+import org.richfaces.javascript.ClientScriptService;
+import org.richfaces.javascript.ClientScriptServiceImpl;
+import org.richfaces.javascript.ClientServiceConfigParser;
+import org.richfaces.javascript.LibraryFunction;
import org.richfaces.validator.BeanValidator;
import org.richfaces.validator.BeanValidatorFactory;
import org.richfaces.validator.BeanValidatorService;
import org.richfaces.validator.BeanValidatorServiceImpl;
-import org.richfaces.validator.ClientScriptService;
-import org.richfaces.validator.ClientScriptServiceImpl;
-import org.richfaces.validator.ClientServiceConfigParser;
import org.richfaces.validator.ConverterServiceImpl;
import org.richfaces.validator.DummyBeanValidatorService;
import org.richfaces.validator.FacesConverterService;
import org.richfaces.validator.FacesValidatorService;
import org.richfaces.validator.FacesValidatorServiceImpl;
-import org.richfaces.validator.LibraryFunction;
import org.richfaces.validator.NullValidator;
import org.richfaces.validator.ObjectValidator;
import org.richfaces.validator.RichFacesBeanValidatorFactory;
Copied:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java
(from rev 20061,
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java)
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,74 @@
+/**
+ *
+ */
+package org.richfaces.javascript;
+
+import java.util.Map;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.util.Strings;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ClientScriptServiceImpl implements ClientScriptService {
+
+ private static final String TEXT_JAVASCRIPT = "text/javascript";
+
+ private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
+
+ private final Map<Class<?>, LibraryFunction> defaultMapping;
+
+ public ClientScriptServiceImpl(Map<Class<?>, LibraryFunction>
defaultMapping) {
+ this.defaultMapping = defaultMapping;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.validator.ClientScriptService#getScript(java.lang.Class)
+ */
+ public LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass)
throws ScriptNotFoundException {
+ if (null == facesContext || null == javaClass) {
+ throw new NullPointerException();
+ }
+ LibraryFunction function;
+ try {
+ function = getScriptResource(facesContext, javaClass);
+ } catch (ScriptNotFoundException e) {
+ if (defaultMapping.containsKey(javaClass)) {
+ function = defaultMapping.get(javaClass);
+ } else {
+ function = getScriptFromAnnotation(javaClass);
+ }
+ }
+ return function;
+ }
+
+ private LibraryFunction getScriptFromAnnotation(Class<?> javaClass) throws
ScriptNotFoundException {
+ if (javaClass.isAnnotationPresent(ClientSideScript.class)) {
+ ClientSideScript clientSideScript =
javaClass.getAnnotation(ClientSideScript.class);
+ return new LibraryFunctionImplementation(clientSideScript.library(),
clientSideScript.resource(), clientSideScript.function());
+ } else {
+ throw new ScriptNotFoundException();
+ }
+ }
+
+ private LibraryFunction getScriptResource(FacesContext facesContext, Class<?>
javaClass)
+ throws ScriptNotFoundException {
+ ResourceHandler resourceHandler =
facesContext.getApplication().getResourceHandler();
+ String resourceName = javaClass.getSimpleName() + ".js";
+ Resource facesResource = resourceHandler.createResource(resourceName,
ORG_RICHFACES_CSV, TEXT_JAVASCRIPT);
+ if (null != facesResource) {
+ final String functionName =
Strings.firstToLowerCase(javaClass.getSimpleName());
+ return new LibraryFunctionImplementation(ORG_RICHFACES_CSV,resourceName,
functionName);
+ } else {
+ throw new ScriptNotFoundException();
+ }
+ }
+
+}
Property changes on:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
(from rev 20061,
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java)
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.richfaces.javascript;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.xml.bind.JAXB;
+
+import org.richfaces.validator.model.ClientSideScripts;
+import org.richfaces.validator.model.Component;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Maps;
+
+/**
+ * @author asmirnov
+ *
+ */
+public final class ClientServiceConfigParser {
+
+ private ClientServiceConfigParser() {
+ }
+
+ public static Map<Class<?>, LibraryFunction> parseConfig(String name) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (null == loader) {
+ loader = ClientServiceConfigParser.class.getClassLoader();
+ }
+ Builder<Class<?>, LibraryFunction> resultBuilder =
ImmutableMap.builder();
+ try {
+ Enumeration<URL> resources = loader.getResources(name);
+ while (resources.hasMoreElements()) {
+ URL url = (URL) resources.nextElement();
+ resultBuilder.putAll(parse(loader, url));
+ }
+ } catch (IOException e) {
+ return Collections.emptyMap();
+ }
+ return resultBuilder.build();
+ }
+
+ static Map<Class<?>, LibraryFunction> parse(ClassLoader loader, URL url)
{
+ Map<Class<?>, LibraryFunction> result = Maps.newHashMap();
+ try {
+ ClientSideScripts clientSideScripts = JAXB.unmarshal(url,
ClientSideScripts.class);
+ for (Component component : clientSideScripts.getComponent()) {
+ Class<?> componentClass = loader.loadClass(component.getType());
+ LibraryFunctionImplementation function = new
LibraryFunctionImplementation(component.getLibrary(),
+ component.getResource(), component.getFunction());
+ result.put(componentClass, function);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new FacesException("Class for component not found",e);
+ } catch (Exception e) {
+ throw new FacesException("Error parsing config file "+url,e);
+ }
+ return result;
+ }
+
+}
Property changes on:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
(from rev 20061,
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java)
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,25 @@
+package org.richfaces.javascript;
+
+
+final class LibraryFunctionImplementation implements LibraryFunction {
+ private final LibraryResource library;
+ private final String functionName;
+
+ LibraryFunctionImplementation(LibraryResource library, String functionName) {
+ this.library = library;
+ this.functionName = functionName;
+ }
+
+ LibraryFunctionImplementation(String library, String resource, String functionName)
{
+ this.library = new LibraryResource(library, resource);
+ this.functionName = functionName;
+ }
+
+ public LibraryResource getResource() {
+ return library;
+ }
+
+ public String getName() {
+ return functionName;
+ }
+}
\ No newline at end of file
Property changes on:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -3,7 +3,7 @@
import java.util.Collection;
import java.util.Collections;
-import org.richfaces.validator.LibraryResource;
+import org.richfaces.javascript.LibraryResource;
public class AjaxOnlyScript extends ValidatorScriptBase {
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -2,7 +2,7 @@
import java.util.Collection;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryScriptString;
public class ClientAndAjaxScript extends ClientOnlyScript{
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -3,8 +3,8 @@
import java.util.Collection;
import java.util.LinkedHashSet;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
import com.google.common.collect.Sets;
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -24,12 +24,12 @@
import org.richfaces.component.UIValidatorScript;
import org.richfaces.component.behavior.ClientValidatorBehavior;
import org.richfaces.component.behavior.ConverterNotFoundException;
-import org.richfaces.validator.ClientScriptService;
+import org.richfaces.javascript.ClientScriptService;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesObjectDescriptor;
-import org.richfaces.validator.LibraryFunction;
-import org.richfaces.validator.LibraryScriptString;
-import org.richfaces.validator.ScriptNotFoundException;
import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Lists;
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -3,7 +3,7 @@
import java.util.Collection;
import org.ajax4jsf.javascript.ScriptString;
-import org.richfaces.validator.LibraryResource;
+import org.richfaces.javascript.LibraryResource;
public interface ComponentValidatorScript extends ScriptString {
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -24,9 +24,9 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryFunction;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
/**
* <p class="changed_added_4_0">
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -4,8 +4,8 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.javascript.JSLiteral;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
/**
* This class represents "dummy" converter call ( just refference to
"value" variable )
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -16,7 +16,7 @@
import javax.faces.render.Renderer;
import org.richfaces.component.UIValidatorScript;
-import org.richfaces.validator.LibraryResource;
+import org.richfaces.javascript.LibraryResource;
import com.google.common.collect.Sets;
Deleted:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,74 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-import java.util.Map;
-
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.component.util.Strings;
-
-/**
- * @author asmirnov
- *
- */
-public class ClientScriptServiceImpl implements ClientScriptService {
-
- private static final String TEXT_JAVASCRIPT = "text/javascript";
-
- private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
-
- private final Map<Class<?>, LibraryFunction> defaultMapping;
-
- public ClientScriptServiceImpl(Map<Class<?>, LibraryFunction>
defaultMapping) {
- this.defaultMapping = defaultMapping;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.validator.ClientScriptService#getScript(java.lang.Class)
- */
- public LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass)
throws ScriptNotFoundException {
- if (null == facesContext || null == javaClass) {
- throw new NullPointerException();
- }
- LibraryFunction function;
- try {
- function = getScriptResource(facesContext, javaClass);
- } catch (ScriptNotFoundException e) {
- if (defaultMapping.containsKey(javaClass)) {
- function = defaultMapping.get(javaClass);
- } else {
- function = getScriptFromAnnotation(javaClass);
- }
- }
- return function;
- }
-
- private LibraryFunction getScriptFromAnnotation(Class<?> javaClass) throws
ScriptNotFoundException {
- if (javaClass.isAnnotationPresent(ClientSideScript.class)) {
- ClientSideScript clientSideScript =
javaClass.getAnnotation(ClientSideScript.class);
- return new LibraryFunctionImplementation(clientSideScript.library(),
clientSideScript.resource(), clientSideScript.function());
- } else {
- throw new ScriptNotFoundException();
- }
- }
-
- private LibraryFunction getScriptResource(FacesContext facesContext, Class<?>
javaClass)
- throws ScriptNotFoundException {
- ResourceHandler resourceHandler =
facesContext.getApplication().getResourceHandler();
- String resourceName = javaClass.getSimpleName() + ".js";
- Resource facesResource = resourceHandler.createResource(resourceName,
ORG_RICHFACES_CSV, TEXT_JAVASCRIPT);
- if (null != facesResource) {
- final String functionName =
Strings.firstToLowerCase(javaClass.getSimpleName());
- return new LibraryFunctionImplementation(ORG_RICHFACES_CSV,resourceName,
functionName);
- } else {
- throw new ScriptNotFoundException();
- }
- }
-
-}
Deleted:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,67 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.xml.bind.JAXB;
-
-import org.richfaces.validator.model.ClientSideScripts;
-import org.richfaces.validator.model.Component;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.collect.Maps;
-
-/**
- * @author asmirnov
- *
- */
-public final class ClientServiceConfigParser {
-
- private ClientServiceConfigParser() {
- }
-
- public static Map<Class<?>, LibraryFunction> parseConfig(String name) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (null == loader) {
- loader = ClientServiceConfigParser.class.getClassLoader();
- }
- Builder<Class<?>, LibraryFunction> resultBuilder =
ImmutableMap.builder();
- try {
- Enumeration<URL> resources = loader.getResources(name);
- while (resources.hasMoreElements()) {
- URL url = (URL) resources.nextElement();
- resultBuilder.putAll(parse(loader, url));
- }
- } catch (IOException e) {
- return Collections.emptyMap();
- }
- return resultBuilder.build();
- }
-
- static Map<Class<?>, LibraryFunction> parse(ClassLoader loader, URL url)
{
- Map<Class<?>, LibraryFunction> result = Maps.newHashMap();
- try {
- ClientSideScripts clientSideScripts = JAXB.unmarshal(url,
ClientSideScripts.class);
- for (Component component : clientSideScripts.getComponent()) {
- Class<?> componentClass = loader.loadClass(component.getType());
- LibraryFunctionImplementation function = new
LibraryFunctionImplementation(component.getLibrary(),
- component.getResource(), component.getFunction());
- result.put(componentClass, function);
- }
- } catch (ClassNotFoundException e) {
- throw new FacesException("Class for component not found",e);
- } catch (Exception e) {
- throw new FacesException("Error parsing config file "+url,e);
- }
- return result;
- }
-
-}
Deleted:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,24 +0,0 @@
-package org.richfaces.validator;
-
-final class LibraryFunctionImplementation implements LibraryFunction {
- private final LibraryResource library;
- private final String functionName;
-
- LibraryFunctionImplementation(LibraryResource library, String functionName) {
- this.library = library;
- this.functionName = functionName;
- }
-
- LibraryFunctionImplementation(String library, String resource, String functionName)
{
- this.library = new LibraryResource(library, resource);
- this.functionName = functionName;
- }
-
- public LibraryResource getResource() {
- return library;
- }
-
- public String getName() {
- return functionName;
- }
-}
\ No newline at end of file
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -9,8 +9,8 @@
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
+import org.richfaces.javascript.LibraryResource;
import org.richfaces.renderkit.html.ComponentValidatorScript;
-import org.richfaces.validator.LibraryResource;
/**
* @author asmirnov
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,7 +1,7 @@
package org.richfaces.component;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
final class Script implements LibraryScriptString {
private final String name;
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -6,10 +6,10 @@
import java.util.Collection;
import org.junit.Test;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.renderkit.html.ClientOnlyScript;
import org.richfaces.renderkit.html.ComponentValidatorScript;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
Copied:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
(from rev 20061,
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java)
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,126 @@
+/**
+ *
+ */
+package org.richfaces.javascript;
+
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.util.Map;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.validation.constraints.Max;
+
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Environment.Feature;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockController;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.javascript.ClientScriptServiceImpl;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.ScriptNotFoundException;
+import org.richfaces.validator.ValidatorWithFacesResource;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author asmirnov
+ *
+ */
+(a)RunWith(MockTestRunner.class)
+public class ClientScriptServiceTest {
+
+ private static final String TEXT_JAVASCRIPT = "text/javascript";
+
+ private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
+
+ private static final String RESOURCE_NAME =
ValidatorWithFacesResource.class.getSimpleName() + ".js";
+
+ @Mock
+ @Environment({ Feature.APPLICATION })
+ private MockFacesEnvironment environment;
+
+ @Mock
+ private ResourceHandler resourceHandler;
+
+ private MockController controller;
+
+ @Mock
+ private Resource resource;
+
+ @Mock
+ private LibraryFunction function;
+
+ private ClientScriptServiceImpl serviceImpl;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+
expect(environment.getApplication().getResourceHandler()).andStubReturn(resourceHandler);
+ Map<Class<?>, LibraryFunction> defaultMapping = ImmutableMap
+ .<Class<?>, LibraryFunction> of(Max.class, function);
+ serviceImpl = new ClientScriptServiceImpl(defaultMapping);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ controller.verify();
+ controller.release();
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.javascript.ClientScriptServiceImpl#getScript(FacesContext,
java.lang.Class)}.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetScriptAsJsfResource() throws Exception {
+ LibraryFunction script = getScript(resource, ValidatorWithFacesResource.class);
+ assertEquals(RESOURCE_NAME, script.getResource().getResourceName());
+ assertEquals(ORG_RICHFACES_CSV, script.getResource().getLibrary());
+ assertEquals("validatorWithFacesResource", script.getName());
+ }
+
+ @Test
+ public void testGetScriptFromAnnotation() throws Exception {
+ LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
+ assertEquals("baz.js", script.getResource().getResourceName());
+ assertEquals("bar", script.getResource().getLibrary());
+ assertEquals("foo", script.getName());
+ }
+
+ @Test
+ public void testGetScriptFromDefaultMapping() throws Exception {
+ LibraryFunction script = getScript(null, Max.class);
+ assertSame(function, script);
+ }
+
+ @Test
+ public void testGetScriptOverrideAnnotation() throws Exception {
+ Map<Class<?>, LibraryFunction> defaultMapping =
ImmutableMap.<Class<?>, LibraryFunction> of(
+ ValidatorWithFacesResource.class, function);
+ serviceImpl = new ClientScriptServiceImpl(defaultMapping);
+ LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
+ assertSame(function, script);
+ }
+
+ private LibraryFunction getScript(Resource resource, Class<?> serverSideType)
throws ScriptNotFoundException {
+ expect(resourceHandler.createResource(serverSideType.getSimpleName() +
".js", ORG_RICHFACES_CSV, TEXT_JAVASCRIPT)).andReturn(resource);
+ controller.replay();
+ LibraryFunction script = serviceImpl.getScript(environment.getFacesContext(),
serverSideType);
+ return script;
+ }
+
+}
Property changes on:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
(from rev 20061,
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java)
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
(rev 0)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -0,0 +1,45 @@
+package org.richfaces.javascript;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import javax.faces.FacesException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.javascript.ClientServiceConfigParser;
+import org.richfaces.javascript.LibraryFunction;
+
+public class ServiceConfigParserTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testParseConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig =
ClientServiceConfigParser.parseConfig("csv.xml");
+ assertEquals(2, parseConfig.size());
+ assertTrue(parseConfig.containsKey(String.class));
+ LibraryFunction libraryFunction = parseConfig.get(String.class);
+ assertEquals("stringConverter", libraryFunction.getName());
+ assertEquals("csv.js",
libraryFunction.getResource().getResourceName());
+ assertEquals("org.richfaces",
libraryFunction.getResource().getLibrary());
+ }
+
+ @Test(expected=FacesException.class)
+ public void testParseBadConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig =
ClientServiceConfigParser.parseConfig("badcsv.xml");
+ }
+ @Test()
+ public void testParseNoConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig =
ClientServiceConfigParser.parseConfig("non-exists-csv.xml");
+ assertEquals(0, parseConfig.size());
+ }
+}
Property changes on:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -18,11 +18,11 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.application.ServiceTracker;
-import org.richfaces.validator.ClientScriptService;
+import org.richfaces.javascript.ClientScriptService;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
-import org.richfaces.validator.LibraryFunction;
-import org.richfaces.validator.LibraryScriptString;
-import org.richfaces.validator.ScriptNotFoundException;
import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Iterables;
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -27,12 +27,12 @@
import org.jboss.test.faces.mock.MockTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesObjectDescriptor;
-import org.richfaces.validator.LibraryFunction;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
-import org.richfaces.validator.ScriptNotFoundException;
import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Lists;
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -7,7 +7,7 @@
import org.jboss.test.faces.mock.Mock;
import org.richfaces.component.behavior.BehaviorTestBase;
import org.richfaces.component.behavior.ClientValidatorBehavior;
-import org.richfaces.validator.LibraryResource;
+import org.richfaces.javascript.LibraryResource;
import com.google.common.collect.ImmutableMap;
Deleted:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,122 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
-import java.util.Map;
-
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.validation.constraints.Max;
-
-import org.jboss.test.faces.mock.Environment;
-import org.jboss.test.faces.mock.Environment.Feature;
-import org.jboss.test.faces.mock.Mock;
-import org.jboss.test.faces.mock.MockController;
-import org.jboss.test.faces.mock.MockFacesEnvironment;
-import org.jboss.test.faces.mock.MockTestRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * @author asmirnov
- *
- */
-(a)RunWith(MockTestRunner.class)
-public class ClientScriptServiceTest {
-
- private static final String TEXT_JAVASCRIPT = "text/javascript";
-
- private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
-
- private static final String RESOURCE_NAME =
ValidatorWithFacesResource.class.getSimpleName() + ".js";
-
- @Mock
- @Environment({ Feature.APPLICATION })
- private MockFacesEnvironment environment;
-
- @Mock
- private ResourceHandler resourceHandler;
-
- private MockController controller;
-
- @Mock
- private Resource resource;
-
- @Mock
- private LibraryFunction function;
-
- private ClientScriptServiceImpl serviceImpl;
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
-
expect(environment.getApplication().getResourceHandler()).andStubReturn(resourceHandler);
- Map<Class<?>, LibraryFunction> defaultMapping = ImmutableMap
- .<Class<?>, LibraryFunction> of(Max.class, function);
- serviceImpl = new ClientScriptServiceImpl(defaultMapping);
- }
-
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- controller.verify();
- controller.release();
- }
-
- /**
- * Test method for {@link
org.richfaces.validator.ClientScriptServiceImpl#getScript(FacesContext,
java.lang.Class)}.
- *
- * @throws Exception
- */
- @Test
- public void testGetScriptAsJsfResource() throws Exception {
- LibraryFunction script = getScript(resource, ValidatorWithFacesResource.class);
- assertEquals(RESOURCE_NAME, script.getResource().getResourceName());
- assertEquals(ORG_RICHFACES_CSV, script.getResource().getLibrary());
- assertEquals("validatorWithFacesResource", script.getName());
- }
-
- @Test
- public void testGetScriptFromAnnotation() throws Exception {
- LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
- assertEquals("baz.js", script.getResource().getResourceName());
- assertEquals("bar", script.getResource().getLibrary());
- assertEquals("foo", script.getName());
- }
-
- @Test
- public void testGetScriptFromDefaultMapping() throws Exception {
- LibraryFunction script = getScript(null, Max.class);
- assertSame(function, script);
- }
-
- @Test
- public void testGetScriptOverrideAnnotation() throws Exception {
- Map<Class<?>, LibraryFunction> defaultMapping =
ImmutableMap.<Class<?>, LibraryFunction> of(
- ValidatorWithFacesResource.class, function);
- serviceImpl = new ClientScriptServiceImpl(defaultMapping);
- LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
- assertSame(function, script);
- }
-
- private LibraryFunction getScript(Resource resource, Class<?> serverSideType)
throws ScriptNotFoundException {
- expect(resourceHandler.createResource(serverSideType.getSimpleName() +
".js", ORG_RICHFACES_CSV, TEXT_JAVASCRIPT)).andReturn(resource);
- controller.replay();
- LibraryFunction script = serviceImpl.getScript(environment.getFacesContext(),
serverSideType);
- return script;
- }
-
-}
Deleted:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,43 +0,0 @@
-package org.richfaces.validator;
-
-import static org.junit.Assert.*;
-
-import java.util.Map;
-
-import javax.faces.FacesException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ServiceConfigParserTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testParseConfig() {
- Map<Class<?>, LibraryFunction> parseConfig =
ClientServiceConfigParser.parseConfig("csv.xml");
- assertEquals(2, parseConfig.size());
- assertTrue(parseConfig.containsKey(String.class));
- LibraryFunction libraryFunction = parseConfig.get(String.class);
- assertEquals("stringConverter", libraryFunction.getName());
- assertEquals("csv.js",
libraryFunction.getResource().getResourceName());
- assertEquals("org.richfaces",
libraryFunction.getResource().getLibrary());
- }
-
- @Test(expected=FacesException.class)
- public void testParseBadConfig() {
- Map<Class<?>, LibraryFunction> parseConfig =
ClientServiceConfigParser.parseConfig("badcsv.xml");
- }
- @Test()
- public void testParseNoConfig() {
- Map<Class<?>, LibraryFunction> parseConfig =
ClientServiceConfigParser.parseConfig("non-exists-csv.xml");
- assertEquals(0, parseConfig.size());
- }
-}
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java 2010-11-16
17:05:51 UTC (rev 20061)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java 2010-11-17
00:13:58 UTC (rev 20062)
@@ -1,5 +1,7 @@
package org.richfaces.validator;
+import org.richfaces.javascript.ClientSideScript;
+
@ClientSideScript(function="foo",library="bar",resource="baz.js")
public class ValidatorWithFacesResource {