aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/configuration/resource/configurationRoot/d1/d11/d111/f1.txt0
-rw-r--r--test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config2
-rw-r--r--test/configuration/resource/configurationRoot/d1/d11/lombok.config5
-rw-r--r--test/configuration/resource/configurationRoot/d1/d12/lombok.config3
-rw-r--r--test/configuration/resource/configurationRoot/d1/lombok.config3
-rw-r--r--test/configuration/resource/configurationRoot/err.txt0
-rw-r--r--test/configuration/resource/configurationRoot/out.txt90
-rw-r--r--test/configuration/src/lombok/core/configuration/RunConfigurationTests.java31
-rw-r--r--test/configuration/src/lombok/core/configuration/TestConfiguration.java95
-rw-r--r--test/core/src/lombok/RunAllTests.java4
10 files changed, 231 insertions, 2 deletions
diff --git a/test/configuration/resource/configurationRoot/d1/d11/d111/f1.txt b/test/configuration/resource/configurationRoot/d1/d11/d111/f1.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/configuration/resource/configurationRoot/d1/d11/d111/f1.txt
diff --git a/test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config b/test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config
new file mode 100644
index 00000000..bcea2a72
--- /dev/null
+++ b/test/configuration/resource/configurationRoot/d1/d11/d111/lombok.config
@@ -0,0 +1,2 @@
+clear lombok.Accessors.chain
+lombok.Accessors.prefix += m_ \ No newline at end of file
diff --git a/test/configuration/resource/configurationRoot/d1/d11/lombok.config b/test/configuration/resource/configurationRoot/d1/d11/lombok.config
new file mode 100644
index 00000000..fcdc4823
--- /dev/null
+++ b/test/configuration/resource/configurationRoot/d1/d11/lombok.config
@@ -0,0 +1,5 @@
+stop-bubbling=true
+
+lombok.Accessors.chain = false
+lombok.Accessors.flagUsage = ERROR
+lombok.Accessors.prefix += f \ No newline at end of file
diff --git a/test/configuration/resource/configurationRoot/d1/d12/lombok.config b/test/configuration/resource/configurationRoot/d1/d12/lombok.config
new file mode 100644
index 00000000..a18a4756
--- /dev/null
+++ b/test/configuration/resource/configurationRoot/d1/d12/lombok.config
@@ -0,0 +1,3 @@
+stop-bubbling=true
+
+lombok.Accessors.chain = true \ No newline at end of file
diff --git a/test/configuration/resource/configurationRoot/d1/lombok.config b/test/configuration/resource/configurationRoot/d1/lombok.config
new file mode 100644
index 00000000..dec482e6
--- /dev/null
+++ b/test/configuration/resource/configurationRoot/d1/lombok.config
@@ -0,0 +1,3 @@
+stop-bubbling=true
+# this file shouldn't be read
+no error expected \ No newline at end of file
diff --git a/test/configuration/resource/configurationRoot/err.txt b/test/configuration/resource/configurationRoot/err.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/configuration/resource/configurationRoot/err.txt
diff --git a/test/configuration/resource/configurationRoot/out.txt b/test/configuration/resource/configurationRoot/out.txt
new file mode 100644
index 00000000..54e91094
--- /dev/null
+++ b/test/configuration/resource/configurationRoot/out.txt
@@ -0,0 +1,90 @@
+Configuration for 'BASE/d1/d11'.
+
+# Emit a warning or error if @Accessors is used.
+lombok.Accessors.flagUsage = ERROR
+# BASE/d1/lombok.config:
+# <'lombok.Accessors.flagUsage' not mentioned>
+#
+# BASE/d1/d11/lombok.config:
+# 3: lombok.Accessors.flagUsage = ERROR
+
+# Generate setters that return 'this' instead of 'void'.
+lombok.Accessors.chain = false
+# BASE/d1/lombok.config:
+# <'lombok.Accessors.chain' not mentioned>
+#
+# BASE/d1/d11/lombok.config:
+# 2: lombok.Accessors.chain = false
+
+# Strip this field prefix, like 'f' or 'm_', from the names of generated getters and setters.
+lombok.Accessors.prefix += f
+# BASE/d1/lombok.config:
+# <'lombok.Accessors.prefix' not mentioned>
+#
+# BASE/d1/d11/lombok.config:
+# 4: lombok.Accessors.prefix += f
+
+# Use this name for the generated logger fields (default: 'log')
+clear lombok.log.fieldName
+
+
+Configuration for:
+- BASE/d1/d11/d111
+- BASE/d1/d11/d111/f1.txt
+
+# Emit a warning or error if @Accessors is used.
+lombok.Accessors.flagUsage = ERROR
+# BASE/d1/lombok.config:
+# <'lombok.Accessors.flagUsage' not mentioned>
+#
+# BASE/d1/d11/lombok.config:
+# 3: lombok.Accessors.flagUsage = ERROR
+#
+# BASE/d1/d11/d111/lombok.config:
+# <'lombok.Accessors.flagUsage' not mentioned>
+
+# Generate setters that return 'this' instead of 'void'.
+clear lombok.Accessors.chain
+# BASE/d1/lombok.config:
+# <'lombok.Accessors.chain' not mentioned>
+#
+# BASE/d1/d11/lombok.config:
+# 2: lombok.Accessors.chain = false
+#
+# BASE/d1/d11/d111/lombok.config:
+# 1: clear lombok.Accessors.chain
+
+# Strip this field prefix, like 'f' or 'm_', from the names of generated getters and setters.
+lombok.Accessors.prefix += f
+lombok.Accessors.prefix += m_
+# BASE/d1/lombok.config:
+# <'lombok.Accessors.prefix' not mentioned>
+#
+# BASE/d1/d11/lombok.config:
+# 4: lombok.Accessors.prefix += f
+#
+# BASE/d1/d11/d111/lombok.config:
+# 2: lombok.Accessors.prefix += m_
+
+# Use this name for the generated logger fields (default: 'log')
+clear lombok.log.fieldName
+
+
+Configuration for 'BASE/d1/d12'.
+
+# Emit a warning or error if @Accessors is used.
+clear lombok.Accessors.flagUsage
+
+# Generate setters that return 'this' instead of 'void'.
+lombok.Accessors.chain = true
+# BASE/d1/lombok.config:
+# <'lombok.Accessors.chain' not mentioned>
+#
+# BASE/d1/d12/lombok.config:
+# 2: lombok.Accessors.chain = true
+
+# Strip this field prefix, like 'f' or 'm_', from the names of generated getters and setters.
+clear lombok.Accessors.prefix
+
+# Use this name for the generated logger fields (default: 'log')
+clear lombok.log.fieldName \ No newline at end of file
diff --git a/test/configuration/src/lombok/core/configuration/RunConfigurationTests.java b/test/configuration/src/lombok/core/configuration/RunConfigurationTests.java
new file mode 100644
index 00000000..40e0a7f4
--- /dev/null
+++ b/test/configuration/src/lombok/core/configuration/RunConfigurationTests.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2014 The Project Lombok Authors.
+ *
+ * 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.core.configuration;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({TestConfiguration.class})
+public class RunConfigurationTests {
+}
diff --git a/test/configuration/src/lombok/core/configuration/TestConfiguration.java b/test/configuration/src/lombok/core/configuration/TestConfiguration.java
new file mode 100644
index 00000000..4ded8cf2
--- /dev/null
+++ b/test/configuration/src/lombok/core/configuration/TestConfiguration.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2014 The Project Lombok Authors.
+ *
+ * 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.core.configuration;
+
+import static lombok.ConfigurationKeys.*;
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.PrintStream;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.regex.Pattern;
+
+import org.junit.Test;
+
+public class TestConfiguration {
+
+ @Test
+ public void testIt() throws Exception {
+
+ @SuppressWarnings("unchecked")
+ Collection<ConfigurationKey<?>> keys = Arrays.asList(ACCESSORS_FLAG_USAGE, ACCESSORS_CHAIN, ACCESSORS_PREFIX, LOG_ANY_FIELD_NAME);
+
+ String baseName = "test/configuration/resource/configurationRoot/";
+ File directory = new File(baseName);
+ String normalizedName = new File(directory.getAbsoluteFile().toURI().normalize()).toString().replace('\\', '/') + "/";
+ Collection<String> paths = Arrays.asList(normalizedName + "d1/d11", normalizedName + "d1/d12", normalizedName + "d1/d11/d111", normalizedName + "d1/d11/d111/f1.txt");
+
+ ByteArrayOutputStream rawOut = new ByteArrayOutputStream();
+ ByteArrayOutputStream rawErr = new ByteArrayOutputStream();
+ PrintStream outStream = new PrintStream(rawOut);
+ PrintStream errStream = new PrintStream(rawErr);
+
+ int result = new ConfigurationApp().redirectOutput(outStream, errStream).display(keys, true, paths, true);
+
+ outStream.flush();
+ errStream.flush();
+
+ String out = new String(rawOut.toByteArray()).replace("\r\n", "\n").replace('\\', '/').replaceAll(Pattern.quote(normalizedName) + "|" + Pattern.quote(baseName), "BASE/").trim();
+ String err = new String(rawErr.toByteArray()).replace("\r\n", "\n").replace('\\', '/').replaceAll(Pattern.quote(normalizedName) + "|" + Pattern.quote(baseName), "BASE/").trim();
+
+ checkContent(directory, out, "out");
+ checkContent(directory, err, "err");
+ assertEquals(0, result);
+ }
+
+ private void checkContent(File dir, String actual, String type) throws Exception {
+ String expected = fileToString(new File(dir, type + ".txt")).trim();
+ if (!expected.equals(actual)) {
+ System.out.printf("**** Expected %s:\n", type);
+ System.out.println(expected);
+ System.out.printf("**** Actual %s:\n", type);
+ System.out.println(actual);
+ System.out.println("****");
+ }
+ assertEquals(expected, actual);
+ }
+
+ static String fileToString(File configFile) throws Exception {
+ byte[] b = new byte[65536];
+ FileInputStream fis = new FileInputStream(configFile);
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ while (true) {
+ int r = fis.read(b);
+ if (r == -1) break;
+ out.write(b, 0, r);
+ }
+ return new String(out.toByteArray(), "UTF-8");
+ } finally {
+ fis.close();
+ }
+ }
+}
diff --git a/test/core/src/lombok/RunAllTests.java b/test/core/src/lombok/RunAllTests.java
index 0076e662..9f56b45b 100644
--- a/test/core/src/lombok/RunAllTests.java
+++ b/test/core/src/lombok/RunAllTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Project Lombok Authors.
+ * Copyright (C) 2011-2014 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,6 +26,6 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({lombok.transform.RunTransformTests.class, lombok.bytecode.RunBytecodeTests.class})
+@SuiteClasses({lombok.transform.RunTransformTests.class, lombok.bytecode.RunBytecodeTests.class, lombok.core.configuration.RunConfigurationTests.class})
public class RunAllTests {
}