Search in sources :

Example 66 with Properties

use of java.util.Properties in project hadoop by apache.

the class TestFileSignerSecretProvider method testGetSecrets.

@Test
public void testGetSecrets() throws Exception {
    File testDir = new File(System.getProperty("test.build.data", "target/test-dir"));
    testDir.mkdirs();
    String secretValue = "hadoop";
    File secretFile = new File(testDir, "http-secret.txt");
    Writer writer = new FileWriter(secretFile);
    writer.write(secretValue);
    writer.close();
    FileSignerSecretProvider secretProvider = new FileSignerSecretProvider();
    Properties secretProviderProps = new Properties();
    secretProviderProps.setProperty(AuthenticationFilter.SIGNATURE_SECRET_FILE, secretFile.getAbsolutePath());
    secretProvider.init(secretProviderProps, null, -1);
    Assert.assertArrayEquals(secretValue.getBytes(), secretProvider.getCurrentSecret());
    byte[][] allSecrets = secretProvider.getAllSecrets();
    Assert.assertEquals(1, allSecrets.length);
    Assert.assertArrayEquals(secretValue.getBytes(), allSecrets[0]);
}
Also used : FileWriter(java.io.FileWriter) Properties(java.util.Properties) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 67 with Properties

use of java.util.Properties in project hadoop by apache.

the class TestSigner method createStringSignerSecretProvider.

private StringSignerSecretProvider createStringSignerSecretProvider() throws Exception {
    StringSignerSecretProvider secretProvider = new StringSignerSecretProvider();
    Properties secretProviderProps = new Properties();
    secretProviderProps.setProperty(AuthenticationFilter.SIGNATURE_SECRET, "secret");
    secretProvider.init(secretProviderProps, null, -1);
    return secretProvider;
}
Also used : Properties(java.util.Properties)

Example 68 with Properties

use of java.util.Properties in project hadoop by apache.

the class TestConfigurationSubclass method testGetProps.

public void testGetProps() {
    SubConf conf = new SubConf(true);
    Properties properties = conf.getProperties();
    assertNotNull("hadoop.tmp.dir is not set", properties.getProperty("hadoop.tmp.dir"));
}
Also used : Properties(java.util.Properties)

Example 69 with Properties

use of java.util.Properties in project hadoop by apache.

the class TestConfigurationSubclass method testReload.

public void testReload() throws Throwable {
    SubConf conf = new SubConf(true);
    assertFalse(conf.isReloaded());
    Configuration.addDefaultResource(EMPTY_CONFIGURATION_XML);
    assertTrue(conf.isReloaded());
    Properties properties = conf.getProperties();
}
Also used : Properties(java.util.Properties)

Example 70 with Properties

use of java.util.Properties in project flink by apache.

the class EnvironmentInformation method getRevisionInformation.

/**
	 * Returns the code revision (commit and commit date) of Flink, as generated by the Maven builds.
	 * 
	 * @return The code revision.
	 */
public static RevisionInformation getRevisionInformation() {
    String revision = UNKNOWN;
    String commitDate = UNKNOWN;
    try (InputStream propFile = EnvironmentInformation.class.getClassLoader().getResourceAsStream(".version.properties")) {
        if (propFile != null) {
            Properties properties = new Properties();
            properties.load(propFile);
            String propRevision = properties.getProperty("git.commit.id.abbrev");
            String propCommitDate = properties.getProperty("git.commit.time");
            revision = propRevision != null ? propRevision : UNKNOWN;
            commitDate = propCommitDate != null ? propCommitDate : UNKNOWN;
        }
    } catch (Throwable t) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Cannot determine code revision: Unable to read version property file.", t);
        } else {
            LOG.info("Cannot determine code revision: Unable to read version property file.");
        }
    }
    return new RevisionInformation(revision, commitDate);
}
Also used : InputStream(java.io.InputStream) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)9354 Test (org.junit.Test)3005 IOException (java.io.IOException)1277 Connection (java.sql.Connection)1179 File (java.io.File)1013 ResultSet (java.sql.ResultSet)860 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)819 PreparedStatement (java.sql.PreparedStatement)791 InputStream (java.io.InputStream)614 FileInputStream (java.io.FileInputStream)598 HashMap (java.util.HashMap)475 Map (java.util.Map)387 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)387 ArrayList (java.util.ArrayList)371 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)321 SQLException (java.sql.SQLException)308 Before (org.junit.Before)272 AttributesFactory (org.apache.geode.cache.AttributesFactory)245 InitialContext (javax.naming.InitialContext)214 Configuration (org.apache.hadoop.conf.Configuration)187