Search in sources :

Example 41 with Properties

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

the class KafkaComponentTest method getProducerKeys.

private Properties getProducerKeys() {
    Properties props = new Properties();
    props.put(ProducerConfig.ACKS_CONFIG, "1");
    props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, "33554432");
    props.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "none");
    props.put(ProducerConfig.RETRIES_CONFIG, "0");
    props.put(ProducerConfig.BATCH_SIZE_CONFIG, "16384");
    props.put(ProducerConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG, "540000");
    props.put(ProducerConfig.LINGER_MS_CONFIG, "0");
    props.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, "60000");
    props.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, "1048576");
    props.put(ProducerConfig.PARTITIONER_CLASS_CONFIG, KafkaConstants.KAFKA_DEFAULT_PARTITIONER);
    props.put(ProducerConfig.RECEIVE_BUFFER_CONFIG, "32768");
    props.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, "30000");
    props.put(ProducerConfig.SEND_BUFFER_CONFIG, "131072");
    props.put(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, "5");
    props.put(ProducerConfig.METADATA_MAX_AGE_CONFIG, "300000");
    props.put(ProducerConfig.METRICS_NUM_SAMPLES_CONFIG, "2");
    props.put(ProducerConfig.METRICS_SAMPLE_WINDOW_MS_CONFIG, "30000");
    props.put(ProducerConfig.RECONNECT_BACKOFF_MS_CONFIG, "50");
    props.put(ProducerConfig.RETRY_BACKOFF_MS_CONFIG, "100");
    props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaConstants.KAFKA_DEFAULT_SERIALIZER);
    props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, KafkaConstants.KAFKA_DEFAULT_SERIALIZER);
    props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "PLAINTEXT");
    props.put(SslConfigs.SSL_ENABLED_PROTOCOLS_CONFIG, "TLSv1.2, TLSv1.1, TLSv1");
    props.put(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, "JKS");
    props.put(SslConfigs.SSL_PROTOCOL_CONFIG, "TLS");
    props.put(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, "JKS");
    props.put(SaslConfigs.SASL_KERBEROS_KINIT_CMD, "/usr/bin/kinit");
    props.put(SaslConfigs.SASL_KERBEROS_MIN_TIME_BEFORE_RELOGIN, "60000");
    props.put(SaslConfigs.SASL_KERBEROS_TICKET_RENEW_JITTER, "0.05");
    props.put(SaslConfigs.SASL_KERBEROS_TICKET_RENEW_WINDOW_FACTOR, "0.8");
    props.put(SaslConfigs.SASL_MECHANISM, "PLAIN");
    props.put(SslConfigs.SSL_KEYMANAGER_ALGORITHM_CONFIG, "SunX509");
    props.put(SslConfigs.SSL_TRUSTMANAGER_ALGORITHM_CONFIG, "PKIX");
    return props;
}
Also used : Properties(java.util.Properties)

Example 42 with Properties

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

the class MailEndpointTlsTest method testMailEndpointNoTslConfig.

@Test
public void testMailEndpointNoTslConfig() throws Exception {
    MailConfiguration cfg = new MailConfiguration();
    cfg.setPort(21);
    cfg.setProtocol(protocol);
    cfg.setHost("myhost");
    cfg.setUsername("james");
    cfg.setPassword("secret");
    cfg.setSslContextParameters(MailTestHelper.createSslContextParameters());
    Properties javaMailProperties = cfg.createJavaMailSender().getJavaMailProperties();
    assertFalse(cfg.isStartTlsEnabled());
    if (protocol.endsWith("s")) {
        assertTrue(cfg.isSecureProtocol());
        assertNotNull(javaMailProperties.get("mail." + protocol + ".socketFactory"));
        assertNotNull(javaMailProperties.get("mail." + protocol + ".socketFactory.fallback"));
        assertNotNull(javaMailProperties.get("mail." + protocol + ".socketFactory.port"));
    } else {
        assertFalse(cfg.isSecureProtocol());
        assertNull(javaMailProperties.get("mail." + protocol + ".socketFactory"));
        assertNull(javaMailProperties.get("mail." + protocol + ".socketFactory.fallback"));
        assertNull(javaMailProperties.get("mail." + protocol + ".socketFactory.port"));
    }
}
Also used : Properties(java.util.Properties) Test(org.junit.Test)

Example 43 with Properties

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

the class MailUsingCustomSessionTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    mailSession = Session.getInstance(new Properties());
    registry.bind("myCustomMailSession", mailSession);
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) Properties(java.util.Properties)

Example 44 with Properties

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

the class MimeMessageConsumeTest method testSendAndReceiveMails.

@Test
public void testSendAndReceiveMails() throws Exception {
    Mailbox.clearAll();
    MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
    resultEndpoint.expectedMinimumMessageCount(1);
    Properties properties = new Properties();
    properties.put("mail.smtp.host", "localhost");
    Session session = Session.getInstance(properties, null);
    MimeMessage message = new MimeMessage(session);
    populateMimeMessageBody(message);
    message.setRecipients(Message.RecipientType.TO, "james3@localhost");
    Transport.send(message);
    // lets test the receive worked
    resultEndpoint.assertIsSatisfied();
    Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
    String text = exchange.getIn().getBody(String.class);
    assertEquals("mail body", body, text);
    assertNotNull("attachments got lost", exchange.getIn().getAttachments());
    for (String s : exchange.getIn().getAttachmentNames()) {
        DataHandler dh = exchange.getIn().getAttachment(s);
        Object content = dh.getContent();
        assertNotNull("Content should not be empty", content);
        assertEquals("log4j2.properties", dh.getName());
    }
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MimeMessage(javax.mail.internet.MimeMessage) DataHandler(javax.activation.DataHandler) Properties(java.util.Properties) Session(javax.mail.Session) Test(org.junit.Test)

Example 45 with Properties

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

the class MultipleDestinationConsumeTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    Properties properties = new Properties();
    properties.put("mail.smtp.host", "localhost");
    mailSession = Session.getInstance(properties, null);
    super.setUp();
}
Also used : Properties(java.util.Properties) Before(org.junit.Before)

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