Search in sources :

Example 1 with DLInputStream

use of com.twitter.heron.dlog.DLInputStream in project incubator-heron by apache.

the class DLDownloaderTest method testOpenInputStream.

@Test
public void testOpenInputStream() throws Exception {
    Namespace ns = mock(Namespace.class);
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    LogReader reader = mock(LogReader.class);
    when(ns.openLog(anyString())).thenReturn(dlm);
    when(dlm.getInputStream(eq(DLSN.InitialDLSN))).thenReturn(reader);
    InputStream is = DLDownloader.openInputStream(ns, "test-open-inputstream");
    assertTrue(is instanceof DLInputStream);
    is.close();
    verify(dlm, times(1)).close();
    verify(reader, times(1)).close();
}
Also used : DLInputStream(com.twitter.heron.dlog.DLInputStream) DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) DLInputStream(com.twitter.heron.dlog.DLInputStream) InputStream(java.io.InputStream) LogReader(org.apache.distributedlog.api.LogReader) Namespace(org.apache.distributedlog.api.namespace.Namespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DLInputStream (com.twitter.heron.dlog.DLInputStream)1 InputStream (java.io.InputStream)1 DistributedLogManager (org.apache.distributedlog.api.DistributedLogManager)1 LogReader (org.apache.distributedlog.api.LogReader)1 Namespace (org.apache.distributedlog.api.namespace.Namespace)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1