use of org.apache.samza.system.azureblob.AzureBlobConfig in project samza by apache.
the class TestAzureBlobSystemProducer method setup.
@Before
public void setup() throws Exception {
AzureBlobConfig azureBlobConfig = new AzureBlobConfig(getBasicConfigs());
mockMetricsRegistry = mock(MetricsRegistry.class);
mockErrorCounter = mock(Counter.class);
when(mockMetricsRegistry.newCounter(anyString(), anyString())).thenReturn(mock(Counter.class));
when(mockMetricsRegistry.newCounter(SOURCE, AzureBlobBasicMetrics.EVENT_PRODUCE_ERROR)).thenReturn(mockErrorCounter);
ome = createOME(STREAM);
mockThreadPoolExecutor = spy(new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>()));
PowerMockito.whenNew(ThreadPoolExecutor.class).withAnyArguments().thenReturn(mockThreadPoolExecutor);
mockAzureWriter = mock(AzureBlobWriter.class);
doNothing().when(mockAzureWriter).close();
systemProducer = spy(new AzureBlobSystemProducer(SYSTEM_NAME, azureBlobConfig, mockMetricsRegistry));
// use mock writer impl
setupWriterForProducer(systemProducer, mockAzureWriter, STREAM);
// bypass Azure connection setup
doNothing().when(systemProducer).setupAzureContainer();
}
use of org.apache.samza.system.azureblob.AzureBlobConfig in project samza by apache.
the class TestAzureBlobSystemProducer method testSendWhenWriterCreateFails.
@Test
public void testSendWhenWriterCreateFails() throws Exception {
AzureBlobConfig azureBlobConfig = new AzureBlobConfig(getBasicConfigs());
AzureBlobSystemProducer systemProducer = spy(new AzureBlobSystemProducer(SYSTEM_NAME, azureBlobConfig, mockMetricsRegistry));
PowerMockito.whenNew(AzureBlobAvroWriter.class).withAnyArguments().thenThrow(new SystemProducerException("Failed"));
// bypass Azure connection setup
doNothing().when(systemProducer).setupAzureContainer();
systemProducer.register(SOURCE);
systemProducer.start();
try {
systemProducer.send(SOURCE, ome);
Assert.fail("Expected exception not thrown.");
} catch (SystemProducerException e) {
}
verify(mockErrorCounter).inc();
}
Aggregations