Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down
18 changes: 8 additions & 10 deletions src/test/java/net/openhft/chronicle/queue/AcquireReleaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@
import net.openhft.chronicle.queue.impl.StoreFileListener;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueue;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

import static net.openhft.chronicle.queue.rollcycles.TestRollCycles.TEST_SECONDLY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.*;

@RequiredForClient
public class AcquireReleaseTest extends QueueTestCommon {
class AcquireReleaseTest extends QueueTestCommon {
@Test
public void testAcquireAndRelease() {
void testAcquireAndRelease() {
File dir = IOTools.createTempDirectory("testAcquireAndRelease").toFile();

AtomicInteger acount = new AtomicInteger();
Expand Down Expand Up @@ -66,14 +64,14 @@

BackgroundResourceReleaser.releasePendingResources();

Assert.assertEquals(iter, acount.get());
Assert.assertEquals(iter, qcount.get());
assertEquals(iter, acount.get());
assertEquals(iter, qcount.get());
}
IOTools.deleteDirWithFiles(dir);
}

@Test
public void testReserveAndRelease() {
void testReserveAndRelease() {
File dir = getTmpDir();

SetTimeProvider stp = new SetTimeProvider();
Expand All @@ -98,7 +96,7 @@
}

@Test
public void testWithCleanupStoreFilesWithNoDataAcquireAndRelease() throws InterruptedException, ExecutionException {
void testWithCleanupStoreFilesWithNoDataAcquireAndRelease() throws InterruptedException, ExecutionException {

Check warning on line 99 in src/test/java/net/openhft/chronicle/queue/AcquireReleaseTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the declaration of thrown exception 'java.lang.InterruptedException', as it cannot be thrown from method's body.

See more on https://sonarcloud.io/project/issues?id=OpenHFT_Chronicle-Queue&issues=AZ0rWsCt7ASJbBRNKqdq&open=AZ0rWsCt7ASJbBRNKqdq&pullRequest=1702

Check warning on line 99 in src/test/java/net/openhft/chronicle/queue/AcquireReleaseTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the declaration of thrown exception 'java.util.concurrent.ExecutionException', as it cannot be thrown from method's body.

See more on https://sonarcloud.io/project/issues?id=OpenHFT_Chronicle-Queue&issues=AZ0rWsCt7ASJbBRNKqdr&open=AZ0rWsCt7ASJbBRNKqdr&pullRequest=1702
final File dir = getTmpDir();
final SetTimeProvider stp = new SetTimeProvider();
final AtomicInteger acount = new AtomicInteger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import net.openhft.chronicle.core.io.IOTools;
import net.openhft.chronicle.core.time.SetTimeProvider;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

public class AppenderListenerTest extends QueueTestCommon {
class AppenderListenerTest extends QueueTestCommon {

@Test
public void appenderListenerTest() {
void appenderListenerTest() {
String path = OS.getTarget() + "/appenderListenerTest";
StringBuilder results = new StringBuilder();
try (ChronicleQueue q = SingleChronicleQueueBuilder.single(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@
import net.openhft.chronicle.core.OS;
import net.openhft.chronicle.testframework.process.JavaProcessBuilder;
import net.openhft.chronicle.wire.DocumentContext;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;

public class CheckHalfWrittenMsgNotSeenByTailerTest extends QueueTestCommon {
class CheckHalfWrittenMsgNotSeenByTailerTest extends QueueTestCommon {
static {
// load the lass
HalfWriteAMessage.class.getName();
}

public static class HalfWriteAMessage {
static class HalfWriteAMessage {

// writes three messages the third messas is half written
public static void main(String[] args) throws InterruptedException {
Expand Down Expand Up @@ -65,8 +64,8 @@ private static void writeIncompleteMessage(String arg, boolean exit) throws Inte
}

@Test
public void checkTailerOnlyReadsTwoMessageOneProcess() throws InterruptedException {
Assume.assumeTrue(!OS.isWindows());
void checkTailerOnlyReadsTwoMessageOneProcess() throws InterruptedException {
assumeTrue(!OS.isWindows());
final File queueDirectory = DirectoryUtils.tempDir("halfWritten");

HalfWriteAMessage.writeIncompleteMessage(queueDirectory.toString(), false);
Expand All @@ -79,15 +78,15 @@ public void checkTailerOnlyReadsTwoMessageOneProcess() throws InterruptedExcepti
final ExcerptTailer tailer = single.createTailer()) {

try (final DocumentContext dc = tailer.readingDocument()) {
Assert.assertTrue(dc.isPresent());
Assert.assertEquals("hello world 1", dc.wire().read("key1").text());
Assert.assertEquals("hello world 2", dc.wire().read("key2").text());
assertTrue(dc.isPresent());
assertEquals("hello world 1", dc.wire().read("key1").text());
assertEquals("hello world 2", dc.wire().read("key2").text());
}

try (final DocumentContext dc = tailer.readingDocument()) {
Assert.assertTrue(dc.isPresent());
Assert.assertEquals("hello world 3", dc.wire().read("key1").text());
Assert.assertEquals("hello world 4", dc.wire().read("key2").text());
assertTrue(dc.isPresent());
assertEquals("hello world 3", dc.wire().read("key1").text());
assertEquals("hello world 4", dc.wire().read("key2").text());
}

try (final DocumentContext dc = tailer.readingDocument()) {
Expand All @@ -103,8 +102,8 @@ public void checkTailerOnlyReadsTwoMessageOneProcess() throws InterruptedExcepti
}

@Test
public void checkTailerOnlyReadsTwoMessageTwoProcesses() throws IOException, InterruptedException {
Assume.assumeTrue(OS.isLinux() && OS.is64Bit());
void checkTailerOnlyReadsTwoMessageTwoProcesses() throws IOException, InterruptedException {
assumeTrue(OS.isLinux() && OS.is64Bit());
ignoreException("Forced unlocking `chronicle.write.lock` in lock file:target/halfWritten");

final File queueDirectory = DirectoryUtils.tempDir("halfWritten");
Expand All @@ -117,15 +116,15 @@ public void checkTailerOnlyReadsTwoMessageTwoProcesses() throws IOException, Int
final ExcerptTailer tailer = single.createTailer()) {

try (final DocumentContext dc = tailer.readingDocument()) {
Assert.assertTrue(dc.isPresent());
Assert.assertEquals("hello world 1", dc.wire().read("key1").text());
Assert.assertEquals("hello world 2", dc.wire().read("key2").text());
assertTrue(dc.isPresent());
assertEquals("hello world 1", dc.wire().read("key1").text());
assertEquals("hello world 2", dc.wire().read("key2").text());
}

try (final DocumentContext dc = tailer.readingDocument()) {
Assert.assertTrue(dc.isPresent());
Assert.assertEquals("hello world 3", dc.wire().read("key1").text());
Assert.assertEquals("hello world 4", dc.wire().read("key2").text());
assertTrue(dc.isPresent());
assertEquals("hello world 3", dc.wire().read("key1").text());
assertEquals("hello world 4", dc.wire().read("key2").text());
}

try (final DocumentContext dc = tailer.readingDocument()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueue;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;
import net.openhft.chronicle.wire.WireType;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.file.Path;
Expand All @@ -18,24 +18,24 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;

import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;

/**
* This test case replicates the assertion error in Chronicle StoreAppender's checkWritePositionHeaderNumber() method. see
* https://github.com/OpenHFT/Chronicle-Queue/issues/611
*/
public class ChronicleAppenderCycleTest extends QueueTestCommon {
class ChronicleAppenderCycleTest extends QueueTestCommon {

private static final long LATCH_TIMEOUT_MS = 5000;

@Override
@Before
@BeforeEach
public void threadDump() {
super.threadDump();
}

@Test
public void testAppenderCycle() throws IOException {
void testAppenderCycle() throws IOException {
String id = "testAppenderCycle";
Bytes<?> msg = Bytes.allocateDirect(64);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
import net.openhft.chronicle.queue.reader.ChronicleHistoryReader;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

public class ChronicleHistoryReaderMainCliTest extends QueueTestCommon {
class ChronicleHistoryReaderMainCliTest extends QueueTestCommon {

@Test
public void runConfiguresReaderFromArguments() throws Exception {
void runConfiguresReaderFromArguments() throws Exception {
final Path queueDir = Files.createTempDirectory("history-reader");
final TestChronicleHistoryReaderMain main = new TestChronicleHistoryReaderMain();

Expand All @@ -39,7 +39,7 @@ public void runConfiguresReaderFromArguments() throws Exception {
}

@Test
public void parseCommandLineWithHelpOption() {
void parseCommandLineWithHelpOption() {
final TestChronicleHistoryReaderMain main = new TestChronicleHistoryReaderMain();

try {
Expand All @@ -52,7 +52,7 @@ public void parseCommandLineWithHelpOption() {
}

@Test
public void parseCommandLineMissingDirectoryPrintsError() {
void parseCommandLineMissingDirectoryPrintsError() {
final TestChronicleHistoryReaderMain main = new TestChronicleHistoryReaderMain();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
import net.openhft.chronicle.queue.reader.ChronicleHistoryReader;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.*;

import java.nio.file.Path;
import java.security.Permission;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;

@SuppressWarnings({"deprecation", "removal"})
public class ChronicleHistoryReaderMainTest {
class ChronicleHistoryReaderMainTest {

private static class NoExitSecurityManager extends SecurityManager {
@Override
Expand All @@ -34,20 +32,20 @@
}
}

@Before
public void setUp() {
@BeforeEach
void setUp() {
// SecurityManager is effectively disabled from JDK 17 onwards
assumeTrue(Jvm.majorVersion() < 17);
System.setSecurityManager(new NoExitSecurityManager());
}

@After
public void tearDown() {
@AfterEach
protected void tearDown() {

Check warning on line 43 in src/test/java/net/openhft/chronicle/queue/ChronicleHistoryReaderMainTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'protected' modifier.

See more on https://sonarcloud.io/project/issues?id=OpenHFT_Chronicle-Queue&issues=AZ0rWsbz7ASJbBRNKqes&open=AZ0rWsbz7ASJbBRNKqes&pullRequest=1702
System.setSecurityManager(null);
}

@Test
public void testRunExecutesChronicleHistoryReader() {
void testRunExecutesChronicleHistoryReader() {
// Setup
ChronicleHistoryReaderMain main = new ChronicleHistoryReaderMain() {
@Override
Expand All @@ -67,7 +65,7 @@
}

@Test
public void testSetupChronicleHistoryReader() {
void testSetupChronicleHistoryReader() {
// Simulate command line arguments
String[] args = {"-d", "test-directory", "-p", "-m", "-t", "NANOSECONDS"};
ChronicleHistoryReaderMain main = new ChronicleHistoryReaderMain();
Expand Down Expand Up @@ -118,7 +116,7 @@
}

@Test
public void testParseCommandLine() {
void testParseCommandLine() {
// Test that parseCommandLine correctly parses arguments
ChronicleHistoryReaderMain main = new ChronicleHistoryReaderMain();
Options options = main.options();
Expand All @@ -130,7 +128,7 @@
}

@Test
public void testParseCommandLineHelpOption() {
void testParseCommandLineHelpOption() {
ChronicleHistoryReaderMain main = new ChronicleHistoryReaderMain() {
@Override
protected void printHelpAndExit(Options options, int status, String message) {
Expand All @@ -154,7 +152,7 @@
}

@Test
public void testOptionsConfiguration() {
void testOptionsConfiguration() {
ChronicleHistoryReaderMain main = new ChronicleHistoryReaderMain();
Options options = main.options();

Expand All @@ -170,7 +168,7 @@
}

@Test
public void testPrintHelpAndExit() {
void testPrintHelpAndExit() {
ChronicleHistoryReaderMain main = new ChronicleHistoryReaderMain();
Options options = main.options();
try {
Expand Down
Loading