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();
}
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));
}
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);
}
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);
}
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();
}
Aggregations