Search in sources :

Example 1 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-pulsar by apache.

the class DLOutputStreamTest method testClose.

/**
 * Test Case: close output stream.
 */
@Test
public void testClose() throws Exception {
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    AppendOnlyStreamWriter writer = mock(AppendOnlyStreamWriter.class);
    DLOutputStream out = new DLOutputStream(dlm, writer);
    out.close();
    verify(writer, times(1)).markEndOfStream();
    verify(writer, times(1)).close();
    verify(dlm, times(1)).close();
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) Test(org.testng.annotations.Test)

Example 2 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-pulsar by apache.

the class DLOutputStreamTest method testFlush.

/**
 * Test Case: flush should force writing the data.
 */
@Test
public void testFlush() throws Exception {
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    AppendOnlyStreamWriter writer = mock(AppendOnlyStreamWriter.class);
    DLOutputStream out = new DLOutputStream(dlm, writer);
    out.flush();
    verify(writer, times(1)).force(eq(false));
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) Test(org.testng.annotations.Test)

Example 3 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-pulsar by apache.

the class DLOutputStreamTest method testWrite.

/**
 * Test Case: test writing the data.
 */
@Test
public void testWrite() throws Exception {
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    AppendOnlyStreamWriter writer = mock(AppendOnlyStreamWriter.class);
    DLOutputStream out = new DLOutputStream(dlm, writer);
    byte[] data = new byte[16];
    out.write(data);
    verify(writer, times(1)).write(data);
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) Test(org.testng.annotations.Test)

Example 4 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-heron by apache.

the class DLOutputStreamTest method testWrite.

/**
 * Test Case: test writing the data.
 */
@Test
public void testWrite() throws Exception {
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    AppendOnlyStreamWriter writer = mock(AppendOnlyStreamWriter.class);
    DLOutputStream out = new DLOutputStream(dlm, writer);
    byte[] data = new byte[16];
    out.write(data);
    verify(writer, times(1)).write(data);
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) Test(org.junit.Test)

Example 5 with AppendOnlyStreamWriter

use of org.apache.distributedlog.AppendOnlyStreamWriter in project incubator-heron by apache.

the class DlogUploaderTest method testUploadPackageExisting.

@Test
public void testUploadPackageExisting() throws Exception {
    uploader = Mockito.spy(uploader);
    Namespace ns = mock(Namespace.class);
    when(nsBuilder.build()).thenReturn(ns);
    when(ns.logExists(anyString())).thenReturn(true);
    DistributedLogManager dlm = mock(DistributedLogManager.class);
    when(ns.openLog(anyString())).thenReturn(dlm);
    AppendOnlyStreamWriter asw = mock(AppendOnlyStreamWriter.class);
    when(dlm.getAppendOnlyStreamWriter()).thenReturn(asw);
    Mockito.doReturn(true).when(uploader).isLocalFileExists(Mockito.anyString());
    uploader.initialize(config);
    uploader.uploadPackage();
    verify(ns, times(1)).deleteLog(eq(uploader.getPackageName()));
    verify(copier, times(1)).copyFileToStream(eq(uploader.getTopologyPackageLocation()), any(OutputStream.class));
    verify(asw, times(1)).close();
    verify(dlm, times(1)).close();
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) OutputStream(java.io.OutputStream) Namespace(org.apache.distributedlog.api.namespace.Namespace) Test(org.junit.Test)

Aggregations

AppendOnlyStreamWriter (org.apache.distributedlog.AppendOnlyStreamWriter)13 DistributedLogManager (org.apache.distributedlog.api.DistributedLogManager)13 Test (org.junit.Test)6 OutputStream (java.io.OutputStream)3 Test (org.testng.annotations.Test)3 DLOutputStream (com.twitter.heron.dlog.DLOutputStream)2 Namespace (org.apache.distributedlog.api.namespace.Namespace)2 CheckpointManager (com.twitter.heron.proto.ckptmgr.CheckpointManager)1 Checkpoint (com.twitter.heron.spi.statefulstorage.Checkpoint)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 DLOutputStream (org.apache.pulsar.functions.worker.dlog.DLOutputStream)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1