BAEL-995: resolved merge issues (#2255)

This commit is contained in:
Syed Ali Raza 2017-07-13 12:02:05 +05:00 committed by Grzegorz Piwowarek
parent 84956990b6
commit 78de955aac
3 changed files with 71 additions and 0 deletions

View File

@ -331,6 +331,11 @@
<artifactId>datanucleus-xml</artifactId>
<version>5.0.0-release</version>
</dependency>
<dependency>
<groupId>net.openhft</groupId>
<artifactId>chronicle</artifactId>
<version>3.6.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>

View File

@ -0,0 +1,23 @@
package com.baeldung.chronicle.queue;
import java.io.IOException;
import net.openhft.chronicle.Chronicle;
import net.openhft.chronicle.ExcerptAppender;
public class ChronicleQueue {
public static void writeToQueue(
Chronicle chronicle, String stringValue, int intValue, long longValue, double doubleValue)
throws IOException {
ExcerptAppender appender = chronicle.createAppender();
appender.startExcerpt();
appender.writeUTF(stringValue);
appender.writeInt(intValue);
appender.writeLong(longValue);
appender.writeDouble(doubleValue);
appender.finish();
appender.close();
}
}

View File

@ -0,0 +1,43 @@
package com.baeldung.chronicle.queue;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import org.junit.Test;
import net.openhft.chronicle.Chronicle;
import net.openhft.chronicle.ChronicleQueueBuilder;
import net.openhft.chronicle.ExcerptTailer;
import net.openhft.chronicle.tools.ChronicleTools;
public class ChronicleQueueTest {
@Test
public void givenSetOfValues_whenWriteToQueue_thenWriteSuccesfully() throws IOException {
File queueDir = Files.createTempDirectory("chronicle-queue").toFile();
ChronicleTools.deleteOnExit(queueDir.getPath());
Chronicle chronicle = ChronicleQueueBuilder.indexed(queueDir).build();
String stringVal = "Hello World";
int intVal = 101;
long longVal = System.currentTimeMillis();
double doubleVal = 90.00192091d;
ChronicleQueue.writeToQueue(chronicle, stringVal, intVal, longVal, doubleVal);
ExcerptTailer tailer = chronicle.createTailer();
while (tailer.nextIndex()) {
assertEquals(stringVal, tailer.readUTF());
assertEquals(intVal, tailer.readInt());
assertEquals(longVal, tailer.readLong());
assertEquals((Double) doubleVal, (Double) tailer.readDouble());
}
tailer.finish();
tailer.close();
chronicle.close();
}
}