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
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@

<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.squareup.javapoet.ArrayTypeName;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.MethodSpec;
import net.openhft.chronicle.core.Jvm;

import java.lang.reflect.Method;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,4 @@ public String inferBinaryName(Location location, JavaFileObject file) {
}
return super.inferBinaryName(location, file);
}

}
4 changes: 2 additions & 2 deletions src/test/java/net/openhft/chronicle/values/AlignTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import net.openhft.chronicle.bytes.Byteable;
import net.openhft.chronicle.bytes.BytesStore;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static net.openhft.chronicle.values.Values.newNativeReference;

Expand All @@ -18,8 +18,8 @@
* correctly.</p>
*/
public class AlignTest extends ValuesTestCommon {
@SuppressWarnings("unchecked")
@Test
@SuppressWarnings("unchecked")
public void testAlign() {
DemoOrderVOInterface value = newNativeReference(DemoOrderVOInterface.class);
long size = value.maxSize();
Expand Down
16 changes: 7 additions & 9 deletions src/test/java/net/openhft/chronicle/values/ComplexValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

import net.openhft.chronicle.bytes.Byteable;
import net.openhft.chronicle.bytes.BytesStore;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import static net.openhft.chronicle.values.Values.newHeapInstance;
import static net.openhft.chronicle.values.Values.newNativeReference;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

public class ComplexValueTest extends ValuesTestCommon {

Expand Down Expand Up @@ -44,13 +44,11 @@ public void heapAndNativeBehaviourMatch() {
Map<String, FieldModel> byName = model.fields()
.collect(Collectors.toMap(FieldModel::name, Function.identity()));

assertTrue("label field present", byName.containsKey("label"));
assertTrue("mirrorEnabled field present", byName.containsKey("mirrorEnabled"));
assertTrue("label offset should be resolved",
model.fieldBitOffset(byName.get("label")) >= 0);
assertTrue("history should allocate extent per element",
model.fieldBitExtent(byName.get("history"))
>= 3 * Long.SIZE);
assertTrue(byName.containsKey("label"), "label field present");
assertTrue(byName.containsKey("mirrorEnabled"), "mirrorEnabled field present");
assertTrue(model.fieldBitOffset(byName.get("label")) >= 0, "label offset should be resolved");
assertTrue(model.fieldBitExtent(byName.get("history")) >= 3 * Long.SIZE,
"history should allocate extent per element");

// behaviour assertions
assertEquals(ComplexValue.Status.ACTIVE, nativeValue.getStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import net.openhft.chronicle.bytes.BytesStore;
import net.openhft.chronicle.core.values.*;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static net.openhft.chronicle.bytes.BytesStore.nativeStoreWithFixedCapacity;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

@SuppressWarnings({"rawtypes", "unchecked"})
public class CoreValuesTest extends ValuesTestCommon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import net.openhft.chronicle.core.values.IntValue;
import net.openhft.chronicle.core.values.LongValue;
import org.junit.Test;
import org.junit.jupiter.api.Test;

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

/**
* Interface holding a five element array of {@code long} values for field type tests.
Expand Down Expand Up @@ -58,16 +58,24 @@ interface FiveBooleanValues {
* generated proxy.
*/
interface FiveLongAndBooleanValues {
/** Returns the long array view. */
/**
* Returns the long array view.
*/
FiveLongValues getLongValues();

/** Assigns the long array view. */
/**
* Assigns the long array view.
*/
void setLongValues(FiveLongValues values);

/** Returns the boolean array view. */
/**
* Returns the boolean array view.
*/
FiveBooleanValues getBooleanValues();

/** Assigns the boolean array view. */
/**
* Assigns the boolean array view.
*/
void setBooleanValues(FiveBooleanValues values);
}

Expand All @@ -79,16 +87,12 @@ public class FirstPrimitiveFieldTest extends ValuesTestCommon {

@Test
public void firstPrimitiveFieldTest() {
assertEquals(int.class, ValueModel.acquire(IntValue.class).firstPrimitiveFieldType());
assertEquals(long.class, ValueModel.acquire(LongValue.class).firstPrimitiveFieldType());
assertEquals(long.class,
ValueModel.acquire(Values.nativeClassFor(LongValue.class))
.firstPrimitiveFieldType());
assertEquals(long.class,
ValueModel.acquire(FiveLongValues.class).firstPrimitiveFieldType());
assertEquals(boolean.class,
ValueModel.acquire(FiveBooleanValues.class).firstPrimitiveFieldType());
assertEquals(long.class,
ValueModel.acquire(FiveLongAndBooleanValues.class).firstPrimitiveFieldType());
assertSame(int.class, ValueModel.acquire(IntValue.class).firstPrimitiveFieldType());
assertSame(long.class, ValueModel.acquire(LongValue.class).firstPrimitiveFieldType());
assertSame(long.class, ValueModel.acquire(Values.nativeClassFor(LongValue.class))
.firstPrimitiveFieldType());
assertSame(long.class, ValueModel.acquire(FiveLongValues.class).firstPrimitiveFieldType());
assertSame(boolean.class, ValueModel.acquire(FiveBooleanValues.class).firstPrimitiveFieldType());
assertSame(long.class, ValueModel.acquire(FiveLongAndBooleanValues.class).firstPrimitiveFieldType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
package net.openhft.chronicle.values;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class UnderscoreFieldNameTest extends ValuesTestCommon {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.bytes.BytesStore;
import net.openhft.chronicle.core.values.LongValue;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.lang.reflect.InvocationTargetException;
import java.nio.ByteBuffer;
Expand All @@ -17,7 +17,7 @@
import static net.openhft.chronicle.values.Generators.generateNativeClass;
import static net.openhft.chronicle.values.Values.newHeapInstance;
import static net.openhft.chronicle.values.Values.newNativeReference;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static net.openhft.compiler.CompilerUtils.CACHED_COMPILER;

/**
Expand Down Expand Up @@ -87,8 +87,8 @@ public void testGenerateJavaCode2() {
assertTrue(mi2.flag());
}

@SuppressWarnings("rawtypes")
@Test
@SuppressWarnings("rawtypes")
public void testGenerateNativeWithGetUsing() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
String actual = generateNativeClass(ValueModel.acquire(JavaBeanInterfaceGetUsing.class),
ValueModel.simpleName(JavaBeanInterfaceGetUsing.class) + "$$Native");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import net.openhft.chronicle.bytes.Byteable;
import net.openhft.chronicle.bytes.BytesStore;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static net.openhft.chronicle.values.ValueInterfaceWithEnumTest.SimpleValueInterface.SVIEnum.SIX;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

/**
* @author ges
Expand All @@ -20,8 +20,8 @@ public class ValueInterfaceWithEnumTest extends ValuesTestCommon {
* This test will throw an {@link ArrayIndexOutOfBoundsException}. This seems to occur only with Enums having even number of
* values
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void testValueInterface() {
SimpleValueInterface nativeValue = Values.newNativeReference(SimpleValueInterface.class);
int modelSize = ValueModel.acquire(SimpleValueInterface.class).sizeInBytes();
Expand All @@ -35,7 +35,7 @@ public void testValueInterface() {
heapValue.copyFrom(nativeValue);

assertEquals(1, heapValue.getId());
assertEquals(true, heapValue.getTruth());
assertTrue(heapValue.getTruth());
assertEquals(SIX, heapValue.getSVIEnum());

heapValue.setId(2);
Expand All @@ -45,7 +45,7 @@ public void testValueInterface() {
nativeValue.copyFrom(heapValue);

assertEquals(2, nativeValue.getId());
assertEquals(false, nativeValue.getTruth());
assertFalse(nativeValue.getTruth());
assertEquals(null, nativeValue.getSVIEnum());
}

Expand Down
16 changes: 10 additions & 6 deletions src/test/java/net/openhft/chronicle/values/ValuesTestCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import net.openhft.chronicle.core.threads.CleaningThread;
import net.openhft.chronicle.core.threads.ThreadDump;
import net.openhft.chronicle.core.time.SystemTimeProvider;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -32,7 +32,13 @@
private Map<ExceptionKey, Integer> exceptions;
private final Map<Predicate<ExceptionKey>, String> expectedExceptions = new LinkedHashMap<>();

@Before
@BeforeEach
public void beforeEachValuesTestCommon() {

Check warning on line 36 in src/test/java/net/openhft/chronicle/values/ValuesTestCommon.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=OpenHFT_Chronicle-Values&issues=AZ0_AaPojPYQPFDxbwW6&open=AZ0_AaPojPYQPFDxbwW6&pullRequest=168
enableReferenceTracing();
threadDump();
recordExceptions();
}

public void enableReferenceTracing() {
AbstractReferenceCounted.enableReferenceTracing();
}
Expand All @@ -45,7 +51,6 @@
AbstractReferenceCounted.assertReferencesReleased();
}

@Before
public void threadDump() {
threadDump = new ThreadDump();
}
Expand All @@ -54,7 +59,6 @@
threadDump.assertNoNewThreads();
}

@Before
public void recordExceptions() {
exceptions = Jvm.recordExceptions();
}
Expand Down Expand Up @@ -98,7 +102,7 @@
}
}

@After
@AfterEach
public void afterChecks() {
SystemTimeProvider.CLOCK = SystemTimeProvider.INSTANCE;
CleaningThread.performCleanup(Thread.currentThread());
Expand Down
15 changes: 7 additions & 8 deletions src/test/java/net/openhft/chronicle/values/VolatileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,32 @@

import net.openhft.chronicle.bytes.Byteable;
import net.openhft.chronicle.bytes.BytesStore;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.nio.ByteBuffer;

import static net.openhft.chronicle.values.Values.newHeapInstance;
import static net.openhft.chronicle.values.Values.newNativeReference;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.*;

/*
* Created by daniel on 11/06/2014.
*/
public class VolatileTest extends ValuesTestCommon {
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void testGenerateJavaCode() throws ClassNotFoundException, IllegalAccessException, InstantiationException {

/* try{
BadInterface1 jbi = dvg.heapInstance(BadInterface1.class);
assertFalse("Should have thrown an IllegalArgumentException", true);
assertFalse(true, "Should have thrown an IllegalArgumentException");
}catch(AssertionError e){
assertTrue("Throws an IllegalArgumentException", true);
}

try{
BadInterface2 jbi = dvg.heapInstance(BadInterface2.class);
assertFalse("Should have thrown an IllegalArgumentException", true);
assertFalse(true, "Should have thrown an IllegalArgumentException");
}catch(AssertionError e){
assertTrue("Throws an IllegalArgumentException", true);
}
Expand All @@ -53,7 +52,7 @@ public void testGenerateJavaCode() throws ClassNotFoundException, IllegalAccessE
assertEquals(3, jbi.getVolatileIntAt(3));
} catch (AssertionError e) {
e.printStackTrace();
assertFalse("Throws an IllegalArgumentException", true);
assertFalse(true, "Throws an IllegalArgumentException");
}

//Test the native interface
Expand All @@ -75,7 +74,7 @@ public void testGenerateJavaCode() throws ClassNotFoundException, IllegalAccessE
assertEquals(3, jbi.getVolatileIntAt(3));
} catch (AssertionError e) {
e.printStackTrace();
assertFalse("Throws an IllegalArgumentException", true);
assertFalse(true, "Throws an IllegalArgumentException");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import net.openhft.chronicle.values.Values;
import net.openhft.chronicle.values.ValuesTestCommon;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ChronicleValueTypeTest extends ValuesTestCommon {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import net.openhft.chronicle.values.NotNull;
import net.openhft.chronicle.values.Values;
import net.openhft.chronicle.values.ValuesTestCommon;
import org.junit.Test;
import org.junit.jupiter.api.Test;

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

/**
* Tests that heap and native {@link Entity} values hold the same content but
Expand All @@ -33,8 +32,8 @@ public void heap() {
/**
* Exercises a native reference and checks it behaves like the heap variant.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
@SuppressWarnings({"rawtypes", "unchecked"})
public void nativeRef() {
Entity entity = Values.newNativeReference(Entity.class);
byte[] bytes = new byte[7];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import net.openhft.chronicle.values.Values;
import net.openhft.chronicle.values.ValuesTestCommon;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static java.util.Objects.requireNonNull;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

public class PointerTest extends ValuesTestCommon {

Expand Down