Skip to content

Commit f73c178

Browse files
committed
Fix JUnit Jupiter migration: compilation errors from CI
- Fix @test(timeout=N) → @timeout + @test in SessionConcurrencyTest and MultimodalIntegrationTest - Fix @test(expected=X.class) → assertThrows() in ErrorHandlingTest, InferenceParametersTest, ParameterJsonSerializerTest - Fix @BeforeClass/@afterclass → @BeforeAll/@afterall across all affected test files - Fix broken imports: org.junit.assertNotEquals → org.junit.jupiter.api.Assertions.assertNotEquals - Fix org.junit.assertNull and org.junit.fail → static-imported equivalents - Add missing assertThrows imports in ContentPartTest, MultimodalMessagesTest, NativeLibraryPermissionSetterTest - Fix assertEquals argument order for float delta: message-first → message-last (RerankingModelTest) - Fix Assume.assumeNotNull → Assumptions.assumeTrue (LlamaEmbeddingsTest) https://claude.ai/code/session_01Wz6qiYa6SGNirh9tVs4jUL
1 parent bdaf0d2 commit f73c178

22 files changed

Lines changed: 61 additions & 50 deletions

src/test/java/net/ladenthin/llama/ChatAdvancedTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ChatAdvancedTest {
5353

5454
private static LlamaModel model;
5555

56-
@BeforeClass
56+
@BeforeAll
5757
public static void setup() {
5858
Assumptions.assumeTrue(new File(TestConstants.MODEL_PATH).exists(), "Model file not found, skipping ChatAdvancedTest");
5959
int gpuLayers = Integer.getInteger(TestConstants.PROP_TEST_NGL, TestConstants.DEFAULT_TEST_NGL);
@@ -66,7 +66,7 @@ public static void setup() {
6666
);
6767
}
6868

69-
@AfterClass
69+
@AfterAll
7070
public static void tearDown() {
7171
if (model != null) {
7272
model.close();

src/test/java/net/ladenthin/llama/ChatResponseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void buildMessagesJsonRoundTripsToolTurns() {
113113
@Test
114114
public void buildToolsJsonEmptyWhenNoTools() {
115115
ChatRequest req = new ChatRequest().addMessage("user", "hi");
116-
org.junit.assertNull(req.buildToolsJson());
116+
assertNull(req.buildToolsJson());
117117
}
118118

119119
@Test

src/test/java/net/ladenthin/llama/ChatScenarioTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ChatScenarioTest {
5353

5454
private static LlamaModel model;
5555

56-
@BeforeClass
56+
@BeforeAll
5757
public static void setup() {
5858
Assumptions.assumeTrue(new File(TestConstants.MODEL_PATH).exists(), "Model file not found, skipping ChatScenarioTest");
5959
int gpuLayers = Integer.getInteger(TestConstants.PROP_TEST_NGL, TestConstants.DEFAULT_TEST_NGL);
@@ -70,7 +70,7 @@ public static void setup() {
7070
);
7171
}
7272

73-
@AfterClass
73+
@AfterAll
7474
public static void tearDown() {
7575
if (model != null) {
7676
model.close();

src/test/java/net/ladenthin/llama/ConfigureParallelInferenceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class ConfigureParallelInferenceTest {
3232

3333
private static LlamaModel model;
3434

35-
@BeforeClass
35+
@BeforeAll
3636
public static void setup() {
3737
Assumptions.assumeTrue(new File(TestConstants.MODEL_PATH).exists(), "Model file not found, skipping ConfigureParallelInferenceTest");
3838
int gpuLayers = Integer.getInteger(TestConstants.PROP_TEST_NGL, TestConstants.DEFAULT_TEST_NGL);
@@ -45,7 +45,7 @@ public static void setup() {
4545
);
4646
}
4747

48-
@AfterClass
48+
@AfterAll
4949
public static void tearDown() {
5050
if (model != null) {
5151
model.close();

src/test/java/net/ladenthin/llama/ContentPartTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.junit.jupiter.api.Test;
1313
import org.junit.jupiter.api.io.TempDir;
1414

15+
import static org.junit.jupiter.api.Assertions.assertThrows;
1516
import static org.junit.jupiter.api.Assertions.assertEquals;
1617
import static org.junit.jupiter.api.Assertions.assertNotNull;
1718
import static org.junit.jupiter.api.Assertions.assertNull;

src/test/java/net/ladenthin/llama/ErrorHandlingTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ErrorHandlingTest {
3636
private static LlamaModel model;
3737
private static LlamaModel modelNoEmbed;
3838

39-
@BeforeClass
39+
@BeforeAll
4040
public static void setup() {
4141
Assumptions.assumeTrue(new File(TestConstants.MODEL_PATH).exists(), "Model file not found, skipping ErrorHandlingTest");
4242
int gpuLayers = Integer.getInteger(TestConstants.PROP_TEST_NGL, TestConstants.DEFAULT_TEST_NGL);
@@ -59,7 +59,7 @@ public static void setup() {
5959
);
6060
}
6161

62-
@AfterClass
62+
@AfterAll
6363
public static void tearDown() {
6464
if (model != null) {
6565
model.close();
@@ -73,22 +73,22 @@ public static void tearDown() {
7373
// Invalid model path
7474
// -------------------------------------------------------------------------
7575

76-
@Test(expected = LlamaException.class)
76+
@Test
7777
public void testInvalidModelPathThrows() {
78-
new LlamaModel(
78+
assertThrows(LlamaException.class, () -> new LlamaModel(
7979
new ModelParameters()
8080
.setModel("/nonexistent/path/model.gguf")
8181
.setFit(false)
82-
);
82+
));
8383
}
8484

85-
@Test(expected = LlamaException.class)
85+
@Test
8686
public void testEmptyModelPathThrows() {
87-
new LlamaModel(
87+
assertThrows(LlamaException.class, () -> new LlamaModel(
8888
new ModelParameters()
8989
.setModel("")
9090
.setFit(false)
91-
);
91+
));
9292
}
9393

9494
// -------------------------------------------------------------------------

src/test/java/net/ladenthin/llama/InferenceParametersTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,16 +556,16 @@ public void testSetMessagesEmptySystemMessage() {
556556
assertFalse(value.contains("system"));
557557
}
558558

559-
@Test(expected = IllegalArgumentException.class)
559+
@Test
560560
public void testSetMessagesInvalidRole() {
561561
List<Pair<String, String>> messages = Collections.singletonList(new Pair<>("system", "Bad"));
562-
new InferenceParameters("").setMessages(null, messages);
562+
assertThrows(IllegalArgumentException.class, () -> new InferenceParameters("").setMessages(null, messages));
563563
}
564564

565-
@Test(expected = IllegalArgumentException.class)
565+
@Test
566566
public void testSetMessagesInvalidRoleOther() {
567567
List<Pair<String, String>> messages = Collections.singletonList(new Pair<>("admin", "Hack"));
568-
new InferenceParameters("").setMessages(null, messages);
568+
assertThrows(IllegalArgumentException.class, () -> new InferenceParameters("").setMessages(null, messages));
569569
}
570570

571571
// -------------------------------------------------------------------------

src/test/java/net/ladenthin/llama/JsonEndpointParametersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class JsonEndpointParametersTest {
4545

4646
private static LlamaModel model;
4747

48-
@BeforeClass
48+
@BeforeAll
4949
public static void setup() {
5050
Assumptions.assumeTrue(new File(TestConstants.MODEL_PATH).exists(), "Model file not found, skipping JsonEndpointParametersTest");
5151
int gpuLayers = Integer.getInteger(TestConstants.PROP_TEST_NGL, TestConstants.DEFAULT_TEST_NGL);
@@ -58,7 +58,7 @@ public static void setup() {
5858
);
5959
}
6060

61-
@AfterClass
61+
@AfterAll
6262
public static void tearDown() {
6363
if (model != null) {
6464
model.close();

src/test/java/net/ladenthin/llama/LlamaEmbeddingsTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,8 @@ private static void assertEmbeddingValid(float[] embedding, PoolingType type) {
184184
@Test
185185
public void testNomicEmbedLoads() {
186186
String nomicPath = System.getProperty(TestConstants.PROP_NOMIC_MODEL_PATH);
187-
Assume.assumeNotNull(
188-
"Set -D" + TestConstants.PROP_NOMIC_MODEL_PATH + " to a nomic-embed-text GGUF to run this test",
189-
nomicPath);
187+
Assumptions.assumeTrue(nomicPath != null,
188+
"Set -D" + TestConstants.PROP_NOMIC_MODEL_PATH + " to a nomic-embed-text GGUF to run this test");
190189
Assumptions.assumeTrue(new File(nomicPath).exists(), "Nomic model file not found at " + nomicPath);
191190

192191
int gpuLayers = Integer.getInteger(TestConstants.PROP_TEST_NGL, TestConstants.DEFAULT_TEST_NGL);

src/test/java/net/ladenthin/llama/LlamaModelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class LlamaModelTest {
4444

4545
private static LlamaModel model;
4646

47-
@BeforeClass
47+
@BeforeAll
4848
public static void setup() {
4949
Assumptions.assumeTrue(new java.io.File("models/codellama-7b.Q2_K.gguf").exists(), "Model file not found, skipping LlamaModelTest");
5050
// LlamaModel.setLogger(LogFormat.TEXT, (level, msg) -> System.out.println(level + ": " + msg));
@@ -60,7 +60,7 @@ public static void setup() {
6060
);
6161
}
6262

63-
@AfterClass
63+
@AfterAll
6464
public static void tearDown() {
6565
if (model != null) {
6666
model.close();

0 commit comments

Comments
 (0)