类org.junit.contrib.java.lang.system.EnvironmentVariables源码实例Demo

下面列出了怎么用org.junit.contrib.java.lang.system.EnvironmentVariables的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: geowave   文件: BigtableStoreTestEnvironment.java
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;
  }
}
 
源代码2 项目: tessera   文件: EncryptedStringResolverTest.java
@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();
}
 
源代码3 项目: fabric-chaincode-java   文件: ChaincodeBaseTest.java
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();
}
 
源代码4 项目: tessera   文件: ConfigSecretReaderTest.java
@Test
public void testNotAbleToReadSecret() {

    envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH, "not-existed");
    assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty();
}
 
源代码5 项目: tessera   文件: ConfigSecretReaderTest.java
@Test
public void envNotSet() {
    envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH);
    assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty();
}
 
SolaceJavaAutoConfigurationTestBase(Class<? extends SpringJCSMPFactoryCloudFactory> configClass) {
    this.configClass = configClass;
    this.environmentVariables = new EnvironmentVariables();
}
 
源代码7 项目: tessera   文件: ConfigSecretReaderTest.java
@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());
}
 
源代码8 项目: tessera   文件: ConfigSecretReaderTest.java
@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();


}
 
源代码9 项目: tessera   文件: EncryptedStringResolverTest.java
@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);
}
 
源代码10 项目: tessera   文件: EncryptedStringResolverTest.java
@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);
}
 
 类所在包
 类方法
 同包方法