forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust terminal tests to new behavior in JDK 22. (elastic#103614) (el…
…astic#106049) JDK 22 may return a console even if the terminal is redirected. These cases are detected using the new Console#isTerminal() to maintain the current behavior (closes elastic#98033). Co-authored-by: Moritz Mack <[email protected]>
- Loading branch information
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
libs/cli/src/test/java/org/elasticsearch/cli/TerminalTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.cli; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.test.ESTestCase.WithoutSecurityManager; | ||
|
||
@WithoutSecurityManager | ||
public class TerminalTests extends ESTestCase { | ||
|
||
public void testSystemTerminalIfRedirected() { | ||
// Expect system terminal if redirected for tests. | ||
// To force new behavior in JDK 22 this should run without security manager. | ||
// Otherwise, JDK 22 doesn't provide a console if redirected. | ||
assertEquals(Terminal.SystemTerminal.class, Terminal.DEFAULT.getClass()); | ||
} | ||
} |