-
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.
Introducing dss-test-instrumented and dss-test-unit
- Loading branch information
1 parent
53c0ec0
commit 61848a1
Showing
14 changed files
with
199 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.signerry.dss.test.instrumented" | ||
android:versionName="1.0" > | ||
</manifest> |
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,10 @@ | ||
dependencies { | ||
testFixturesImplementation 'androidx.test:monitor:1.5.0' | ||
testFixturesImplementation testFixtures(project(':dss-test')) | ||
testFixturesImplementation 'commons-io:commons-io:1.3.1' | ||
} | ||
|
||
description = 'DSS Test Intrumented' | ||
|
||
|
||
|
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
1 change: 1 addition & 0 deletions
1
...nstrumented/src/testFixtures/resources/META-INF/services/com.signerry.dss.test.ITestUtils
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 @@ | ||
com.signerry.dss.test.InstrumentedTestUtils |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.signerry.dss.test.unit" | ||
android:versionName="1.0" > | ||
</manifest> |
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,10 @@ | ||
dependencies { | ||
testFixturesImplementation testFixtures(project(':dss-utils')) | ||
testFixturesImplementation testFixtures(project(':dss-test')) | ||
testFixturesImplementation 'commons-io:commons-io:1.3.1' | ||
} | ||
|
||
description = 'DSS Test Unit' | ||
|
||
|
||
|
58 changes: 58 additions & 0 deletions
58
dss-test-unit/src/testFixtures/java/com/signerry/dss/test/UnitTestUtils.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,58 @@ | ||
package com.signerry.dss.test; | ||
|
||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Collection; | ||
import java.util.UUID; | ||
|
||
import eu.europa.esig.dss.utils.Utils; | ||
|
||
public class UnitTestUtils implements ITestUtils { | ||
@Override | ||
public Collection<File> listFiles(String folder, String[] extensions, boolean recursive) { | ||
return Utils.listFiles(new File(folder), extensions, true); | ||
} | ||
|
||
@Override | ||
public File getTmpFile(String filename) { | ||
return new File(getTmpDirectory(), filename); | ||
} | ||
|
||
@Override | ||
public File getTmpDedicatedDirectory() { | ||
File dirToCreate = new File(getTmpDirectory(), UUID.randomUUID().toString()); | ||
try { | ||
Path dir = Files.createDirectories(dirToCreate.toPath()); | ||
return dir.toFile(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public File getTmpDirectory() { | ||
String projectDir = System.getProperty("projectDir"); | ||
|
||
try { | ||
Path dir = Files.createDirectories(Paths.get(projectDir, "build", "tmp")); | ||
return dir.toFile(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public InputStream getResourceAsStream(String resourcePath) { | ||
return UnitTestUtils.class.getResourceAsStream("/" + resourcePath); | ||
} | ||
|
||
@Override | ||
public File getResourceAsFile(String resourcePath) { | ||
return new File(UnitTestUtils.class.getResource("/" + resourcePath).getFile()); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
dss-test-unit/src/testFixtures/resources/META-INF/services/com.signerry.dss.test.ITestUtils
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 @@ | ||
com.signerry.dss.test.UnitTestUtils |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pki.factory.host = http://dss.nowina.lu/pki-factory/ | ||
pki.alternative.factory.host=http://test-pki.signerry.com:8080 | ||
pki.factory.keystore.password = ks-password |
19 changes: 19 additions & 0 deletions
19
dss-test/src/testFixtures/java/com/signerry/dss/test/ITestUtils.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,19 @@ | ||
package com.signerry.dss.test; | ||
|
||
import java.io.File; | ||
import java.io.InputStream; | ||
import java.util.Collection; | ||
|
||
public interface ITestUtils { | ||
Collection<File> listFiles(String folder, String[] extensions, boolean recursive); | ||
|
||
File getTmpFile(String filename); | ||
|
||
File getTmpDedicatedDirectory(); | ||
|
||
File getTmpDirectory(); | ||
|
||
InputStream getResourceAsStream(String resourcePath); | ||
|
||
File getResourceAsFile(String resourcePath); | ||
} |
47 changes: 47 additions & 0 deletions
47
dss-test/src/testFixtures/java/com/signerry/dss/test/TestUtils.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,47 @@ | ||
package com.signerry.dss.test; | ||
|
||
import java.io.File; | ||
import java.io.InputStream; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
import java.util.ServiceLoader; | ||
|
||
public class TestUtils { | ||
|
||
/** The implementation to be used */ | ||
private static ITestUtils impl; | ||
|
||
static { | ||
ServiceLoader<ITestUtils> loader = ServiceLoader.load(ITestUtils.class); | ||
Iterator<ITestUtils> iterator = loader.iterator(); | ||
|
||
if (!iterator.hasNext()) { | ||
throw new ExceptionInInitializerError( | ||
"No implementation found for ITestUtils in classpath, please choose between dss-test-instrumented or dss-test-unit"); | ||
} | ||
impl = iterator.next(); | ||
} | ||
|
||
private TestUtils() { | ||
} | ||
|
||
public static Collection<File> listFiles(String folder, String[] extensions, boolean recursive) { | ||
return impl.listFiles(folder, extensions, recursive); | ||
} | ||
|
||
public static File getTmpDirectory() { | ||
return impl.getTmpDirectory(); | ||
} | ||
|
||
public static InputStream getResourceAsStream(String resourcePath) { | ||
return impl.getResourceAsStream(resourcePath); | ||
} | ||
|
||
public static File getResourceAsFile(String resourcePath) { | ||
return impl.getResourceAsFile(resourcePath); | ||
} | ||
|
||
public static File getTmpFile(String filename) { | ||
return impl.getTmpFile(filename); | ||
} | ||
} |
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