You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/08/28 22:24:22 UTC
svn commit: r1518363 - in /myfaces/tobago/trunk/tobago-example:
tobago-example-data/src/main/resources/META-INF/resources/data/
tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/
tobago-example-test/src/main/webapp/WEB-INF/ tobag...
Author: lofwyr
Date: Wed Aug 28 20:24:21 2013
New Revision: 1518363
URL: http://svn.apache.org/r1518363
Log:
Adding Tests for the changes to fix TOBAGO-1295: Loading themes on JBoss 7.x.x with vfs protocol
Added:
myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/resources/META-INF/resources/data/sun-behind-mountains.jpg (with props)
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceBean.java
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceEntry.java
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceType.java
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/resource/resource-manager.xhtml
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml
Added: myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/resources/META-INF/resources/data/sun-behind-mountains.jpg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/resources/META-INF/resources/data/sun-behind-mountains.jpg?rev=1518363&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/resources/META-INF/resources/data/sun-behind-mountains.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceBean.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceBean.java?rev=1518363&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceBean.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceBean.java Wed Aug 28 20:24:21 2013
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.test;
+
+import org.apache.myfaces.tobago.context.ResourceManager;
+import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.faces.context.FacesContext;
+import java.util.Arrays;
+import java.util.List;
+
+public class ResourceBean {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ResourceBean.class);
+
+ private List<ResourceEntry> resources;
+ private int fails;
+
+ public ResourceBean() {
+ if (resources == null) {
+ final FacesContext facesContext = FacesContext.getCurrentInstance();
+ final ResourceManager resourceManager
+ = ResourceManagerFactory.getResourceManager(facesContext);
+
+ resources = Arrays.asList(
+ new ResourceEntry(
+ "data/sun-behind-mountains.jpg",
+ ResourceType.IMAGE,
+ "comes from JAR (tobago-example-data): META-INF/resources"),
+ new ResourceEntry(
+ "non-existing.jpg",
+ ResourceType.IMAGE,
+ "should fail"),
+ new ResourceEntry(
+ "image/date.gif",
+ ResourceType.IMAGE,
+ "comes from JAR (tobago-theme-speyside)"),
+ new ResourceEntry(
+ "image/wait/cat.jpg",
+ ResourceType.IMAGE,
+ "comes from the WAR directly"),
+ new ResourceEntry(
+ "tobago",
+ "configTheme",
+ ResourceType.PROPERTY,
+ "comes from the theme (tobago-theme-scarborough)"),
+ new ResourceEntry(
+ "tobago",
+ "not-existing",
+ ResourceType.PROPERTY,
+ "should fail")
+ );
+
+ for (ResourceEntry resource : resources) {
+ if (!resource.check(facesContext, resourceManager)) {
+ fails++;
+ }
+ }
+ }
+ }
+
+ public List<ResourceEntry> getResultList() {
+ return resources;
+ }
+
+ public int getFails() {
+ return fails;
+ }
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceEntry.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceEntry.java?rev=1518363&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceEntry.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceEntry.java Wed Aug 28 20:24:21 2013
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.test;
+
+import org.apache.myfaces.tobago.context.ResourceManager;
+
+import javax.faces.context.FacesContext;
+
+public class ResourceEntry {
+
+ private String name;
+ private String key;
+ private ResourceType type;
+ private boolean valid;
+ private String comment;
+
+ public ResourceEntry(String name, ResourceType type, String comment) {
+ this.name = name;
+ this.type = type;
+ this.comment = comment;
+ assert type == ResourceType.IMAGE;
+ }
+
+ public ResourceEntry(String name, String key, ResourceType type, String comment) {
+ this.name = name;
+ this.key = key;
+ this.type = type;
+ this.comment = comment;
+ assert type == ResourceType.PROPERTY;
+ }
+
+ public boolean check(FacesContext facesContext, ResourceManager resourceManager) {
+ switch (type) {
+ case IMAGE:
+ valid = resourceManager.getImage(facesContext, name) != null;
+ break;
+ case PROPERTY:
+ valid = resourceManager.getProperty(facesContext, name, key) != null;
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown type " + type);
+ }
+ return valid;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ResourceType getType() {
+ return type;
+ }
+
+ public void setType(ResourceType type) {
+ this.type = type;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceType.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceType.java?rev=1518363&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceType.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ResourceType.java Wed Aug 28 20:24:21 2013
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.test;
+
+public enum ResourceType {
+ IMAGE,
+ PROPERTY
+}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml?rev=1518363&r1=1518362&r2=1518363&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/faces-config.xml Wed Aug 28 20:24:21 2013
@@ -185,6 +185,12 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>resourceBean</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.tobago.example.test.ResourceBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
<navigation-rule>
<navigation-case>
<from-outcome>navigation</from-outcome>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/resource/resource-manager.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/resource/resource-manager.xhtml?rev=1518363&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/resource/resource-manager.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/test/resource/resource-manager.xhtml Wed Aug 28 20:24:21 2013
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<f:view
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <tc:page>
+
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;auto;*"/>
+ </f:facet>
+ <tc:gridLayoutConstraint width="600px" height="300px"/>
+
+ <tx:in label="Fails" markup="#{resourceBean.fails == 2 ? '' : 'error' }"
+ value="#{resourceBean.fails}" tip="expected are 2"/>
+
+ <tc:messages/>
+
+ <tc:sheet columns="3*;*;*;3*" value="#{resourceBean.resultList}" var="item">
+ <tc:column label="Name">
+ <tc:out value="#{item.name}"/>
+ </tc:column>
+ <tc:column label="Type">
+ <tc:out value="#{item.type}"/>
+ </tc:column>
+ <tc:column label="Valid">
+ <tc:out value="#{item.valid}"/>
+ </tc:column>
+ <tc:column label="Comment">
+ <tc:out value="#{item.comment}"/>
+ </tc:column>
+ </tc:sheet>
+
+ </tc:page>
+</f:view>