Fixes #510 - Module [depend] property expansion should support eg foo/${bar}/${bar}-xxx
This commit is contained in:
parent
76476b6d28
commit
210f9a8d7c
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.start;
|
package org.eclipse.jetty.start;
|
||||||
|
|
||||||
import static org.eclipse.jetty.start.UsageException.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -34,6 +32,8 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
import org.eclipse.jetty.start.Props.Prop;
|
||||||
|
|
||||||
|
import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Management of Properties.
|
* Management of Properties.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -225,8 +225,6 @@ public final class Props implements Iterable<Prop>
|
||||||
throw new PropsException(err.toString());
|
throw new PropsException(err.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
seenStack.push(property);
|
|
||||||
|
|
||||||
// find property name
|
// find property name
|
||||||
expanded.append(str.subSequence(offset,mat.start(1)));
|
expanded.append(str.subSequence(offset,mat.start(1)));
|
||||||
// get property value
|
// get property value
|
||||||
|
@ -239,7 +237,9 @@ public final class Props implements Iterable<Prop>
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// recursively expand
|
// recursively expand
|
||||||
|
seenStack.push(property);
|
||||||
value = expand(value,seenStack);
|
value = expand(value,seenStack);
|
||||||
|
seenStack.pop();
|
||||||
expanded.append(value);
|
expanded.append(value);
|
||||||
}
|
}
|
||||||
// update offset
|
// update offset
|
||||||
|
|
|
@ -18,12 +18,15 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.start;
|
package org.eclipse.jetty.start;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
import org.eclipse.jetty.start.Props.Prop;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class PropsTest
|
public class PropsTest
|
||||||
{
|
{
|
||||||
private static final String FROM_TEST = "(test)";
|
private static final String FROM_TEST = "(test)";
|
||||||
|
@ -118,6 +121,17 @@ public class PropsTest
|
||||||
assertThat(props.expand("server-id=corporate-${id}"),is("server-id=corporate-jetty-9.1"));
|
assertThat(props.expand("server-id=corporate-${id}"),is("server-id=corporate-jetty-9.1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExpandDouble()
|
||||||
|
{
|
||||||
|
Props props = new Props();
|
||||||
|
props.setProperty("bar","apple",FROM_TEST);
|
||||||
|
props.setProperty("foo","foo/${bar}/${bar}-xx",FROM_TEST);
|
||||||
|
|
||||||
|
// Should expand
|
||||||
|
assertThat(props.expand("foo/${bar}/${bar}-xx"),is("foo/apple/apple-xx"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExpandLoop()
|
public void testExpandLoop()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue