-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing codacy issues, mostly related to logging
- Loading branch information
1 parent
7b2e914
commit eab811e
Showing
3 changed files
with
55 additions
and
22 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
26 changes: 26 additions & 0 deletions
26
src/test/groovy/edu/ie3/test/helper/TestContainerHelper.groovy
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,26 @@ | ||
package edu.ie3.test.helper | ||
|
||
import org.testcontainers.utility.MountableFile | ||
|
||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
trait TestContainerHelper { | ||
|
||
/** | ||
* Retrieve resource with the class' resource loader. | ||
* In contrast to {@link org.testcontainers.utility.MountableFile#forClasspathResource(java.lang.String, java.lang.Integer)}, | ||
* this also works with paths relative to the current class (i.e. without leading '/'). | ||
* @param resource the resource directory or file path | ||
* @return a MountableFile to use with test containers | ||
*/ | ||
MountableFile getMountableFile(String resource) { | ||
URL url = getClass().getResource(resource) | ||
if (url == null) { | ||
throw new ResourceException("Resource '" + resource + "' was not found from " + getClass().toString()) | ||
} | ||
Path path = Paths.get(url.toURI()) | ||
|
||
return MountableFile.forHostPath(path) | ||
} | ||
} |