@Test public void testReplacementForSingleVariableWithPrefixAndAppendix() { String value = "prefix.${testproperty}.appendix"; System.setProperty("testproperty", "correctreplacement"); String result = BounceProxySystemPropertyLoader.replaceVariableBySystemProperty(value); Assert.assertEquals("prefix.correctreplacement.appendix", result); System.clearProperty("testproperty"); }
@Test public void testReplacementForSingleVariable() { String value = "${testproperty}"; System.setProperty("testproperty", "correctreplacement"); String result = BounceProxySystemPropertyLoader.replaceVariableBySystemProperty(value); Assert.assertEquals("correctreplacement", result); System.clearProperty("testproperty"); }
@Test public void testReplacementForTwoVariablesWithAppendix() { String value = "${testproperty1}${testproperty2}.appendix"; System.setProperty("testproperty1", "correctreplacement1"); System.setProperty("testproperty2", "correctreplacement2"); String result = BounceProxySystemPropertyLoader.replaceVariableBySystemProperty(value); Assert.assertEquals("correctreplacement1correctreplacement2.appendix", result); System.clearProperty("testproperty1"); System.clearProperty("testproperty2"); }
@Test public void testReplacementForSingleVariableWithUnsetSystemProperty() { try { String value = "${testproperty}"; BounceProxySystemPropertyLoader.replaceVariableBySystemProperty(value); Assert.fail("Should throw a runtime exception"); } catch (JoynrRuntimeException e) { } }
@Test public void testReplacementOnString() { String value = "nothingToReplace"; String result = BounceProxySystemPropertyLoader.replaceVariableBySystemProperty(value); Assert.assertEquals(value, result); }