Skip to content

Commit 1c146b2

Browse files
authored
Add support for IntelliJ IDEA Ultimate (#111)
Fixes #77 Signed-off-by: Zbynek Cervinka <[email protected]>
1 parent 9743c40 commit 1c146b2

File tree

8 files changed

+49
-7
lines changed

8 files changed

+49
-7
lines changed

src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public static RemoteRobot runIde(IdeaVersion ideaVersion, int port) {
6363

6464
return step("Start IntelliJ Idea ('" + ideaVersion.toString() + "') listening on port " + port, () -> {
6565
UITestRunner.ideaVersion = ideaVersion;
66-
makeSureAllTermsAndConditionsAreAccepted();
66+
acceptAllTermsAndConditions();
67+
68+
if (ideaVersion.isUltimate()) {
69+
activateEvaluateForFree();
70+
}
6771

6872
String fileExtension = OS_NAME.contains("windows") ? ".bat" : "";
6973
ProcessBuilder pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + ideaVersion.toString(), "-Drobot-server.port=" + port);
@@ -154,8 +158,7 @@ public enum IdeaVersion {
154158
ULTIMATE_V_2020_2("IU-2020.2"),
155159
ULTIMATE_V_2020_3("IU-2020.3"),
156160
ULTIMATE_V_2021_1("IU-2021.1"),
157-
ULTIMATE_V_2021_2("IU-2021.2"),
158-
ULTIMATE_V_2021_3("IU-2021.3");
161+
ULTIMATE_V_2021_2("IU-2021.2");
159162

160163
private final String ideaVersionStringRepresentation;
161164

@@ -172,12 +175,21 @@ public int toInt() {
172175
String ideaVersion = this.ideaVersionStringRepresentation.substring(3).replace(".", "");
173176
return Integer.parseInt(ideaVersion);
174177
}
178+
179+
public boolean isUltimate() {
180+
return this.ideaVersionStringRepresentation.charAt(1) == 'U';
181+
}
175182
}
176183

177-
private static void makeSureAllTermsAndConditionsAreAccepted() {
184+
private static void acceptAllTermsAndConditions() {
178185
if (OS_NAME.contains("linux")) {
179186
step("Copy the 'prefs.xml' file to the appropriate location", () -> {
180-
String prefsXmlSourceLocation = "prefs.xml";
187+
String prefsXmlSourceLocation;
188+
if (!ideaVersion.isUltimate()) {
189+
prefsXmlSourceLocation = "prefs.xml";
190+
} else {
191+
prefsXmlSourceLocation = "prefs_xml/ultimate_all/prefs.xml";
192+
}
181193
String prefsXmlDir = USER_HOME + "/.java/.userPrefs/jetbrains/_!(!!cg\"p!(}!}@\"j!(k!|w\"w!'8!b!\"p!':!e@==";
182194
createDirectoryHierarchy(prefsXmlDir);
183195
copyFileFromJarResourceDir(prefsXmlSourceLocation, prefsXmlDir + "/prefs.xml");
@@ -190,7 +202,12 @@ private static void makeSureAllTermsAndConditionsAreAccepted() {
190202
});
191203
} else if (OS_NAME.contains("os x")) {
192204
step("Copy the 'com.apple.java.util.prefs.plist' file to the appropriate location", () -> {
193-
String plistSourceLocation = "com.apple.java.util.prefs.plist";
205+
String plistSourceLocation;
206+
if (!ideaVersion.isUltimate()) {
207+
plistSourceLocation = "com.apple.java.util.prefs.plist";
208+
} else {
209+
plistSourceLocation = "plist/ultimate_all/com.apple.java.util.prefs.plist";
210+
}
194211
String plistDir = USER_HOME + "/Library/Preferences";
195212
copyFileFromJarResourceDir(plistSourceLocation, plistDir + "/com.apple.java.util.prefs.plist");
196213
});
@@ -224,6 +241,7 @@ private static void makeSureAllTermsAndConditionsAreAccepted() {
224241
ProcessBuilder pb1 = new ProcessBuilder(powershellLocation, "New-Item", powershellPathParameter, registryPath, "-Force");
225242
ProcessBuilder pb2 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "accepted_version", "-Value", "'2.1'");
226243
ProcessBuilder pb3 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "euacommunity_accepted_version", "-Value", "'1.0'");
244+
ProcessBuilder pb4 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "eua_accepted_version", "-Value", "'1.2'");
227245

228246
try {
229247
Process p1 = pb1.start();
@@ -232,6 +250,8 @@ private static void makeSureAllTermsAndConditionsAreAccepted() {
232250
p2.waitFor();
233251
Process p3 = pb3.start();
234252
p3.waitFor();
253+
Process p4 = pb4.start();
254+
p4.waitFor();
235255
} catch (IOException | InterruptedException e) {
236256
LOGGER.log(Level.SEVERE, e.getMessage(), e);
237257
Thread.currentThread().interrupt();
@@ -240,6 +260,18 @@ private static void makeSureAllTermsAndConditionsAreAccepted() {
240260
}
241261
}
242262

263+
private static void activateEvaluateForFree() {
264+
String targetEvaluationKeysDir = System.getProperty("user.dir") + "/build/idea-sandbox/config-uiTest/eval/";
265+
createDirectoryHierarchy(targetEvaluationKeysDir);
266+
267+
for (String ideaVersionSubstring : new String[]{"202", "203", "211", "212"}) {
268+
String keyFilename = "idea" + ideaVersionSubstring + ".evaluation.key";
269+
String sourcePathToKey = "evaluate_for_free_keys/" + keyFilename;
270+
String targetPathToKey = targetEvaluationKeysDir + keyFilename;
271+
copyFileFromJarResourceDir(sourcePathToKey, targetPathToKey);
272+
}
273+
}
274+
243275
private static void waitUntilIntelliJStarts(int port) {
244276
waitFor(Duration.ofSeconds(600), Duration.ofSeconds(3), "The IntelliJ Idea did not start in 10 minutes.", () -> isIntelliJUIVisible(port));
245277
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
������
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
�����D�
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
������^
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
�����&
148 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
3+
<map MAP_XML_VERSION="1.0">
4+
<entry key="eua_accepted_version" value="1.2"/>
5+
<entry key="euacommunity_accepted_version" value="1.0"/>
6+
</map>

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
public class LibraryTestBase {
3232
protected static RemoteRobot remoteRobot;
3333
private static boolean intelliJHasStarted = false;
34-
private static UITestRunner.IdeaVersion ideaVersion = UITestRunner.IdeaVersion.COMMUNITY_V_2021_1;
34+
private static UITestRunner.IdeaVersion ideaVersion = UITestRunner.IdeaVersion.ULTIMATE_V_2021_1;
3535
protected static int ideaVersionInt = ideaVersion.toInt();
3636
protected static final Logger LOGGER = Logger.getLogger(LibraryTestBase.class.getName());
3737

0 commit comments

Comments
 (0)