Skip to content

Commit

Permalink
Attempt to fix Travis build failures by switching test truststore bas…
Browse files Browse the repository at this point in the history
…ed on JVM version
  • Loading branch information
tomakehurst committed Mar 16, 2019
1 parent bad5c7f commit 739999f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ jdk:
- openjdk8

install:
- sudo apt-get upgrade -y openjdk-7-jdk
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install 8.12.0
- JAVA_HOME=$(jdk_switcher home openjdk8) ./gradlew classes testClasses -x generateApiDocs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@

import java.security.KeyStore;

import static com.github.tomakehurst.wiremock.testsupport.TestFiles.TRUST_STORE_PASSWORD;
import static com.github.tomakehurst.wiremock.testsupport.TestFiles.filePath;
import static com.github.tomakehurst.wiremock.testsupport.TestFiles.*;
import static org.junit.Assert.assertNotNull;

public class KeyStoreSettingsTest {

@Test
public void loadsTrustStoreFromClasspath() {
KeyStoreSettings trustStoreSettings = new KeyStoreSettings("test-truststore.pkcs12", TRUST_STORE_PASSWORD);
KeyStoreSettings trustStoreSettings = new KeyStoreSettings(TRUST_STORE_NAME, TRUST_STORE_PASSWORD);

KeyStore keyStore = trustStoreSettings.loadStore();
assertNotNull(keyStore);
}

@Test
public void loadsTrustStoreFromFilesystem() {
KeyStoreSettings trustStoreSettings = new KeyStoreSettings(filePath("test-truststore.pkcs12"), TRUST_STORE_PASSWORD);
KeyStoreSettings trustStoreSettings = new KeyStoreSettings(TRUST_STORE_PATH, TRUST_STORE_PASSWORD);

KeyStore keyStore = trustStoreSettings.loadStore();
assertNotNull(keyStore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@
public class TestFiles {

public static final String TRUST_STORE_PASSWORD = "mytruststorepassword";
public static final String TRUST_STORE_PATH = filePath("test-truststore.pkcs12");
public static final String TRUST_STORE_NAME = getTrustStoreRelativeName();
public static final String TRUST_STORE_PATH = filePath(TRUST_STORE_NAME);
public static final String KEY_STORE_PATH = filePath("test-keystore");

private static String getTrustStoreRelativeName() {
return System.getProperty("java.specification.version").equals("1.7") ?
"test-truststore.jks" :
"test-truststore.pkcs12";
}

public static String defaultTestFilesRoot() {
return filePath("test-file-root");
}
Expand Down
Binary file added src/test/resources/test-truststore.jks
Binary file not shown.

0 comments on commit 739999f

Please sign in to comment.