[jboss-cvs] JBossAS SVN: r91613 - in projects/spring-int/trunk/vfs: src and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 23 13:21:17 EDT 2009
Author: marius.bogoevici
Date: 2009-07-23 13:21:16 -0400 (Thu, 23 Jul 2009)
New Revision: 91613
Added:
projects/spring-int/trunk/vfs/src/test/
projects/spring-int/trunk/vfs/src/test/java/
projects/spring-int/trunk/vfs/src/test/java/org/
projects/spring-int/trunk/vfs/src/test/java/org/jboss/
projects/spring-int/trunk/vfs/src/test/java/org/jboss/spring/
projects/spring-int/trunk/vfs/src/test/java/org/jboss/spring/vfs/
projects/spring-int/trunk/vfs/src/test/java/org/jboss/spring/vfs/context/
projects/spring-int/trunk/vfs/src/test/java/org/jboss/spring/vfs/context/SpringResourceLoadingTestCase.java
projects/spring-int/trunk/vfs/src/test/resources/
projects/spring-int/trunk/vfs/src/test/resources/spring-config/
projects/spring-int/trunk/vfs/src/test/resources/spring-config/spring-app-config.xml
Modified:
projects/spring-int/trunk/vfs/pom.xml
projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourceLoader.java
Log:
Fix an issue concerning classpath: prefixes.
Modified: projects/spring-int/trunk/vfs/pom.xml
===================================================================
--- projects/spring-int/trunk/vfs/pom.xml 2009-07-23 16:53:00 UTC (rev 91612)
+++ projects/spring-int/trunk/vfs/pom.xml 2009-07-23 17:21:16 UTC (rev 91613)
@@ -42,6 +42,10 @@
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourceLoader.java
===================================================================
--- projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourceLoader.java 2009-07-23 16:53:00 UTC (rev 91612)
+++ projects/spring-int/trunk/vfs/src/main/java/org/jboss/spring/vfs/VFSResourceLoader.java 2009-07-23 17:21:16 UTC (rev 91613)
@@ -36,56 +36,50 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class VFSResourceLoader extends DefaultResourceLoader
-{
- public VFSResourceLoader(ClassLoader classLoader)
- {
- super(classLoader);
- }
+public class VFSResourceLoader extends DefaultResourceLoader {
+ public VFSResourceLoader(ClassLoader classLoader) {
+ super(classLoader);
+ }
- public Resource getResource(String location)
- {
- Assert.notNull(location, "Location must not be null");
- if (location.startsWith(CLASSPATH_URL_PREFIX))
- {
- return getResourceByPath(location.substring(CLASSPATH_URL_PREFIX.length()));
- }
- else
- {
- return super.getResource(location);
- }
- }
+ public Resource getResource(String location) {
+ Assert.notNull(location, "Location must not be null");
+ if (location.startsWith(CLASSPATH_URL_PREFIX)) {
+ return doGetResourceForLocation(location.substring(CLASSPATH_URL_PREFIX.length()));
+ } else {
+ return super.getResource(location);
+ }
+ }
- protected Resource getResourceByPath(String path)
- {
- URL url = getClassLoader().getResource(path);
- if (url != null)
- return new VFSResource(url);
- else
- return new InexistentResource(path);
- }
+ protected Resource getResourceByPath(String path) {
+ return doGetResourceForLocation(path);
+ }
- /* A special type of resource, for the case when the resource does not exit */
- private static class InexistentResource extends AbstractResource
- {
- private final String path;
+ private final Resource doGetResourceForLocation(String path) {
+ URL url = getClassLoader().getResource(path);
+ if (url != null)
+ return new VFSResource(url);
+ else
+ return new InexistentResource(path);
+ }
- private InexistentResource(String path) {
- this.path = path;
- }
+ /* A special type of resource, for the case when the resource does not exit */
+ private static class InexistentResource extends AbstractResource {
+ private final String path;
- public String getDescription()
- {
- return null;
- }
+ private InexistentResource(String path) {
+ this.path = path;
+ }
- public InputStream getInputStream() throws IOException
- {
- throw new FileNotFoundException("Resource does not exist for path " + path);
- }
+ public String getDescription() {
+ return null;
+ }
- public boolean exists() {
- return false;
- }
+ public InputStream getInputStream() throws IOException {
+ throw new FileNotFoundException("Resource does not exist for path " + path);
+ }
+
+ public boolean exists() {
+ return false;
+ }
}
}
\ No newline at end of file
Added: projects/spring-int/trunk/vfs/src/test/java/org/jboss/spring/vfs/context/SpringResourceLoadingTestCase.java
===================================================================
--- projects/spring-int/trunk/vfs/src/test/java/org/jboss/spring/vfs/context/SpringResourceLoadingTestCase.java (rev 0)
+++ projects/spring-int/trunk/vfs/src/test/java/org/jboss/spring/vfs/context/SpringResourceLoadingTestCase.java 2009-07-23 17:21:16 UTC (rev 91613)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jboss.spring.vfs.context;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author: marius
+ */
+public class SpringResourceLoadingTestCase {
+
+ @Test
+ public void testLoadResourceFromClasspath() {
+ VFSXmlWebApplicationContext context = new VFSXmlWebApplicationContext();
+ context.setConfigLocations(new String[]{"classpath:spring-config/spring-app-config.xml"});
+ context.refresh();
+ String myBean = (String) context.getBean("myBean");
+ }
+
+
+ @Test
+ public void testLoadResourceFromClasspathWildCard() {
+ VFSXmlWebApplicationContext context = new VFSXmlWebApplicationContext();
+ context.setConfigLocations(new String[]{"classpath*:spring-config/spring-app-config.xml"});
+ context.refresh();
+ String myBean = (String) context.getBean("myBean");
+ }
+
+ @Test
+ public void testLoadWildCardedResourceFromClasspath() {
+ VFSXmlWebApplicationContext context = new VFSXmlWebApplicationContext();
+ context.setConfigLocations(new String[]{"classpath:/spring-config/spring-*.xml"});
+ context.refresh();
+ String myBean = (String) context.getBean("myBean");
+ }
+
+ @Test
+ public void testLoadWildCardedResourceFromClasspathWildCard() {
+ VFSXmlWebApplicationContext context = new VFSXmlWebApplicationContext();
+ context.setConfigLocations(new String[]{"classpath*:/spring-config/spring-*.xml"});
+ context.refresh();
+ String myBean = (String) context.getBean("myBean");
+ Resource r = context.getResource("classpath:/spring-config/spring-app-config.xml");
+ Assert.assertNotNull(r);
+ }
+
+}
Added: projects/spring-int/trunk/vfs/src/test/resources/spring-config/spring-app-config.xml
===================================================================
--- projects/spring-int/trunk/vfs/src/test/resources/spring-config/spring-app-config.xml (rev 0)
+++ projects/spring-int/trunk/vfs/src/test/resources/spring-config/spring-app-config.xml 2009-07-23 17:21:16 UTC (rev 91613)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="myBean" class="java.lang.String"/>
+
+</beans>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list