@Test @Ignore public void main_A$StringArray() throws Exception { String[] args = new String[] {}; ForceJUnitVersion4Command.main(args); }
public static void main(String[] args) throws Exception { config = getUpdatedConfig(config); config.junitVersion = JUnitVersion.version4; boolean hasFirstArg = (args != null && args.length > 0 && args[0] != null); String dirOrFile = hasFirstArg ? args[0] : config.directoryPathOfProductSourceCode; List<File> javaFiles = findTargets(config, dirOrFile); for (File javaFile : javaFiles) { Stdout.p(" Target: " + javaFile.getAbsolutePath()); } if (confirmToExecute() > 0) { return; } FileReader fileReader = FileReaderFactory.create(); for (File javaFile : javaFiles) { File testFile = null; String currentTestCaseSourceCode = null; try { String testFilePath = javaFile.getAbsolutePath().replaceAll("\\\\", "/").replaceFirst( getDirectoryPathOfProductSourceCode(config), getDirectoryPathOfTestSourceCode(config)) .replaceFirst("\\.java", "Test.java"); testFile = new File(testFilePath); currentTestCaseSourceCode = fileReader.readAsString(testFile); } catch (Exception e) { } CurrentLineBreak currentLineBreak = CurrentLineBreakDetector.detect(currentTestCaseSourceCode); LineBreakProvider lineBreakProvider = new LineBreakProvider(config, currentLineBreak); TestCaseGenerator testCaseGenerator = TestCaseGeneratorFactory.create(config, lineBreakProvider); String targetSourceCodeString = fileReader.readAsString(javaFile); testCaseGenerator.initialize(targetSourceCodeString); String testCodeString = null; if (currentTestCaseSourceCode != null) { testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(testCaseGenerator .getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode), JUnitVersion.version4); } else { testCodeString = testCaseGenerator.getNewTestCaseSourceCode(); } testCodeString = standardizeLineBreak(config, testCodeString); FileWriterFactory.create(testFile).writeText(testCodeString); Stdout.p(" Forced JUnit 4.x: " + testFile.getAbsolutePath()); } }
ForceJUnitVersion4Command extends AbstractCommand { public static void main(String[] args) throws Exception { config = getUpdatedConfig(config); config.junitVersion = JUnitVersion.version4; boolean hasFirstArg = (args != null && args.length > 0 && args[0] != null); String dirOrFile = hasFirstArg ? args[0] : config.directoryPathOfProductSourceCode; List<File> javaFiles = findTargets(config, dirOrFile); for (File javaFile : javaFiles) { Stdout.p(" Target: " + javaFile.getAbsolutePath()); } if (confirmToExecute() > 0) { return; } FileReader fileReader = FileReaderFactory.create(); for (File javaFile : javaFiles) { File testFile = null; String currentTestCaseSourceCode = null; try { String testFilePath = javaFile.getAbsolutePath().replaceAll("\\\\", "/").replaceFirst( getDirectoryPathOfProductSourceCode(config), getDirectoryPathOfTestSourceCode(config)) .replaceFirst("\\.java", "Test.java"); testFile = new File(testFilePath); currentTestCaseSourceCode = fileReader.readAsString(testFile); } catch (Exception e) { } CurrentLineBreak currentLineBreak = CurrentLineBreakDetector.detect(currentTestCaseSourceCode); LineBreakProvider lineBreakProvider = new LineBreakProvider(config, currentLineBreak); TestCaseGenerator testCaseGenerator = TestCaseGeneratorFactory.create(config, lineBreakProvider); String targetSourceCodeString = fileReader.readAsString(javaFile); testCaseGenerator.initialize(targetSourceCodeString); String testCodeString = null; if (currentTestCaseSourceCode != null) { testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(testCaseGenerator .getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode), JUnitVersion.version4); } else { testCodeString = testCaseGenerator.getNewTestCaseSourceCode(); } testCodeString = standardizeLineBreak(config, testCodeString); FileWriterFactory.create(testFile).writeText(testCodeString); Stdout.p(" Forced JUnit 4.x: " + testFile.getAbsolutePath()); } } }
ForceJUnitVersion4Command extends AbstractCommand { public static void main(String[] args) throws Exception { config = getUpdatedConfig(config); config.junitVersion = JUnitVersion.version4; boolean hasFirstArg = (args != null && args.length > 0 && args[0] != null); String dirOrFile = hasFirstArg ? args[0] : config.directoryPathOfProductSourceCode; List<File> javaFiles = findTargets(config, dirOrFile); for (File javaFile : javaFiles) { Stdout.p(" Target: " + javaFile.getAbsolutePath()); } if (confirmToExecute() > 0) { return; } FileReader fileReader = FileReaderFactory.create(); for (File javaFile : javaFiles) { File testFile = null; String currentTestCaseSourceCode = null; try { String testFilePath = javaFile.getAbsolutePath().replaceAll("\\\\", "/").replaceFirst( getDirectoryPathOfProductSourceCode(config), getDirectoryPathOfTestSourceCode(config)) .replaceFirst("\\.java", "Test.java"); testFile = new File(testFilePath); currentTestCaseSourceCode = fileReader.readAsString(testFile); } catch (Exception e) { } CurrentLineBreak currentLineBreak = CurrentLineBreakDetector.detect(currentTestCaseSourceCode); LineBreakProvider lineBreakProvider = new LineBreakProvider(config, currentLineBreak); TestCaseGenerator testCaseGenerator = TestCaseGeneratorFactory.create(config, lineBreakProvider); String targetSourceCodeString = fileReader.readAsString(javaFile); testCaseGenerator.initialize(targetSourceCodeString); String testCodeString = null; if (currentTestCaseSourceCode != null) { testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(testCaseGenerator .getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode), JUnitVersion.version4); } else { testCodeString = testCaseGenerator.getNewTestCaseSourceCode(); } testCodeString = standardizeLineBreak(config, testCodeString); FileWriterFactory.create(testFile).writeText(testCodeString); Stdout.p(" Forced JUnit 4.x: " + testFile.getAbsolutePath()); } } private  ForceJUnitVersion4Command(); }
ForceJUnitVersion4Command extends AbstractCommand { public static void main(String[] args) throws Exception { config = getUpdatedConfig(config); config.junitVersion = JUnitVersion.version4; boolean hasFirstArg = (args != null && args.length > 0 && args[0] != null); String dirOrFile = hasFirstArg ? args[0] : config.directoryPathOfProductSourceCode; List<File> javaFiles = findTargets(config, dirOrFile); for (File javaFile : javaFiles) { Stdout.p(" Target: " + javaFile.getAbsolutePath()); } if (confirmToExecute() > 0) { return; } FileReader fileReader = FileReaderFactory.create(); for (File javaFile : javaFiles) { File testFile = null; String currentTestCaseSourceCode = null; try { String testFilePath = javaFile.getAbsolutePath().replaceAll("\\\\", "/").replaceFirst( getDirectoryPathOfProductSourceCode(config), getDirectoryPathOfTestSourceCode(config)) .replaceFirst("\\.java", "Test.java"); testFile = new File(testFilePath); currentTestCaseSourceCode = fileReader.readAsString(testFile); } catch (Exception e) { } CurrentLineBreak currentLineBreak = CurrentLineBreakDetector.detect(currentTestCaseSourceCode); LineBreakProvider lineBreakProvider = new LineBreakProvider(config, currentLineBreak); TestCaseGenerator testCaseGenerator = TestCaseGeneratorFactory.create(config, lineBreakProvider); String targetSourceCodeString = fileReader.readAsString(javaFile); testCaseGenerator.initialize(targetSourceCodeString); String testCodeString = null; if (currentTestCaseSourceCode != null) { testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(testCaseGenerator .getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode), JUnitVersion.version4); } else { testCodeString = testCaseGenerator.getNewTestCaseSourceCode(); } testCodeString = standardizeLineBreak(config, testCodeString); FileWriterFactory.create(testFile).writeText(testCodeString); Stdout.p(" Forced JUnit 4.x: " + testFile.getAbsolutePath()); } } private  ForceJUnitVersion4Command(); static void main(String[] args); }
ForceJUnitVersion4Command extends AbstractCommand { public static void main(String[] args) throws Exception { config = getUpdatedConfig(config); config.junitVersion = JUnitVersion.version4; boolean hasFirstArg = (args != null && args.length > 0 && args[0] != null); String dirOrFile = hasFirstArg ? args[0] : config.directoryPathOfProductSourceCode; List<File> javaFiles = findTargets(config, dirOrFile); for (File javaFile : javaFiles) { Stdout.p(" Target: " + javaFile.getAbsolutePath()); } if (confirmToExecute() > 0) { return; } FileReader fileReader = FileReaderFactory.create(); for (File javaFile : javaFiles) { File testFile = null; String currentTestCaseSourceCode = null; try { String testFilePath = javaFile.getAbsolutePath().replaceAll("\\\\", "/").replaceFirst( getDirectoryPathOfProductSourceCode(config), getDirectoryPathOfTestSourceCode(config)) .replaceFirst("\\.java", "Test.java"); testFile = new File(testFilePath); currentTestCaseSourceCode = fileReader.readAsString(testFile); } catch (Exception e) { } CurrentLineBreak currentLineBreak = CurrentLineBreakDetector.detect(currentTestCaseSourceCode); LineBreakProvider lineBreakProvider = new LineBreakProvider(config, currentLineBreak); TestCaseGenerator testCaseGenerator = TestCaseGeneratorFactory.create(config, lineBreakProvider); String targetSourceCodeString = fileReader.readAsString(javaFile); testCaseGenerator.initialize(targetSourceCodeString); String testCodeString = null; if (currentTestCaseSourceCode != null) { testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(testCaseGenerator .getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode), JUnitVersion.version4); } else { testCodeString = testCaseGenerator.getNewTestCaseSourceCode(); } testCodeString = standardizeLineBreak(config, testCodeString); FileWriterFactory.create(testFile).writeText(testCodeString); Stdout.p(" Forced JUnit 4.x: " + testFile.getAbsolutePath()); } } private  ForceJUnitVersion4Command(); static void main(String[] args); static Configuration config; }