Fixes #510 - Module [depend] property expansion should support eg foo/${bar}/${bar}-xxx

This commit is contained in:
Joakim Erdfelt 2016-04-13 11:50:57 -07:00
parent 76476b6d28
commit 210f9a8d7c
2 changed files with 21 additions and 7 deletions

View File

@ -18,8 +18,6 @@
package org.eclipse.jetty.start;
import static org.eclipse.jetty.start.UsageException.*;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@ -34,6 +32,8 @@ import java.util.regex.Pattern;
import org.eclipse.jetty.start.Props.Prop;
import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG;
/**
* Management of Properties.
* <p>
@ -225,8 +225,6 @@ public final class Props implements Iterable<Prop>
throw new PropsException(err.toString());
}
seenStack.push(property);
// find property name
expanded.append(str.subSequence(offset,mat.start(1)));
// get property value
@ -239,7 +237,9 @@ public final class Props implements Iterable<Prop>
else
{
// recursively expand
seenStack.push(property);
value = expand(value,seenStack);
seenStack.pop();
expanded.append(value);
}
// update offset

View File

@ -18,12 +18,15 @@
package org.eclipse.jetty.start;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.eclipse.jetty.start.Props.Prop;
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
{
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"));
}
@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
public void testExpandLoop()
{