Bug 303519: [formatter] Formatter does not format Java code correctly,
especially when max line width is set

Change-Id: I1ca87b1deff08dbf8f055312181246c0ce0fcce6
Signed-off-by: Mateusz Matela <mateusz.matela@gmail.com>
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java
index 8771b30..4fecab6 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2014 IBM Corporation and others.
+ * Copyright (c) 2013, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -41,7 +41,7 @@
 		helper1(6, 18, 6, 20);
 	}
 
-	public void test1() throws Exception {
+	public void _test1() throws Exception { // TODO: Enable after bug 458208#c2 is fixed
 		helper1(6, 18, 6, 20);
 	}
 
diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java
index f092a76..0dbe358 100644
--- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java
+++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set
  *******************************************************************************/
 package org.eclipse.jdt.testplugin;
 
@@ -20,7 +21,7 @@
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
 
-import org.eclipse.jdt.internal.formatter.align.Alignment;
+import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions.Alignment;
 
 import org.eclipse.jdt.ui.PreferenceConstants;
 
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CodeFormatterTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CodeFormatterTest.java
index 2041477..ad44cdd 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CodeFormatterTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CodeFormatterTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     Tom Eicher <eclipse@tom.eicher.name> - [formatting] 'Format Element' in JavaDoc does also format method body - https://bugs.eclipse.org/bugs/show_bug.cgi?id=238746
+ *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set
  *******************************************************************************/
 package org.eclipse.jdt.ui.tests.core;
 
@@ -201,7 +202,7 @@
 				+ "    /** \n"
 				+ "* javadoc\n"
 				+ "     */\n"
-				+ "    public method() {\n"
+				+ "    public void method() {\n"
 				+ "int local;\n"
 				+ "    }\n"
 				+ "}\n";
@@ -219,7 +220,7 @@
 				+ "    /**\n"
 				+ "     * javadoc\n" // javadoc is formatted
 				+ "     */\n"
-				+ "    public method() {\n"
+				+ "    public void method() {\n"
 				+ "        int local;\n" // local is formatted
 				+ "    }\n"
 				+ "}\n";
@@ -242,7 +243,7 @@
 				+ "    /** \n"
 				+ "* javadoc\n"
 				+ "     */\n"
-				+ "    public method() {\n"
+				+ "    public void method() {\n"
 				+ "int local;\n"
 				+ "    }\n"
 				+ "}\n";
@@ -260,7 +261,7 @@
 				+ "    /**\n"
 				+ "     * javadoc\n" // javadoc is formatted
 				+ "     */\n"
-				+ "    public method() {\n"
+				+ "    public void method() {\n"
 				+ "int local;\n" // local does not get formatted
 				+ "    }\n"
 				+ "}\n";
@@ -283,7 +284,7 @@
 			+ "    /** \n"
 			+ "* javadoc\n"
 			+ "     */\n"
-			+ "    public method() {\n"
+			+ "    public void method() {\n"
 			+ "/* a\n"
 			+ "comment */\n"
 			+ "int local;\n"
@@ -303,7 +304,7 @@
 			+ "    /** \n"
 			+ "* javadoc\n" // javadoc is not formatted
 			+ "     */\n"
-			+ "    public method() {\n"
+			+ "    public void method() {\n"
 			+ "        /*\n" // comment is formatted
 			+ "         * a comment\n"
 			+ "         */\n"
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
index 42aaf2b..344a7b3 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
@@ -10,6 +10,7 @@
  *     Sebastian Davids <sdavids@gmx.de> - testInvertEquals1-23
  *     Lukas Hanke <hanke@yatta.de> - Bug 241696 [quick fix] quickfix to iterate over a collection - https://bugs.eclipse.org/bugs/show_bug.cgi?id=241696
  *     Lukas Hanke <hanke@yatta.de> - Bug 430818 [1.8][quick fix] Quick fix for "for loop" is not shown for bare local variable/argument/field - https://bugs.eclipse.org/bugs/show_bug.cgi?id=430818
+ *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set
  *******************************************************************************/
 package org.eclipse.jdt.ui.tests.quickfix;
 
@@ -7333,8 +7334,8 @@
 			buf.append("\n");
 			buf.append("public class A {\n");
 			buf.append("    public void foo(Object o1, Object o2) {\n");
-			buf.append("        System.out.println(MessageFormat.format(\"foo{0} \\\"bar\\\" {1}\", new Object[]{o1,\n");
-			buf.append("                o2}));\n");
+			buf.append("        System.out.println(MessageFormat.format(\"foo{0} \\\"bar\\\" {1}\",\n");
+			buf.append("                new Object[]{o1, o2}));\n");
 			buf.append("    }\n");
 			buf.append("}\n");
 			String expected1= buf.toString();
@@ -8530,8 +8531,8 @@
 		buf.append("import java.util.List;\n");
 		buf.append("public class E {\n");
 		buf.append("    void foo() {\n");
-		buf.append("        for (Iterator<? extends Number> iterator = getNums().iterator(); iterator\n");
-		buf.append("                .hasNext();) {\n");
+		buf.append("        for (Iterator<? extends Number> iterator = getNums()\n");
+		buf.append("                .iterator(); iterator.hasNext();) {\n");
 		buf.append("            Number number = iterator.next();\n");
 		buf.append("            System.out.println(number.doubleValue());\n");
 		buf.append("        }\n");
@@ -8689,7 +8690,8 @@
 			buf.append("import java.util.Iterator;\n");
 			buf.append("public class E {\n");
 			buf.append("    void foo(Collection<String> collection) {\n");
-			buf.append("        for (Iterator<String> iterator = collection.iterator(); iterator.hasNext();) {\n");
+			buf.append("        for (Iterator<String> iterator = collection.iterator(); iterator\n");
+			buf.append("                .hasNext();) {\n");
 			buf.append("            String string = iterator.next();\n");
 			buf.append("            \n");
 			buf.append("        }\n");
@@ -8746,7 +8748,8 @@
 			buf.append("import java.util.Iterator;\n");
 			buf.append("public class E {\n");
 			buf.append("    void foo(Collection<String> collection) {\n");
-			buf.append("        for (Iterator<String> iterator = collection.iterator(); iterator.hasNext();) {\n");
+			buf.append("        for (Iterator<String> iterator = collection.iterator(); iterator\n");
+			buf.append("                .hasNext();) {\n");
 			buf.append("            String string = iterator.next();\n");
 			buf.append("            \n");
 			buf.append("        }\n");
@@ -8866,7 +8869,8 @@
 			buf.append("import java.util.LinkedList;\n");
 			buf.append("public class E {\n");
 			buf.append("    void foo(MySecondOwnIterable collection) {\n");
-			buf.append("        for (Iterator<String> iterator = collection.iterator(); iterator.hasNext();) {\n");
+			buf.append("        for (Iterator<String> iterator = collection.iterator(); iterator\n");
+			buf.append("                .hasNext();) {\n");
 			buf.append("            String string = iterator.next();\n");
 			buf.append("            \n");
 			buf.append("        }\n");
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java
index 43a7a2f..ed43536 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpStressTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     Alex Blewitt - https://bugs.eclipse.org/bugs/show_bug.cgi?id=168954
+ *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set
  *******************************************************************************/
 package org.eclipse.jdt.ui.tests.quickfix;
 
@@ -119,15 +120,16 @@
         buf.append("    private static Properties fPreferences;\n");
         buf.append("    public static final String SUITE_METHODNAME = \"suite\"; //$NON-NLS-1$\n");
         buf.append("    static {\n");
-        buf.append("        BaseTestRunner.fgMaxMessageLength = BaseTestRunner.getPreference(\n");
-        buf.append("                \"maxmessage\", BaseTestRunner.fgMaxMessageLength); //$NON-NLS-1$\n");
+        buf.append("        BaseTestRunner.fgMaxMessageLength = BaseTestRunner\n");
+        buf.append("                .getPreference(\"maxmessage\", BaseTestRunner.fgMaxMessageLength); //$NON-NLS-1$\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    static boolean filterLine(final String line) {\n");
         buf.append("        final String[] patterns = new String[]{\"junit.framework.TestCase\", //$NON-NLS-1$\n");
         buf.append("                \"junit.framework.TestResult\", //$NON-NLS-1$\n");
         buf.append("                \"junit.framework.TestSuite\", //$NON-NLS-1$\n");
-        buf.append("                \"junit.framework.Assert.\", // don't filter AssertionFailure //$NON-NLS-1$\n");
+        buf.append("                \"junit.framework.Assert.\", // don't filter //$NON-NLS-1$\n");
+        buf.append("                                           // AssertionFailure\n");
         buf.append("                \"junit.swingui.TestRunner\", //$NON-NLS-1$\n");
         buf.append("                \"junit.awtui.TestRunner\", //$NON-NLS-1$\n");
         buf.append("                \"junit.textui.TestRunner\", //$NON-NLS-1$\n");
@@ -226,8 +228,8 @@
         buf.append("        InputStream is = null;\n");
         buf.append("        try {\n");
         buf.append("            is = new FileInputStream(BaseTestRunner.getPreferencesFile());\n");
-        buf.append("            BaseTestRunner.setPreferences(new Properties(BaseTestRunner\n");
-        buf.append("                    .getPreferences()));\n");
+        buf.append("            BaseTestRunner.setPreferences(\n");
+        buf.append("                    new Properties(BaseTestRunner.getPreferences()));\n");
         buf.append("            BaseTestRunner.getPreferences().load(is);\n");
         buf.append("        } catch (final IOException e) {\n");
         buf.append("            try {\n");
@@ -254,7 +256,8 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    protected static boolean showStackRaw() {\n");
-        buf.append("        return !BaseTestRunner.getPreference(\"filterstack\").equals(\"true\") || (BaseTestRunner.fgFilterStack == false); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        return !BaseTestRunner.getPreference(\"filterstack\").equals(\"true\") //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                || (BaseTestRunner.fgFilterStack == false);\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    /**\n");
@@ -354,12 +357,13 @@
         buf.append("        Test test = null;\n");
         buf.append("        try {\n");
         buf.append("            test = (Test) suiteMethod.invoke(null, new Class[0]); // static\n");
-		buf.append("                                                                  // method\n");
+        buf.append("                                                                  // method\n");
         buf.append("            if (test == null) {\n");
         buf.append("                return test;\n");
         buf.append("            }\n");
         buf.append("        } catch (final InvocationTargetException e) {\n");
-        buf.append("            this.runFailed(\"Failed to invoke suite():\" + e.getTargetException().toString()); //$NON-NLS-1$\n");
+        buf.append("            this.runFailed(\"Failed to invoke suite():\" //$NON-NLS-1$\n");
+        buf.append("                    + e.getTargetException().toString());\n");
         buf.append("            return null;\n");
         buf.append("        } catch (final IllegalAccessException e) {\n");
         buf.append("            this.runFailed(\"Failed to invoke suite():\" + e.toString()); //$NON-NLS-1$\n");
@@ -390,7 +394,7 @@
         buf.append("            } else if (args[i].equals(\"-nofilterstack\")) { //$NON-NLS-1$\n");
         buf.append("                BaseTestRunner.fgFilterStack = false;\n");
         buf.append("            } else if (args[i].equals(\"-c\")) { //$NON-NLS-1$\n");
-		buf.append("                if (args.length > (i + 1)) {\n");
+        buf.append("                if (args.length > (i + 1)) {\n");
         buf.append("                    suiteName = this.extractClassName(args[i + 1]);\n");
         buf.append("                } else {\n");
         buf.append("                    System.out.println(\"Missing Test class name\"); //$NON-NLS-1$\n");
@@ -433,7 +437,8 @@
         buf.append("    public abstract void testStarted(String testName);\n");
         buf.append("\n");
         buf.append("    protected boolean useReloadingTestSuiteLoader() {\n");
-        buf.append("        return BaseTestRunner.getPreference(\"loading\").equals(\"true\") && !BaseTestRunner.inVAJava() && this.fLoading; //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        return BaseTestRunner.getPreference(\"loading\").equals(\"true\") //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                && !BaseTestRunner.inVAJava() && this.fLoading;\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("}");
@@ -479,15 +484,23 @@
         buf.append("        pwin.println(\"    at MyTest.f(MyTest.java:13)\"); //$NON-NLS-1$\n");
         buf.append("        pwin.println(\"    at MyTest.testStackTrace(MyTest.java:8)\"); //$NON-NLS-1$\n");
         buf.append("        pwin.println(\"    at java.lang.reflect.Method.invoke(Native Method)\"); //$NON-NLS-1$\n");
-        buf.append("        pwin.println(\"    at junit.framework.TestCase.runTest(TestCase.java:156)\"); //$NON-NLS-1$\n");
-        buf.append("        pwin.println(\"    at junit.framework.TestCase.runBare(TestCase.java:130)\"); //$NON-NLS-1$\n");
-        buf.append("        pwin.println(\"    at junit.framework.TestResult$1.protect(TestResult.java:100)\"); //$NON-NLS-1$\n");
-        buf.append("        pwin.println(\"    at junit.framework.TestResult.runProtected(TestResult.java:118)\"); //$NON-NLS-1$\n");
-        buf.append("        pwin.println(\"    at junit.framework.TestResult.run(TestResult.java:103)\"); //$NON-NLS-1$\n");
+        buf.append("        pwin.println(\n");
+        buf.append("                \"    at junit.framework.TestCase.runTest(TestCase.java:156)\"); //$NON-NLS-1$\n");
+        buf.append("        pwin.println(\n");
+        buf.append("                \"    at junit.framework.TestCase.runBare(TestCase.java:130)\"); //$NON-NLS-1$\n");
+        buf.append("        pwin.println(\n");
+        buf.append("                \"    at junit.framework.TestResult$1.protect(TestResult.java:100)\"); //$NON-NLS-1$\n");
+        buf.append("        pwin.println(\n");
+        buf.append("                \"    at junit.framework.TestResult.runProtected(TestResult.java:118)\"); //$NON-NLS-1$\n");
+        buf.append("        pwin.println(\n");
+        buf.append("                \"    at junit.framework.TestResult.run(TestResult.java:103)\"); //$NON-NLS-1$\n");
         buf.append("        pwin.println(\"    at junit.framework.TestCase.run(TestCase.java:121)\"); //$NON-NLS-1$\n");
-        buf.append("        pwin.println(\"    at junit.framework.TestSuite.runTest(TestSuite.java:157)\"); //$NON-NLS-1$\n");
-        buf.append("        pwin.println(\"    at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)\"); //$NON-NLS-1$\n");
-        buf.append("        pwin.println(\"    at junit.swingui.TestRunner$17.run(TestRunner.java:669)\"); //$NON-NLS-1$\n");
+        buf.append("        pwin.println(\n");
+        buf.append("                \"    at junit.framework.TestSuite.runTest(TestSuite.java:157)\"); //$NON-NLS-1$\n");
+        buf.append("        pwin.println(\n");
+        buf.append("                \"    at junit.framework.TestSuite.run(TestSuite.java, Compiled Code)\"); //$NON-NLS-1$\n");
+        buf.append("        pwin.println(\n");
+        buf.append("                \"    at junit.swingui.TestRunner$17.run(TestRunner.java:669)\"); //$NON-NLS-1$\n");
         buf.append("        this.fUnfiltered = swin.toString();\n");
         buf.append("\n");
         buf.append("        final StringWriter swout = new StringWriter();\n");
@@ -755,7 +768,8 @@
         buf.append("public class ExceptionTestCaseTest extends junit.framework.TestCase {\n");
         buf.append("\n");
         buf.append("    static public class ThrowExceptionTestCase extends ExceptionTestCase {\n");
-        buf.append("        public ThrowExceptionTestCase(final String name, final Class exception) {\n");
+        buf.append("        public ThrowExceptionTestCase(final String name,\n");
+        buf.append("                final Class exception) {\n");
         buf.append("            super(name, exception);\n");
         buf.append("        }\n");
         buf.append("        public void test() {\n");
@@ -764,14 +778,17 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    static public class ThrowNoExceptionTestCase extends ExceptionTestCase {\n");
-        buf.append("        public ThrowNoExceptionTestCase(final String name, final Class exception) {\n");
+        buf.append("        public ThrowNoExceptionTestCase(final String name,\n");
+        buf.append("                final Class exception) {\n");
         buf.append("            super(name, exception);\n");
         buf.append("        }\n");
         buf.append("        public void test() {\n");
         buf.append("        }\n");
         buf.append("    }\n");
         buf.append("\n");
-        buf.append("    static public class ThrowRuntimeExceptionTestCase extends ExceptionTestCase {\n");
+        buf.append("    static public class ThrowRuntimeExceptionTestCase\n");
+        buf.append("            extends\n");
+        buf.append("                ExceptionTestCase {\n");
         buf.append("        public ThrowRuntimeExceptionTestCase(final String name,\n");
         buf.append("                final Class exception) {\n");
         buf.append("            super(name, exception);\n");
@@ -782,36 +799,36 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testExceptionSubclass() {\n");
-        buf.append("        final ExceptionTestCase test = new ThrowExceptionTestCase(\n");
-        buf.append("                \"test\", IndexOutOfBoundsException.class); //$NON-NLS-1$\n");
+        buf.append("        final ExceptionTestCase test = new ThrowExceptionTestCase(\"test\", //$NON-NLS-1$\n");
+        buf.append("                IndexOutOfBoundsException.class);\n");
         buf.append("        final TestResult result = test.run();\n");
         buf.append("        Assert.assertEquals(1, result.runCount());\n");
         buf.append("        Assert.assertTrue(result.wasSuccessful());\n");
         buf.append("    }\n");
         buf.append("    public void testExceptionTest() {\n");
-        buf.append("        final ExceptionTestCase test = new ThrowExceptionTestCase(\n");
-        buf.append("                \"test\", IndexOutOfBoundsException.class); //$NON-NLS-1$\n");
+        buf.append("        final ExceptionTestCase test = new ThrowExceptionTestCase(\"test\", //$NON-NLS-1$\n");
+        buf.append("                IndexOutOfBoundsException.class);\n");
         buf.append("        final TestResult result = test.run();\n");
         buf.append("        Assert.assertEquals(1, result.runCount());\n");
         buf.append("        Assert.assertTrue(result.wasSuccessful());\n");
         buf.append("    }\n");
         buf.append("    public void testFailure() {\n");
-        buf.append("        final ExceptionTestCase test = new ThrowRuntimeExceptionTestCase(\n");
-        buf.append("                \"test\", IndexOutOfBoundsException.class); //$NON-NLS-1$\n");
+        buf.append("        final ExceptionTestCase test = new ThrowRuntimeExceptionTestCase(\"test\", //$NON-NLS-1$\n");
+        buf.append("                IndexOutOfBoundsException.class);\n");
         buf.append("        final TestResult result = test.run();\n");
         buf.append("        Assert.assertEquals(1, result.runCount());\n");
         buf.append("        Assert.assertEquals(1, result.errorCount());\n");
         buf.append("    }\n");
         buf.append("    public void testNoException() {\n");
-        buf.append("        final ExceptionTestCase test = new ThrowNoExceptionTestCase(\n");
-        buf.append("                \"test\", Exception.class); //$NON-NLS-1$\n");
+        buf.append("        final ExceptionTestCase test = new ThrowNoExceptionTestCase(\"test\", //$NON-NLS-1$\n");
+        buf.append("                Exception.class);\n");
         buf.append("        final TestResult result = test.run();\n");
         buf.append("        Assert.assertEquals(1, result.runCount());\n");
         buf.append("        Assert.assertEquals(1, result.failureCount());\n");
         buf.append("    }\n");
         buf.append("    public void testWrongException() {\n");
-        buf.append("        final ExceptionTestCase test = new ThrowRuntimeExceptionTestCase(\n");
-        buf.append("                \"test\", IndexOutOfBoundsException.class); //$NON-NLS-1$\n");
+        buf.append("        final ExceptionTestCase test = new ThrowRuntimeExceptionTestCase(\"test\", //$NON-NLS-1$\n");
+        buf.append("                IndexOutOfBoundsException.class);\n");
         buf.append("        final TestResult result = test.run();\n");
         buf.append("        Assert.assertEquals(1, result.runCount());\n");
         buf.append("        Assert.assertEquals(1, result.errorCount());\n");
@@ -1654,8 +1671,8 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    @Override\n");
-        buf.append("    public synchronized Class loadClass(final String name, final boolean resolve)\n");
-        buf.append("            throws ClassNotFoundException {\n");
+        buf.append("    public synchronized Class loadClass(final String name,\n");
+        buf.append("            final boolean resolve) throws ClassNotFoundException {\n");
         buf.append("\n");
         buf.append("        Class c = this.findLoadedClass(name);\n");
         buf.append("        if (c != null) {\n");
@@ -1757,8 +1774,8 @@
         buf.append("            this.fExcluded.addElement(defaultExclusion);\n");
         buf.append("        }\n");
         buf.append("\n");
-        buf.append("        final InputStream is = this.getClass().getResourceAsStream(\n");
-        buf.append("                TestCaseClassLoader.EXCLUDED_FILE);\n");
+        buf.append("        final InputStream is = this.getClass()\n");
+        buf.append("                .getResourceAsStream(TestCaseClassLoader.EXCLUDED_FILE);\n");
         buf.append("        if (is == null) {\n");
         buf.append("            return;\n");
         buf.append("        }\n");
@@ -1846,7 +1863,7 @@
         buf.append("\n");
         buf.append("        /*\n");
         buf.append("         * the type safe way\n");
-        buf.append("         * \n");
+        buf.append("         *\n");
         buf.append("         * TestSuite suite= new TestSuite(); suite.addTest( new\n");
         buf.append("         * SimpleTest(\"add\") { protected void runTest() { testAdd(); } } );\n");
         buf.append("         * \n");
@@ -1903,6 +1920,7 @@
         buf.append("");
         fExpectedChangesAllTests.put("junit.runner.Version.java", buf.toString());
         buf= new StringBuffer();
+        buf.append("\n");
         buf.append("package junit.tests.runner;\n");
         buf.append("\n");
         buf.append("import junit.framework.Test;\n");
@@ -1938,7 +1956,10 @@
         buf.append("\n");
         buf.append("    public void testInvokeNonStaticSuite() {\n");
         buf.append("        final BaseTestRunner runner = new MockRunner();\n");
-        buf.append("        runner.getTest(\"junit.tests.runner.BaseTestRunnerTest$NonStatic\"); // Used to throw NullPointerException //$NON-NLS-1$\n");
+        buf.append("        runner.getTest(\"junit.tests.runner.BaseTestRunnerTest$NonStatic\"); // Used //$NON-NLS-1$\n");
+        buf.append("                                                                           // to\n");
+        buf.append("                                                                           // throw\n");
+        buf.append("                                                                           // NullPointerException\n");
         buf.append("    }\n");
         buf.append("}\n");
         buf.append("");
@@ -1978,8 +1999,8 @@
         buf.append(" * \n");
         buf.append(" * <pre>\n");
         buf.append(" * TestSuite suite = new TestSuite();\n");
-        buf.append(" * suite.addTest(new MathTest(&quot;testAdd&quot;));\n");
-        buf.append(" * suite.addTest(new MathTest(&quot;testDivideByZero&quot;));\n");
+        buf.append(" * suite.addTest(new MathTest(\"testAdd\"));\n");
+        buf.append(" * suite.addTest(new MathTest(\"testDivideByZero\"));\n");
         buf.append(" * </pre>\n");
         buf.append(" * \n");
         buf.append(" * Alternatively, a TestSuite can extract the tests to be run automatically. To\n");
@@ -2005,8 +2026,8 @@
         buf.append("        try {\n");
         buf.append("            constructor = TestSuite.getTestConstructor(theClass);\n");
         buf.append("        } catch (final NoSuchMethodException e) {\n");
-        buf.append("            return TestSuite\n");
-        buf.append("                    .warning(\"Class \" + theClass.getName() + \" has no public constructor TestCase(String name) or TestCase()\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("            return TestSuite.warning(\"Class \" + theClass.getName() //$NON-NLS-1$\n");
+        buf.append("                    + \" has no public constructor TestCase(String name) or TestCase()\"); //$NON-NLS-1$\n");
         buf.append("        }\n");
         buf.append("        Object test;\n");
         buf.append("        try {\n");
@@ -2019,14 +2040,15 @@
         buf.append("                test = constructor.newInstance(new Object[]{name});\n");
         buf.append("            }\n");
         buf.append("        } catch (final InstantiationException e) {\n");
-        buf.append("            return (TestSuite\n");
-        buf.append("                    .warning(\"Cannot instantiate test case: \" + name + \" (\" + TestSuite.exceptionToString(e) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n");
+        buf.append("            return (TestSuite.warning(\"Cannot instantiate test case: \" + name //$NON-NLS-1$\n");
+        buf.append("                    + \" (\" + TestSuite.exceptionToString(e) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
         buf.append("        } catch (final InvocationTargetException e) {\n");
-        buf.append("            return (TestSuite\n");
-        buf.append("                    .warning(\"Exception in constructor: \" + name + \" (\" + TestSuite.exceptionToString(e.getTargetException()) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n");
+        buf.append("            return (TestSuite.warning(\"Exception in constructor: \" + name + \" (\" //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                    + TestSuite.exceptionToString(e.getTargetException())\n");
+        buf.append("                    + \")\")); //$NON-NLS-1$\n");
         buf.append("        } catch (final IllegalAccessException e) {\n");
-        buf.append("            return (TestSuite\n");
-        buf.append("                    .warning(\"Cannot access test case: \" + name + \" (\" + TestSuite.exceptionToString(e) + \")\")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n");
+        buf.append("            return (TestSuite.warning(\"Cannot access test case: \" + name + \" (\" //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                    + TestSuite.exceptionToString(e) + \")\")); //$NON-NLS-1$\n");
         buf.append("        }\n");
         buf.append("        return (Test) test;\n");
         buf.append("    }\n");
@@ -2089,8 +2111,8 @@
         buf.append("            TestSuite.getTestConstructor(theClass); // Avoid generating multiple\n");
         buf.append("                                                    // error messages\n");
         buf.append("        } catch (final NoSuchMethodException e) {\n");
-        buf.append("            this.addTest(TestSuite\n");
-        buf.append("                    .warning(\"Class \" + theClass.getName() + \" has no public constructor TestCase(String name) or TestCase()\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("            this.addTest(TestSuite.warning(\"Class \" + theClass.getName() //$NON-NLS-1$\n");
+        buf.append("                    + \" has no public constructor TestCase(String name) or TestCase()\")); //$NON-NLS-1$\n");
         buf.append("            return;\n");
         buf.append("        }\n");
         buf.append("\n");
@@ -2191,8 +2213,8 @@
         buf.append("        final String name = m.getName();\n");
         buf.append("        final Class[] parameters = m.getParameterTypes();\n");
         buf.append("        final Class returnType = m.getReturnType();\n");
-        buf.append("        return (parameters.length == 0)\n");
-        buf.append("                && name.startsWith(\"test\") && returnType.equals(Void.TYPE); //$NON-NLS-1$\n");
+        buf.append("        return (parameters.length == 0) && name.startsWith(\"test\") //$NON-NLS-1$\n");
+        buf.append("                && returnType.equals(Void.TYPE);\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    /**\n");
@@ -2270,13 +2292,13 @@
         buf.append(" * } catch (SpecialException e) {\n");
         buf.append(" *     return;\n");
         buf.append(" * }\n");
-        buf.append(" * fail(&quot;Expected SpecialException&quot;);\n");
+        buf.append(" * fail(\"Expected SpecialException\");\n");
         buf.append(" * </pre>\n");
         buf.append(" *\n");
         buf.append(" * To use ExceptionTestCase, create a TestCase like:\n");
         buf.append(" * \n");
         buf.append(" * <pre>\n");
-        buf.append(" * new ExceptionTestCase(&quot;testShouldThrow&quot;, SpecialException.class);\n");
+        buf.append(" * new ExceptionTestCase(\"testShouldThrow\", SpecialException.class);\n");
         buf.append(" * </pre>\n");
         buf.append(" */\n");
         buf.append("public class ExceptionTestCase extends TestCase {\n");
@@ -2316,7 +2338,8 @@
         buf.append("    /**\n");
         buf.append("     * Asserts that two booleans are equal.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertEquals(final boolean expected, final boolean actual) {\n");
+        buf.append("    static public void assertEquals(final boolean expected,\n");
+        buf.append("            final boolean actual) {\n");
         buf.append("        Assert.assertEquals(null, expected, actual);\n");
         buf.append("    }\n");
         buf.append("\n");
@@ -2364,7 +2387,8 @@
         buf.append("     * Asserts that two objects are equal. If they are not an\n");
         buf.append("     * AssertionFailedError is thrown.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertEquals(final Object expected, final Object actual) {\n");
+        buf.append("    static public void assertEquals(final Object expected,\n");
+        buf.append("            final Object actual) {\n");
         buf.append("        Assert.assertEquals(null, expected, actual);\n");
         buf.append("    }\n");
         buf.append("    /**\n");
@@ -2379,7 +2403,8 @@
         buf.append("     */\n");
         buf.append("    static public void assertEquals(final String message,\n");
         buf.append("            final boolean expected, final boolean actual) {\n");
-        buf.append("        Assert.assertEquals(message, new Boolean(expected), new Boolean(actual));\n");
+        buf.append("        Assert.assertEquals(message, new Boolean(expected),\n");
+        buf.append("                new Boolean(actual));\n");
         buf.append("    }\n");
         buf.append("    /**\n");
         buf.append("     * Asserts that two bytes are equal. If they are not an AssertionFailedError\n");
@@ -2395,27 +2420,27 @@
         buf.append("     */\n");
         buf.append("    static public void assertEquals(final String message, final char expected,\n");
         buf.append("            final char actual) {\n");
-        buf.append("        Assert.assertEquals(message, new Character(expected), new Character(\n");
-        buf.append("                actual));\n");
+        buf.append("        Assert.assertEquals(message, new Character(expected),\n");
+        buf.append("                new Character(actual));\n");
         buf.append("    }\n");
         buf.append("    /**\n");
         buf.append("     * Asserts that two doubles are equal concerning a delta. If they are not an\n");
         buf.append("     * AssertionFailedError is thrown with the given message. If the expected\n");
         buf.append("     * value is infinity then the delta value is ignored.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertEquals(final String message,\n");
-        buf.append("            final double expected, final double actual, final double delta) {\n");
+        buf.append("    static public void assertEquals(final String message, final double expected,\n");
+        buf.append("            final double actual, final double delta) {\n");
         buf.append("        // handle infinity specially since subtracting to infinite values gives\n");
         buf.append("        // NaN and the\n");
         buf.append("        // the following test fails\n");
         buf.append("        if (Double.isInfinite(expected)) {\n");
         buf.append("            if (!(expected == actual)) {\n");
-        buf.append("                Assert.failNotEquals(message, new Double(expected), new Double(\n");
-        buf.append("                        actual));\n");
+        buf.append("                Assert.failNotEquals(message, new Double(expected),\n");
+        buf.append("                        new Double(actual));\n");
         buf.append("            }\n");
         buf.append("        } else if (!(Math.abs(expected - actual) <= delta)) {\n");
-        buf.append("            Assert.failNotEquals(message, new Double(expected), new Double(\n");
-        buf.append("                    actual));\n");
+        buf.append("            Assert.failNotEquals(message, new Double(expected),\n");
+        buf.append("                    new Double(actual));\n");
         buf.append("        }\n");
         buf.append("    }\n");
         buf.append("    /**\n");
@@ -2430,8 +2455,8 @@
         buf.append("        // the following test fails\n");
         buf.append("        if (Float.isInfinite(expected)) {\n");
         buf.append("            if (!(expected == actual)) {\n");
-        buf.append("                Assert.failNotEquals(message, new Float(expected), new Float(\n");
-        buf.append("                        actual));\n");
+        buf.append("                Assert.failNotEquals(message, new Float(expected),\n");
+        buf.append("                        new Float(actual));\n");
         buf.append("            }\n");
         buf.append("        } else if (!(Math.abs(expected - actual) <= delta)) {\n");
         buf.append("            Assert.failNotEquals(message, new Float(expected),\n");
@@ -2444,7 +2469,8 @@
         buf.append("     */\n");
         buf.append("    static public void assertEquals(final String message, final int expected,\n");
         buf.append("            final int actual) {\n");
-        buf.append("        Assert.assertEquals(message, new Integer(expected), new Integer(actual));\n");
+        buf.append("        Assert.assertEquals(message, new Integer(expected),\n");
+        buf.append("                new Integer(actual));\n");
         buf.append("    }\n");
         buf.append("    /**\n");
         buf.append("     * Asserts that two longs are equal. If they are not an AssertionFailedError\n");
@@ -2458,8 +2484,8 @@
         buf.append("     * Asserts that two objects are equal. If they are not an\n");
         buf.append("     * AssertionFailedError is thrown with the given message.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertEquals(final String message,\n");
-        buf.append("            final Object expected, final Object actual) {\n");
+        buf.append("    static public void assertEquals(final String message, final Object expected,\n");
+        buf.append("            final Object actual) {\n");
         buf.append("        if ((expected == null) && (actual == null)) {\n");
         buf.append("            return;\n");
         buf.append("        }\n");
@@ -2479,14 +2505,15 @@
         buf.append("    /**\n");
         buf.append("     * Asserts that two Strings are equal.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertEquals(final String expected, final String actual) {\n");
+        buf.append("    static public void assertEquals(final String expected,\n");
+        buf.append("            final String actual) {\n");
         buf.append("        Assert.assertEquals(null, expected, actual);\n");
         buf.append("    }\n");
         buf.append("    /**\n");
         buf.append("     * Asserts that two Strings are equal.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertEquals(final String message,\n");
-        buf.append("            final String expected, final String actual) {\n");
+        buf.append("    static public void assertEquals(final String message, final String expected,\n");
+        buf.append("            final String actual) {\n");
         buf.append("        if ((expected == null) && (actual == null)) {\n");
         buf.append("            return;\n");
         buf.append("        }\n");
@@ -2506,7 +2533,8 @@
         buf.append("     * Asserts that a condition is false. If it isn't it throws an\n");
         buf.append("     * AssertionFailedError with the given message.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertFalse(final String message, final boolean condition) {\n");
+        buf.append("    static public void assertFalse(final String message,\n");
+        buf.append("            final boolean condition) {\n");
         buf.append("        Assert.assertTrue(message, !condition);\n");
         buf.append("    }\n");
         buf.append("    /**\n");
@@ -2519,14 +2547,16 @@
         buf.append("     * Asserts that an object isn't null. If it is an AssertionFailedError is\n");
         buf.append("     * thrown with the given message.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertNotNull(final String message, final Object object) {\n");
+        buf.append("    static public void assertNotNull(final String message,\n");
+        buf.append("            final Object object) {\n");
         buf.append("        Assert.assertTrue(message, object != null);\n");
         buf.append("    }\n");
         buf.append("    /**\n");
         buf.append("     * Asserts that two objects refer to the same object. If they are not the\n");
         buf.append("     * same an AssertionFailedError is thrown.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertNotSame(final Object expected, final Object actual) {\n");
+        buf.append("    static public void assertNotSame(final Object expected,\n");
+        buf.append("            final Object actual) {\n");
         buf.append("        Assert.assertNotSame(null, expected, actual);\n");
         buf.append("    }\n");
         buf.append("    /**\n");
@@ -2581,7 +2611,8 @@
         buf.append("     * Asserts that a condition is true. If it isn't it throws an\n");
         buf.append("     * AssertionFailedError with the given message.\n");
         buf.append("     */\n");
-        buf.append("    static public void assertTrue(final String message, final boolean condition) {\n");
+        buf.append("    static public void assertTrue(final String message,\n");
+        buf.append("            final boolean condition) {\n");
         buf.append("        if (!condition) {\n");
         buf.append("            Assert.fail(message);\n");
         buf.append("        }\n");
@@ -2603,14 +2634,14 @@
         buf.append("        Assert.fail(Assert.format(message, expected, actual));\n");
         buf.append("    }\n");
         buf.append("\n");
-        buf.append("    static private void failNotSame(final String message,\n");
-        buf.append("            final Object expected, final Object actual) {\n");
+        buf.append("    static private void failNotSame(final String message, final Object expected,\n");
+        buf.append("            final Object actual) {\n");
         buf.append("        String formatted = \"\"; //$NON-NLS-1$\n");
         buf.append("        if (message != null) {\n");
         buf.append("            formatted = message + \" \"; //$NON-NLS-1$\n");
         buf.append("        }\n");
-        buf.append("        Assert.fail(formatted\n");
-        buf.append("                + \"expected same:<\" + expected + \"> was not:<\" + actual + \">\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n");
+        buf.append("        Assert.fail(formatted + \"expected same:<\" + expected + \"> was not:<\" //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                + actual + \">\"); //$NON-NLS-1$\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    static private void failSame(final String message) {\n");
@@ -2627,8 +2658,8 @@
         buf.append("        if (message != null) {\n");
         buf.append("            formatted = message + \" \"; //$NON-NLS-1$\n");
         buf.append("        }\n");
-        buf.append("        return formatted\n");
-        buf.append("                + \"expected:<\" + expected + \"> but was:<\" + actual + \">\"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n");
+        buf.append("        return formatted + \"expected:<\" + expected + \"> but was:<\" + actual //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                + \">\"; //$NON-NLS-1$\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    /**\n");
@@ -2663,8 +2694,8 @@
         buf.append("\n");
         buf.append("    protected String classNameFromFile(final String classFileName) {\n");
         buf.append("        // convert /a/b.class to a.b\n");
-        buf.append("        final String s = classFileName.substring(0, classFileName.length()\n");
-        buf.append("                - ClassPathTestCollector.SUFFIX_LENGTH);\n");
+        buf.append("        final String s = classFileName.substring(0,\n");
+        buf.append("                classFileName.length() - ClassPathTestCollector.SUFFIX_LENGTH);\n");
         buf.append("        final String s2 = s.replace(File.separatorChar, '.');\n");
         buf.append("        if (s2.startsWith(\".\")) {\n");
         buf.append("            return s2.substring(1);\n");
@@ -2673,8 +2704,8 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public Hashtable collectFilesInPath(final String classPath) {\n");
-        buf.append("        final Hashtable result = this.collectFilesInRoots(this\n");
-        buf.append("                .splitClassPath(classPath));\n");
+        buf.append("        final Hashtable result = this\n");
+        buf.append("                .collectFilesInRoots(this.splitClassPath(classPath));\n");
         buf.append("        return result;\n");
         buf.append("    }\n");
         buf.append("\n");
@@ -2706,8 +2737,8 @@
         buf.append("        final String[] contents = thisRoot.list();\n");
         buf.append("        if (contents != null) {\n");
         buf.append("            for (final String content : contents) {\n");
-        buf.append("                this.gatherFiles(classRoot, classFileName + File.separatorChar\n");
-        buf.append("                        + content, result);\n");
+        buf.append("                this.gatherFiles(classRoot,\n");
+        buf.append("                        classFileName + File.separatorChar + content, result);\n");
         buf.append("            }\n");
         buf.append("        }\n");
         buf.append("    }\n");
@@ -3054,8 +3085,8 @@
         buf.append("            } else if (args[i].equals(\"-c\")) {\n");
         buf.append("                testCase = this.extractClassName(args[++i]);\n");
         buf.append("            } else if (args[i].equals(\"-v\")) {\n");
-        buf.append("                System.err\n");
-        buf.append("                        .println(\"JUnit \" + Version.id() + \" by Kent Beck and Erich Gamma\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                System.err.println(\"JUnit \" + Version.id() //$NON-NLS-1$\n");
+        buf.append("                        + \" by Kent Beck and Erich Gamma\"); //$NON-NLS-1$\n");
         buf.append("            } else {\n");
         buf.append("                testCase = args[i];\n");
         buf.append("            }\n");
@@ -3079,7 +3110,8 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    @Override\n");
-        buf.append("    public void testFailed(final int status, final Test test, final Throwable t) {\n");
+        buf.append("    public void testFailed(final int status, final Test test,\n");
+        buf.append("            final Throwable t) {\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    @Override\n");
@@ -3109,14 +3141,14 @@
         buf.append("        this.verifySystemClassNotLoadedByTestLoader();\n");
         buf.append("    }\n");
         buf.append("    private void verifyApplicationClassLoadedByTestLoader() {\n");
-        buf.append("        Assert.assertTrue(this.isTestCaseClassLoader(this.getClass()\n");
-        buf.append("                .getClassLoader()));\n");
+        buf.append("        Assert.assertTrue(\n");
+        buf.append("                this.isTestCaseClassLoader(this.getClass().getClassLoader()));\n");
         buf.append("    }\n");
         buf.append("    private void verifySystemClassNotLoadedByTestLoader() {\n");
-        buf.append("        Assert.assertTrue(!this.isTestCaseClassLoader(Object.class\n");
-        buf.append("                .getClassLoader()));\n");
-        buf.append("        Assert.assertTrue(!this.isTestCaseClassLoader(TestCase.class\n");
-        buf.append("                .getClassLoader()));\n");
+        buf.append("        Assert.assertTrue(\n");
+        buf.append("                !this.isTestCaseClassLoader(Object.class.getClassLoader()));\n");
+        buf.append("        Assert.assertTrue(\n");
+        buf.append("                !this.isTestCaseClassLoader(TestCase.class.getClassLoader()));\n");
         buf.append("    }\n");
         buf.append("}");
         fExpectedChangesAllTests.put("junit.tests.runner.ClassLoaderTest.java", buf.toString());
@@ -3142,6 +3174,7 @@
         buf.append("");
         fExpectedChangesAllTests.put("junit.runner.TestRunListener.java", buf.toString());
         buf= new StringBuffer();
+        buf.append("\n");
         buf.append("package junit.tests.runner;\n");
         buf.append("\n");
         buf.append("import java.io.ByteArrayOutputStream;\n");
@@ -3190,23 +3223,23 @@
         buf.append("    @Override\n");
         buf.append("    public void setUp() {\n");
         buf.append("        this.output = new ByteArrayOutputStream();\n");
-        buf.append("        this.runner = new TestRunner(new TestResultPrinter(new PrintStream(\n");
-        buf.append("                this.output)));\n");
+        buf.append("        this.runner = new TestRunner(\n");
+        buf.append("                new TestResultPrinter(new PrintStream(this.output)));\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testEmptySuite() {\n");
-        buf.append("        final String expected = this.expected(new String[]{\n");
-        buf.append("                \"\", \"Time: 0\", \"\", \"OK (0 tests)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n");
+        buf.append("        final String expected = this\n");
+        buf.append("                .expected(new String[]{\"\", \"Time: 0\", \"\", \"OK (0 tests)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n");
         buf.append("        this.runner.doRun(new TestSuite());\n");
         buf.append("        Assert.assertEquals(expected.toString(), this.output.toString());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testError() {\n");
-        buf.append("        final String expected = this\n");
-        buf.append("                .expected(new String[]{\n");
-        buf.append("                        \".E\", \"Time: 0\", \"Errors here\", \"\", \"FAILURES!!!\", \"Tests run: 1,  Failures: 0,  Errors: 1\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$\n");
-        buf.append("        final ResultPrinter printer = new TestResultPrinter(new PrintStream(\n");
-        buf.append("                this.output)) {\n");
+        buf.append("        final String expected = this.expected(\n");
+        buf.append("                new String[]{\".E\", \"Time: 0\", \"Errors here\", \"\", \"FAILURES!!!\", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n");
+        buf.append("                        \"Tests run: 1,  Failures: 0,  Errors: 1\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final ResultPrinter printer = new TestResultPrinter(\n");
+        buf.append("                new PrintStream(this.output)) {\n");
         buf.append("            @Override\n");
         buf.append("            public void printErrors(final TestResult result) {\n");
         buf.append("                this.getWriter().println(\"Errors here\"); //$NON-NLS-1$\n");
@@ -3225,11 +3258,11 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testFailure() {\n");
-        buf.append("        final String expected = this\n");
-        buf.append("                .expected(new String[]{\n");
-        buf.append("                        \".F\", \"Time: 0\", \"Failures here\", \"\", \"FAILURES!!!\", \"Tests run: 1,  Failures: 1,  Errors: 0\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$\n");
-        buf.append("        final ResultPrinter printer = new TestResultPrinter(new PrintStream(\n");
-        buf.append("                this.output)) {\n");
+        buf.append("        final String expected = this.expected(new String[]{\".F\", \"Time: 0\", //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                \"Failures here\", \"\", \"FAILURES!!!\", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n");
+        buf.append("                \"Tests run: 1,  Failures: 1,  Errors: 0\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final ResultPrinter printer = new TestResultPrinter(\n");
+        buf.append("                new PrintStream(this.output)) {\n");
         buf.append("            @Override\n");
         buf.append("            public void printFailures(final TestResult result) {\n");
         buf.append("                this.getWriter().println(\"Failures here\"); //$NON-NLS-1$\n");
@@ -3248,8 +3281,8 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testOneTest() {\n");
-        buf.append("        final String expected = this.expected(new String[]{\n");
-        buf.append("                \".\", \"Time: 0\", \"\", \"OK (1 test)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n");
+        buf.append("        final String expected = this\n");
+        buf.append("                .expected(new String[]{\".\", \"Time: 0\", \"\", \"OK (1 test)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n");
         buf.append("        final TestSuite suite = new TestSuite();\n");
         buf.append("        suite.addTest(new TestCase() {\n");
         buf.append("            @Override\n");
@@ -3261,8 +3294,8 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testTwoTests() {\n");
-        buf.append("        final String expected = this.expected(new String[]{\n");
-        buf.append("                \"..\", \"Time: 0\", \"\", \"OK (2 tests)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n");
+        buf.append("        final String expected = this.expected(\n");
+        buf.append("                new String[]{\"..\", \"Time: 0\", \"\", \"OK (2 tests)\", \"\"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n");
         buf.append("        final TestSuite suite = new TestSuite();\n");
         buf.append("        suite.addTest(new TestCase() {\n");
         buf.append("            @Override\n");
@@ -3424,8 +3457,8 @@
         buf.append("        this.verifyApplicationClassLoadedByTestLoader();\n");
         buf.append("    }\n");
         buf.append("    private void verifyApplicationClassLoadedByTestLoader() {\n");
-        buf.append("        Assert.assertTrue(this.isTestCaseClassLoader(this.getClass()\n");
-        buf.append("                .getClassLoader()));\n");
+        buf.append("        Assert.assertTrue(\n");
+        buf.append("                this.isTestCaseClassLoader(this.getClass().getClassLoader()));\n");
         buf.append("    }\n");
         buf.append("}");
         fExpectedChangesAllTests.put("junit.tests.runner.LoadedFromJar.java", buf.toString());
@@ -3439,17 +3472,17 @@
         buf.append("public class ComparisonFailureTest extends TestCase {\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorEndSame() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null,\n");
-        buf.append("                \"ab\", \"cb\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
-        buf.append("        Assert.assertEquals(\n");
-        buf.append("                \"expected:<a...> but was:<c...>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"ab\", //$NON-NLS-1$\n");
+        buf.append("                \"cb\"); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertEquals(\"expected:<a...> but was:<c...>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorEndSameComplete() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null,\n");
-        buf.append("                \"bc\", \"abc\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
-        buf.append("        Assert.assertEquals(\n");
-        buf.append("                \"expected:<...> but was:<a...>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"bc\", //$NON-NLS-1$\n");
+        buf.append("                \"abc\"); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertEquals(\"expected:<...> but was:<a...>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorMessage() {\n");
@@ -3458,59 +3491,64 @@
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorOverlapingMatches() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null,\n");
-        buf.append("                \"abc\", \"abbc\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
-        buf.append("        Assert.assertEquals(\n");
-        buf.append("                \"expected:<......> but was:<...b...>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"abc\", //$NON-NLS-1$\n");
+        buf.append("                \"abbc\"); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertEquals(\"expected:<......> but was:<...b...>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorOverlapingMatches2() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null,\n");
-        buf.append("                \"abcdde\", \"abcde\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
-        buf.append("        Assert.assertEquals(\n");
-        buf.append("                \"expected:<...d...> but was:<......>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"abcdde\", //$NON-NLS-1$\n");
+        buf.append("                \"abcde\"); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertEquals(\"expected:<...d...> but was:<......>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorSame() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null,\n");
-        buf.append("                \"ab\", \"ab\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"ab\", //$NON-NLS-1$\n");
+        buf.append("                \"ab\"); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(\"expected:<ab> but was:<ab>\", failure.getMessage()); //$NON-NLS-1$\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorStartAndEndSame() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null,\n");
-        buf.append("                \"abc\", \"adc\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
-        buf.append("        Assert.assertEquals(\n");
-        buf.append("                \"expected:<...b...> but was:<...d...>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"abc\", //$NON-NLS-1$\n");
+        buf.append("                \"adc\"); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertEquals(\"expected:<...b...> but was:<...d...>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorStartSame() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null,\n");
-        buf.append("                \"ba\", \"bc\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
-        buf.append("        Assert.assertEquals(\n");
-        buf.append("                \"expected:<...a> but was:<...c>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"ba\", //$NON-NLS-1$\n");
+        buf.append("                \"bc\"); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertEquals(\"expected:<...a> but was:<...c>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorStartSameComplete() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null,\n");
-        buf.append("                \"ab\", \"abc\"); //$NON-NLS-1$ //$NON-NLS-2$\n");
-        buf.append("        Assert.assertEquals(\n");
-        buf.append("                \"expected:<...> but was:<...c>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"ab\", //$NON-NLS-1$\n");
+        buf.append("                \"abc\"); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertEquals(\"expected:<...> but was:<...c>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorWithActualNull() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"a\", null); //$NON-NLS-1$\n");
-        buf.append("        Assert.assertEquals(\"expected:<a> but was:<null>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, \"a\", //$NON-NLS-1$\n");
+        buf.append("                null);\n");
+        buf.append("        Assert.assertEquals(\"expected:<a> but was:<null>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("    public void testComparisonErrorWithExpectedNull() {\n");
-        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, null, \"a\"); //$NON-NLS-1$\n");
-        buf.append("        Assert.assertEquals(\"expected:<null> but was:<a>\", failure.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        final ComparisonFailure failure = new ComparisonFailure(null, null,\n");
+        buf.append("                \"a\"); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertEquals(\"expected:<null> but was:<a>\", //$NON-NLS-1$\n");
+        buf.append("                failure.getMessage());\n");
         buf.append("    }\n");
         buf.append("}\n");
         buf.append("");
         fExpectedChangesAllTests.put("junit.tests.framework.ComparisonFailureTest.java", buf.toString());
         buf= new StringBuffer();
+        buf.append("\n");
         buf.append("package junit.textui;\n");
         buf.append("\n");
         buf.append("import java.io.PrintStream;\n");
@@ -3581,14 +3619,15 @@
         buf.append("\n");
         buf.append("    public void printDefect(final TestFailure booBoo, final int count) { // only\n");
         buf.append("                                                                         // public\n");
-		buf.append("                                                                         // for\n");
-		buf.append("                                                                         // testing\n");
-		buf.append("                                                                         // purposes\n");
+        buf.append("                                                                         // for\n");
+        buf.append("                                                                         // testing\n");
+        buf.append("                                                                         // purposes\n");
         buf.append("        this.printDefectHeader(booBoo, count);\n");
         buf.append("        this.printDefectTrace(booBoo);\n");
         buf.append("    }\n");
         buf.append("\n");
-        buf.append("    protected void printDefectHeader(final TestFailure booBoo, final int count) {\n");
+        buf.append("    protected void printDefectHeader(final TestFailure booBoo,\n");
+        buf.append("            final int count) {\n");
         buf.append("        // I feel like making this a println, then adding a line giving the\n");
         buf.append("        // throwable a chance to print something\n");
         buf.append("        // before we get to the stack trace.\n");
@@ -3625,16 +3664,16 @@
         buf.append("        if (result.wasSuccessful()) {\n");
         buf.append("            this.getWriter().println();\n");
         buf.append("            this.getWriter().print(\"OK\"); //$NON-NLS-1$\n");
-        buf.append("            this.getWriter()\n");
-        buf.append("                    .println(\n");
-        buf.append("                            \" (\"    + result.runCount() + \" test\" + (result.runCount() == 1 ? \"\" : \"s\") + \")\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$\n");
+        buf.append("            this.getWriter().println(\" (\" + result.runCount() + \" test\" //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                    + (result.runCount() == 1 ? \"\" : \"s\") + \")\"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n");
         buf.append("\n");
         buf.append("        } else {\n");
         buf.append("            this.getWriter().println();\n");
         buf.append("            this.getWriter().println(\"FAILURES!!!\"); //$NON-NLS-1$\n");
-        buf.append("            this.getWriter().println(\"Tests run: \" + result.runCount() + //$NON-NLS-1$\n");
-        buf.append("                    \",  Failures: \" + result.failureCount() + //$NON-NLS-1$\n");
-        buf.append("                    \",  Errors: \" + result.errorCount()); //$NON-NLS-1$\n");
+        buf.append("            this.getWriter()\n");
+        buf.append("                    .println(\"Tests run: \" + result.runCount() + //$NON-NLS-1$\n");
+        buf.append("                            \",  Failures: \" + result.failureCount() + //$NON-NLS-1$\n");
+        buf.append("                            \",  Errors: \" + result.errorCount()); //$NON-NLS-1$\n");
         buf.append("        }\n");
         buf.append("        this.getWriter().println();\n");
         buf.append("    }\n");
@@ -3778,8 +3817,8 @@
         buf.append("                    this.fActual);\n");
         buf.append("        }\n");
         buf.append("\n");
-        buf.append("        final int end = Math\n");
-        buf.append("                .min(this.fExpected.length(), this.fActual.length());\n");
+        buf.append("        final int end = Math.min(this.fExpected.length(),\n");
+        buf.append("                this.fActual.length());\n");
         buf.append("\n");
         buf.append("        int i = 0;\n");
         buf.append("        for (; i < end; i++) {\n");
@@ -3855,7 +3894,8 @@
         buf.append("        // writing self tests. And you thought those weird anonymous\n");
         buf.append("        // inner classes were bad...\n");
         buf.append("        Assert.assertEquals(\n");
-        buf.append("                \"testCaseToString(junit.tests.framework.TestCaseTest)\", this.toString()); //$NON-NLS-1$\n");
+        buf.append("                \"testCaseToString(junit.tests.framework.TestCaseTest)\", //$NON-NLS-1$\n");
+        buf.append("                this.toString());\n");
         buf.append("    }\n");
         buf.append("    public void testError() {\n");
         buf.append("        final TestCase error = new TestCase(\"error\") { //$NON-NLS-1$\n");
@@ -4046,8 +4086,8 @@
         buf.append("    @Override\n");
         buf.append("    public String toString() {\n");
         buf.append("        final StringBuffer buffer = new StringBuffer();\n");
-        buf.append("        buffer.append(this.fFailedTest\n");
-        buf.append("                + \": \" + this.fThrownException.getMessage()); //$NON-NLS-1$\n");
+        buf.append("        buffer.append(\n");
+        buf.append("                this.fFailedTest + \": \" + this.fThrownException.getMessage()); //$NON-NLS-1$\n");
         buf.append("        return buffer.toString();\n");
         buf.append("    }\n");
         buf.append("    public String trace() {\n");
@@ -4162,11 +4202,12 @@
         buf.append("\n");
         buf.append("    void execTest(final String testClass, final boolean success)\n");
         buf.append("            throws Exception {\n");
-        buf.append("        final String java = System.getProperty(\"java.home\") + File.separator + \"bin\" + File.separator + \"java\"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\n");
+        buf.append("        final String java = System.getProperty(\"java.home\") + File.separator //$NON-NLS-1$\n");
+        buf.append("                + \"bin\" + File.separator + \"java\"; //$NON-NLS-1$ //$NON-NLS-2$\n");
         buf.append("        final String cp = System.getProperty(\"java.class.path\"); //$NON-NLS-1$\n");
         buf.append("        // use -classpath for JDK 1.1.7 compatibility\n");
-        buf.append("        final String[] cmd = {java,\n");
-        buf.append("                \"-classpath\", cp, \"junit.textui.TestRunner\", testClass}; //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final String[] cmd = {java, \"-classpath\", cp, \"junit.textui.TestRunner\", //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("                testClass};\n");
         buf.append("        final Process p = Runtime.getRuntime().exec(cmd);\n");
         buf.append("        final InputStream i = p.getInputStream();\n");
         buf.append("        while ((i.read()) != -1) {\n");
@@ -4281,6 +4322,7 @@
         buf.append("}");
         fExpectedChangesAllTests.put("junit.extensions.RepeatedTest.java", buf.toString());
         buf= new StringBuffer();
+        buf.append("\n");
         buf.append("package junit.tests.framework;\n");
         buf.append("\n");
         buf.append("import junit.framework.TestCase;\n");
@@ -4524,7 +4566,8 @@
         buf.append("        return MoneyBag.create(s, this);\n");
         buf.append("    }\n");
         buf.append("    void appendBag(final MoneyBag aBag) {\n");
-        buf.append("        for (final Enumeration e = aBag.fMonies.elements(); e.hasMoreElements();) {\n");
+        buf.append("        for (final Enumeration e = aBag.fMonies.elements(); e\n");
+        buf.append("                .hasMoreElements();) {\n");
         buf.append("            this.appendMoney((Money) e.nextElement());\n");
         buf.append("        }\n");
         buf.append("    }\n");
@@ -4580,7 +4623,8 @@
         buf.append("        return false;\n");
         buf.append("    }\n");
         buf.append("    private Money findMoney(final String currency) {\n");
-        buf.append("        for (final Enumeration e = this.fMonies.elements(); e.hasMoreElements();) {\n");
+        buf.append("        for (final Enumeration e = this.fMonies.elements(); e\n");
+        buf.append("                .hasMoreElements();) {\n");
         buf.append("            final Money m = (Money) e.nextElement();\n");
         buf.append("            if (m.currency().equals(currency)) {\n");
         buf.append("                return m;\n");
@@ -4591,7 +4635,8 @@
         buf.append("    @Override\n");
         buf.append("    public int hashCode() {\n");
         buf.append("        int hash = 0;\n");
-        buf.append("        for (final Enumeration e = this.fMonies.elements(); e.hasMoreElements();) {\n");
+        buf.append("        for (final Enumeration e = this.fMonies.elements(); e\n");
+        buf.append("                .hasMoreElements();) {\n");
         buf.append("            final Object m = e.nextElement();\n");
         buf.append("            hash ^= m.hashCode();\n");
         buf.append("        }\n");
@@ -4613,7 +4658,8 @@
         buf.append("    }\n");
         buf.append("    public IMoney negate() {\n");
         buf.append("        final MoneyBag result = new MoneyBag();\n");
-        buf.append("        for (final Enumeration e = this.fMonies.elements(); e.hasMoreElements();) {\n");
+        buf.append("        for (final Enumeration e = this.fMonies.elements(); e\n");
+        buf.append("                .hasMoreElements();) {\n");
         buf.append("            final Money m = (Money) e.nextElement();\n");
         buf.append("            result.appendMoney((Money) m.negate());\n");
         buf.append("        }\n");
@@ -4632,7 +4678,8 @@
         buf.append("    public String toString() {\n");
         buf.append("        final StringBuffer buffer = new StringBuffer();\n");
         buf.append("        buffer.append(\"{\"); //$NON-NLS-1$\n");
-        buf.append("        for (final Enumeration e = this.fMonies.elements(); e.hasMoreElements();) {\n");
+        buf.append("        for (final Enumeration e = this.fMonies.elements(); e\n");
+        buf.append("                .hasMoreElements();) {\n");
         buf.append("            buffer.append(e.nextElement());\n");
         buf.append("        }\n");
         buf.append("        buffer.append(\"}\"); //$NON-NLS-1$\n");
@@ -4651,8 +4698,8 @@
         buf.append("\n");
         buf.append("    public void testMissingDirectory() {\n");
         buf.append("        final SimpleTestCollector collector = new SimpleTestCollector();\n");
-        buf.append("        Assert.assertFalse(collector\n");
-        buf.append("                .collectFilesInPath(\"foobar\").elements().hasMoreElements()); //$NON-NLS-1$\n");
+        buf.append("        Assert.assertFalse(collector.collectFilesInPath(\"foobar\").elements() //$NON-NLS-1$\n");
+        buf.append("                .hasMoreElements());\n");
         buf.append("    }\n");
         buf.append("\n");
         buf.append("}\n");
@@ -4666,7 +4713,8 @@
         buf.append("import java.lang.reflect.Modifier;\n");
         buf.append("\n");
         buf.append("/**\n");
-        buf.append(" * A test case defines the fixture to run multiple tests. To define a test case<br>\n");
+        buf.append(" * A test case defines the fixture to run multiple tests. To define a test case\n");
+        buf.append(" * <br>\n");
         buf.append(" * 1) implement a subclass of TestCase<br>\n");
         buf.append(" * 2) define instance variables that store the state of the fixture<br>\n");
         buf.append(" * 3) initialize the fixture state by overriding <code>setUp</code><br>\n");
@@ -4678,7 +4726,7 @@
         buf.append(" * public class MathTest extends TestCase {\n");
         buf.append(" *     protected double fValue1;\n");
         buf.append(" *     protected double fValue2;\n");
-        buf.append(" * \n");
+        buf.append(" *\n");
         buf.append(" *     protected void setUp() {\n");
         buf.append(" *         fValue1 = 2.0;\n");
         buf.append(" *         fValue2 = 3.0;\n");
@@ -4703,7 +4751,7 @@
         buf.append(" * way to do so is with an anonymous inner class.\n");
         buf.append(" * \n");
         buf.append(" * <pre>\n");
-        buf.append(" * TestCase test = new MathTest(&quot;add&quot;) {\n");
+        buf.append(" * TestCase test = new MathTest(\"add\") {\n");
         buf.append(" *     public void runTest() {\n");
         buf.append(" *         testAdd();\n");
         buf.append(" *     }\n");
@@ -4716,7 +4764,7 @@
         buf.append(" * case has to correspond to the test method to be run.\n");
         buf.append(" * \n");
         buf.append(" * <pre>\n");
-        buf.append(" * TestCase = new MathTest(&quot;testAdd&quot;);\n");
+        buf.append(" * TestCase = new MathTest(\"testAdd\");\n");
         buf.append(" * test.run();\n");
         buf.append(" * </pre>\n");
         buf.append(" * \n");
@@ -4728,8 +4776,8 @@
         buf.append(" * \n");
         buf.append(" * <pre>\n");
         buf.append(" * public static Test suite() {\n");
-        buf.append(" *     suite.addTest(new MathTest(&quot;testAdd&quot;));\n");
-        buf.append(" *     suite.addTest(new MathTest(&quot;testDivideByZero&quot;));\n");
+        buf.append(" *     suite.addTest(new MathTest(\"testAdd\"));\n");
+        buf.append(" *     suite.addTest(new MathTest(\"testDivideByZero\"));\n");
         buf.append(" *     return suite;\n");
         buf.append(" * }\n");
         buf.append(" * </pre>\n");
@@ -4902,16 +4950,16 @@
         buf.append("    }\n");
         buf.append("    public void testBagMultiply() {\n");
         buf.append("        // {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]}\n");
-        buf.append("        final IMoney expected = MoneyBag.create(\n");
-        buf.append("                new Money(24, \"CHF\"), new Money(14, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney expected = MoneyBag.create(new Money(24, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(14, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(expected, this.fMB1.multiply(2));\n");
         buf.append("        Assert.assertEquals(this.fMB1, this.fMB1.multiply(1));\n");
         buf.append("        Assert.assertTrue(this.fMB1.multiply(0).isZero());\n");
         buf.append("    }\n");
         buf.append("    public void testBagNegate() {\n");
         buf.append("        // {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]}\n");
-        buf.append("        final IMoney expected = MoneyBag.create(\n");
-        buf.append("                new Money(-12, \"CHF\"), new Money(-7, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney expected = MoneyBag.create(new Money(-12, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(-7, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(expected, this.fMB1.negate());\n");
         buf.append("    }\n");
         buf.append("    public void testBagNotEquals() {\n");
@@ -4920,26 +4968,26 @@
         buf.append("    }\n");
         buf.append("    public void testBagSimpleAdd() {\n");
         buf.append("        // {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]}\n");
-        buf.append("        final IMoney expected = MoneyBag.create(\n");
-        buf.append("                new Money(26, \"CHF\"), new Money(7, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(7, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(expected, this.fMB1.add(this.f14CHF));\n");
         buf.append("    }\n");
         buf.append("    public void testBagSubtract() {\n");
         buf.append("        // {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]}\n");
-        buf.append("        final IMoney expected = MoneyBag.create(\n");
-        buf.append("                new Money(-2, \"CHF\"), new Money(-14, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney expected = MoneyBag.create(new Money(-2, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(-14, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(expected, this.fMB1.subtract(this.fMB2));\n");
         buf.append("    }\n");
         buf.append("    public void testBagSumAdd() {\n");
         buf.append("        // {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]}\n");
-        buf.append("        final IMoney expected = MoneyBag.create(\n");
-        buf.append("                new Money(26, \"CHF\"), new Money(28, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(28, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(expected, this.fMB1.add(this.fMB2));\n");
         buf.append("    }\n");
         buf.append("    public void testIsZero() {\n");
         buf.append("        Assert.assertTrue(this.fMB1.subtract(this.fMB1).isZero());\n");
-        buf.append("        Assert.assertTrue(MoneyBag.create(\n");
-        buf.append("                new Money(0, \"CHF\"), new Money(0, \"USD\")).isZero()); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        Assert.assertTrue(MoneyBag\n");
+        buf.append("                .create(new Money(0, \"CHF\"), new Money(0, \"USD\")).isZero()); //$NON-NLS-1$ //$NON-NLS-2$\n");
         buf.append("    }\n");
         buf.append("    public void testMixedSimpleAdd() {\n");
         buf.append("        // [12 CHF] + [7 USD] == {[12 CHF][7 USD]}\n");
@@ -4950,16 +4998,16 @@
         buf.append("        Assert.assertTrue(!this.fMB1.equals(null));\n");
         buf.append("\n");
         buf.append("        Assert.assertEquals(this.fMB1, this.fMB1);\n");
-        buf.append("        final IMoney equal = MoneyBag.create(\n");
-        buf.append("                new Money(12, \"CHF\"), new Money(7, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney equal = MoneyBag.create(new Money(12, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(7, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertTrue(this.fMB1.equals(equal));\n");
         buf.append("        Assert.assertTrue(!this.fMB1.equals(this.f12CHF));\n");
         buf.append("        Assert.assertTrue(!this.f12CHF.equals(this.fMB1));\n");
         buf.append("        Assert.assertTrue(!this.fMB1.equals(this.fMB2));\n");
         buf.append("    }\n");
         buf.append("    public void testMoneyBagHash() {\n");
-        buf.append("        final IMoney equal = MoneyBag.create(\n");
-        buf.append("                new Money(12, \"CHF\"), new Money(7, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney equal = MoneyBag.create(new Money(12, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(7, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(this.fMB1.hashCode(), equal.hashCode());\n");
         buf.append("    }\n");
         buf.append("    public void testMoneyEquals() {\n");
@@ -4982,15 +5030,15 @@
         buf.append("    }\n");
         buf.append("    public void testNormalize3() {\n");
         buf.append("        // {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD]\n");
-        buf.append("        final IMoney ms1 = MoneyBag.create(\n");
-        buf.append("                new Money(12, \"CHF\"), new Money(3, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney ms1 = MoneyBag.create(new Money(12, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(3, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        final Money expected = new Money(4, \"USD\"); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(expected, this.fMB1.subtract(ms1));\n");
         buf.append("    }\n");
         buf.append("    public void testNormalize4() {\n");
         buf.append("        // [12 CHF] - {[12 CHF][3 USD]} == [-3 USD]\n");
-        buf.append("        final IMoney ms1 = MoneyBag.create(\n");
-        buf.append("                new Money(12, \"CHF\"), new Money(3, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney ms1 = MoneyBag.create(new Money(12, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(3, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        final Money expected = new Money(-3, \"USD\"); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(expected, this.f12CHF.subtract(ms1));\n");
         buf.append("    }\n");
@@ -5004,8 +5052,8 @@
         buf.append("    }\n");
         buf.append("    public void testSimpleBagAdd() {\n");
         buf.append("        // [14 CHF] + {[12 CHF][7 USD]} == {[26 CHF][7 USD]}\n");
-        buf.append("        final IMoney expected = MoneyBag.create(\n");
-        buf.append("                new Money(26, \"CHF\"), new Money(7, \"USD\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney expected = MoneyBag.create(new Money(26, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(7, \"USD\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(expected, this.f14CHF.add(this.fMB1));\n");
         buf.append("    }\n");
         buf.append("    public void testSimpleMultiply() {\n");
@@ -5024,8 +5072,8 @@
         buf.append("        Assert.assertEquals(expected, this.f14CHF.subtract(this.f12CHF));\n");
         buf.append("    }\n");
         buf.append("    public void testSimplify() {\n");
-        buf.append("        final IMoney money = MoneyBag.create(\n");
-        buf.append("                new Money(26, \"CHF\"), new Money(28, \"CHF\")); //$NON-NLS-1$ //$NON-NLS-2$\n");
+        buf.append("        final IMoney money = MoneyBag.create(new Money(26, \"CHF\"), //$NON-NLS-1$\n");
+        buf.append("                new Money(28, \"CHF\")); //$NON-NLS-1$\n");
         buf.append("        Assert.assertEquals(new Money(54, \"CHF\"), money); //$NON-NLS-1$\n");
         buf.append("    }\n");
         buf.append("}");
@@ -5088,8 +5136,8 @@
         buf.append("\n");
         buf.append("    public void testClassLoading() throws Exception {\n");
         buf.append("        final TestCaseClassLoader loader = new TestCaseClassLoader();\n");
-        buf.append("        final Class loadedClass = loader.loadClass(\n");
-        buf.append("                \"junit.tests.runner.ClassLoaderTest\", true); //$NON-NLS-1$\n");
+        buf.append("        final Class loadedClass = loader\n");
+        buf.append("                .loadClass(\"junit.tests.runner.ClassLoaderTest\", true); //$NON-NLS-1$\n");
         buf.append("        final Object o = loadedClass.newInstance();\n");
         buf.append("        //\n");
         buf.append("        // Invoke the assertClassLoaders method via reflection.\n");
@@ -5097,8 +5145,8 @@
         buf.append("        // another class loader and we can't do a successfull downcast to\n");
         buf.append("        // ClassLoaderTestCase.\n");
         buf.append("        //\n");
-        buf.append("        final Method method = loadedClass.getDeclaredMethod(\n");
-        buf.append("                \"verify\", new Class[0]); //$NON-NLS-1$\n");
+        buf.append("        final Method method = loadedClass.getDeclaredMethod(\"verify\", //$NON-NLS-1$\n");
+        buf.append("                new Class[0]);\n");
         buf.append("        method.invoke(o, new Class[0]);\n");
         buf.append("    }\n");
         buf.append("\n");
@@ -5107,8 +5155,8 @@
         buf.append("        Assert.assertNotNull(\"Cannot find test.jar\", url); //$NON-NLS-1$\n");
         buf.append("        final String path = url.getFile();\n");
         buf.append("        final TestCaseClassLoader loader = new TestCaseClassLoader(path);\n");
-        buf.append("        final Class loadedClass = loader.loadClass(\n");
-        buf.append("                \"junit.tests.runner.LoadedFromJar\", true); //$NON-NLS-1$\n");
+        buf.append("        final Class loadedClass = loader\n");
+        buf.append("                .loadClass(\"junit.tests.runner.LoadedFromJar\", true); //$NON-NLS-1$\n");
         buf.append("        final Object o = loadedClass.newInstance();\n");
         buf.append("        //\n");
         buf.append("        // Invoke the assertClassLoaders method via reflection.\n");
@@ -5116,8 +5164,8 @@
         buf.append("        // another class loader and we can't do a successfull downcast to\n");
         buf.append("        // ClassLoaderTestCase.\n");
         buf.append("        //\n");
-        buf.append("        final Method method = loadedClass.getDeclaredMethod(\n");
-        buf.append("                \"verify\", new Class[0]); //$NON-NLS-1$\n");
+        buf.append("        final Method method = loadedClass.getDeclaredMethod(\"verify\", //$NON-NLS-1$\n");
+        buf.append("                new Class[0]);\n");
         buf.append("        method.invoke(o, new Class[0]);\n");
         buf.append("    }\n");
         buf.append("}");
@@ -5159,7 +5207,7 @@
         buf.append("    public int amount() {\n");
         buf.append("        return this.fAmount;\n");
         buf.append("    }\n");
-        buf.append("    public/* this makes no sense */void appendTo(final MoneyBag m) {\n");
+        buf.append("    public /* this makes no sense */ void appendTo(final MoneyBag m) {\n");
         buf.append("        m.appendMoney(this);\n");
         buf.append("    }\n");
         buf.append("    public String currency() {\n");
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java
index 009a715..8f8c513c 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class
+ *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set
  *******************************************************************************/
 
 package org.eclipse.jdt.ui.tests.wizardapi;
@@ -711,8 +712,8 @@
 	{
 		typeBodyTest( new NewClassWizardPage(),
 			CodeTemplateContextType.CLASSBODY_ID,
-			"    // test comment\n    String testMember = \"${type_name}\"\n",
-			"    // test comment\n    String testMember = \"TestClassBodyType\"\n",
+			"    // test comment\n    String testMember = \"${type_name}\";\n",
+			"    // test comment\n    String testMember = \"TestClassBodyType\";\n",
 			"testclassbodypackage",
 			"TestClassBodyType",
 			"class" );
@@ -744,8 +745,8 @@
 	{
 		typeBodyTest( new NewAnnotationWizardPage(),
 			CodeTemplateContextType.ANNOTATIONBODY_ID,
-			"\n    @SomeOtherSpecialAnnotation ${package_name}_${type_name}\n",
-			"\n    @SomeOtherSpecialAnnotation annotationbodypackage_AnnotationBodyType\n",
+			"\n    @SomeOtherSpecialAnnotation\n    int ${package_name}_${type_name};\n",
+			"\n    @SomeOtherSpecialAnnotation\n    int annotationbodypackage_AnnotationBodyType;\n",
 			"annotationbodypackage",
 			"AnnotationBodyType",
 			"@interface" );
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GetterSetterUtil.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GetterSetterUtil.java
index 58d0c1b..2c13c34 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GetterSetterUtil.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GetterSetterUtil.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set
  *******************************************************************************/
 package org.eclipse.jdt.internal.corext.codemanipulation;
 
@@ -169,7 +170,6 @@
 			buf.append(body);
 		}
 		buf.append("}"); //$NON-NLS-1$
-		buf.append(lineDelim);
 		return buf.toString();
 	}
 
@@ -229,7 +229,6 @@
 			buf.append(body);
 		}
 		buf.append("}"); //$NON-NLS-1$
-		buf.append(lineDelim);
 		return buf.toString();
 	}