diff options
author | Stephan Herrmann | 2010-04-23 12:43:55 +0000 |
---|---|---|
committer | Stephan Herrmann | 2010-04-23 12:43:55 +0000 |
commit | f9f700f8645a8ec244b84751a0ed18493aff99f1 (patch) | |
tree | 7ebf4ebfb52b4e417d6d4ce04d534664b44784d6 /testplugins | |
parent | 2660ec37e0b791cbccb5d3a2e0894efd7aa54975 (diff) | |
download | org.eclipse.objectteams-f9f700f8645a8ec244b84751a0ed18493aff99f1.tar.gz org.eclipse.objectteams-f9f700f8645a8ec244b84751a0ed18493aff99f1.tar.xz org.eclipse.objectteams-f9f700f8645a8ec244b84751a0ed18493aff99f1.zip |
update these tests to v20100420-0800
Diffstat (limited to 'testplugins')
12 files changed, 222 insertions, 20 deletions
diff --git a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java index b264b4fe9..dc7d0005c 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java +++ b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -270,11 +270,11 @@ public class ChkpiiTests extends TestCase { } if (errors > 0) { - message.append("" + errors + " files containing errors\n"); + message.append("\n" + errors + " files containing errors\n"); hasFailed= true; } if (XML != type && warnings > 0) { - message.append("" + errors + " files containing errors\n"); + message.append("" + warnings + " files containing warnings\n"); hasFailed= true; } if (notProcessed > 0) { diff --git a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreFiles.txt b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreFiles.txt index 9839ed5e6..b6a663759 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreFiles.txt +++ b/testplugins/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ignoreFiles.txt @@ -116,6 +116,8 @@ org.apache.lucene/* org.apache.lucene.analysis/* org.junit4/* org.objectweb.asm/* +org.sat4j.core/* +org.sat4j.pb/* www*eclipse.org-eclipse-root/* www*eclipse.org-development/* diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/AbstractTestRunListenerTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/AbstractTestRunListenerTest.java index 680f1b311..56dad0265 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/AbstractTestRunListenerTest.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/AbstractTestRunListenerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -199,7 +199,7 @@ public class AbstractTestRunListenerTest extends TestCase { return true; } - protected void assertEqualLog(final String[] expectedSequence, String[] logMessages) { + public static void assertEqualLog(final String[] expectedSequence, String[] logMessages) { StringBuffer actual= new StringBuffer(); for (int i= 0; i < logMessages.length; i++) { actual.append(logMessages[i]).append('\n'); diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunListenerTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunListenerTest.java index 3f8a486cc..2fdbec991 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunListenerTest.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunListenerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2010 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 @@ -46,7 +46,6 @@ public class TestRunListenerTest extends AbstractTestRunListenerTest { } public void testOK() throws Exception { - new TestRunListeners(); String source= "package pack;\n" + "import junit.framework.TestCase;\n" + @@ -146,7 +145,6 @@ public class TestRunListenerTest extends AbstractTestRunListenerTest { public void testTreeOnSessionStarted() throws Exception { - new TestRunListeners(); String source= "package pack;\n" + "import junit.framework.TestCase;\n" + @@ -165,7 +163,6 @@ public class TestRunListenerTest extends AbstractTestRunListenerTest { } public void testTreeOnSessionEnded() throws Exception { - new TestRunListeners(); String source= "package pack;\n" + "import junit.framework.TestCase;\n" + @@ -184,7 +181,6 @@ public class TestRunListenerTest extends AbstractTestRunListenerTest { } public void testTreeOnSecondTestStarted() throws Exception { - new TestRunListeners(); String source= "package pack;\n" + "import junit.framework.TestCase;\n" + @@ -205,7 +201,6 @@ public class TestRunListenerTest extends AbstractTestRunListenerTest { } public void testTreeOnSecondTestStarted2() throws Exception { - new TestRunListeners(); String source= "package pack;\n" + "import junit.framework.TestCase;\n" + @@ -227,7 +222,6 @@ public class TestRunListenerTest extends AbstractTestRunListenerTest { public void testTreeUnrootedEnded() throws Exception { // regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=153807 - new TestRunListeners(); String source= "package pack;\n" + "\n" + diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunSessionSerializationTests4.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunSessionSerializationTests4.java index 9194971ed..beb4a1c2e 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunSessionSerializationTests4.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestRunSessionSerializationTests4.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. + * Copyright (c) 2007, 2010 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 @@ -18,6 +18,12 @@ import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; +import org.eclipse.jdt.junit.JUnitCore; +import org.eclipse.jdt.junit.TestRunListener; +import org.eclipse.jdt.junit.model.ITestElement.FailureTrace; +import org.eclipse.jdt.junit.model.ITestElement.ProgressState; +import org.eclipse.jdt.junit.model.ITestElement.Result; +import org.eclipse.jdt.junit.tests.AbstractTestRunListenerTest.TestRunLog; import org.eclipse.jdt.testplugin.JavaTestPlugin; import org.eclipse.core.runtime.Path; @@ -66,7 +72,43 @@ public class TestRunSessionSerializationTests4 extends AbstractTestRunSessionSer public void testFailures() throws Exception { String test= "Failures"; - runCUTest(test); + + TestRunLog log= new TestRunLog(); + final TestRunListener testRunListener= new TestRunListeners.SequenceTest(log); + JUnitCore.addTestRunListener(testRunListener); + try { + runCUTest(test); + String[] expectedSequence= new String[] { + "sessionStarted-" + TestRunListeners.sessionAsString("Failures", ProgressState.RUNNING, Result.UNDEFINED, 0), + + "testCaseStarted-" + TestRunListeners.testCaseAsString("testNasty", "pack.Failures", ProgressState.RUNNING, Result.UNDEFINED, null, 0), + "testCaseFinished-" + TestRunListeners.testCaseAsString("testNasty", "pack.Failures", ProgressState.COMPLETED, Result.FAILURE, new FailureTrace("java.lang.AssertionError", null, null), 0), + + "testCaseStarted-" + TestRunListeners.testCaseAsString("ignored", "pack.Failures", ProgressState.RUNNING, Result.UNDEFINED, null, 0), + "testCaseFinished-" + TestRunListeners.testCaseAsString("ignored", "pack.Failures", ProgressState.COMPLETED, Result.IGNORED, null, 0), + + "testCaseStarted-" + TestRunListeners.testCaseAsString("testError", "pack.Failures", ProgressState.RUNNING, Result.UNDEFINED, null, 0), + "testCaseFinished-" + TestRunListeners.testCaseAsString("testError", "pack.Failures", ProgressState.COMPLETED, Result.ERROR, new FailureTrace("java.lang.IllegalStateException", null, null), 0), + + "testCaseStarted-" + TestRunListeners.testCaseAsString("errorExpected", "pack.Failures", ProgressState.RUNNING, Result.UNDEFINED, null, 0), + "testCaseFinished-" + TestRunListeners.testCaseAsString("errorExpected", "pack.Failures", ProgressState.COMPLETED, Result.OK, null, 0), + + "testCaseStarted-" + TestRunListeners.testCaseAsString("errorExpectedOther", "pack.Failures", ProgressState.RUNNING, Result.UNDEFINED, null, 0), + "testCaseFinished-" + TestRunListeners.testCaseAsString("errorExpectedOther", "pack.Failures", ProgressState.COMPLETED, Result.ERROR, new FailureTrace("java.lang.Exception", null, null), 0), + + "testCaseStarted-" + TestRunListeners.testCaseAsString("compareTheStuff", "pack.Failures", ProgressState.RUNNING, Result.UNDEFINED, null, 0), + "testCaseFinished-" + TestRunListeners.testCaseAsString("compareTheStuff", "pack.Failures", ProgressState.COMPLETED, Result.FAILURE, new FailureTrace("org.junit.ComparisonFailure", "\nHello World.\n\n", "\n\nHello my friend."), 0), + + "testCaseStarted-" + TestRunListeners.testCaseAsString("testCompareNull", "pack.Failures", ProgressState.RUNNING, Result.UNDEFINED, null, 0), + "testCaseFinished-" + TestRunListeners.testCaseAsString("testCompareNull", "pack.Failures", ProgressState.COMPLETED, Result.FAILURE, new FailureTrace("java.lang.AssertionError", null, null), 0), + + "sessionFinished-" + TestRunListeners.sessionAsString("Failures", ProgressState.COMPLETED, Result.ERROR, 0) + }; + String[] actual= log.getLog(); + AbstractTestRunListenerTest.assertEqualLog(expectedSequence, actual); + } finally { + JUnitCore.removeTestRunListener(testRunListener); + } } public void testAllTests() throws Exception { diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java index d565c6582..4578b72e2 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -245,7 +245,6 @@ public class PackagesViewContentProviderTests2 extends TestCase { fMyPart.fViewer.setInput(fJProject2); fMyPart.clear(); - fMyPart.setRefreshLoggingEnabled(true); // tracking down https://bugs.eclipse.org/bugs/show_bug.cgi?id=243132 IElementChangedListener listener= (IElementChangedListener) fProvider; IJavaElementDelta delta= TestDelta.createCUDelta(new ICompilationUnit[] { cu }, fPack81, IJavaElementDelta.ADDED); @@ -265,7 +264,6 @@ public class PackagesViewContentProviderTests2 extends TestCase { "PackagesViewContentProviderTests2.testAddCUFromPackageNotLogicalPackage():\n" + "Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject()); - fMyPart.setRefreshLoggingEnabled(false); } public void testAddFragmentToLogicalPackage() throws Exception { diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest.java index bf895f9fa..0ea2fc24c 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -29,6 +29,8 @@ import org.eclipse.jdt.core.ITypeParameter; import org.eclipse.jdt.ui.JavaElementLabels; import org.eclipse.jdt.ui.PreferenceConstants; +import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabelComposer; + public class JavaElementLabelsTest extends CoreTests { @@ -472,9 +474,30 @@ public class JavaElementLabelsTest extends CoreTests { assertExpectedLabel(packOrgTest, "org.test", JavaElementLabels.P_COMPRESSED); assertExpectedLabel(packOrgTestLongname, "org.te*.longname", JavaElementLabels.P_COMPRESSED); + + store.setValue(JavaElementLabelComposer.APPEARANCE_ABBREVIATE_PACKAGE_NAMES, true); + + assertExpectedLabel(packOrgTestLongname, "org.te*.longname", JavaElementLabels.P_COMPRESSED); + + store.setValue(JavaElementLabelComposer.APPEARANCE_PKG_NAME_ABBREVIATION_PATTERN_FOR_PKG_VIEW, "#com=@C\norg=@O"); + + assertExpectedLabel(packDefault, "(default package)", JavaElementLabels.P_COMPRESSED); + assertExpectedLabel(packOrg, "@O", JavaElementLabels.P_COMPRESSED); + assertExpectedLabel(packOrgTest, "@O.test", JavaElementLabels.P_COMPRESSED); + assertExpectedLabel(packOrgTestLongname, "@O.te*.longname", JavaElementLabels.P_COMPRESSED); + + store.setValue(JavaElementLabelComposer.APPEARANCE_PKG_NAME_ABBREVIATION_PATTERN_FOR_PKG_VIEW, "org=@O\n\norg.test=@OT\n"); + + assertExpectedLabel(packDefault, "(default package)", JavaElementLabels.P_COMPRESSED); + assertExpectedLabel(packOrg, "@O", JavaElementLabels.P_COMPRESSED); + assertExpectedLabel(packOrgTest, "@OT", JavaElementLabels.P_COMPRESSED); + assertExpectedLabel(packOrgTestLongname, "@OT.longname", JavaElementLabels.P_COMPRESSED); + } finally { store.setToDefault(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW); store.setValue(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false); + store.setToDefault(JavaElementLabelComposer.APPEARANCE_PKG_NAME_ABBREVIATION_PATTERN_FOR_PKG_VIEW); + store.setValue(JavaElementLabelComposer.APPEARANCE_ABBREVIATE_PACKAGE_NAMES, false); } } diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java index c374ed861..41eab9d10 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -3244,6 +3244,26 @@ public class CleanUpTest extends CleanUpTestCase { assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 }); } + public void testCodeStyle_StaticAccessThroughInstance_Bug307407() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuffer buf= new StringBuffer(); + buf.append("package test1;\n"); + buf.append("public class E1 {\n"); + buf.append(" private final String localString = new MyClass().getMyString();\n"); + buf.append(" public static class MyClass {\n"); + buf.append(" public static String getMyString() {\n"); + buf.append(" return \"a\";\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu1= pack1.createCompilationUnit("E1.java", buf.toString(), false, null); + + enable(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS); + enable(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS); + + assertRefactoringHasNoChange(new ICompilationUnit[] { cu1 }); + } + public void testRemoveNonStaticQualifier_Bug219204_1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); @@ -6896,7 +6916,52 @@ public class CleanUpTest extends CleanUpTestCase { assertRefactoringHasNoChange(new ICompilationUnit[] {cu1}); } + + public void testAddFinalBug297566() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuffer buf= new StringBuffer(); + buf.append("package test1;\n"); + buf.append("public class E1 {\n"); + buf.append(" private int x;\n"); + buf.append(" public E1() {\n"); + buf.append(" this();\n"); + buf.append(" }\n"); + buf.append(" public E1(int a) {\n"); + buf.append(" x = a;\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu1= pack1.createCompilationUnit("E1.java", buf.toString(), false, null); + + enable(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL); + enable(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS); + + assertRefactoringHasNoChange(new ICompilationUnit[] {cu1}); + } + public void testAddFinalBug297566_2() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuffer buf= new StringBuffer(); + buf.append("package test1;\n"); + buf.append("public class E1 {\n"); + buf.append(" private int x;\n"); + buf.append(" public E1() {\n"); + buf.append(" this(10);\n"); + buf.append(" }\n"); + buf.append(" public E1(int a) {\n"); + buf.append(" this();\n"); + buf.append(" }\n"); + buf.append(" public E1(int f, int y) {\n"); + buf.append(" x = a;\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu1= pack1.createCompilationUnit("E1.java", buf.toString(), false, null); + + enable(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL); + enable(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PRIVATE_FIELDS); + + assertRefactoringHasNoChange(new ICompilationUnit[] {cu1}); + } + public void testRemoveBlockReturnThrows01() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); StringBuffer buf= new StringBuffer(); diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java index 9024e6db9..1867139a8 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java @@ -133,6 +133,9 @@ public class CleanUpTestCase extends QuickFixTest { new InstanceScope().getNode(JavaUI.ID_PLUGIN).put(CleanUpConstants.SAVE_PARTICIPANT_PROFILE, fProfile.getID()); disableAll(); + fJProject1= null; + fSourceFolder= null; + fProfile= null; } protected void tearDown() throws Exception { diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java index 31d995371..abc969935 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java @@ -1800,6 +1800,25 @@ public class ConvertForLoopQuickFixTest extends QuickFixTest { assertFalse(satisfiesPrecondition(cu)); } + public void testBodyPrecondition13() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); + StringBuffer buf= new StringBuffer(); + buf.append("package test;\n"); + buf.append("import java.util.Iterator;\n"); + buf.append("import java.util.List;\n"); + buf.append("public class E {\n"); + buf.append(" void foo(List<String> data) {\n"); + buf.append(" for (Iterator<String> iterator = data.iterator(); iterator.hasNext();) {\n"); + buf.append(" String row = iterator.next();\n"); + buf.append(" row.equals(iterator.hasNext());\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + buf.append("\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); + + assertFalse(satisfiesPrecondition(cu)); + } + public void testBug110599() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java index 67ca74d8e..32d001393 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java @@ -4389,6 +4389,62 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest { assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } + public void testIndirectStaticAccess_bug307407() throws Exception { + Hashtable hashtable= JavaCore.getOptions(); + hashtable.put(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS, JavaCore.ERROR); + JavaCore.setOptions(hashtable); + + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuffer buf= new StringBuffer(); + buf.append("package test1;\n"); + buf.append("public class E {\n"); + buf.append(" private final String localString = new MyClass().getMyString();\n"); + buf.append(" public static class MyClass {\n"); + buf.append(" public static String getMyString() {\n"); + buf.append(" return \"a\";\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); + + CompilationUnit astRoot= getASTRoot(cu); + ArrayList proposals= collectCorrections(cu, astRoot); + assertNumberOfProposals(proposals, 2); + assertCorrectLabels(proposals); + + CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); + String preview1= getPreviewContent(proposal); + + buf= new StringBuffer(); + buf.append("package test1;\n"); + buf.append("public class E {\n"); + buf.append(" private final String localString = MyClass.getMyString();\n"); + buf.append(" public static class MyClass {\n"); + buf.append(" public static String getMyString() {\n"); + buf.append(" return \"a\";\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + String expected1= buf.toString(); + + proposal= (CUCorrectionProposal) proposals.get(1); + String preview2= getPreviewContent(proposal); + + buf= new StringBuffer(); + buf.append("package test1;\n"); + buf.append("public class E {\n"); + buf.append(" private final String localString = new MyClass().getMyString();\n"); + buf.append(" public static class MyClass {\n"); + buf.append(" public String getMyString() {\n"); + buf.append(" return \"a\";\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + String expected2= buf.toString(); + + assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); + } + public void testUnnecessaryInstanceof1() throws Exception { Hashtable hashtable= JavaCore.getOptions(); diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java index f2edf15e7..e20353883 100644 --- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java +++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java @@ -441,7 +441,7 @@ public class NLSSearchTest extends TestCase { buf.append("Main.indirect=Main.indirect\n"); IFile propertiesFile= write((IFolder)pack1.getCorrespondingResource(), buf.toString(), "Accessor.properties"); - NLSSearchTestHelper.assertNumberOfProblems(accessor, propertiesFile, 1); + NLSSearchTestHelper.assertNumberOfProblems(accessor, propertiesFile, 0); } public void testBug247012_3() throws Exception { |