PropertiesLocator { public static void main(String[] args) throws Exception { PropertiesLocatorArgs propertiesLocatorArgs = new PropertiesLocatorArgs(); JCommander jCommander = new JCommander(propertiesLocatorArgs); try { File jarFile = _getJarFile(); if (jarFile.isFile()) { jCommander.setProgramName("java -jar " + jarFile.getName()); } else { jCommander.setProgramName(PropertiesLocator.class.getName()); } jCommander.parse(args); if (propertiesLocatorArgs.isHelp()) { jCommander.usage(); } else { new PropertiesLocator(propertiesLocatorArgs); } } catch (ParameterException pe) { System.err.println(pe.getMessage()); jCommander.usage(); } } PropertiesLocator(PropertiesLocatorArgs propertiesLocatorArgs); static void main(String[] args); SortedSet<PropertyProblem> getProblems();  }
@Test public void testPropertiesFromComments() throws Exception { File outputFile = new File(_buildDir, "commentedProperties.out"); String[] args = { "-p", "test-resources/originalProperties.properties", "-d", _liferayHome.getAbsolutePath(), "-o", outputFile.getAbsolutePath() }; PropertiesLocator.main(args); Path propertiesPath = Paths.get("test-resources/upgradeProperties.out"); String expectedOutput = new String(Files.readAllBytes(propertiesPath)); String testOutput = new String(Files.readAllBytes(outputFile.toPath())); Assert.assertEquals( expectedOutput.replaceAll(System.lineSeparator(), ""), testOutput.replaceAll(System.lineSeparator(), "")); }
@Test public void testPropertiesLocatorOutputFile() throws Exception { String version = System.getProperty("java.specification.version"); if (version.indexOf('.') > -1) { version = version.substring(version.indexOf('.') + 1); } int versionNumber = Integer.parseInt(version); Assume.assumeTrue(versionNumber > 8); File outputFile = new File(_buildDir, "testProperties.out"); String[] args = { "-p", "test-resources/6.2-fix-pack-131/portal.properties", "-d", _liferayHome.getAbsolutePath(), "-o", outputFile.getAbsolutePath() }; PropertiesLocator.main(args); Path propertiesPath = Paths.get("test-resources/checkProperties.out"); try (Stream<String> expectedLines = Files.lines(propertiesPath); Stream<String> actualLine = Files.lines(outputFile.toPath())) { String[] expected = expectedLines.sorted( ).collect( Collectors.toList() ).toArray( new String[0] ); String[] actual = actualLine.sorted( ).collect( Collectors.toList() ).toArray( new String[0] ); Assert.assertArrayEquals(expected, actual); } }