-
Notifications
You must be signed in to change notification settings - Fork 82
/
QuickFixTest15.java
81 lines (61 loc) · 2.75 KB
/
QuickFixTest15.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*******************************************************************************
* Copyright (c) 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.ui.tests.quickfix;
import java.util.ArrayList;
import org.junit.Rule;
import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.ui.tests.core.rules.Java15ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
public class QuickFixTest15 extends QuickFixTest {
@Rule
public ProjectTestSetup projectsetup= new Java15ProjectTestSetup(true);
private IJavaProject fJProject;
private IPackageFragmentRoot fSourceFolder;
@Test
public void testTextBlockGetNeedHigherComplianceProposal() throws Exception {
fJProject= projectsetup.getProject();
fJProject.setRawClasspath(projectsetup.getDefaultClasspath(), null);
JavaProjectHelper.set14CompilerOptions(fJProject, false);
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject, "src");
IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
def.createCompilationUnit(QuickFixTest14.MODULE_INFO_FILE, QuickFixTest.MODULE_INFO_FILE_CONTENT, false, null);
IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
String test= ""
+ "package test;\n"
+ "public class Cls1 {\n"
+ " public static void main(String[] args) {\n"
+ " String str= \"\"\"\n"
+ " Hello\n"
+ " World\n"
+ " \"\"\";\n"
+ " System.out.println(str);\n"
+ " }\n"
+ "}\n";
ICompilationUnit cu= pack.createCompilationUnit("Cls1.java", test, false, null);
CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1, null);
assertNumberOfProposals(proposals, 1);
String label= Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_change_project_compliance_description, "15");
assertProposalExists(proposals, label);
}
}