Search in sources :

Example 6 with SinkContext

use of org.apache.pulsar.io.core.SinkContext in project pulsar by yahoo.

the class ContextImplTest method testGetSinkConfig.

@Test
public void testGetSinkConfig() {
    SinkContext sinkContext = context;
    SinkConfig sinkConfig = sinkContext.getSinkConfig();
    Assert.assertNotNull(sinkConfig);
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) SinkContext(org.apache.pulsar.io.core.SinkContext) Test(org.testng.annotations.Test)

Example 7 with SinkContext

use of org.apache.pulsar.io.core.SinkContext in project incubator-pulsar by apache.

the class ContextImplTest method testGetSubscriptionType.

@Test
public void testGetSubscriptionType() {
    SinkContext ctx = context;
    // make sure SinkContext can get SubscriptionType.
    Assert.assertEquals(ctx.getSubscriptionType(), SubscriptionType.Shared);
}
Also used : SinkContext(org.apache.pulsar.io.core.SinkContext) Test(org.testng.annotations.Test)

Example 8 with SinkContext

use of org.apache.pulsar.io.core.SinkContext in project incubator-pulsar by apache.

the class KinesisSinkConfigTests method loadFromMapCredentialFromSecretTest.

@Test
public final void loadFromMapCredentialFromSecretTest() throws IOException {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("awsEndpoint", "https://some.endpoint.aws");
    map.put("awsRegion", "us-east-1");
    map.put("awsKinesisStreamName", "my-stream");
    SinkContext sinkContext = Mockito.mock(SinkContext.class);
    Mockito.when(sinkContext.getSecret("awsCredentialPluginParam")).thenReturn("{\"accessKey\":\"myKey\",\"secretKey\":\"my-Secret\"}");
    KinesisSinkConfig config = IOConfigUtils.loadWithSecrets(map, KinesisSinkConfig.class, sinkContext);
    assertNotNull(config);
    assertEquals(config.getAwsEndpoint(), "https://some.endpoint.aws");
    assertEquals(config.getAwsRegion(), "us-east-1");
    assertEquals(config.getAwsKinesisStreamName(), "my-stream");
    assertEquals(config.getAwsCredentialPluginParam(), "{\"accessKey\":\"myKey\",\"secretKey\":\"my-Secret\"}");
}
Also used : HashMap(java.util.HashMap) SinkContext(org.apache.pulsar.io.core.SinkContext) Test(org.testng.annotations.Test)

Example 9 with SinkContext

use of org.apache.pulsar.io.core.SinkContext in project incubator-pulsar by apache.

the class KinesisSinkConfigTests method loadFromMapTest.

@Test
public final void loadFromMapTest() throws IOException {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("awsEndpoint", "https://some.endpoint.aws");
    map.put("awsRegion", "us-east-1");
    map.put("awsKinesisStreamName", "my-stream");
    map.put("awsCredentialPluginParam", "{\"accessKey\":\"myKey\",\"secretKey\":\"my-Secret\"}");
    SinkContext sinkContext = Mockito.mock(SinkContext.class);
    KinesisSinkConfig config = IOConfigUtils.loadWithSecrets(map, KinesisSinkConfig.class, sinkContext);
    assertNotNull(config);
    assertEquals(config.getAwsEndpoint(), "https://some.endpoint.aws");
    assertEquals(config.getAwsRegion(), "us-east-1");
    assertEquals(config.getAwsKinesisStreamName(), "my-stream");
    assertEquals(config.getAwsCredentialPluginParam(), "{\"accessKey\":\"myKey\",\"secretKey\":\"my-Secret\"}");
}
Also used : HashMap(java.util.HashMap) SinkContext(org.apache.pulsar.io.core.SinkContext) Test(org.testng.annotations.Test)

Example 10 with SinkContext

use of org.apache.pulsar.io.core.SinkContext in project incubator-pulsar by apache.

the class ContextImplTest method testGetSinkConfig.

@Test
public void testGetSinkConfig() {
    SinkContext sinkContext = context;
    SinkConfig sinkConfig = sinkContext.getSinkConfig();
    Assert.assertNotNull(sinkConfig);
}
Also used : SinkConfig(org.apache.pulsar.common.io.SinkConfig) SinkContext(org.apache.pulsar.io.core.SinkContext) Test(org.testng.annotations.Test)

Aggregations

SinkContext (org.apache.pulsar.io.core.SinkContext)17 Test (org.testng.annotations.Test)16 HashMap (java.util.HashMap)10 ByteBuffer (java.nio.ByteBuffer)3 KafkaAbstractSink (org.apache.pulsar.io.kafka.KafkaAbstractSink)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Message (org.apache.pulsar.client.api.Message)2 GenericObject (org.apache.pulsar.client.api.schema.GenericObject)2 SinkConfig (org.apache.pulsar.common.io.SinkConfig)2 Record (org.apache.pulsar.functions.api.Record)2 GetRecordsResponse (software.amazon.awssdk.services.kinesis.model.GetRecordsResponse)2 CloudStorageSinkConfig (org.apache.pulsar.io.jcloud.sink.CloudStorageSinkConfig)1 Test (org.junit.Test)1