This closes #159 fixing path resolution
This commit is contained in:
commit
8843a9ee1e
|
@ -74,7 +74,7 @@ public class ArtemisTest {
|
|||
|
||||
@Test
|
||||
public void testSync() throws Exception {
|
||||
int writes = 2560;
|
||||
int writes = 20;
|
||||
int tries = 10;
|
||||
long totalAvg = SyncCalculation.syncTest(temporaryFolder.getRoot(), 4096, writes, tries, true, true);
|
||||
System.out.println();
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.File;
|
|||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.ArrayList;
|
||||
|
@ -1425,10 +1424,7 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
|||
*/
|
||||
private File subFolder(String subFolder) {
|
||||
try {
|
||||
// Resolve wont work without "/" as the last character
|
||||
URI artemisHome = new URI(getBrokerInstance().toURI() + "/");
|
||||
URI relative = artemisHome.resolve(subFolder);
|
||||
return new File(relative.getPath());
|
||||
return getBrokerInstance().toPath().resolve(subFolder).toFile();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.config.impl;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
|
@ -483,6 +485,68 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
|
|||
Assert.assertTrue(conf.equals(conf2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolvePath() throws Throwable {
|
||||
// Validate that the resolve method will work even with artemis.instance doesn't exist
|
||||
|
||||
String oldProperty = System.getProperty("artemis.instance");
|
||||
|
||||
try {
|
||||
System.setProperty("artemis.instance", "/tmp/" + RandomUtil.randomString());
|
||||
ConfigurationImpl configuration = new ConfigurationImpl();
|
||||
configuration.setJournalDirectory("./data-journal");
|
||||
File journalLocation = configuration.getJournalLocation();
|
||||
Assert.assertFalse("This path shouldn't resolve to a real folder", journalLocation.exists());
|
||||
}
|
||||
finally {
|
||||
if (oldProperty == null) {
|
||||
System.clearProperty("artemis.instance");
|
||||
}
|
||||
else {
|
||||
System.setProperty("artemis.instance", oldProperty);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbsolutePath() throws Throwable {
|
||||
// Validate that the resolve method will work even with artemis.instance doesn't exist
|
||||
|
||||
String oldProperty = System.getProperty("artemis.instance");
|
||||
|
||||
File tempFolder = null;
|
||||
try {
|
||||
System.setProperty("artemis.instance", "/tmp/" + RandomUtil.randomString());
|
||||
tempFolder = File.createTempFile("journal-folder", "");
|
||||
tempFolder.delete();
|
||||
|
||||
tempFolder = new File(tempFolder.getAbsolutePath());
|
||||
tempFolder.mkdirs();
|
||||
|
||||
System.out.println("TempFolder = " + tempFolder.getAbsolutePath());
|
||||
|
||||
ConfigurationImpl configuration = new ConfigurationImpl();
|
||||
configuration.setJournalDirectory(tempFolder.getAbsolutePath());
|
||||
File journalLocation = configuration.getJournalLocation();
|
||||
|
||||
Assert.assertTrue(journalLocation.exists());
|
||||
}
|
||||
finally {
|
||||
if (oldProperty == null) {
|
||||
System.clearProperty("artemis.instance");
|
||||
}
|
||||
else {
|
||||
System.setProperty("artemis.instance", oldProperty);
|
||||
}
|
||||
|
||||
if (tempFolder != null) {
|
||||
tempFolder.delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue