Skip to content

Commit 1dc40e4

Browse files
committed
Final (?) changes for Junit5 migration
1 parent 83dd8ea commit 1dc40e4

File tree

21 files changed

+415
-606
lines changed

21 files changed

+415
-606
lines changed

app/alarm/datasource/src/test/java/org/phoebus/pv/alarm/AlarmContextTest.java

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@ public void testURLEncoding()
1717
String encodedPathWithColon = "OPR/TEST/SR%3Atest%3Apv";
1818
String encodedPathWithDelimiterAndColon = "OPR/TEST/sim%3A%2F%2FSR%3Atest%3Apv";
1919

20-
assertEquals("Failed to encode pv name the delimiter", encodedPathWithDelimiter, AlarmContext.encodedURLPath(pathWithDelimiter));
21-
assertEquals("Failed to encode pv name with colon", encodedPathWithColon, AlarmContext.encodedURLPath(pathWithColon));
22-
assertEquals("Failed to encode pv name with delimiter and colon", encodedPathWithDelimiterAndColon, AlarmContext.encodedURLPath(pathWithDelimiterAndColon));
20+
assertEquals(
21+
encodedPathWithDelimiter,
22+
AlarmContext.encodedURLPath(pathWithDelimiter),
23+
"Failed to encode pv name the delimiter");
24+
assertEquals(
25+
encodedPathWithColon,
26+
AlarmContext.encodedURLPath(pathWithColon),
27+
"Failed to encode pv name with colon");
28+
assertEquals(
29+
encodedPathWithDelimiterAndColon,
30+
AlarmContext.encodedURLPath(pathWithDelimiterAndColon),
31+
"Failed to encode pv name with delimiter and colon");
2332
}
2433

2534
@Test
@@ -33,9 +42,18 @@ public void testURLDecoding()
3342
String encodedPathWithColon = "OPR/TEST/SR%3Atest%3Apv";
3443
String encodedPathWithDelimiterAndColon = "OPR/TEST/sim%3A%2F%2FSR%3Atest%3Apv";
3544

36-
assertEquals("Failed to decode pv name the delimiter", pathWithDelimiter, AlarmContext.decodedURLPath(encodedPathWithDelimiter));
37-
assertEquals("Failed to decode pv name with colon", pathWithColon, AlarmContext.decodedURLPath(encodedPathWithColon));
38-
assertEquals("Failed to decode pv name with delimiter and colon", pathWithDelimiterAndColon, AlarmContext.decodedURLPath(encodedPathWithDelimiterAndColon));
45+
assertEquals(
46+
pathWithDelimiter,
47+
AlarmContext.decodedURLPath(encodedPathWithDelimiter),
48+
"Failed to decode pv name the delimiter");
49+
assertEquals(
50+
pathWithColon,
51+
AlarmContext.decodedURLPath(encodedPathWithColon),
52+
"Failed to decode pv name with colon");
53+
assertEquals(
54+
pathWithDelimiterAndColon,
55+
AlarmContext.decodedURLPath(encodedPathWithDelimiterAndColon),
56+
"Failed to decode pv name with delimiter and colon");
3957
}
4058

4159
@Test
@@ -49,8 +67,17 @@ public void testKafkaPathDecoding()
4967
String encodedPathWithColon = "OPR/TEST/SR:test:pv";
5068
String encodedPathWithDelimiterAndColon = "OPR/TEST/sim:\\/\\/SR:test:pv";
5169

