org.junit.contrib.java.lang.system.EnvironmentVariables Java Examples

The following examples show how to use org.junit.contrib.java.lang.system.EnvironmentVariables. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BigtableStoreTestEnvironment.java    From geowave with Apache License 2.0 6 votes vote down vote up
private void initEnv() {
  if (!environmentInitialized) {
    final String internalEmulatorProp = System.getProperty(BigtableEmulator.INTERNAL_PROPERTY);
    if (TestUtils.isSet(internalEmulatorProp)) {
      internalEmulator = Boolean.parseBoolean(internalEmulatorProp);
      LOGGER.warn("Bigtable internal emulator enabled: " + internalEmulator);
    } else {
      LOGGER.warn("Bigtable internal emulator disabled by default");
    }

    final String hostPortProp = System.getProperty(BigtableEmulator.HOST_PORT_PROPERTY);
    if (TestUtils.isSet(hostPortProp)) {
      emulatorHostPort = hostPortProp;
      LOGGER.warn("Bigtable emulator will run at: " + emulatorHostPort);
    } else {
      LOGGER.warn("Bigtable emulator will run at default location: " + emulatorHostPort);
    }

    // Set the host:port property in the junit env, even if external
    // gcloud emulator
    final EnvironmentVariables environmentVariables = new EnvironmentVariables();
    environmentVariables.set("BIGTABLE_EMULATOR_HOST", emulatorHostPort);
    environmentInitialized = true;
  }
}
 
Example #2
Source File: EncryptedStringResolverTest.java    From tessera with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {

    final String filePath = getClass().getResource("/key.secret").getPath();
    envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH, filePath);
    resolver = new EncryptedStringResolver();
}
 
Example #3
Source File: ChaincodeBaseTest.java    From fabric-chaincode-java with Apache License 2.0 5 votes vote down vote up
public static void setLogLevelForChaincode(final EnvironmentVariables environmentVariables, final ChaincodeBase cb, final String shimLevel,
        final String chaincodeLevel) {
    environmentVariables.set(ChaincodeBase.CORE_CHAINCODE_LOGGING_SHIM, shimLevel);
    environmentVariables.set(ChaincodeBase.CORE_CHAINCODE_LOGGING_LEVEL, chaincodeLevel);
    cb.processEnvironmentOptions();
    cb.initializeLogging();
}
 
Example #4
Source File: ConfigSecretReaderTest.java    From tessera with Apache License 2.0 4 votes vote down vote up
@Test
public void testNotAbleToReadSecret() {

    envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH, "not-existed");
    assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty();
}
 
Example #5
Source File: ConfigSecretReaderTest.java    From tessera with Apache License 2.0 4 votes vote down vote up
@Test
public void envNotSet() {
    envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH);
    assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty();
}
 
Example #6
Source File: SolaceJavaAutoConfigurationTestBase.java    From solace-java-spring-boot with Apache License 2.0 4 votes vote down vote up
SolaceJavaAutoConfigurationTestBase(Class<? extends SpringJCSMPFactoryCloudFactory> configClass) {
    this.configClass = configClass;
    this.environmentVariables = new EnvironmentVariables();
}
 
Example #7
Source File: ConfigSecretReaderTest.java    From tessera with Apache License 2.0 3 votes vote down vote up
@Test
public void testReadSecret() {

    envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH, filePath);

    Optional<char[]> secret = ConfigSecretReader.readSecretFromFile();

    assertThat(secret).isPresent();
    assertThat(secret.get()).isEqualTo("quorum".toCharArray());
}
 
Example #8
Source File: ConfigSecretReaderTest.java    From tessera with Apache License 2.0 3 votes vote down vote up
@Test
public void testReadException() throws IOException {
    envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH);

    final File tempFile = tempDir.newFile("key.secret");
    tempFile.setReadable(false);


    envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH,
        tempFile.getAbsolutePath());

    assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty();


}
 
Example #9
Source File: EncryptedStringResolverTest.java    From tessera with Apache License 2.0 3 votes vote down vote up
@Test
public void testUnMarshallWithUserInputSecret() {

    envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH);

    resolver = new EncryptedStringResolver();

    ByteArrayInputStream in = new ByteArrayInputStream(("quorum" + System.lineSeparator() + "quorum").getBytes());
    System.setIn(in);

    assertThat(resolver.resolve("ENC(KLa6pRQpxI8Ez3Bo6D3cI6y13YYdntu7)")).isEqualTo("password");

    System.setIn(System.in);
}
 
Example #10
Source File: EncryptedStringResolverTest.java    From tessera with Apache License 2.0 3 votes vote down vote up
@Test
public void testUnMarshallWrongPassword() {

    envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH);

    resolver = new EncryptedStringResolver();

    ByteArrayInputStream in = new ByteArrayInputStream(("bogus" + System.lineSeparator() + "bogus").getBytes());
    System.setIn(in);

    assertThatExceptionOfType(EncryptionOperationNotPossibleException.class)
            .isThrownBy(() -> resolver.resolve("ENC(KLa6pRQpxI8Ez3Bo6D3cI6y13YYdntu7)"));

    System.setIn(System.in);
}