Search in sources :

Example 31 with Properties

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

the class PubsubTestSupport method loadProperties.

private static Properties loadProperties() {
    Properties testProperties = new Properties();
    InputStream fileIn = testProperties.getClass().getResourceAsStream("/simple.properties");
    try {
        testProperties.load(fileIn);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return testProperties;
}
Also used : InputStream(java.io.InputStream) Properties(java.util.Properties) GoogleJsonResponseException(com.google.api.client.googleapis.json.GoogleJsonResponseException)

Example 32 with Properties

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

the class AbstractGoogleDriveTestSupport method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    final InputStream in = getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES);
    if (in == null) {
        throw new IOException(TEST_OPTIONS_PROPERTIES + " could not be found");
    }
    final StringBuilder builder = new StringBuilder();
    final BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
    String line;
    while ((line = reader.readLine()) != null) {
        builder.append(line).append(LINE_SEPARATOR);
    }
    propertyText = builder.toString();
    final Properties properties = new Properties();
    try {
        properties.load(new StringReader(propertyText));
    } catch (IOException e) {
        throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()), e);
    }
    //
    //        // cache test properties
    //        refreshToken = properties.getProperty(REFRESH_TOKEN_PROPERTY);
    //        testFolderId = properties.getProperty("testFolderId");
    //        testFileId = properties.getProperty("testFileId");
    //        testUserId = properties.getProperty("testUserId");
    //
    Map<String, Object> options = new HashMap<String, Object>();
    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
        options.put(entry.getKey().toString(), entry.getValue());
    }
    final GoogleDriveConfiguration configuration = new GoogleDriveConfiguration();
    IntrospectionSupport.setProperties(configuration, options);
    // add GoogleDriveComponent  to Camel context
    final CamelContext context = super.createCamelContext();
    final GoogleDriveComponent component = new GoogleDriveComponent(context);
    component.setConfiguration(configuration);
    context.addComponent("google-drive", component);
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) InputStream(java.io.InputStream) IOException(java.io.IOException) Properties(java.util.Properties) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) HashMap(java.util.HashMap) Map(java.util.Map)

Example 33 with Properties

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

the class GmailUsersMessagesIntegrationTest method createTestEmail.

private Message createTestEmail() throws MessagingException, IOException {
    com.google.api.services.gmail.model.Profile profile = requestBody("google-mail://users/getProfile?inBody=userId", CURRENT_USERID);
    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage mm = new MimeMessage(session);
    mm.addRecipients(javax.mail.Message.RecipientType.TO, profile.getEmailAddress());
    mm.setSubject("Hello from camel-google-mail");
    mm.setContent("Camel rocks!", "text/plain");
    Message createMessageWithEmail = createMessageWithEmail(mm);
    return createMessageWithEmail;
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) Message(com.google.api.services.gmail.model.Message) MimeMessage(javax.mail.internet.MimeMessage) Properties(java.util.Properties) Session(javax.mail.Session)

Example 34 with Properties

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

the class GuiceInitialContextFactory method createJndiNamesProperties.

/**
     * Creates a properties object containing all of the values whose keys start
     * with {@link #NAME_PREFIX} with the prefix being removed on the key
     * 
     * @return a properties object
     */
@SuppressWarnings({ "rawtypes", "unchecked" })
private Properties createJndiNamesProperties(Hashtable environment) {
    Set<Map.Entry<?, ?>> set = environment.entrySet();
    Properties answer = new Properties();
    for (Entry<?, ?> entry : set) {
        String key = entry.getKey().toString();
        if (key.startsWith(NAME_PREFIX)) {
            String name = key.substring(NAME_PREFIX.length());
            Object value = entry.getValue();
            answer.put(name, value);
        }
    }
    return answer;
}
Also used : Entry(java.util.Map.Entry) Properties(java.util.Properties)

Example 35 with Properties

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

the class KafkaConfiguration method createConsumerProperties.

