public void testCircularExpansionTrap() { IProperties<String> props = new ExpandingProperties<String>(); props.put("some.text", "text is ${some.text.again}!"); // $NON-NLS-1$ //$NON-NLS-2$ props.put("some.other.text", "Hello ${some.text}!"); // $NON-NLS-1$ //$NON-NLS-2$ props.put("some.text.again", "Ouch! ${some.other.text}"); // $NON-NLS-1$ //$NON-NLS-2$ try { log(props.get("some.text.again")); // $NON-NLS-1$ assertFalse(true); } catch (CircularExpansionException e) { log("OK: \"%s\" resulted in a CircularExpansionException", e.getMessage()); // $NON-NLS-1$ } }
public void testExpandingEnvVarProperties() { IProperties<String> props = new ExpandingProperties<String>(BMProperties.getSystemProperties()); props.put("env.salut", "Hello ${env_var:LOGNAME}!"); props.put("env.salut.home", "${env.salut} Your $${env_var:PATH} is ${env_var:PATH}"); String result = props.get("env.salut.home"); // $NON-NLS-1$ String expected = "Hello " + System.getenv("LOGNAME") + "! Your ${env_var:PATH} is " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + System.getenv("PATH"); // $NON-NLS-1$ log(result); assertEquals(expected, result); }
public void testExpandingProperties() { IProperties<String> props = new ExpandingProperties<String>(BMProperties.getSystemProperties()); props.put("salut", "Hello ${user.name}!"); // $NON-NLS-1$ //$NON-NLS-2$ props.put( "salut.home", "${salut} Your $${user.home} is ${user.home}"); // $NON-NLS-1$ //$NON-NLS-2$ String result = props.get("salut.home"); // $NON-NLS-1$ String expected = "Hello " + System.getProperty("user.name") + "! Your ${user.home} is " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + System.getProperty("user.home"); // $NON-NLS-1$ log(result); assertEquals(expected, result); }
public void testPropertyParser() throws Exception { IProperties<String> props = new ExpandingProperties<String>(BMProperties.getSystemProperties()); props.put("buckminster.component.target", "ant-optional"); // $NON-NLS-1$ //$NON-NLS-2$ props.put("buckminster.component.name", "org.apache.tools.ant"); // $NON-NLS-1$ //$NON-NLS-2$ props.put("buckminster.component.version", "1.7.0beta1"); // $NON-NLS-1$ //$NON-NLS-2$ DummyParser parser = new DummyParser(props); parser.parse(this.getClass().getResource("/testData/misc/valuetest.xml")); // $NON-NLS-1$ String result = props.get("maven.url"); // $NON-NLS-1$ String verboseResult = props.get("verbose.maven.url"); // $NON-NLS-1$ log(result); log(verboseResult); assertEquals( "http://www.ibiblio.org/maven/ant/jars/ant-optional-1.7.0.jar", result); // $NON-NLS-1$ assertEquals("The created URL is \"" + result + '"', verboseResult); // $NON-NLS-1$ }