Search in sources :

Example 16 with FileOutputStreamPlus

use of org.apache.cassandra.io.util.FileOutputStreamPlus in project cassandra by apache.

the class SnapshotManifestTest method testOptionalFields.

@Test
public void testOptionalFields() throws IOException {
    Map<String, Object> map = new HashMap<>();
    map.put("files", Arrays.asList("db1", "db2", "db3"));
    ObjectMapper mapper = new ObjectMapper();
    File manifestFile = new File(tempFolder.newFile("manifest.json"));
    mapper.writeValue((OutputStream) new FileOutputStreamPlus(manifestFile), map);
    SnapshotManifest manifest = SnapshotManifest.deserializeFromJsonFile(manifestFile);
    assertThat(manifest.getExpiresAt()).isNull();
    assertThat(manifest.getCreatedAt()).isNull();
    assertThat(manifest.getFiles()).contains("db1").contains("db2").contains("db3").hasSize(3);
}
Also used : HashMap(java.util.HashMap) File(org.apache.cassandra.io.util.File) FileOutputStreamPlus(org.apache.cassandra.io.util.FileOutputStreamPlus) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

FileOutputStreamPlus (org.apache.cassandra.io.util.FileOutputStreamPlus)16 File (org.apache.cassandra.io.util.File)14 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 DataOutputStream (java.io.DataOutputStream)6 OutputStream (java.io.OutputStream)6 ByteBuffer (java.nio.ByteBuffer)5 Test (org.junit.Test)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 HashMap (java.util.HashMap)3 FileInputStreamPlus (org.apache.cassandra.io.util.FileInputStreamPlus)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 CassandraOutgoingFile (org.apache.cassandra.db.streaming.CassandraOutgoingFile)1 DataOutputStreamPlus (org.apache.cassandra.io.util.DataOutputStreamPlus)1 RandomAccessReader (org.apache.cassandra.io.util.RandomAccessReader)1 EncryptionContext (org.apache.cassandra.security.EncryptionContext)1 BloomFilter (org.apache.cassandra.utils.BloomFilter)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1