Java Code Examples for org.testcontainers.shaded.com.google.common.collect.ImmutableMap#of()
The following examples show how to use
org.testcontainers.shaded.com.google.common.collect.ImmutableMap#of() .
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: KafkaLegacyClientIT.java From apm-agent-java with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() { // confluent versions 5.3.x correspond Kafka versions 2.3.x - // https://docs.confluent.io/current/installation/versions-interoperability.html#cp-and-apache-ak-compatibility kafka = new KafkaContainer("5.3.0"); kafka.start(); kafkaPort = kafka.getMappedPort(KafkaContainer.KAFKA_PORT); bootstrapServers = kafka.getBootstrapServers(); consumerThread = new Consumer(); consumerThread.start(); replyConsumer = createKafkaConsumer(); replyConsumer.subscribe(Collections.singletonList(REPLY_TOPIC)); producer = new KafkaProducer<>( ImmutableMap.of( ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers, ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString(), // This should guarantee that records are batched, as long as they are sent within the configured duration ProducerConfig.LINGER_MS_CONFIG, 50 ), new StringSerializer(), new StringSerializer() ); }
Example 2
Source File: TestStringEL.java From datacollector with Apache License 2.0 | 6 votes |
@Test public void testMapJoiner() throws Exception { ELEvaluator eval = new ELEvaluator("testJoiner", elDefinitionExtractor, StringEL.class, RecordEL.class); ELVariables variables = new ELVariables(); Record record = mock(Record.class); Map<String, Field> mapField = ImmutableMap.of( "a", Field.create(1), "b", Field.create(Field.Type.INTEGER, null), "c", Field.create("xyz") ); when(record.get("/map")).thenReturn(Field.create(mapField)); RecordEL.setRecordInContext(variables, record); Assert.assertEquals( "a=1,b=null,c=xyz", eval.eval(variables, "${map:join(record:value('/map'), ',', '=')}", String.class) ); Assert.assertEquals("", eval.eval(variables, "${map:join(record:value('/not-there'), ',', '=')}", String.class) ); }
Example 3
Source File: TestAmazonS3Executor.java From datacollector with Apache License 2.0 | 6 votes |
@Test public void testApplyTagsBrokenEL() throws Exception { AmazonS3ExecutorConfig config = getConfig(); config.taskConfig.tags = ImmutableMap.of( "${record:value('/ke", "${record:value('/value')}" ); AmazonS3Executor executor = new AmazonS3Executor(config); TargetRunner runner = new TargetRunner.Builder(AmazonS3DExecutor.class, executor) .setOnRecordError(OnRecordError.TO_ERROR) .build(); runner.runInit(); try { runner.runWrite(ImmutableList.of(getTestRecord())); Assert.assertEquals(1, runner.getErrorRecords().size()); } finally { runner.runDestroy(); } }
Example 4
Source File: KafkaSourceTester.java From pulsar with Apache License 2.0 | 6 votes |
@Override public Map<String, String> produceSourceMessages(int numMessages) throws Exception{ KafkaProducer<String, String> producer = new KafkaProducer<>( ImmutableMap.of( ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(), ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString() ), new StringSerializer(), new StringSerializer() ); LinkedHashMap<String, String> kvs = new LinkedHashMap<>(); for (int i = 0; i < numMessages; i++) { String key = "key-" + i; String value = "value-" + i; ProducerRecord<String, String> record = new ProducerRecord<>( kafkaTopicName, key, value ); kvs.put(key, value); producer.send(record).get(); } log.info("Successfully produced {} messages to kafka topic {}", numMessages, kafkaTopicName); return kvs; }
Example 5
Source File: KafkaIT.java From apm-agent-java with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() { // confluent versions 5.3.0 correspond Kafka versions 2.3.0 - // https://docs.confluent.io/current/installation/versions-interoperability.html#cp-and-apache-ak-compatibility kafka = new KafkaContainer("5.3.0"); kafka.start(); kafkaPort = kafka.getMappedPort(KafkaContainer.KAFKA_PORT); bootstrapServers = kafka.getBootstrapServers(); consumerThread = new Consumer(); consumerThread.start(); replyConsumer = createKafkaConsumer(); replyConsumer.subscribe(Collections.singletonList(REPLY_TOPIC)); producer = new KafkaProducer<>( ImmutableMap.of( ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers, ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString(), // This should guarantee that records are batched, as long as they are sent within the configured duration ProducerConfig.LINGER_MS_CONFIG, 50 ), new StringSerializer(), new StringSerializer() ); }
Example 6
Source File: KafkaLegacyBrokerIT.java From apm-agent-java with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() { reporter.disableDestinationAddressCheck(); // confluent versions 3.2.x correspond Kafka versions 0.10.2.2 - // https://docs.confluent.io/current/installation/versions-interoperability.html#cp-and-apache-ak-compatibility kafka = new KafkaContainer("3.2.2"); kafka.start(); bootstrapServers = kafka.getBootstrapServers(); consumerThread = new Consumer(); consumerThread.start(); replyConsumer = createKafkaConsumer(); replyConsumer.subscribe(Collections.singletonList(REPLY_TOPIC)); producer = new KafkaProducer<>( ImmutableMap.of( ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers, ProducerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString(), // This should guarantee that records are batched, as long as they are sent within the configured duration ProducerConfig.LINGER_MS_CONFIG, 50 ), new StringSerializer(), new StringSerializer() ); }
Example 7
Source File: KafkaLegacyBrokerIT.java From apm-agent-java with Apache License 2.0 | 5 votes |
static KafkaConsumer<String, String> createKafkaConsumer() { return new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers, ConsumerConfig.GROUP_ID_CONFIG, "tc-" + UUID.randomUUID(), ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest" ), new StringDeserializer(), new StringDeserializer() ); }
Example 8
Source File: KafkaIT.java From apm-agent-java with Apache License 2.0 | 5 votes |
static KafkaConsumer<String, String> createKafkaConsumer() { return new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers, ConsumerConfig.GROUP_ID_CONFIG, "tc-" + UUID.randomUUID(), ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest" ), new StringDeserializer(), new StringDeserializer() ); }
Example 9
Source File: RabbitMqIngressTest.java From pitchfork with Apache License 2.0 | 5 votes |
/** * Create consumer and subscribe to spans topic. */ private KafkaConsumer<String, byte[]> setupConsumer() { KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(), ConsumerConfig.GROUP_ID_CONFIG, "test-group", ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest" ), new StringDeserializer(), new ByteArrayDeserializer() ); consumer.subscribe(singletonList("proto-spans")); return consumer; }
Example 10
Source File: KafkaIngressTest.java From pitchfork with Apache License 2.0 | 5 votes |
/** * Create consumer and subscribe to spans topic. */ private KafkaConsumer<String, byte[]> setupConsumer() { KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(), ConsumerConfig.GROUP_ID_CONFIG, "test-group", ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest" ), new StringDeserializer(), new ByteArrayDeserializer() ); consumer.subscribe(singletonList("proto-spans")); return consumer; }
Example 11
Source File: HaystackKafkaForwarderTest.java From pitchfork with Apache License 2.0 | 5 votes |
/** * Create consumer and subscribe to spans topic. */ private KafkaConsumer<String, byte[]> setupConsumer() { KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(), ConsumerConfig.GROUP_ID_CONFIG, "test-group", ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest" ), new StringDeserializer(), new ByteArrayDeserializer() ); consumer.subscribe(singletonList("proto-spans")); return consumer; }
Example 12
Source File: KafkaSourceTester.java From pulsar with Apache License 2.0 | 5 votes |
@Override public void prepareSource() throws Exception { ExecResult execResult = kafkaContainer.execInContainer( "/usr/bin/kafka-topics", "--create", "--zookeeper", "localhost:2181", "--partitions", "1", "--replication-factor", "1", "--topic", kafkaTopicName); assertTrue( execResult.getStdout().contains("Created topic"), execResult.getStdout()); kafkaConsumer = new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers(), ConsumerConfig.GROUP_ID_CONFIG, "source-test-" + randomName(8), ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest" ), new StringDeserializer(), new StringDeserializer() ); kafkaConsumer.subscribe(Arrays.asList(kafkaTopicName)); log.info("Successfully subscribe to kafka topic {}", kafkaTopicName); }
Example 13
Source File: KafkaSinkTester.java From pulsar with Apache License 2.0 | 5 votes |
@Override public void prepareSink() throws Exception { ExecResult execResult = serviceContainer.execInContainer( "/usr/bin/kafka-topics", "--create", "--zookeeper", "localhost:2181", "--partitions", "1", "--replication-factor", "1", "--topic", kafkaTopicName); assertTrue( execResult.getStdout().contains("Created topic"), execResult.getStdout()); kafkaConsumer = new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, serviceContainer.getBootstrapServers(), ConsumerConfig.GROUP_ID_CONFIG, "sink-test-" + randomName(8), ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest" ), new StringDeserializer(), new StringDeserializer() ); kafkaConsumer.subscribe(Arrays.asList(kafkaTopicName)); log.info("Successfully subscribe to kafka topic {}", kafkaTopicName); }
Example 14
Source File: KafkaLegacyClientIT.java From apm-agent-java with Apache License 2.0 | 5 votes |
static KafkaConsumer<String, String> createKafkaConsumer() { return new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers, ConsumerConfig.GROUP_ID_CONFIG, "tc-" + UUID.randomUUID(), ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest" ), new StringDeserializer(), new StringDeserializer() ); }
Example 15
Source File: TestRuleDefinitionValidator.java From datacollector with Apache License 2.0 | 5 votes |
@Test public void testInValidConfiguration() { List<Config> rulesConfiguration = ImmutableList.of( new Config("emailIDs", ImmutableList.of("${USER_EMAIL_ID}")) ); RuleDefinitions ruleDefinitions = new RuleDefinitions( FilePipelineStoreTask.RULE_DEFINITIONS_SCHEMA_VERSION, RuleDefinitionsConfigBean.VERSION, Collections.<MetricsRuleDefinition>emptyList(), Collections.<DataRuleDefinition>emptyList(), Collections.<DriftRuleDefinition>emptyList(), null, UUID.randomUUID(), rulesConfiguration ); RuleDefinitionValidator ruleDefinitionValidator = new RuleDefinitionValidator( "pipelineId", ruleDefinitions, Collections.emptyMap() ); Assert.assertFalse(ruleDefinitionValidator.validateRuleDefinition()); Assert.assertNotNull(ruleDefinitions.getConfigIssues()); Assert.assertEquals(1, ruleDefinitions.getConfigIssues().size()); Assert.assertEquals("emailIDs", ruleDefinitions.getConfigIssues().get(0).getConfigName()); Assert.assertTrue( ruleDefinitions.getConfigIssues().get(0).getMessage().contains("'USER_EMAIL_ID' cannot be resolved") ); ruleDefinitionValidator = new RuleDefinitionValidator( "pipelineId", ruleDefinitions, ImmutableMap.of("USER_EMAIL_ID", "[email protected]") ); Assert.assertTrue(ruleDefinitionValidator.validateRuleDefinition()); Assert.assertNotNull(ruleDefinitions.getConfigIssues()); Assert.assertEquals(0, ruleDefinitions.getConfigIssues().size()); }
Example 16
Source File: KafkaConnectConverterIT.java From apicurio-registry with Apache License 2.0 | 5 votes |
private KafkaConsumer<byte[], byte[]> getConsumerBytes(KafkaContainer kafkaContainer) { return new KafkaConsumer<>( ImmutableMap.of( ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092", ConsumerConfig.GROUP_ID_CONFIG, "tc-" + UUID.randomUUID(), ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"), new ByteArrayDeserializer(), new ByteArrayDeserializer()); }
Example 17
Source File: DatastoreEntityExtension.java From nomulus with Apache License 2.0 | 4 votes |
@Override public Map<String, Object> getAttributes() { return ImmutableMap.of(); }
Example 18
Source File: ProfileE2E.java From skywalking with Apache License 2.0 | 4 votes |
private ResponseEntity<String> sendRequest(boolean needProfiling) { final Map<String, String> user = ImmutableMap.of( "name", "SkyWalking", "enableProfiling", String.valueOf(needProfiling) ); return restTemplate.postForEntity(instrumentedServiceUrl + "/profile/users?e2e=true", user, String.class); }