Author: timfox
Date: 2009-11-11 15:26:29 -0500 (Wed, 11 Nov 2009)
New Revision: 8265
Modified:
trunk/src/main/org/hornetq/core/deployers/impl/FileDeploymentManager.java
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/FileDeploymentManagerTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-213
Modified: trunk/src/main/org/hornetq/core/deployers/impl/FileDeploymentManager.java
===================================================================
--- trunk/src/main/org/hornetq/core/deployers/impl/FileDeploymentManager.java 2009-11-11
18:33:34 UTC (rev 8264)
+++ trunk/src/main/org/hornetq/core/deployers/impl/FileDeploymentManager.java 2009-11-11
20:26:29 UTC (rev 8265)
@@ -15,6 +15,7 @@
import java.io.File;
import java.net.URL;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -24,6 +25,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import java.io.UnsupportedEncodingException;
import org.hornetq.core.deployers.Deployer;
import org.hornetq.core.deployers.DeploymentManager;
@@ -111,7 +113,7 @@
for (String filename : filenames)
{
- log.debug("the filename is " + filename);
+ log.debug("the filename is " + filename);
log.debug(System.getProperty("java.class.path"));
@@ -135,7 +137,7 @@
Pair<URL, Deployer> pair = new Pair<URL, Deployer>(url,
deployer);
- deployed.put(pair, new DeployInfo(deployer, new
File(url.getFile()).lastModified()));
+ deployed.put(pair, new DeployInfo(deployer,
getFileFromURL(url).lastModified()));
}
}
}
@@ -161,6 +163,11 @@
}
}
+ private File getFileFromURL(URL url) throws UnsupportedEncodingException
+ {
+ return new File(URLDecoder.decode(url.getFile(), "UTF-8"));
+ }
+
/**
* called by the ExecutorService every n seconds
*/
@@ -189,7 +196,7 @@
DeployInfo info = deployed.get(pair);
- long newLastModified = new File(url.getFile()).lastModified();
+ long newLastModified = getFileFromURL(url).lastModified();
if (info == null)
{
@@ -197,7 +204,7 @@
{
deployer.deploy(url);
- deployed.put(pair, new DeployInfo(deployer, new
File(url.getFile()).lastModified()));
+ deployed.put(pair, new DeployInfo(deployer,
getFileFromURL(url).lastModified()));
}
catch (Exception e)
{
@@ -210,7 +217,7 @@
{
deployer.redeploy(url);
- deployed.put(pair, new DeployInfo(deployer, new
File(url.getFile()).lastModified()));
+ deployed.put(pair, new DeployInfo(deployer,
getFileFromURL(url).lastModified()));
}
catch (Exception e)
{
@@ -272,7 +279,7 @@
{
try
{
- File f = new File(resourceURL.getPath());
+ File f = getFileFromURL(resourceURL); // this was the orginal line, which doesnt
work for File-URLs with white spaces: File f = new File(resourceURL.getPath());
Enumeration<URL> resources =
Thread.currentThread().getContextClassLoader().getResources(f.getName());
while (resources.hasMoreElements())
{
Modified:
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/FileDeploymentManagerTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/FileDeploymentManagerTest.java 2009-11-11
18:33:34 UTC (rev 8264)
+++
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/FileDeploymentManagerTest.java 2009-11-11
20:26:29 UTC (rev 8265)
@@ -32,13 +32,33 @@
public class FileDeploymentManagerTest extends UnitTestCase
{
private static final Logger log = Logger.getLogger(FileDeploymentManagerTest.class);
-
+
public void testStartStop1() throws Exception
{
+ testStartStop1("fdm_test_file.xml");
+ }
+
+ public void testStartStop2() throws Exception
+ {
+ testStartStop2("fdm_test_file.xml");
+ }
+
+ public void testStartStop1WithWhitespace() throws Exception
+ {
+ testStartStop1("fdm test file.xml");
+ testStartStop1("fdm\ttest\tfile.xml");
+ }
+
+ public void testStartStop2WithWhitespace() throws Exception
+ {
+ testStartStop2("fdm test file.xml");
+ testStartStop2("fdm\ttest\tfile.xml");
+ }
+
+ private void testStartStop1(final String filename) throws Exception
+ {
FileDeploymentManager fdm = new FileDeploymentManager(Long.MAX_VALUE);
- String filename = "fdm_test_file.xml";
-
log.debug("Filename is " + filename);
File file = new File("tests/tmpfiles/" + filename);
@@ -71,12 +91,10 @@
}
}
- public void testStartStop2() throws Exception
+ private void testStartStop2(final String filename) throws Exception
{
FileDeploymentManager fdm = new FileDeploymentManager(Long.MAX_VALUE);
- String filename = "fdm_test_file.xml";
-
log.debug("Filename is " + filename);
File file = new File("tests/tmpfiles/" + filename);