@Test public void attemptToMergeReservedProperty() throws Exception { HashMap<String, String> customProperties = new HashMap<String, String>(); customProperties.put("user.dir", "/home/foo"); Properties propertiesFile = new Properties(); propertiesFile.load(new FileInputStream(new File(this.testFile.toURI()))); ByteArrayOutputStream logCapture = new ByteArrayOutputStream(); System.setOut(new PrintStream(logCapture)); Properties modifiedProperties = new PropertyFileMerger().mergeProperties(customProperties, propertiesFile); String loggedMessage = UtilityFunctions.stripCarriageReturns(logCapture.toString()); System.setOut(this.originalOut); assertThat(modifiedProperties.containsKey("user.dir"), is(equalTo(false))); assertThat(modifiedProperties.size(), is(equalTo(2))); assertThat( loggedMessage, is( equalTo( "[warn] Unable to set 'user.dir', it is a reserved property in the jmeter-maven-plugin"))); }
@Test public void showWarningWithSimilarProperty() throws Exception { HashMap<String, String> customProperties = new HashMap<String, String>(); customProperties.put("log_level.Jmeter", "INFO"); Properties propertiesFile = new Properties(); propertiesFile.load(new FileInputStream(new File(this.testFile.toURI()))); ByteArrayOutputStream logCapture = new ByteArrayOutputStream(); System.setOut(new PrintStream(logCapture)); Properties modifiedProperties = new PropertyFileMerger().mergeProperties(customProperties, propertiesFile); String loggedMessage = UtilityFunctions.stripCarriageReturns(logCapture.toString()); System.setOut(this.originalOut); assertThat(modifiedProperties.size(), is(equalTo(3))); assertThat( loggedMessage, is( equalTo( "[warn] You have set a property called 'log_level.Jmeter' which is very similar to 'log_level.jmeter'!"))); }