52-
assertEquals("Failed to decode pv kafka path the delimiter", pathWithDelimiter, AlarmContext.decodedKafaPath(encodedPathWithDelimiter));
53-
assertEquals("Failed to decode pv kafka path with colon", pathWithColon, AlarmContext.decodedKafaPath(encodedPathWithColon));
54-
assertEquals("Failed to decode pv kafka path with delimiter and colon", pathWithDelimiterAndColon, AlarmContext.decodedKafaPath(encodedPathWithDelimiterAndColon));
70+
assertEquals(
71+
pathWithDelimiter,
72+
AlarmContext.decodedKafaPath(encodedPathWithDelimiter),
73+
"Failed to decode pv kafka path the delimiter");
74+
assertEquals(
75+
pathWithColon,
76+
AlarmContext.decodedKafaPath(encodedPathWithColon),
77+
"Failed to decode pv kafka path with colon");
78+
assertEquals(
79+
pathWithDelimiterAndColon,
80+
AlarmContext.decodedKafaPath(encodedPathWithDelimiterAndColon),
81+
"Failed to decode pv kafka path with delimiter and colon");
5582
}
5683
}

app/alarm/datasource/src/test/java/org/phoebus/pv/alarm/AlarmPVInfoTest.java

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,33 @@ public class AlarmPVInfoTest {
1717
public void parsePath()
1818
{
1919
AlarmPVInfo alarmPVInfo = AlarmPVInfo.of(onlyRoot);
20-
assertEquals("Failed to parse the root info for pv: " + onlyRoot,
21-
alarmPVInfo.getRoot(), "root");
20+
assertEquals(
21+
alarmPVInfo.getRoot(), "root",
22+
"Failed to parse the root info for pv: " + onlyRoot);
2223
assertEquals(
2324
alarmPVInfo.getPath(), Optional.empty(),
2425
"Failed to parse the path info for pv: " + onlyRoot);
2526

2627
alarmPVInfo = AlarmPVInfo.of(oneNode);
27-
assertEquals("Failed to parse the root info for pv: " + oneNode,
28-
alarmPVInfo.getRoot(), "root");
28+
assertEquals(
29+
alarmPVInfo.getRoot(), "root",
30+
"Failed to parse the root info for pv: " + oneNode);
2931
assertEquals(
3032
alarmPVInfo.getPath(), Optional.of("/firstNode"),
3133
"Failed to parse the path info for pv: " + oneNode);
3234

3335
alarmPVInfo = AlarmPVInfo.of(twoNode);
34-
assertEquals("Failed to parse the root info for pv: " + twoNode,
35-
alarmPVInfo.getRoot(), "root");
36+
assertEquals(
37+
alarmPVInfo.getRoot(), "root",
38+
"Failed to parse the root info for pv: " + twoNode);
3639
assertEquals(
3740
alarmPVInfo.getPath(), Optional.of("/firstNode/secondNode"),
3841
"Failed to parse the path info for pv: " + twoNode);
3942

4043
alarmPVInfo = AlarmPVInfo.of(leaf);
41-
assertEquals("Failed to parse the root info for pv: " + leaf,
42-
alarmPVInfo.getRoot(), "root");
44+
assertEquals(
45+
alarmPVInfo.getRoot(), "root",
46+
"Failed to parse the root info for pv: " + leaf);
4347
assertEquals(
4448
alarmPVInfo.getPath(), Optional.of("/firstNode/secondNode/alarmPV"),
4549
"Failed to parse the path info for pv: " + leaf);
@@ -54,24 +58,28 @@ public void parsePath()
5458
public void parseCompletePath()
5559
{
5660
AlarmPVInfo alarmPVInfo = AlarmPVInfo.of(onlyRoot);
57-
assertEquals("Failed to parse the complete path info for pv: " + onlyRoot,
61+
assertEquals(
5862
"/root",
59-
alarmPVInfo.getCompletePath());
63+
alarmPVInfo.getCompletePath(),
64+
"Failed to parse the complete path info for pv: " + onlyRoot);
6065

6166
alarmPVInfo = AlarmPVInfo.of(oneNode);
62-
assertEquals("Failed to parse the complete path info for pv: " + onlyRoot,
67+
assertEquals(
6368
"/root/firstNode",
64-
alarmPVInfo.getCompletePath());
69+
alarmPVInfo.getCompletePath(),
70+
"Failed to parse the complete path info for pv: " + onlyRoot);
6571

6672
alarmPVInfo = AlarmPVInfo.of(twoNode);
67-
assertEquals("Failed to parse the complete path info for pv: " + onlyRoot,
73+
assertEquals(
6874
"/root/firstNode/secondNode",
69-
alarmPVInfo.getCompletePath());
75+
alarmPVInfo.getCompletePath(),
76+
"Failed to parse the complete path info for pv: " + onlyRoot);
7077

7178
alarmPVInfo = AlarmPVInfo.of(leaf);
72-
assertEquals("Failed to parse the complete path info for pv: " + onlyRoot,
79+
assertEquals(
7380
"/root/firstNode/secondNode/alarmPV",
74-
alarmPVInfo.getCompletePath());
81+
alarmPVInfo.getCompletePath(),
82+
"Failed to parse the complete path info for pv: " + onlyRoot);
7583
}
7684

7785
String activeField = "active";
@@ -86,56 +94,64 @@ public void parseCompletePath()
8694
public void parseFields()
8795
{
8896
AlarmPVInfo alarmPVInfo = AlarmPVInfo.of(onlyRoot+"."+activeField);
89-
assertEquals("Failed to parse the root info for pv: " + onlyRoot,
90-
alarmPVInfo.getRoot(), "root");
97+
assertEquals(
98+
alarmPVInfo.getRoot(), "root",
99+
"Failed to parse the root info for pv: " + onlyRoot);
91100
assertEquals(
92101
alarmPVInfo.getPath(), Optional.empty(),
93102
"Failed to parse the path info for pv: " + onlyRoot);
94-
assertEquals("Failed to parse the complete path info for pv: " + onlyRoot,
103+
assertEquals(
95104
"/root",
96-
alarmPVInfo.getCompletePath());
105+
alarmPVInfo.getCompletePath(),
106+
"Failed to parse the complete path info for pv: " + onlyRoot);
97107
assertEquals(
98108
Optional.of(activeField),
99109
alarmPVInfo.getField(),
100110
"Failed to parse the field path info for pv: " + onlyRoot);
101111

102112
alarmPVInfo = AlarmPVInfo.of(onlyRoot+"."+stateField);
103-
assertEquals("Failed to parse the root info for pv: " + onlyRoot,
104-
alarmPVInfo.getRoot(), "root");
113+
assertEquals(
114+
alarmPVInfo.getRoot(), "root",
115+
"Failed to parse the root info for pv: " + onlyRoot);
105116
assertEquals(
106117
alarmPVInfo.getPath(), Optional.empty(),
107118
"Failed to parse the path info for pv: " + onlyRoot);
108-
assertEquals("Failed to parse the complete path info for pv: " + onlyRoot,
119+
assertEquals(
109120
"/root",
110-
alarmPVInfo.getCompletePath());
121+
alarmPVInfo.getCompletePath(),
122+
"Failed to parse the complete path info for pv: " + onlyRoot);
111123
assertEquals(
112124
Optional.of(stateField),
113125
alarmPVInfo.getField(),
114126
"Failed to parse the field path info for pv: " + onlyRoot);
115127

116128
alarmPVInfo = AlarmPVInfo.of(onlyRoot+"."+enableField);
117-
assertEquals("Failed to parse the root info for pv: " + onlyRoot,
118-
alarmPVInfo.getRoot(), "root");
129+
assertEquals(
130+
alarmPVInfo.getRoot(), "root",
131+
"Failed to parse the root info for pv: " + onlyRoot);
119132
assertEquals(
120133
alarmPVInfo.getPath(), Optional.empty(),
121134
"Failed to parse the path info for pv: " + onlyRoot);
122-
assertEquals("Failed to parse the complete path info for pv: " + onlyRoot,
135+
assertEquals(
123136
"/root",
124-
alarmPVInfo.getCompletePath());
137+
alarmPVInfo.getCompletePath(),
138+
"Failed to parse the complete path info for pv: " + onlyRoot);
125139
assertEquals(
126140
Optional.of(enableField),
127141
alarmPVInfo.getField(),
128142
"Failed to parse the field path info for pv: " + onlyRoot);
129143

130144
alarmPVInfo = AlarmPVInfo.of(onlyRoot+"."+durationField);
131-
assertEquals("Failed to parse the root info for pv: " + onlyRoot,
132-
alarmPVInfo.getRoot(), "root");
145+
assertEquals(
146+
alarmPVInfo.getRoot(), "root",
147+
"Failed to parse the root info for pv: " + onlyRoot);
133148
assertEquals(
134149
alarmPVInfo.getPath(), Optional.empty(),
135150
"Failed to parse the path info for pv: " + onlyRoot);
136-
assertEquals("Failed to parse the complete path info for pv: " + onlyRoot,
151+
assertEquals(
137152
"/root",
138-
alarmPVInfo.getCompletePath());
153+
alarmPVInfo.getCompletePath(),
154+
"Failed to parse the complete path info for pv: " + onlyRoot);
139155
assertEquals(
140156
Optional.of(durationField),
141157
alarmPVInfo.getField(),

app/display/model/src/test/java/org/csstudio/display/builder/PathTest.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
*******************************************************************************/
88
package org.csstudio.display.builder;
99

10-
import static org.hamcrest.CoreMatchers.equalTo;
11-
import static org.hamcrest.MatcherAssert.assertThat;
12-
import static org.junit.jupiter.api.Assumptions.*;
13-
1410
import org.csstudio.display.builder.model.util.ModelResourceUtil;
1511
import org.junit.jupiter.api.Test;
16-
import org.phoebus.ui.javafx.PlatformInfo;
12+
import org.junit.jupiter.api.condition.DisabledOnOs;
13+
import org.junit.jupiter.api.condition.EnabledOnOs;
14+
import org.junit.jupiter.api.condition.OS;
15+
16+
import static org.hamcrest.CoreMatchers.equalTo;
17+
import static org.hamcrest.MatcherAssert.assertThat;
1718

1819
/** JUnit test of path handling
1920
* @author Kay Kasemir
@@ -22,7 +23,7 @@
2223
public class PathTest
2324
{
2425
@Test
25-
public void testNormalize() throws Exception
26+
public void testNormalize()
2627
{
2728
String path;
2829

@@ -57,10 +58,7 @@ public void testDirectory()
5758
@Test
5859
public void testCombineNotWindows()
5960
{
60-
//assumingThat(false, () -> PlatformInfo.isWindows);
61-
String path;
62-
63-
path = ModelResourceUtil.combineDisplayPaths(null, "example.opi");
61+
String path = ModelResourceUtil.combineDisplayPaths(null, "example.opi");
6462
assertThat(path, equalTo("example.opi"));
6563

6664
path = ModelResourceUtil.combineDisplayPaths("examples/dummy.opi", "example.opi");
@@ -77,12 +75,10 @@ public void testCombineNotWindows()
7775
}
7876

7977
@Test
78+
@EnabledOnOs(OS.WINDOWS)
8079
public void testCombineWindows()
8180
{
82-
//assumeThat(PlatformInfo.isWindows, equalTo(true));
83-
String path;
84-
85-
path = ModelResourceUtil.combineDisplayPaths(null, "example.opi");
81+
String path = ModelResourceUtil.combineDisplayPaths(null, "example.opi");
8682
assertThat(path, equalTo("example.opi"));
8783

8884
path = ModelResourceUtil.combineDisplayPaths("examples/dummy.opi", "example.opi");
@@ -105,9 +101,9 @@ public void checkRelativePath(String parent, String path, String expectedResult)
105101
}
106102

107103
@Test
104+
@DisabledOnOs(OS.WINDOWS)
108105
public void testRelativeNotWindows()
109106
{
110-
//assumeThat(PlatformInfo.isWindows, equalTo(false));
111107
String parent = "/one/of/my/directories/parent.bob";
112108

113109
// Same dir
@@ -146,9 +142,9 @@ public void testRelativeNotWindows()
146142
}
147143

148144
@Test
145+
@EnabledOnOs(OS.WINDOWS)
149146
public void testRelativeWindows()
150147
{
151-
//assumeThat(PlatformInfo.isWindows, equalTo(true));
152148
String parent = "C:\\one\\of\\my\\directories\\parent.bob";
153149

154150
// Same dir

app/rtplot/src/test/java/org/csstudio/javafx/rtplot/TicksTestBase.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
package org.csstudio.javafx.rtplot;
99

1010
import static org.hamcrest.CoreMatchers.equalTo;
11-
import static org.junit.Assert.assertThat;
11+
import static org.hamcrest.MatcherAssert.*;
1212

1313
import java.awt.Graphics2D;
1414
import java.awt.image.BufferedImage;
@@ -20,28 +20,29 @@
2020
import org.csstudio.javafx.rtplot.internal.MajorTick;
2121
import org.csstudio.javafx.rtplot.internal.MinorTick;
2222
import org.csstudio.javafx.rtplot.internal.Ticks;
23-
import org.junit.After;
24-
import org.junit.BeforeClass;
25-
import org.junit.Test;
23+
import org.junit.jupiter.api.AfterAll;
24+
import org.junit.jupiter.api.BeforeAll;
25+
import org.junit.jupiter.api.Test;
26+
2627

2728
/** Helper for testing ticks
2829
* @author Kay Kasemir
2930
*/
3031
@SuppressWarnings("nls")
3132
public class TicksTestBase
3233
{
33-
final BufferedImage buf = new BufferedImage(400, 50, BufferedImage.TYPE_INT_ARGB);
34-
final Graphics2D gc = buf.createGraphics();
34+
final static BufferedImage buf = new BufferedImage(400, 50, BufferedImage.TYPE_INT_ARGB);
35+
final static Graphics2D gc = buf.createGraphics();
3536

36-
@BeforeClass
37+
@BeforeAll
3738
public static void setup()
3839
{
3940
// Set locate for predictable formatting results
4041
Locale.setDefault(Locale.US);
4142
}
4243

43-
@After
44-
public void cleanup()
44+
@AfterAll
45+
public static void cleanup()
4546
{
4647
gc.dispose();
4748
}

app/update/src/test/java/org/phoebus/applications/update/PathWranglerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
package org.phoebus.applications.update;
99

1010
import static org.hamcrest.CoreMatchers.equalTo;
11-
import static MatcherAssert.*;
11+
import static org.hamcrest.MatcherAssert.assertThat;
1212

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

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<mysql.version>8.0.30</mysql.version>
7070
<jetty.version>9.4.30.v20200611</jetty.version>
7171
<apache.commons.math.version>3.6.1</apache.commons.math.version>
72-
<junit.version>5.8.1</junit.version>
72+
<junit.version>5.8.2</junit.version>
7373
<elasticsearch.version>8.2.0</elasticsearch.version>
7474
<!--<maven.repo.local>${project.build.directory}/.m2</maven.repo.local> -->
7575
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

services/alarm-logger/pom.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,21 @@
126126
<groupId>org.springframework.boot</groupId>
127127
<artifactId>spring-boot-starter-test</artifactId>
128128
<scope>test</scope>
129+
<exclusions>
130+
<exclusion>
131+
<groupId>org.junit.jupiter</groupId>
132+
<artifactId>junit-jupiter</artifactId>
133+
</exclusion>
134+
</exclusions>
129135
</dependency>
136+
130137
<dependency>
131-
<groupId>junit</groupId>
132-
<artifactId>junit</artifactId>
138+
<groupId>org.junit.jupiter</groupId>
139+
<artifactId>junit-jupiter</artifactId>
140+
<version>${junit.version}</version>
133141
<scope>test</scope>
134142
</dependency>
135143

136-
137144
</dependencies>
138145
<build>
139146
<plugins>

0 commit comments

Comments
 (0)