diff options
-rw-r--r-- | build.xml | 8 | ||||
-rw-r--r-- | test/core/src/lombok/AbstractRunTests.java | 136 | ||||
-rw-r--r-- | test/core/src/lombok/DirectoryRunner.java | 72 | ||||
-rw-r--r-- | test/core/src/lombok/RunTestsViaDelombok.java | 128 | ||||
-rw-r--r-- | test/core/src/lombok/RunTestsViaEcj.java | 56 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/ClassNamedAfterGetter.java (renamed from test/delombok/resource/after/ClassNamedAfterGetter.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/CleanupName.java (renamed from test/delombok/resource/after/CleanupName.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/CleanupPlain.java (renamed from test/delombok/resource/after/CleanupPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/CommentsInterspersed.java (renamed from test/delombok/resource/after/CommentsInterspersed.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/DataExtended.java | 37 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/DataIgnore.java (renamed from test/delombok/resource/after/DataIgnore.java) | 6 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/DataPlain.java (renamed from test/delombok/resource/after/DataPlain.java) | 20 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/GetterAccessLevel.java (renamed from test/delombok/resource/after/GetterAccessLevel.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/GetterAlreadyExists.java (renamed from test/delombok/resource/after/GetterAlreadyExists.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/GetterBoolean.java (renamed from test/delombok/resource/after/GetterBoolean.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/GetterOnClass.java (renamed from test/delombok/resource/after/GetterOnClass.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/GetterPlain.java (renamed from test/delombok/resource/after/GetterPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/GetterWithDollar.java (renamed from test/delombok/resource/after/GetterWithDollar.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/NonNullPlain.java (renamed from test/delombok/resource/after/NonNullPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SetterAccessLevel.java (renamed from test/delombok/resource/after/SetterAccessLevel.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SetterAlreadyExists.java (renamed from test/delombok/resource/after/SetterAlreadyExists.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SetterOnClass.java (renamed from test/delombok/resource/after/SetterOnClass.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SetterPlain.java (renamed from test/delombok/resource/after/SetterPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SetterWithDollar.java (renamed from test/delombok/resource/after/SetterWithDollar.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SneakyThrowsMultiple.java (renamed from test/delombok/resource/after/SneakyThrowsMultiple.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SneakyThrowsPlain.java (renamed from test/delombok/resource/after/SneakyThrowsPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SneakyThrowsSingle.java (renamed from test/delombok/resource/after/SneakyThrowsSingle.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SynchronizedName.java (renamed from test/delombok/resource/after/SynchronizedName.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/SynchronizedPlain.java (renamed from test/delombok/resource/after/SynchronizedPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/ToStringInner.java (renamed from test/delombok/resource/after/ToStringInner.java) | 12 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/ToStringPlain.java (renamed from test/delombok/resource/after/ToStringPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/ClassNamedAfterGetter.java (renamed from test/delombok/resource/before/ClassNamedAfterGetter.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/CleanupName.java (renamed from test/delombok/resource/before/CleanupName.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/CleanupPlain.java (renamed from test/delombok/resource/before/CleanupPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/CommentsInterspersed.java (renamed from test/delombok/resource/before/CommentsInterspersed.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/DataExtended.java | 5 | ||||
-rw-r--r-- | test/transform/resource/before/DataIgnore.java (renamed from test/delombok/resource/before/DataIgnore.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/DataPlain.java (renamed from test/delombok/resource/before/DataPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/GetterAccessLevel.java (renamed from test/delombok/resource/before/GetterAccessLevel.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/GetterAlreadyExists.java (renamed from test/delombok/resource/before/GetterAlreadyExists.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/GetterBoolean.java (renamed from test/delombok/resource/before/GetterBoolean.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/GetterOnClass.java (renamed from test/delombok/resource/before/GetterOnClass.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/GetterPlain.java (renamed from test/delombok/resource/before/GetterPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/GetterWithDollar.java (renamed from test/delombok/resource/before/GetterWithDollar.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/NonNullPlain.java (renamed from test/delombok/resource/before/NonNullPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SetterAccessLevel.java (renamed from test/delombok/resource/before/SetterAccessLevel.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SetterAlreadyExists.java (renamed from test/delombok/resource/before/SetterAlreadyExists.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SetterOnClass.java (renamed from test/delombok/resource/before/SetterOnClass.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SetterPlain.java (renamed from test/delombok/resource/before/SetterPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SetterWithDollar.java (renamed from test/delombok/resource/before/SetterWithDollar.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SneakyThrowsMultiple.java (renamed from test/delombok/resource/before/SneakyThrowsMultiple.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SneakyThrowsPlain.java (renamed from test/delombok/resource/before/SneakyThrowsPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SneakyThrowsSingle.java (renamed from test/delombok/resource/before/SneakyThrowsSingle.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SynchronizedName.java (renamed from test/delombok/resource/before/SynchronizedName.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/SynchronizedPlain.java (renamed from test/delombok/resource/before/SynchronizedPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/before/ToStringInner.java (renamed from test/delombok/resource/before/ToStringInner.java) | 1 | ||||
-rw-r--r-- | test/transform/resource/before/ToStringPlain.java (renamed from test/delombok/resource/before/ToStringPlain.java) | 0 | ||||
-rw-r--r-- | test/transform/resource/messages-delombok/GetterAlreadyExists.java.messages (renamed from test/delombok/resource/before/GetterAlreadyExists.java.messages) | 0 | ||||
-rw-r--r-- | test/transform/resource/messages-delombok/GetterBoolean.java.messages (renamed from test/delombok/resource/before/GetterBoolean.java.messages) | 0 | ||||
-rw-r--r-- | test/transform/resource/messages-delombok/SetterAlreadyExists.java.messages (renamed from test/delombok/resource/before/SetterAlreadyExists.java.messages) | 0 | ||||
-rw-r--r-- | test/transform/src/lombok/transform/TestLombokFilesIdempotent.java (renamed from test/delombok/src/lombok/delombok/TestLombokFilesIdempotent.java) | 32 | ||||
-rw-r--r-- | test/transform/src/lombok/transform/TestSourceFiles.java (renamed from test/delombok/src/lombok/delombok/TestSourceFiles.java) | 25 | ||||
-rw-r--r-- | test/transform/src/lombok/transform/TestWithDelombok.java (renamed from test/delombok/src/lombok/delombok/TestLombokFiles.java) | 32 |
63 files changed, 385 insertions, 185 deletions
@@ -168,7 +168,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr <srcdir dir="src/installer" /> <srcdir dir="src/delombok" /> <srcdir dir="experimental/src" /> - <srcdir dir="test/delombok/src" /> + <srcdir dir="test/transform/src" /> <srcdir dir="test/core/src" /> <conf name="build" sources="contrib" /> <conf name="test" sources="contrib" /> @@ -206,11 +206,11 @@ the common tasks and can be called on to run the main aspects of all the sub-scr <classpath refid="test.path" /> <classpath path="build/lombok" /> <src path="test/core/src" /> - <src path="test/delombok/src" /> + <src path="test/transform/src" /> </ivy:compile> <copy todir="build/tests"> <fileset dir="test/pretty/resource" /> - <fileset dir="test/delombok/resource" /> + <fileset dir="test/transform/resource" /> </copy> </target> @@ -224,7 +224,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr <fileset dir="test/core/src"> <include name="**/Test*.java" /> </fileset> - <fileset dir="test/delombok/src"> + <fileset dir="test/transform/src"> <include name="**/Test*.java" /> </fileset> </batchtest> diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java new file mode 100644 index 00000000..ad9c45af --- /dev/null +++ b/test/core/src/lombok/AbstractRunTests.java @@ -0,0 +1,136 @@ +/* + * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok; + +import static org.junit.Assert.*; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +public abstract class AbstractRunTests { + protected static final String LINE_SEPARATOR = System.getProperty("line.separator"); + + public void compareFile(DirectoryRunner.TestParams params, File file) throws Throwable { + StringBuilder messages = new StringBuilder(); + StringWriter result = new StringWriter(); + transformCode(messages, result, file); + compare( + file.getName(), + readFile(params.getAfterDirectory(), file, false), + result.toString(), + readFile(params.getMessagesDirectory(), file, true), + messages.toString(), + params.printErrors()); + } + + protected abstract void transformCode(StringBuilder message, StringWriter result, File file) throws Throwable; + + protected String readFile(File file) throws IOException { + BufferedReader reader; + try { + reader = new BufferedReader(new FileReader(file)); + } catch (FileNotFoundException e) { + return ""; + } + StringBuilder result = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + result.append(line); + result.append(LINE_SEPARATOR); + } + reader.close(); + return result.toString(); + } + + private String readFile(File dir, File file, boolean messages) throws IOException { + if (dir == null) return ""; + return readFile(new File(dir, file.getName() + (messages ? ".messages" : ""))); + } + + private void compare(String name, String expectedFile, String actualFile, String expectedMessages, String actualMessages, boolean printErrors) throws Throwable { + try { + compareContent(name, expectedFile, actualFile); + } catch (Throwable e) { + if (printErrors) { + System.out.println("***** " + name + " *****"); + System.out.println(e.getMessage()); + System.out.println("**** Expected ******"); + System.out.println(expectedFile); + System.out.println("**** Actual ******"); + System.out.println(actualFile); + System.out.println("*******************"); + } + throw e; + } + try { + compareContent(name, expectedMessages, actualMessages); + } + catch (Throwable e) { + if (printErrors) { + System.out.println("***** " + name + " *****"); + System.out.println(e.getMessage()); + System.out.println("**** Expected ******"); + System.out.println(expectedMessages); + System.out.println("**** Actual ******"); + System.out.println(actualMessages); + System.out.println("*******************"); + } + throw e; + } + } + + private static void compareContent(String name, String expectedFile, String actualFile) { + String[] expectedLines = expectedFile.split("(\\r?\\n)"); + String[] actualLines = actualFile.split("(\\r?\\n)"); + if (actualLines[0].startsWith("// Generated by delombok at ")) { + actualLines[0] = ""; + } + expectedLines = removeBlanks(expectedLines); + actualLines = removeBlanks(actualLines); + int size = Math.min(expectedLines.length, actualLines.length); + for (int i = 0; i < size; i++) { + String expected = expectedLines[i]; + String actual = actualLines[i]; + assertEquals(String.format("Difference in %s on line %d", name, i + 1), expected, actual); + } + if (expectedLines.length > actualLines.length) { + fail(String.format("Missing line %d in generated %s: %s", size + 1, name, expectedLines[size])); + } + if (expectedLines.length < actualLines.length) { + fail(String.format("Extra line %d in generated %s: %s", size + 1, name, actualLines[size])); + } + } + + private static String[] removeBlanks(String[] in) { + List<String> out = new ArrayList<String>(); + for (String s : in) { + if (!s.trim().isEmpty()) out.add(s); + } + return out.toArray(new String[0]); + } +} diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java index db474ff0..89fe6ab0 100644 --- a/test/core/src/lombok/DirectoryRunner.java +++ b/test/core/src/lombok/DirectoryRunner.java @@ -1,3 +1,24 @@ +/* + * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok; import java.io.BufferedReader; @@ -6,7 +27,6 @@ import java.io.FileFilter; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.lang.reflect.Method; import java.util.Map; import java.util.TreeMap; @@ -16,6 +36,17 @@ import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; public class DirectoryRunner extends Runner { + public enum Compiler { + DELOMBOK, JAVAC, ECJ; + } + + public interface TestParams { + Compiler getCompiler(); + boolean printErrors(); + File getBeforeDirectory(); + File getAfterDirectory(); + File getMessagesDirectory(); + } private static final FileFilter JAVA_FILE_FILTER = new FileFilter() { @Override public boolean accept(File file) { @@ -26,11 +57,13 @@ public class DirectoryRunner extends Runner { private final Description description; private final Map<String, Description> tests = new TreeMap<String, Description>(); private final Throwable failure; - private File beforeDirectory; - private File afterDirectory; + private final TestParams params; - public DirectoryRunner(Class<?> testClass) { + public DirectoryRunner(Class<?> testClass) throws Exception { description = Description.createSuiteDescription(testClass); + + this.params = (TestParams) testClass.newInstance(); + Throwable error = null; try { addTests(testClass); @@ -40,26 +73,20 @@ public class DirectoryRunner extends Runner { } this.failure = error; } - + private void addTests(Class<?> testClass) throws Exception { - Method beforeMethod = testClass.getDeclaredMethod("getBeforeDirectory"); - beforeDirectory = (File) beforeMethod.invoke(null); - - Method afterMethod = testClass.getDeclaredMethod("getAfterDirectory"); - afterDirectory = (File) afterMethod.invoke(null); - - for (File file : beforeDirectory.listFiles(JAVA_FILE_FILTER)) { + for (File file : params.getBeforeDirectory().listFiles(JAVA_FILE_FILTER)) { Description testDescription = Description.createTestDescription(testClass, file.getName()); description.addChild(testDescription); tests.put(file.getName(), testDescription); } } - + @Override public Description getDescription() { return description; } - + @Override public void run(RunNotifier notifier) { if (failure != null) { @@ -83,16 +110,25 @@ public class DirectoryRunner extends Runner { notifier.fireTestFinished(testDescription); } } - + private boolean runTest(String fileName) throws Throwable { - File file = new File(beforeDirectory, fileName); + File file = new File(params.getBeforeDirectory(), fileName); if (mustIgnore(file)) { return false; } - RunTestsViaDelombok.compareFile(beforeDirectory, afterDirectory, file); + switch (params.getCompiler()) { + case DELOMBOK: + new RunTestsViaDelombok().compareFile(params, file); + break; + case ECJ: + new RunTestsViaEcj().compareFile(params, file); + break; + case JAVAC: + throw new UnsupportedOperationException(); + } return true; } - + private boolean mustIgnore(File file) throws FileNotFoundException, IOException { BufferedReader reader = new BufferedReader(new FileReader(file)); String line = reader.readLine(); diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java index 37ff8f69..7f99b99e 100644 --- a/test/core/src/lombok/RunTestsViaDelombok.java +++ b/test/core/src/lombok/RunTestsViaDelombok.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,17 +21,8 @@ */ package lombok; -import static org.junit.Assert.*; - -import java.io.BufferedReader; import java.io.File; -import java.io.FileFilter; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; import java.util.Locale; import javax.tools.Diagnostic; @@ -40,124 +31,21 @@ import javax.tools.JavaFileObject; import lombok.delombok.Delombok; -public class RunTestsViaDelombok { - private static final FileFilter JAVA_FILE_FILTER = new FileFilter() { - @Override public boolean accept(File file) { - return file.isFile() && file.getName().endsWith(".java"); - } - }; - - private static Delombok delombok = new Delombok(); - private static volatile boolean printErrors = false; - - private static final String LINE_SEPARATOR = System.getProperty("line.separator"); +public class RunTestsViaDelombok extends AbstractRunTests { + private Delombok delombok = new Delombok(); - public static void runComparison(File beforeDir, File afterDir) throws Throwable { - File[] listFiles = beforeDir.listFiles(JAVA_FILE_FILTER); - - for (File file : listFiles) { - compareFile(beforeDir, afterDir, file); - } - } - - public static void compareFile(File beforeDir, File afterDir, File file) throws Throwable { + @Override + public void transformCode(final StringBuilder messages, StringWriter result, File file) throws Throwable { delombok.setVerbose(false); delombok.setForceProcess(true); delombok.setCharset("UTF-8"); - - final StringBuilder messages = new StringBuilder(); + delombok.setDiagnosticsListener(new DiagnosticListener<JavaFileObject>() { @Override public void report(Diagnostic<? extends JavaFileObject> d) { messages.append(String.format("%d:%d %s %s\n", d.getLineNumber(), d.getColumnNumber(), d.getKind(), d.getMessage(Locale.ENGLISH))); } }); - StringWriter writer = new StringWriter(); - delombok.delombok(file.getAbsolutePath(), writer); - compare(file.getName(), readFile(afterDir, file, false), writer.toString(), readFile(beforeDir, file, true), messages.toString()); - } - - public static void printErrors(boolean print) { - printErrors = print; - } - - private static void compare(String name, String expectedFile, String actualFile, String expectedMessages, String actualMessages) throws Throwable { - try { - compareContent(name, expectedFile, actualFile); - } - catch (Throwable e) { - if (printErrors) { - System.out.println("***** " + name + " *****"); - System.out.println(e.getMessage()); - System.out.println("**** Expected ******"); - System.out.println(expectedFile); - System.out.println("**** Actual ******"); - System.out.println(actualFile); - System.out.println("*******************"); - } - throw e; - } - try { - compareContent(name, expectedMessages, actualMessages); - } - catch (Throwable e) { - if (printErrors) { - System.out.println("***** " + name + " *****"); - System.out.println(e.getMessage()); - System.out.println("**** Expected ******"); - System.out.println(expectedMessages); - System.out.println("**** Actual ******"); - System.out.println(actualMessages); - System.out.println("*******************"); - } - throw e; - } - } - - private static void compareContent(String name, String expectedFile, String actualFile) { - String[] expectedLines = expectedFile.split("(\\r?\\n)"); - String[] actualLines = actualFile.split("(\\r?\\n)"); - if (actualLines[0].startsWith("// Generated by delombok at ")) { - actualLines[0] = ""; - } - expectedLines = removeBlanks(expectedLines); - actualLines = removeBlanks(actualLines); - int size = Math.min(expectedLines.length, actualLines.length); - for (int i = 0; i < size; i++) { - String expected = expectedLines[i]; - String actual = actualLines[i]; - assertEquals(String.format("Difference in %s on line %d", name, i + 1), expected, actual); - } - if (expectedLines.length > actualLines.length) { - fail(String.format("Missing line %d in generated %s: %s", size + 1, name, expectedLines[size])); - } - if (expectedLines.length < actualLines.length) { - fail(String.format("Extra line %d in generated %s: %s", size + 1, name, actualLines[size])); - } - } - - private static String readFile(File afterDir, File file, boolean messages) throws IOException { - BufferedReader reader; - try { - reader = new BufferedReader(new FileReader(new File(afterDir, file.getName() + (messages ? ".messages" : "")))); - } catch (FileNotFoundException e) { - return ""; - } - StringBuilder result = new StringBuilder(); - String line; - while ((line = reader.readLine()) != null) { - result.append(line); - result.append(LINE_SEPARATOR); - } - reader.close(); - return result.toString(); - } - - private static String[] removeBlanks(String[] in) { - List<String> out = new ArrayList<String>(); - for (String s : in) { - if (!s.trim().isEmpty()) out.add(s); - } - return out.toArray(new String[0]); + delombok.delombok(file.getAbsolutePath(), result); } -}
\ No newline at end of file +} diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java new file mode 100644 index 00000000..3f7d6e81 --- /dev/null +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -0,0 +1,56 @@ +package lombok; + +import java.io.File; +import java.io.StringWriter; +import java.util.Locale; + +import lombok.eclipse.TransformEclipseAST; + +import org.eclipse.jdt.core.compiler.CategorizedProblem; +import org.eclipse.jdt.internal.compiler.CompilationResult; +import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; +import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; +import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.eclipse.jdt.internal.compiler.parser.Parser; +import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; +import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; + +public class RunTestsViaEcj extends AbstractRunTests { + protected static CompilerOptions ecjCompilerOptions() { + CompilerOptions options = new CompilerOptions(); + options.complianceLevel = ClassFileConstants.JDK1_6; + options.sourceLevel = ClassFileConstants.JDK1_6; + options.targetJDK = ClassFileConstants.JDK1_6; + options.parseLiteralExpressionsAsConstants = true; + return options; + } + + @Override + public void transformCode(final StringBuilder messages, StringWriter result, File file) throws Throwable { + ProblemReporter problemReporter = new ProblemReporter(new IErrorHandlingPolicy() { + public boolean proceedOnErrors() { + return true; + } + + public boolean stopOnFirstError() { + return false; + } + }, ecjCompilerOptions(), new DefaultProblemFactory(Locale.ENGLISH)); + + Parser parser = new Parser(problemReporter, true); + String source = readFile(file); + CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), "UTF-8"); + CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); + CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult); + + TransformEclipseAST.transform(parser, cud); + + for (CategorizedProblem p : compilationResult.getErrors()) { + messages.append(p.toString()).append("\n"); + } + + result.append(cud.toString()); + } +} diff --git a/test/delombok/resource/after/ClassNamedAfterGetter.java b/test/transform/resource/after-delombok/ClassNamedAfterGetter.java index 769aaf7c..769aaf7c 100644 --- a/test/delombok/resource/after/ClassNamedAfterGetter.java +++ b/test/transform/resource/after-delombok/ClassNamedAfterGetter.java diff --git a/test/delombok/resource/after/CleanupName.java b/test/transform/resource/after-delombok/CleanupName.java index cd29eb68..cd29eb68 100644 --- a/test/delombok/resource/after/CleanupName.java +++ b/test/transform/resource/after-delombok/CleanupName.java diff --git a/test/delombok/resource/after/CleanupPlain.java b/test/transform/resource/after-delombok/CleanupPlain.java index 35d51543..35d51543 100644 --- a/test/delombok/resource/after/CleanupPlain.java +++ b/test/transform/resource/after-delombok/CleanupPlain.java diff --git a/test/delombok/resource/after/CommentsInterspersed.java b/test/transform/resource/after-delombok/CommentsInterspersed.java index 5aaafe42..5aaafe42 100644 --- a/test/delombok/resource/after/CommentsInterspersed.java +++ b/test/transform/resource/after-delombok/CommentsInterspersed.java diff --git a/test/transform/resource/after-delombok/DataExtended.java b/test/transform/resource/after-delombok/DataExtended.java new file mode 100644 index 00000000..6f55bc2c --- /dev/null +++ b/test/transform/resource/after-delombok/DataExtended.java @@ -0,0 +1,37 @@ +class DataExtended { + int x; + @java.lang.SuppressWarnings("all") + public DataExtended() { + } + @java.lang.SuppressWarnings("all") + public int getX() { + return this.x; + } + @java.lang.SuppressWarnings("all") + public void setX(final int x) { + this.x = x; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (o == null) return false; + if (o.getClass() != this.getClass()) return false; + final DataExtended other = (DataExtended)o; + if (this.getX() != other.getX()) return false; + return true; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 31; + int result = 1; + result = result * PRIME + this.getX(); + return result; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "DataExtended(x=" + this.x + ")"; + } +}
\ No newline at end of file diff --git a/test/delombok/resource/after/DataIgnore.java b/test/transform/resource/after-delombok/DataIgnore.java index feb2c0ef..7e81432d 100644 --- a/test/delombok/resource/after/DataIgnore.java +++ b/test/transform/resource/after-delombok/DataIgnore.java @@ -17,7 +17,7 @@ class DataIgnore { if (o == null) return false; if (o.getClass() != this.getClass()) return false; final DataIgnore other = (DataIgnore)o; - if (this.x != other.x) return false; + if (this.getX() != other.getX()) return false; return true; } @java.lang.Override @@ -25,12 +25,12 @@ class DataIgnore { public int hashCode() { final int PRIME = 31; int result = 1; - result = result * PRIME + this.x; + result = result * PRIME + this.getX(); return result; } @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "DataIgnore(x=" + this.x + ")"; + return "DataIgnore(x=" + this.getX() + ")"; } } diff --git a/test/delombok/resource/after/DataPlain.java b/test/transform/resource/after-delombok/DataPlain.java index 2938a46e..1e11a33d 100644 --- a/test/delombok/resource/after/DataPlain.java +++ b/test/transform/resource/after-delombok/DataPlain.java @@ -25,8 +25,8 @@ class Data1 { if (o == null) return false; if (o.getClass() != this.getClass()) return false; final Data1 other = (Data1)o; - if (this.x != other.x) return false; - if (this.name == null ? other.name != null : !this.name.equals(other.name)) return false; + if (this.getX() != other.getX()) return false; + if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false; return true; } @java.lang.Override @@ -34,14 +34,14 @@ class Data1 { public int hashCode() { final int PRIME = 31; int result = 1; - result = result * PRIME + this.x; - result = result * PRIME + (this.name == null ? 0 : this.name.hashCode()); + result = result * PRIME + this.getX(); + result = result * PRIME + (this.getName() == null ? 0 : this.getName().hashCode()); return result; } @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "Data1(x=" + this.x + ", name=" + this.name + ")"; + return "Data1(x=" + this.getX() + ", name=" + this.getName() + ")"; } } class Data2 { @@ -71,8 +71,8 @@ class Data2 { if (o == null) return false; if (o.getClass() != this.getClass()) return false; final Data2 other = (Data2)o; - if (this.x != other.x) return false; - if (this.name == null ? other.name != null : !this.name.equals(other.name)) return false; + if (this.getX() != other.getX()) return false; + if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false; return true; } @java.lang.Override @@ -80,13 +80,13 @@ class Data2 { public int hashCode() { final int PRIME = 31; int result = 1; - result = result * PRIME + this.x; - result = result * PRIME + (this.name == null ? 0 : this.name.hashCode()); + result = result * PRIME + this.getX(); + result = result * PRIME + (this.getName() == null ? 0 : this.getName().hashCode()); return result; } @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "Data2(x=" + this.x + ", name=" + this.name + ")"; + return "Data2(x=" + this.getX() + ", name=" + this.getName() + ")"; } } diff --git a/test/delombok/resource/after/GetterAccessLevel.java b/test/transform/resource/after-delombok/GetterAccessLevel.java index 6d977d87..6d977d87 100644 --- a/test/delombok/resource/after/GetterAccessLevel.java +++ b/test/transform/resource/after-delombok/GetterAccessLevel.java diff --git a/test/delombok/resource/after/GetterAlreadyExists.java b/test/transform/resource/after-delombok/GetterAlreadyExists.java index 6a5377ba..6a5377ba 100644 --- a/test/delombok/resource/after/GetterAlreadyExists.java +++ b/test/transform/resource/after-delombok/GetterAlreadyExists.java diff --git a/test/delombok/resource/after/GetterBoolean.java b/test/transform/resource/after-delombok/GetterBoolean.java index a727e49b..a727e49b 100644 --- a/test/delombok/resource/after/GetterBoolean.java +++ b/test/transform/resource/after-delombok/GetterBoolean.java diff --git a/test/delombok/resource/after/GetterOnClass.java b/test/transform/resource/after-delombok/GetterOnClass.java index bd15ce35..bd15ce35 100644 --- a/test/delombok/resource/after/GetterOnClass.java +++ b/test/transform/resource/after-delombok/GetterOnClass.java diff --git a/test/delombok/resource/after/GetterPlain.java b/test/transform/resource/after-delombok/GetterPlain.java index 359d46e2..359d46e2 100644 --- a/test/delombok/resource/after/GetterPlain.java +++ b/test/transform/resource/after-delombok/GetterPlain.java diff --git a/test/delombok/resource/after/GetterWithDollar.java b/test/transform/resource/after-delombok/GetterWithDollar.java index 9e02ccb8..9e02ccb8 100644 --- a/test/delombok/resource/after/GetterWithDollar.java +++ b/test/transform/resource/after-delombok/GetterWithDollar.java diff --git a/test/delombok/resource/after/NonNullPlain.java b/test/transform/resource/after-delombok/NonNullPlain.java index 19869db1..19869db1 100644 --- a/test/delombok/resource/after/NonNullPlain.java +++ b/test/transform/resource/after-delombok/NonNullPlain.java diff --git a/test/delombok/resource/after/SetterAccessLevel.java b/test/transform/resource/after-delombok/SetterAccessLevel.java index dce4cc2f..dce4cc2f 100644 --- a/test/delombok/resource/after/SetterAccessLevel.java +++ b/test/transform/resource/after-delombok/SetterAccessLevel.java diff --git a/test/delombok/resource/after/SetterAlreadyExists.java b/test/transform/resource/after-delombok/SetterAlreadyExists.java index e4992b29..e4992b29 100644 --- a/test/delombok/resource/after/SetterAlreadyExists.java +++ b/test/transform/resource/after-delombok/SetterAlreadyExists.java diff --git a/test/delombok/resource/after/SetterOnClass.java b/test/transform/resource/after-delombok/SetterOnClass.java index 05528ff8..05528ff8 100644 --- a/test/delombok/resource/after/SetterOnClass.java +++ b/test/transform/resource/after-delombok/SetterOnClass.java diff --git a/test/delombok/resource/after/SetterPlain.java b/test/transform/resource/after-delombok/SetterPlain.java index 39aa7b61..39aa7b61 100644 --- a/test/delombok/resource/after/SetterPlain.java +++ b/test/transform/resource/after-delombok/SetterPlain.java diff --git a/test/delombok/resource/after/SetterWithDollar.java b/test/transform/resource/after-delombok/SetterWithDollar.java index c26a1ccd..c26a1ccd 100644 --- a/test/delombok/resource/after/SetterWithDollar.java +++ b/test/transform/resource/after-delombok/SetterWithDollar.java diff --git a/test/delombok/resource/after/SneakyThrowsMultiple.java b/test/transform/resource/after-delombok/SneakyThrowsMultiple.java index bab13990..bab13990 100644 --- a/test/delombok/resource/after/SneakyThrowsMultiple.java +++ b/test/transform/resource/after-delombok/SneakyThrowsMultiple.java diff --git a/test/delombok/resource/after/SneakyThrowsPlain.java b/test/transform/resource/after-delombok/SneakyThrowsPlain.java index d5abc478..d5abc478 100644 --- a/test/delombok/resource/after/SneakyThrowsPlain.java +++ b/test/transform/resource/after-delombok/SneakyThrowsPlain.java diff --git a/test/delombok/resource/after/SneakyThrowsSingle.java b/test/transform/resource/after-delombok/SneakyThrowsSingle.java index 519d06a9..519d06a9 100644 --- a/test/delombok/resource/after/SneakyThrowsSingle.java +++ b/test/transform/resource/after-delombok/SneakyThrowsSingle.java diff --git a/test/delombok/resource/after/SynchronizedName.java b/test/transform/resource/after-delombok/SynchronizedName.java index 066e3bdf..066e3bdf 100644 --- a/test/delombok/resource/after/SynchronizedName.java +++ b/test/transform/resource/after-delombok/SynchronizedName.java diff --git a/test/delombok/resource/after/SynchronizedPlain.java b/test/transform/resource/after-delombok/SynchronizedPlain.java index 695a3089..695a3089 100644 --- a/test/delombok/resource/after/SynchronizedPlain.java +++ b/test/transform/resource/after-delombok/SynchronizedPlain.java diff --git a/test/delombok/resource/after/ToStringInner.java b/test/transform/resource/after-delombok/ToStringInner.java index 29e7dc91..fc376a77 100644 --- a/test/delombok/resource/after/ToStringInner.java +++ b/test/transform/resource/after-delombok/ToStringInner.java @@ -4,29 +4,33 @@ class ToStringOuter { class ToStringInner { final int y; @java.lang.Override + @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "ToStringOuter.ToStringInner(y=" + y + ")"; + return "ToStringInner(y=" + this.y + ")"; } } static class ToStringStaticInner { final int y; @java.lang.Override + @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "ToStringOuter.ToStringStaticInner(y=" + y + ")"; + return "ToStringStaticInner(y=" + this.y + ")"; } } class ToStringMiddle { class ToStringMoreInner { final String name; @java.lang.Override + @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "ToStringOuter.ToStringMiddle.ToStringMoreInner(name=" + name + ")"; + return "ToStringMoreInner(name=" + this.name + ")"; } } } @java.lang.Override + @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "ToStringOuter(x=" + x + ", name=" + name + ")"; + return "ToStringOuter(x=" + this.x + ", name=" + this.name + ")"; } }
\ No newline at end of file diff --git a/test/delombok/resource/after/ToStringPlain.java b/test/transform/resource/after-delombok/ToStringPlain.java index 20227464..20227464 100644 --- a/test/delombok/resource/after/ToStringPlain.java +++ b/test/transform/resource/after-delombok/ToStringPlain.java diff --git a/test/delombok/resource/before/ClassNamedAfterGetter.java b/test/transform/resource/before/ClassNamedAfterGetter.java index fe61eda1..fe61eda1 100644 --- a/test/delombok/resource/before/ClassNamedAfterGetter.java +++ b/test/transform/resource/before/ClassNamedAfterGetter.java diff --git a/test/delombok/resource/before/CleanupName.java b/test/transform/resource/before/CleanupName.java index cbc5b447..cbc5b447 100644 --- a/test/delombok/resource/before/CleanupName.java +++ b/test/transform/resource/before/CleanupName.java diff --git a/test/delombok/resource/before/CleanupPlain.java b/test/transform/resource/before/CleanupPlain.java index a91ac3c1..a91ac3c1 100644 --- a/test/delombok/resource/before/CleanupPlain.java +++ b/test/transform/resource/before/CleanupPlain.java diff --git a/test/delombok/resource/before/CommentsInterspersed.java b/test/transform/resource/before/CommentsInterspersed.java index e7898aaa..e7898aaa 100644 --- a/test/delombok/resource/before/CommentsInterspersed.java +++ b/test/transform/resource/before/CommentsInterspersed.java diff --git a/test/transform/resource/before/DataExtended.java b/test/transform/resource/before/DataExtended.java new file mode 100644 index 00000000..a545460c --- /dev/null +++ b/test/transform/resource/before/DataExtended.java @@ -0,0 +1,5 @@ +@lombok.Data +@lombok.ToString(doNotUseGetters = true) +class DataExtended { + int x; +}
\ No newline at end of file diff --git a/test/delombok/resource/before/DataIgnore.java b/test/transform/resource/before/DataIgnore.java index 5f957bdc..5f957bdc 100644 --- a/test/delombok/resource/before/DataIgnore.java +++ b/test/transform/resource/before/DataIgnore.java diff --git a/test/delombok/resource/before/DataPlain.java b/test/transform/resource/before/DataPlain.java index 680ae46f..680ae46f 100644 --- a/test/delombok/resource/before/DataPlain.java +++ b/test/transform/resource/before/DataPlain.java diff --git a/test/delombok/resource/before/GetterAccessLevel.java b/test/transform/resource/before/GetterAccessLevel.java index 413b888e..413b888e 100644 --- a/test/delombok/resource/before/GetterAccessLevel.java +++ b/test/transform/resource/before/GetterAccessLevel.java diff --git a/test/delombok/resource/before/GetterAlreadyExists.java b/test/transform/resource/before/GetterAlreadyExists.java index 93b77dc1..93b77dc1 100644 --- a/test/delombok/resource/before/GetterAlreadyExists.java +++ b/test/transform/resource/before/GetterAlreadyExists.java diff --git a/test/delombok/resource/before/GetterBoolean.java b/test/transform/resource/before/GetterBoolean.java index 7d53ebbf..7d53ebbf 100644 --- a/test/delombok/resource/before/GetterBoolean.java +++ b/test/transform/resource/before/GetterBoolean.java diff --git a/test/delombok/resource/before/GetterOnClass.java b/test/transform/resource/before/GetterOnClass.java index 0a38b386..0a38b386 100644 --- a/test/delombok/resource/before/GetterOnClass.java +++ b/test/transform/resource/before/GetterOnClass.java diff --git a/test/delombok/resource/before/GetterPlain.java b/test/transform/resource/before/GetterPlain.java index d104f428..d104f428 100644 --- a/test/delombok/resource/before/GetterPlain.java +++ b/test/transform/resource/before/GetterPlain.java diff --git a/test/delombok/resource/before/GetterWithDollar.java b/test/transform/resource/before/GetterWithDollar.java index e1ef0818..e1ef0818 100644 --- a/test/delombok/resource/before/GetterWithDollar.java +++ b/test/transform/resource/before/GetterWithDollar.java diff --git a/test/delombok/resource/before/NonNullPlain.java b/test/transform/resource/before/NonNullPlain.java index eef64b2f..eef64b2f 100644 --- a/test/delombok/resource/before/NonNullPlain.java +++ b/test/transform/resource/before/NonNullPlain.java diff --git a/test/delombok/resource/before/SetterAccessLevel.java b/test/transform/resource/before/SetterAccessLevel.java index 8a30a7de..8a30a7de 100644 --- a/test/delombok/resource/before/SetterAccessLevel.java +++ b/test/transform/resource/before/SetterAccessLevel.java diff --git a/test/delombok/resource/before/SetterAlreadyExists.java b/test/transform/resource/before/SetterAlreadyExists.java index a7a94123..a7a94123 100644 --- a/test/delombok/resource/before/SetterAlreadyExists.java +++ b/test/transform/resource/before/SetterAlreadyExists.java diff --git a/test/delombok/resource/before/SetterOnClass.java b/test/transform/resource/before/SetterOnClass.java index 5d195ff5..5d195ff5 100644 --- a/test/delombok/resource/before/SetterOnClass.java +++ b/test/transform/resource/before/SetterOnClass.java diff --git a/test/delombok/resource/before/SetterPlain.java b/test/transform/resource/before/SetterPlain.java index e1ac99f8..e1ac99f8 100644 --- a/test/delombok/resource/before/SetterPlain.java +++ b/test/transform/resource/before/SetterPlain.java diff --git a/test/delombok/resource/before/SetterWithDollar.java b/test/transform/resource/before/SetterWithDollar.java index c09173b0..c09173b0 100644 --- a/test/delombok/resource/before/SetterWithDollar.java +++ b/test/transform/resource/before/SetterWithDollar.java diff --git a/test/delombok/resource/before/SneakyThrowsMultiple.java b/test/transform/resource/before/SneakyThrowsMultiple.java index 7e644f3d..7e644f3d 100644 --- a/test/delombok/resource/before/SneakyThrowsMultiple.java +++ b/test/transform/resource/before/SneakyThrowsMultiple.java diff --git a/test/delombok/resource/before/SneakyThrowsPlain.java b/test/transform/resource/before/SneakyThrowsPlain.java index 97fecf8f..97fecf8f 100644 --- a/test/delombok/resource/before/SneakyThrowsPlain.java +++ b/test/transform/resource/before/SneakyThrowsPlain.java diff --git a/test/delombok/resource/before/SneakyThrowsSingle.java b/test/transform/resource/before/SneakyThrowsSingle.java index e7b78ec7..e7b78ec7 100644 --- a/test/delombok/resource/before/SneakyThrowsSingle.java +++ b/test/transform/resource/before/SneakyThrowsSingle.java diff --git a/test/delombok/resource/before/SynchronizedName.java b/test/transform/resource/before/SynchronizedName.java index 6d9ca5e9..6d9ca5e9 100644 --- a/test/delombok/resource/before/SynchronizedName.java +++ b/test/transform/resource/before/SynchronizedName.java diff --git a/test/delombok/resource/before/SynchronizedPlain.java b/test/transform/resource/before/SynchronizedPlain.java index 6f5f3b64..6f5f3b64 100644 --- a/test/delombok/resource/before/SynchronizedPlain.java +++ b/test/transform/resource/before/SynchronizedPlain.java diff --git a/test/delombok/resource/before/ToStringInner.java b/test/transform/resource/before/ToStringInner.java index 418c2f92..f56865e0 100644 --- a/test/delombok/resource/before/ToStringInner.java +++ b/test/transform/resource/before/ToStringInner.java @@ -1,4 +1,3 @@ -//ignore import lombok.ToString; @ToString class ToStringOuter { final int x; diff --git a/test/delombok/resource/before/ToStringPlain.java b/test/transform/resource/before/ToStringPlain.java index 5b9db1c7..5b9db1c7 100644 --- a/test/delombok/resource/before/ToStringPlain.java +++ b/test/transform/resource/before/ToStringPlain.java diff --git a/test/delombok/resource/before/GetterAlreadyExists.java.messages b/test/transform/resource/messages-delombok/GetterAlreadyExists.java.messages index 99de957b..99de957b 100644 --- a/test/delombok/resource/before/GetterAlreadyExists.java.messages +++ b/test/transform/resource/messages-delombok/GetterAlreadyExists.java.messages diff --git a/test/delombok/resource/before/GetterBoolean.java.messages b/test/transform/resource/messages-delombok/GetterBoolean.java.messages index 91ba7340..91ba7340 100644 --- a/test/delombok/resource/before/GetterBoolean.java.messages +++ b/test/transform/resource/messages-delombok/GetterBoolean.java.messages diff --git a/test/delombok/resource/before/SetterAlreadyExists.java.messages b/test/transform/resource/messages-delombok/SetterAlreadyExists.java.messages index 7d0397ad..7d0397ad 100644 --- a/test/delombok/resource/before/SetterAlreadyExists.java.messages +++ b/test/transform/resource/messages-delombok/SetterAlreadyExists.java.messages diff --git a/test/delombok/src/lombok/delombok/TestLombokFilesIdempotent.java b/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java index da6377f3..63d34820 100644 --- a/test/delombok/src/lombok/delombok/TestLombokFilesIdempotent.java +++ b/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -19,24 +19,38 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package lombok.delombok; +package lombok.transform; import java.io.File; import lombok.DirectoryRunner; -import lombok.RunTestsViaDelombok; import org.junit.runner.RunWith; @RunWith(DirectoryRunner.class) -public class TestLombokFilesIdempotent { - - public static File getBeforeDirectory() { - RunTestsViaDelombok.printErrors(true); +public class TestLombokFilesIdempotent implements DirectoryRunner.TestParams { + @Override + public File getBeforeDirectory() { return getAfterDirectory(); } - public static File getAfterDirectory() { - return new File("test/delombok/resource/after"); + @Override + public File getAfterDirectory() { + return new File("test/transform/resource/after-delombok"); + } + + @Override + public DirectoryRunner.Compiler getCompiler() { + return DirectoryRunner.Compiler.DELOMBOK; + } + + @Override + public boolean printErrors() { + return true; + } + + @Override + public File getMessagesDirectory() { + return null; } } diff --git a/test/delombok/src/lombok/delombok/TestSourceFiles.java b/test/transform/src/lombok/transform/TestSourceFiles.java index 77693200..7bcaa1f7 100644 --- a/test/delombok/src/lombok/delombok/TestSourceFiles.java +++ b/test/transform/src/lombok/transform/TestSourceFiles.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -19,23 +19,34 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package lombok.delombok; +package lombok.transform; import java.io.File; import lombok.DirectoryRunner; -import lombok.RunTestsViaDelombok; import org.junit.runner.RunWith; @RunWith(DirectoryRunner.class) -public class TestSourceFiles { - public static File getBeforeDirectory() { - RunTestsViaDelombok.printErrors(true); +public class TestSourceFiles implements DirectoryRunner.TestParams { + public DirectoryRunner.Compiler getCompiler() { + return DirectoryRunner.Compiler.DELOMBOK; + } + + public boolean printErrors() { + return true; + } + + public File getBeforeDirectory() { return new File("test/pretty/resource/before"); } - public static File getAfterDirectory() { + public File getAfterDirectory() { return new File("test/pretty/resource/after"); } + + @Override + public File getMessagesDirectory() { + return null; + } } diff --git a/test/delombok/src/lombok/delombok/TestLombokFiles.java b/test/transform/src/lombok/transform/TestWithDelombok.java index 713f81f5..b4ee6793 100644 --- a/test/delombok/src/lombok/delombok/TestLombokFiles.java +++ b/test/transform/src/lombok/transform/TestWithDelombok.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -19,24 +19,38 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package lombok.delombok; +package lombok.transform; import java.io.File; import lombok.DirectoryRunner; -import lombok.RunTestsViaDelombok; import org.junit.runner.RunWith; @RunWith(DirectoryRunner.class) -public class TestLombokFiles { +public class TestWithDelombok implements DirectoryRunner.TestParams { + @Override + public DirectoryRunner.Compiler getCompiler() { + return DirectoryRunner.Compiler.DELOMBOK; + } + + @Override + public boolean printErrors() { + return true; + } + + @Override + public File getBeforeDirectory() { + return new File("test/transform/resource/before"); + } - public static File getBeforeDirectory() { - RunTestsViaDelombok.printErrors(true); - return new File("test/delombok/resource/before"); + @Override + public File getAfterDirectory() { + return new File("test/transform/resource/after-delombok"); } - public static File getAfterDirectory() { - return new File("test/delombok/resource/after"); + @Override + public File getMessagesDirectory() { + return new File("test/transform/resource/messages-delombok"); } } |