Fixing AttributeNormalizerTest to use real 'user.home'
+ Removing many debug lines + Resolving System.getProperty("user.home") to real system path before using it in the test case
This commit is contained in:
parent
81c8708c52
commit
5d882d12ab
|
@ -361,42 +361,25 @@ public class AttributeNormalizer
|
|||
{
|
||||
if(property == null)
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("getString({}) = <null>", property);
|
||||
return null;
|
||||
}
|
||||
|
||||
String val = null;
|
||||
|
||||
// Use war path (if known)
|
||||
if("WAR".equalsIgnoreCase(property))
|
||||
{
|
||||
val = warURI.toASCIIString();
|
||||
if (LOG.isDebugEnabled()) LOG.debug("getString({})#is(WAR)", property);
|
||||
return warURI.toASCIIString();
|
||||
}
|
||||
|
||||
// Use known path attributes
|
||||
if (val == null)
|
||||
for (PathAttribute attr : attributes)
|
||||
{
|
||||
for (PathAttribute attr : attributes)
|
||||
if (attr.key.equalsIgnoreCase(property))
|
||||
{
|
||||
if (attr.key.equalsIgnoreCase(property))
|
||||
{
|
||||
val = uriSeparators(attr.path.toString());
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("getString({})#isPathAttribute({}) = {}", property, attr, val);
|
||||
return val;
|
||||
}
|
||||
return uriSeparators(attr.path.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if(val == null)
|
||||
{
|
||||
// Use system properties next
|
||||
val = System.getProperty(property);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("getString({}}#systemProperty = %s", property, val == null ? "<null>" : "\"" + val + "\"");
|
||||
}
|
||||
|
||||
return val;
|
||||
// Use system properties next
|
||||
return System.getProperty(property);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.quickstart;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
|
@ -32,16 +29,17 @@ import java.nio.file.Path;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class AttributeNormalizerPathTest
|
||||
{
|
||||
|
@ -67,7 +65,7 @@ public class AttributeNormalizerPathTest
|
|||
* <p>
|
||||
* Eg: on fedora /etc/init.d is a symlink to /etc/rc.d/init.d
|
||||
*/
|
||||
private static String toSystemPath(String rawpath)
|
||||
public static String toSystemPath(String rawpath)
|
||||
{
|
||||
Path path = FileSystems.getDefault().getPath(rawpath);
|
||||
if (Files.exists(path))
|
||||
|
|
|
@ -60,10 +60,10 @@ public class AttributeNormalizerTest
|
|||
AttributeNormalizer normalizer = new AttributeNormalizer(webresource);
|
||||
|
||||
// Setup example from windows
|
||||
String userhome = AttributeNormalizer.uriSeparators(System.getProperty("user.home"));
|
||||
LOG.debug("System.getProperty('user.home') = [{}]", System.getProperty("user.home"));
|
||||
LOG.debug("userhome = [{}]", userhome);
|
||||
String path = "jar:file:" + userhome + "/.m2/repository/something/somejar.jar!/META-INF/some.tld";
|
||||
String javaUserHome = System.getProperty("user.home");
|
||||
String realUserHome = AttributeNormalizerPathTest.toSystemPath(javaUserHome);
|
||||
String userHome = AttributeNormalizer.uriSeparators(realUserHome);
|
||||
String path = "jar:file:" + userHome + "/.m2/repository/something/somejar.jar!/META-INF/some.tld";
|
||||
|
||||
String result = normalizer.normalize(path);
|
||||
assertThat(result, is("jar:file:${user.home}/.m2/repository/something/somejar.jar!/META-INF/some.tld"));
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
org.eclipse.jetty.LEVEL=INFO
|
||||
org.eclipse.jetty.quickstart.AttributeNormalizer.LEVEL=DEBUG
|
||||
# org.eclipse.jetty.quickstart.AttributeNormalizer.LEVEL=DEBUG
|
||||
|
|
Loading…
Reference in New Issue