Search in sources :

Example 11 with BufferWriteStream

use of io.georocket.util.io.BufferWriteStream in project georocket by georocket.

the class AllSameStrategyTest method mergeFail.

/**
 * Test if the merge method fails if it is called with an unexpected chunk
 * @param context the test context
 */
@Test
public void mergeFail(TestContext context) {
    XMLChunkMeta cm2 = new XMLChunkMeta(Arrays.asList(new XMLStartElement("other")), 10, 20);
    Async async = context.async();
    MergeStrategy strategy = new AllSameStrategy();
    BufferWriteStream bws = new BufferWriteStream();
    strategy.init(cm).flatMap(v -> strategy.merge(new DelegateChunkReadStream(chunk2), cm2, bws)).subscribe(v -> context.fail(), err -> {
        context.assertTrue(err instanceof IllegalArgumentException);
        async.complete();
    });
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) Arrays(java.util.Arrays) DelegateChunkReadStream(io.georocket.util.io.DelegateChunkReadStream) Buffer(io.vertx.core.buffer.Buffer) BufferWriteStream(io.georocket.util.io.BufferWriteStream) RunWith(org.junit.runner.RunWith) XMLStartElement(io.georocket.util.XMLStartElement) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) XMLChunkMeta(io.georocket.storage.XMLChunkMeta) DelegateChunkReadStream(io.georocket.util.io.DelegateChunkReadStream) XMLStartElement(io.georocket.util.XMLStartElement) Async(io.vertx.ext.unit.Async) XMLChunkMeta(io.georocket.storage.XMLChunkMeta) BufferWriteStream(io.georocket.util.io.BufferWriteStream) Test(org.junit.Test)

Aggregations

BufferWriteStream (io.georocket.util.io.BufferWriteStream)11 DelegateChunkReadStream (io.georocket.util.io.DelegateChunkReadStream)11 Buffer (io.vertx.core.buffer.Buffer)11 Async (io.vertx.ext.unit.Async)11 TestContext (io.vertx.ext.unit.TestContext)11 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)11 Test (org.junit.Test)11 RunWith (org.junit.runner.RunWith)11 XMLChunkMeta (io.georocket.storage.XMLChunkMeta)8 XMLStartElement (io.georocket.util.XMLStartElement)8 Arrays (java.util.Arrays)8 ChunkReadStream (io.georocket.storage.ChunkReadStream)6 RunTestOnContext (io.vertx.ext.unit.junit.RunTestOnContext)6 Pair (org.apache.commons.lang3.tuple.Pair)6 Rule (org.junit.Rule)6 Observable (rx.Observable)6 GeoJsonChunkMeta (io.georocket.storage.GeoJsonChunkMeta)5 ChunkMeta (io.georocket.storage.ChunkMeta)2