diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java index 0d260157..a65de979 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java @@ -63,7 +63,11 @@ public static RemoteRobot runIde(IdeaVersion ideaVersion, int port) { return step("Start IntelliJ Idea ('" + ideaVersion.toString() + "') listening on port " + port, () -> { UITestRunner.ideaVersion = ideaVersion; - makeSureAllTermsAndConditionsAreAccepted(); + acceptAllTermsAndConditions(); + + if (ideaVersion.isUltimate()) { + activateEvaluateForFree(); + } String fileExtension = OS_NAME.contains("windows") ? ".bat" : ""; ProcessBuilder pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + ideaVersion.toString(), "-Drobot-server.port=" + port); @@ -154,8 +158,7 @@ public enum IdeaVersion { ULTIMATE_V_2020_2("IU-2020.2"), ULTIMATE_V_2020_3("IU-2020.3"), ULTIMATE_V_2021_1("IU-2021.1"), - ULTIMATE_V_2021_2("IU-2021.2"), - ULTIMATE_V_2021_3("IU-2021.3"); + ULTIMATE_V_2021_2("IU-2021.2"); private final String ideaVersionStringRepresentation; @@ -172,12 +175,21 @@ public int toInt() { String ideaVersion = this.ideaVersionStringRepresentation.substring(3).replace(".", ""); return Integer.parseInt(ideaVersion); } + + public boolean isUltimate() { + return this.ideaVersionStringRepresentation.charAt(1) == 'U'; + } } - private static void makeSureAllTermsAndConditionsAreAccepted() { + private static void acceptAllTermsAndConditions() { if (OS_NAME.contains("linux")) { step("Copy the 'prefs.xml' file to the appropriate location", () -> { - String prefsXmlSourceLocation = "prefs.xml"; + String prefsXmlSourceLocation; + if (!ideaVersion.isUltimate()) { + prefsXmlSourceLocation = "prefs.xml"; + } else { + prefsXmlSourceLocation = "prefs_xml/ultimate_all/prefs.xml"; + } String prefsXmlDir = USER_HOME + "/.java/.userPrefs/jetbrains/_!(!!cg\"p!(}!}@\"j!(k!|w\"w!'8!b!\"p!':!e@=="; createDirectoryHierarchy(prefsXmlDir); copyFileFromJarResourceDir(prefsXmlSourceLocation, prefsXmlDir + "/prefs.xml"); @@ -190,7 +202,12 @@ private static void makeSureAllTermsAndConditionsAreAccepted() { }); } else if (OS_NAME.contains("os x")) { step("Copy the 'com.apple.java.util.prefs.plist' file to the appropriate location", () -> { - String plistSourceLocation = "com.apple.java.util.prefs.plist"; + String plistSourceLocation; + if (!ideaVersion.isUltimate()) { + plistSourceLocation = "com.apple.java.util.prefs.plist"; + } else { + plistSourceLocation = "plist/ultimate_all/com.apple.java.util.prefs.plist"; + } String plistDir = USER_HOME + "/Library/Preferences"; copyFileFromJarResourceDir(plistSourceLocation, plistDir + "/com.apple.java.util.prefs.plist"); }); @@ -224,6 +241,7 @@ private static void makeSureAllTermsAndConditionsAreAccepted() { ProcessBuilder pb1 = new ProcessBuilder(powershellLocation, "New-Item", powershellPathParameter, registryPath, "-Force"); ProcessBuilder pb2 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "accepted_version", "-Value", "'2.1'"); ProcessBuilder pb3 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "euacommunity_accepted_version", "-Value", "'1.0'"); + ProcessBuilder pb4 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "eua_accepted_version", "-Value", "'1.2'"); try { Process p1 = pb1.start(); @@ -232,6 +250,8 @@ private static void makeSureAllTermsAndConditionsAreAccepted() { p2.waitFor(); Process p3 = pb3.start(); p3.waitFor(); + Process p4 = pb4.start(); + p4.waitFor(); } catch (IOException | InterruptedException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); Thread.currentThread().interrupt(); @@ -240,6 +260,18 @@ private static void makeSureAllTermsAndConditionsAreAccepted() { } } + private static void activateEvaluateForFree() { + String targetEvaluationKeysDir = System.getProperty("user.dir") + "/build/idea-sandbox/config-uiTest/eval/"; + createDirectoryHierarchy(targetEvaluationKeysDir); + + for (String ideaVersionSubstring : new String[]{"202", "203", "211", "212"}) { + String keyFilename = "idea" + ideaVersionSubstring + ".evaluation.key"; + String sourcePathToKey = "evaluate_for_free_keys/" + keyFilename; + String targetPathToKey = targetEvaluationKeysDir + keyFilename; + copyFileFromJarResourceDir(sourcePathToKey, targetPathToKey); + } + } + private static void waitUntilIntelliJStarts(int port) { waitFor(Duration.ofSeconds(600), Duration.ofSeconds(3), "The IntelliJ Idea did not start in 10 minutes.", () -> isIntelliJUIVisible(port)); } diff --git a/src/main/resources/evaluate_for_free_keys/idea202.evaluation.key b/src/main/resources/evaluate_for_free_keys/idea202.evaluation.key new file mode 100644 index 00000000..723124c7 --- /dev/null +++ b/src/main/resources/evaluate_for_free_keys/idea202.evaluation.key @@ -0,0 +1 @@ +ÿÿþŠµË \ No newline at end of file diff --git a/src/main/resources/evaluate_for_free_keys/idea203.evaluation.key b/src/main/resources/evaluate_for_free_keys/idea203.evaluation.key new file mode 100644 index 00000000..ac30c8f1 --- /dev/null +++ b/src/main/resources/evaluate_for_free_keys/idea203.evaluation.key @@ -0,0 +1 @@ +ÿÿþŠ³Dœ \ No newline at end of file diff --git a/src/main/resources/evaluate_for_free_keys/idea211.evaluation.key b/src/main/resources/evaluate_for_free_keys/idea211.evaluation.key new file mode 100644 index 00000000..4b3588f0 --- /dev/null +++ b/src/main/resources/evaluate_for_free_keys/idea211.evaluation.key @@ -0,0 +1 @@ +ÿÿþŠ¤–^ \ No newline at end of file diff --git a/src/main/resources/evaluate_for_free_keys/idea212.evaluation.key b/src/main/resources/evaluate_for_free_keys/idea212.evaluation.key new file mode 100644 index 00000000..965a98de --- /dev/null +++ b/src/main/resources/evaluate_for_free_keys/idea212.evaluation.key @@ -0,0 +1 @@ +ÿÿþŠ¢& \ No newline at end of file diff --git a/src/main/resources/plist/ultimate_all/com.apple.java.util.prefs.plist b/src/main/resources/plist/ultimate_all/com.apple.java.util.prefs.plist new file mode 100644 index 00000000..b16e95c8 Binary files /dev/null and b/src/main/resources/plist/ultimate_all/com.apple.java.util.prefs.plist differ diff --git a/src/main/resources/prefs_xml/ultimate_all/prefs.xml b/src/main/resources/prefs_xml/ultimate_all/prefs.xml new file mode 100644 index 00000000..62f22f49 --- /dev/null +++ b/src/main/resources/prefs_xml/ultimate_all/prefs.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java index cd80628a..225d4b03 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java @@ -31,7 +31,7 @@ public class LibraryTestBase { protected static RemoteRobot remoteRobot; private static boolean intelliJHasStarted = false; - private static UITestRunner.IdeaVersion ideaVersion = UITestRunner.IdeaVersion.COMMUNITY_V_2021_1; + private static UITestRunner.IdeaVersion ideaVersion = UITestRunner.IdeaVersion.ULTIMATE_V_2021_1; protected static int ideaVersionInt = ideaVersion.toInt(); protected static final Logger LOGGER = Logger.getLogger(LibraryTestBase.class.getName());