Author: alexsmirnov
Date: 2010-11-29 18:32:20 -0500 (Mon, 29 Nov 2010)
New Revision: 20218
Removed:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
Modified:
branches/RF-8742-1/core/api/src/main/java/org/richfaces/resource/ResourceLibrary.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/html/ResourceLibraryRenderer.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/resource/StaticResourceLibrary.java
branches/RF-8742-1/core/impl/src/test/java/org/richfaces/resource/DynamicResourceLibrary.java
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.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/LibraryScriptString.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.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/ClientOnlyScript.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/el/ValueExpressionAnalayserTest.java
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
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
Log:
CODING IN PROGRESS - issue RF-9799: CSV code review
https://jira.jboss.org/browse/RF-9799
Modified:
branches/RF-8742-1/core/api/src/main/java/org/richfaces/resource/ResourceLibrary.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/richfaces/resource/ResourceLibrary.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/core/api/src/main/java/org/richfaces/resource/ResourceLibrary.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -21,7 +21,6 @@
*/
package org.richfaces.resource;
-import javax.faces.context.FacesContext;
/**
* @author Nick Belaevski
@@ -29,6 +28,6 @@
*/
public interface ResourceLibrary {
- public Iterable<ResourceKey> getResources(FacesContext context);
+ public Iterable<ResourceKey> getResources();
}
Modified:
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/html/ResourceLibraryRenderer.java
===================================================================
---
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/html/ResourceLibraryRenderer.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/html/ResourceLibraryRenderer.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -95,7 +95,7 @@
Application application = context.getApplication();
UIComponent resourceComponent = null;
- for (ResourceKey resourceKey: resourceLibrary.getResources(context)) {
+ for (ResourceKey resourceKey: resourceLibrary.getResources()) {
String rendererType =
application.getResourceHandler().getRendererTypeForResourceName(resourceKey.getResourceName());
if (resourceComponent == null) {
Modified:
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/resource/StaticResourceLibrary.java
===================================================================
---
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/resource/StaticResourceLibrary.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/resource/StaticResourceLibrary.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -21,7 +21,6 @@
*/
package org.richfaces.resource;
-import javax.faces.context.FacesContext;
import com.google.common.collect.ImmutableList;
@@ -38,7 +37,7 @@
this.keys = ImmutableList.copyOf(keys);
}
- public Iterable<ResourceKey> getResources(FacesContext context) {
+ public Iterable<ResourceKey> getResources() {
return keys;
}
Modified:
branches/RF-8742-1/core/impl/src/test/java/org/richfaces/resource/DynamicResourceLibrary.java
===================================================================
---
branches/RF-8742-1/core/impl/src/test/java/org/richfaces/resource/DynamicResourceLibrary.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/core/impl/src/test/java/org/richfaces/resource/DynamicResourceLibrary.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -21,7 +21,6 @@
*/
package org.richfaces.resource;
-import javax.faces.context.FacesContext;
import com.google.common.collect.ImmutableList;
@@ -33,7 +32,7 @@
private ImmutableList<ResourceKey> keys =
ImmutableList.of(ResourceKey.create("skinning_classes.ecss"),
ResourceKey.create("jquery.js", null));
- public Iterable<ResourceKey> getResources(FacesContext context) {
+ public Iterable<ResourceKey> getResources() {
return keys;
}
Modified:
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java
===================================================================
---
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -25,6 +25,7 @@
import javax.faces.context.FacesContext;
+
import org.richfaces.application.CommonComponentsConfiguration;
import com.google.common.collect.ImmutableList;
@@ -42,8 +43,9 @@
private static final ImmutableList<ResourceKey> AJAX_WITH_QUEUE_KEYS =
ImmutableList.<ResourceKey>builder().addAll(AJAX_ONLY_KEYS).add(ResourceKey.create("richfaces-queue.js",
null)).build();
- public Iterable<ResourceKey> getResources(FacesContext context) {
- if (getBooleanConfigurationValue(context,
CommonComponentsConfiguration.Items.queueEnabled)) {
+ public Iterable<ResourceKey> getResources() {
+ // TODO - initialize at creation.
+ if (getBooleanConfigurationValue(FacesContext.getCurrentInstance(),
CommonComponentsConfiguration.Items.queueEnabled)) {
return AJAX_WITH_QUEUE_KEYS;
}
Modified:
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/LibraryFunction.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -23,6 +23,8 @@
package org.richfaces.javascript;
+import org.richfaces.resource.ResourceLibrary;
+
/**
* <p class="changed_added_4_0">
* This class contains information about JavaScript function in external library (
resource )
@@ -31,9 +33,13 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface LibraryFunction extends LibraryScript {
+public interface LibraryFunction extends ResourceLibrary {
+ /**
+ * <p class="changed_added_4_0">JavaScript function name in resource
library</p>
+ * @return
+ */
String getName();
}
Deleted:
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/LibraryScript.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -1,40 +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.javascript;
-
-import org.richfaces.resource.ResourceKey;
-
-/**
- * <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 {
-
- ResourceKey getResource();
-
-}
Modified:
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/LibraryScriptString.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -1,13 +1,14 @@
package org.richfaces.javascript;
import org.ajax4jsf.javascript.ScriptString;
+import org.richfaces.resource.ResourceLibrary;
/**
- * This interface describes JavaScript object with possible dependent resource.
+ * This interface describes JavaScript object with optional dependent resources.
* @author asmirnov
*
*/
-public interface LibraryScriptString extends LibraryScript, ScriptString {
+public interface LibraryScriptString extends ResourceLibrary, ScriptString {
}
\ No newline at end of file
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -1,23 +1,25 @@
package org.richfaces.javascript;
+import java.util.Collections;
+
import org.richfaces.resource.ResourceKey;
final class LibraryFunctionImplementation implements LibraryFunction {
- private final ResourceKey library;
+ private final Iterable<ResourceKey> library;
private final String functionName;
LibraryFunctionImplementation(String functionName, ResourceKey library) {
- this.library = library;
+ this.library = Collections.singleton(library);
this.functionName = functionName;
}
LibraryFunctionImplementation(String functionName, String resource, String library)
{
- this.library = ResourceKey.create(resource,library);
+ this.library = Collections.singleton(ResourceKey.create(resource,library));
this.functionName = functionName;
}
- public ResourceKey getResource() {
+ public Iterable<ResourceKey> getResources() {
return library;
}
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -2,6 +2,8 @@
import java.util.Collections;
+import javax.faces.context.FacesContext;
+
import org.richfaces.resource.ResourceKey;
public class AjaxOnlyScript extends ValidatorScriptBase {
@@ -15,7 +17,7 @@
}
- public Iterable<ResourceKey> getResources() {
+ public Iterable<ResourceKey> getResources(FacesContext context) {
return Collections.emptySet();
}
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -3,9 +3,12 @@
import java.util.Collection;
import java.util.LinkedHashSet;
+import javax.faces.context.FacesContext;
+
import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.resource.ResourceKey;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
public class ClientOnlyScript extends ValidatorScriptBase{
@@ -25,12 +28,12 @@
}
- public Iterable<ResourceKey> getResources() {
+ public Iterable<ResourceKey> getResources(FacesContext context) {
// TODO - make immutable.
LinkedHashSet<ResourceKey> resources = Sets.newLinkedHashSet();
- resources.add(converter.getResource());
+ Iterables.addAll(resources,converter.getResources());
for (LibraryScriptString scriptString : validators) {
- resources.add(scriptString.getResource());
+ Iterables.addAll(resources,scriptString.getResources());
}
return resources;
}
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -1,5 +1,7 @@
package org.richfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.javascript.ScriptString;
import org.richfaces.resource.ResourceKey;
@@ -7,7 +9,7 @@
String getName();
- Iterable<ResourceKey> getResources();
+ Iterable<ResourceKey> getResources(FacesContext context);
/**
* <p class="changed_added_4_0">Creates JavasCript that calls
validator function.</p>
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -38,12 +38,12 @@
*/
public class LibraryScriptFunction extends JSFunction implements LibraryScriptString {
- private final ResourceKey resource;
+ private final Iterable<ResourceKey> resources;
private final String name;
public LibraryScriptFunction(LibraryFunction libraryScript, Object... parameters) {
super(libraryScript.getName(), parameters);
- this.resource = libraryScript.getResource();
+ this.resources = libraryScript.getResources();
this.name = libraryScript.getName();
}
@@ -56,8 +56,8 @@
*
* @see org.richfaces.renderkit.html.LibraryScriptString#getResource()
*/
- public ResourceKey getResource() {
- return resource;
+ public Iterable<ResourceKey> getResources() {
+ return resources;
}
/*
@@ -70,7 +70,7 @@
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((resource == null) ? 0 : resource.hashCode());
+ result = prime * result + ((resources == null) ? 0 : resources.hashCode());
result = prime * result + getParameters().hashCode();
return result;
}
@@ -99,11 +99,11 @@
} else if (!name.equals(other.name)) {
return false;
}
- if (resource == null) {
- if (other.resource != null) {
+ if (resources == null) {
+ if (other.resources != null) {
return false;
}
- } else if (!resource.equals(other.resource)) {
+ } else if (!resources.equals(other.resources)) {
return false;
} else if (!getParameters().equals(other.getParameters())) {
return false;
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -3,6 +3,8 @@
*/
package org.richfaces.renderkit.html;
+import java.util.Collections;
+
import org.ajax4jsf.javascript.JSLiteral;
import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.resource.ResourceKey;
@@ -30,8 +32,8 @@
*
* @see org.richfaces.renderkit.html.LibraryScriptString#getResource()
*/
- public ResourceKey getResource() {
- return null;
+ public Iterable<ResourceKey> getResources() {
+ return Collections.emptySet();
}
}
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -41,7 +41,7 @@
// flatten all dependent resources.
LinkedHashSet<ResourceKey> resources = Sets.newLinkedHashSet();
for (ComponentValidatorScript script : scripts) {
- Iterables.addAll(resources, script.getResources());
+ Iterables.addAll(resources, script.getResources(context));
}
// render dependencies
for (ResourceKey resource : resources) {
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -49,7 +49,7 @@
}
}
- public Collection<ResourceKey> getResources() {
+ public Collection<ResourceKey> getResources(FacesContext context) {
return Collections.singleton(TEST_RESOURCE);
}
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -1,10 +1,14 @@
package org.richfaces.component;
import java.io.IOException;
+import java.util.Collections;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.resource.ResourceKey;
-final class Script implements org.richfaces.javascript.LibraryScriptString {
+final class Script implements LibraryScriptString {
private final String name;
Script(String name) {
@@ -27,8 +31,8 @@
}
}
- public ResourceKey getResource() {
- return UIValidatorScriptCollectionTest.FOO_RESOURCE;
+ public Iterable<ResourceKey> getResources() {
+ return Collections.singleton(UIValidatorScriptCollectionTest.FOO_RESOURCE);
}
/* (non-Javadoc)
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -34,6 +34,7 @@
@After
public void tearDownAnalayser() throws Exception {
analayser = null;
+ facesContext.release();
}
@Test
public void testGetDescriptionPositive() throws Exception {
Modified:
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/ClientScriptServiceTest.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -11,6 +11,7 @@
import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
import javax.validation.constraints.Max;
import org.jboss.test.faces.mock.Environment;
@@ -26,9 +27,11 @@
import org.richfaces.javascript.ClientScriptServiceImpl;
import org.richfaces.javascript.LibraryFunction;
import org.richfaces.javascript.ScriptNotFoundException;
+import org.richfaces.resource.ResourceKey;
import org.richfaces.validator.ValidatorWithFacesResource;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
/**
* @author asmirnov
@@ -88,16 +91,20 @@
@Test
public void testGetScriptAsJsfResource() throws Exception {
LibraryFunction script = getScript(resource, ValidatorWithFacesResource.class);
- assertEquals(RESOURCE_NAME, script.getResource().getResourceName());
- assertEquals(ORG_RICHFACES_CSV, script.getResource().getLibraryName());
+ assertEquals(RESOURCE_NAME, getOnlyResource(script).getResourceName());
+ assertEquals(ORG_RICHFACES_CSV, getOnlyResource(script).getLibraryName());
assertEquals("validatorWithFacesResource", script.getName());
}
+ private ResourceKey getOnlyResource(LibraryFunction script) {
+ return Iterables.getOnlyElement(script.getResources());
+ }
+
@Test
public void testGetScriptFromAnnotation() throws Exception {
LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
- assertEquals("baz.js", script.getResource().getResourceName());
- assertEquals("bar", script.getResource().getLibraryName());
+ assertEquals("baz.js", getOnlyResource(script).getResourceName());
+ assertEquals("bar", getOnlyResource(script).getLibraryName());
assertEquals("foo", script.getName());
}
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2010-11-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -11,7 +11,10 @@
import org.junit.Test;
import org.richfaces.javascript.ClientServiceConfigParser;
import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.resource.ResourceKey;
+import com.google.common.collect.Iterables;
+
public class ServiceConfigParserTest {
@Before
@@ -29,8 +32,9 @@
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().getLibraryName());
+ ResourceKey resource = Iterables.getOnlyElement(libraryFunction.getResources());
+ assertEquals("csv.js", resource.getResourceName());
+ assertEquals("org.richfaces", resource.getLibraryName());
}
@Test(expected=FacesException.class)
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -86,14 +86,14 @@
(Map<String, Object>) VALIDATOR_PARAMS);
expect(scriptService.getScript(environment.getFacesContext(),
RegexValidator.class)).andReturn(script);
expect(script.getName()).andReturn(REGEX_VALIDATOR).atLeastOnce();
- expect(script.getResource()).andReturn(CLIENT_VALIDATOR_LIBRARY);
+ expect(script.getResources()).andReturn(CLIENT_VALIDATOR_LIBRARY);
controller.replay();
Collection<? extends LibraryScriptString> clientSideScripts =
renderer.getClientSideValidatorScript(environment.getFacesContext(), descriptors);
LibraryScriptFunction clientSideScript = (LibraryScriptFunction)
Iterables.getOnlyElement(clientSideScripts);
assertEquals(ClientValidatorRenderer.CONVERTED_VALUE_LITERAL,
clientSideScript.getParameters().get(0));
assertEquals(VALIDATOR_MESSAGE, clientSideScript.getParameters().get(1));
assertEquals(VALIDATOR_PARAMS, clientSideScript.getParameters().get(2));
- assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResource());
+ assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResources());
controller.verify();
}
@@ -105,14 +105,14 @@
(Map<String, Object>) VALIDATOR_PARAMS);
expect(scriptService.getScript(environment.getFacesContext(),
NumberConverter.class)).andReturn(script);
expect(script.getName()).andReturn(REGEX_VALIDATOR).atLeastOnce();
- expect(script.getResource()).andReturn(CLIENT_VALIDATOR_LIBRARY);
+ expect(script.getResources()).andReturn(CLIENT_VALIDATOR_LIBRARY);
controller.replay();
LibraryScriptFunction clientSideScript =
(LibraryScriptFunction)
renderer.getClientSideConverterScript(environment.getFacesContext(),
converterDescriptor);
assertEquals(ClientValidatorRenderer.VALUE_LITERAL,
clientSideScript.getParameters().get(0));
assertEquals(VALIDATOR_MESSAGE, clientSideScript.getParameters().get(1));
assertEquals(VALIDATOR_PARAMS, clientSideScript.getParameters().get(2));
- assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResource());
+ assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResources());
controller.verify();
}
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -139,7 +139,7 @@
// check what generated script contains ajax and client side scripts.
assertThat(script,
allOf(containsString(JSF_AJAX_REQUEST), containsString(REGEX_VALIDATOR),
containsString(NUMBER_CONVERTER)));
- assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(environment.getFacesContext()),
hasItem(CORE_LIBRARY_MATCHER));
}
/**
@@ -175,7 +175,7 @@
script,
allOf(not(containsString(JSF_AJAX_REQUEST)),
containsString(REGEX_VALIDATOR),
not(containsString(NUMBER_CONVERTER))));
- assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(environment.getFacesContext()),
hasItem(CORE_LIBRARY_MATCHER));
}
/**
@@ -196,7 +196,7 @@
script,
allOf(not(containsString(JSF_AJAX_REQUEST)),
containsString(REGEX_VALIDATOR),
containsString(NUMBER_CONVERTER)));
- assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(environment.getFacesContext()),
hasItem(CORE_LIBRARY_MATCHER));
}
private LibraryScriptFunction createValidatorFunction() {
@@ -216,7 +216,7 @@
return name;
}
- public ResourceKey getResource() {
+ public Iterable<ResourceKey> getResources() {
return CLIENT_VALIDATOR_LIBRARY;
}
};
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-29
20:58:34 UTC (rev 20217)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-11-29
23:32:20 UTC (rev 20218)
@@ -1,5 +1,6 @@
package org.richfaces.renderkit.html;
+import java.util.Collections;
import java.util.Map;
import javax.faces.application.FacesMessage;
@@ -18,7 +19,7 @@
protected static final String REGEX_VALIDATOR = "regexValidator";
protected static final FacesMessage VALIDATOR_MESSAGE = new
FacesMessage("Validator Message");
protected static final Map<String, ? extends Object> VALIDATOR_PARAMS =
ImmutableMap.of("foo", "value", "bar", 10);
- protected static final ResourceKey CLIENT_VALIDATOR_LIBRARY =
ResourceKey.create(CLIENT_VALIDATORS_JS,ORG_RICHFACES);
+ protected static final Iterable<ResourceKey> CLIENT_VALIDATOR_LIBRARY =
Collections.singleton(ResourceKey.create(CLIENT_VALIDATORS_JS,ORG_RICHFACES));
protected ClientValidatorRenderer renderer = new ClientValidatorRenderer();