public Properties createConsumerProperties() {
    Properties props = new Properties();
    addPropertyIfNotNull(props, ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, getKeyDeserializer());
    addPropertyIfNotNull(props, ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, getValueDeserializer());
    addPropertyIfNotNull(props, ConsumerConfig.FETCH_MIN_BYTES_CONFIG, getFetchMinBytes());
    addPropertyIfNotNull(props, ConsumerConfig.FETCH_MAX_BYTES_CONFIG, getFetchMaxBytes());
    addPropertyIfNotNull(props, ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, getHeartbeatIntervalMs());
    addPropertyIfNotNull(props, ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG, getMaxPartitionFetchBytes());
    addPropertyIfNotNull(props, ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, getSessionTimeoutMs());
    addPropertyIfNotNull(props, ConsumerConfig.MAX_POLL_RECORDS_CONFIG, getMaxPollRecords());
    addPropertyIfNotNull(props, ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, getInterceptorClasses());
    // SSL
    applySslConfiguration(props, getSslContextParameters());
    addPropertyIfNotNull(props, SslConfigs.SSL_KEY_PASSWORD_CONFIG, getSslKeyPassword());
    addPropertyIfNotNull(props, SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, getSslKeystoreLocation());
    addPropertyIfNotNull(props, SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, getSslKeystorePassword());
    addPropertyIfNotNull(props, SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, getSslTruststoreLocation());
    addPropertyIfNotNull(props, SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, getSslTruststorePassword());
    addPropertyIfNotNull(props, ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, getAutoOffsetReset());
    addPropertyIfNotNull(props, ConsumerConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG, getConnectionMaxIdleMs());
    addPropertyIfNotNull(props, ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, isAutoCommitEnable());
    addPropertyIfNotNull(props, ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG, getPartitionAssignor());
    addPropertyIfNotNull(props, ConsumerConfig.RECEIVE_BUFFER_CONFIG, getReceiveBufferBytes());
    addPropertyIfNotNull(props, ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, getConsumerRequestTimeoutMs());
    // Security protocol
    addPropertyIfNotNull(props, CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, getSecurityProtocol());
    addPropertyIfNotNull(props, ProducerConfig.SEND_BUFFER_CONFIG, getSendBufferBytes());
    //SSL
    addPropertyIfNotNull(props, SslConfigs.SSL_ENABLED_PROTOCOLS_CONFIG, getSslEnabledProtocols());
    addPropertyIfNotNull(props, SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, getSslKeystoreType());
    addPropertyIfNotNull(props, SslConfigs.SSL_PROTOCOL_CONFIG, getSslProtocol());
    addPropertyIfNotNull(props, SslConfigs.SSL_PROVIDER_CONFIG, getSslProvider());
    addPropertyIfNotNull(props, SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, getSslTruststoreType());
    addPropertyIfNotNull(props, ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, getAutoCommitIntervalMs());
    addPropertyIfNotNull(props, ConsumerConfig.CHECK_CRCS_CONFIG, getCheckCrcs());
    addPropertyIfNotNull(props, ConsumerConfig.CLIENT_ID_CONFIG, getClientId());
    addPropertyIfNotNull(props, ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG, getFetchWaitMaxMs());
    addPropertyIfNotNull(props, ConsumerConfig.METADATA_MAX_AGE_CONFIG, getMetadataMaxAgeMs());
    addPropertyIfNotNull(props, ConsumerConfig.METRIC_REPORTER_CLASSES_CONFIG, getMetricReporters());
    addPropertyIfNotNull(props, ConsumerConfig.METRICS_NUM_SAMPLES_CONFIG, getNoOfMetricsSample());
    addPropertyIfNotNull(props, ConsumerConfig.METRICS_SAMPLE_WINDOW_MS_CONFIG, getMetricsSampleWindowMs());
    addPropertyIfNotNull(props, ConsumerConfig.RECONNECT_BACKOFF_MS_CONFIG, getReconnectBackoffMs());
    addPropertyIfNotNull(props, ConsumerConfig.RETRY_BACKOFF_MS_CONFIG, getRetryBackoffMs());
    //SASL
    addPropertyIfNotNull(props, SaslConfigs.SASL_KERBEROS_SERVICE_NAME, getSaslKerberosServiceName());
    addPropertyIfNotNull(props, SaslConfigs.SASL_KERBEROS_KINIT_CMD, getKerberosInitCmd());
    addPropertyIfNotNull(props, SaslConfigs.SASL_KERBEROS_MIN_TIME_BEFORE_RELOGIN, getKerberosBeforeReloginMinTime());
    addPropertyIfNotNull(props, SaslConfigs.SASL_KERBEROS_TICKET_RENEW_JITTER, getKerberosRenewJitter());
    addPropertyIfNotNull(props, SaslConfigs.SASL_KERBEROS_TICKET_RENEW_WINDOW_FACTOR, getKerberosRenewWindowFactor());
    addListPropertyIfNotNull(props, SaslConfigs.SASL_KERBEROS_PRINCIPAL_TO_LOCAL_RULES, getKerberosPrincipalToLocalRules());
    addPropertyIfNotNull(props, SaslConfigs.SASL_MECHANISM, getSaslMechanism());
    //SSL
    addPropertyIfNotNull(props, SslConfigs.SSL_CIPHER_SUITES_CONFIG, getSslCipherSuites());
    addPropertyIfNotNull(props, SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, getSslEndpointAlgorithm());
    addPropertyIfNotNull(props, SslConfigs.SSL_KEYMANAGER_ALGORITHM_CONFIG, getSslKeymanagerAlgorithm());
    addPropertyIfNotNull(props, SslConfigs.SSL_TRUSTMANAGER_ALGORITHM_CONFIG, getSslTrustmanagerAlgorithm());
    return props;
}
Also used : 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