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/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests | |
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/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests')
7 files changed, 170 insertions, 6 deletions
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 { |