forked from devonfw/IDEasy
-
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.
devonfw#1024: added tests of WindowsHelperImpl
- Loading branch information
1 parent
075a79c
commit 31d8719
Showing
5 changed files
with
68 additions
and
2 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
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
51 changes: 51 additions & 0 deletions
51
cli/src/test/java/com/devonfw/tools/ide/os/WindowsHelperImplTest.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,51 @@ | ||
package com.devonfw.tools.ide.os; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.devonfw.tools.ide.context.AbstractIdeContextTest; | ||
import com.devonfw.tools.ide.context.AbstractIdeTestContext; | ||
import com.devonfw.tools.ide.context.IdeSlf4jContext; | ||
|
||
/** | ||
* Tests for {@link WindowsHelperImpl}. | ||
*/ | ||
public class WindowsHelperImplTest extends AbstractIdeContextTest { | ||
|
||
/** | ||
* Tests if the USER_PATH registry entry can be parsed properly. | ||
*/ | ||
@Test | ||
public void testWindowsHelperParseRegString() { | ||
// arrange | ||
AbstractIdeTestContext context = new IdeSlf4jContext(); | ||
WindowsHelperImpl helper = new WindowsHelperImpl(context); | ||
List<String> output = new ArrayList<>(); | ||
output.add(""); | ||
output.add("HKEY_CURRENT_USER\\Environment"); | ||
output.add(" PATH REG_SZ D:\\projects\\_ide\\installation\\bin;"); | ||
output.add(""); | ||
// act | ||
String regString = helper.retrieveRegString("PATH", output); | ||
// assert | ||
assertThat(regString).isEqualTo("D:\\projects\\_ide\\installation\\bin;"); | ||
} | ||
|
||
/** | ||
* Tests if an empty list of outputs will result in null. | ||
*/ | ||
@Test | ||
public void testWindowsHelperParseEmptyRegStringReturnsNull() { | ||
// arrange | ||
AbstractIdeTestContext context = new IdeSlf4jContext(); | ||
WindowsHelperImpl helper = new WindowsHelperImpl(context); | ||
List<String> output = new ArrayList<>(); | ||
// act | ||
String regString = helper.retrieveRegString("PATH", output); | ||
// assert | ||
assertThat(regString).isNull(); | ||
} | ||
|
||
} |
4 changes: 3 additions & 1 deletion
4
cli/src/test/resources/ide-projects/basic/project/home/environment.properties
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# if this file is present, it will replace and mock System.getenv in the text context | ||
PATH="/usr/bin:${IDE_ROOT}/_ide/bin" | ||
#PATH="/usr/bin:${IDE_ROOT}/_ide/bin" | ||
PATH=${IDE_ROOT}/_ide/bin | ||
|