Skip to content

Commit baea4e2

Browse files
committed
Fixed Maven in integration profile
1 parent 63b8b17 commit baea4e2

119 files changed

Lines changed: 126 additions & 33 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cs-comparison.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ jobs:
2525
restore-keys: |
2626
${{ runner.os }}-maven-
2727
28-
# Run the comparison using the test classpath
29-
- name: Build and run CS Comparison
28+
- name: Build and run CS comparison
3029
run: |
3130
chmod +x ./mvnw
32-
./mvnw -B test-compile -DskipTests
33-
./mvnw -B exec:java -DskipTests -Dexec.mainClass=com.imsweb.staging.cs.CsIntegrationTest -Dexec.classpathScope=test
31+
./mvnw -B -Pcs-comparison verify

pom.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,64 @@
267267
</build>
268268

269269
<profiles>
270+
<profile>
271+
<id>cs-comparison</id>
272+
<build>
273+
<plugins>
274+
<plugin>
275+
<groupId>org.codehaus.mojo</groupId>
276+
<artifactId>build-helper-maven-plugin</artifactId>
277+
<version>3.6.1</version>
278+
<executions>
279+
<execution>
280+
<id>add-cs-comparison-test-source</id>
281+
<phase>generate-test-sources</phase>
282+
<goals>
283+
<goal>add-test-source</goal>
284+
</goals>
285+
<configuration>
286+
<sources>
287+
<source>src/cs-comparison/java</source>
288+
</sources>
289+
</configuration>
290+
</execution>
291+
<execution>
292+
<id>add-cs-comparison-test-resource</id>
293+
<phase>generate-test-resources</phase>
294+
<goals>
295+
<goal>add-test-resource</goal>
296+
</goals>
297+
<configuration>
298+
<resources>
299+
<resource>
300+
<directory>src/cs-comparison/resources</directory>
301+
</resource>
302+
</resources>
303+
</configuration>
304+
</execution>
305+
</executions>
306+
</plugin>
307+
<plugin>
308+
<groupId>org.codehaus.mojo</groupId>
309+
<artifactId>exec-maven-plugin</artifactId>
310+
<version>3.6.3</version>
311+
<executions>
312+
<execution>
313+
<id>run-cs-comparison</id>
314+
<phase>integration-test</phase>
315+
<goals>
316+
<goal>java</goal>
317+
</goals>
318+
<configuration>
319+
<mainClass>com.imsweb.staging.cs.CsComparisonRunner</mainClass>
320+
<classpathScope>test</classpathScope>
321+
</configuration>
322+
</execution>
323+
</executions>
324+
</plugin>
325+
</plugins>
326+
</build>
327+
</profile>
270328
<profile>
271329
<id>release</id>
272330
<build>

src/test/java/com/imsweb/staging/cs/CsIntegrationTest.java renamed to src/cs-comparison/java/com/imsweb/staging/cs/CsComparisonRunner.java

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
*/
44
package com.imsweb.staging.cs;
55

6+
import static com.imsweb.staging.StagingTest.getAlgorithmPath;
7+
8+
import com.imsweb.staging.ExternalStagingFileDataProvider;
9+
import com.imsweb.staging.Staging;
10+
import com.imsweb.staging.cs.IntegrationUtils.IntegrationResult;
11+
import com.imsweb.staging.util.Stopwatch;
612
import java.io.BufferedReader;
713
import java.io.IOException;
814
import java.io.InputStreamReader;
@@ -15,21 +21,12 @@
1521
import java.util.Objects;
1622
import java.util.concurrent.TimeUnit;
1723
import java.util.zip.GZIPInputStream;
18-
1924
import org.slf4j.Logger;
2025
import org.slf4j.LoggerFactory;
2126

22-
import com.imsweb.staging.ExternalStagingFileDataProvider;
23-
import com.imsweb.staging.Staging;
24-
import com.imsweb.staging.cs.IntegrationUtils.IntegrationResult;
25-
import com.imsweb.staging.util.Stopwatch;
27+
public class CsComparisonRunner {
2628

27-
import static com.imsweb.staging.StagingTest.getAlgorithmPath;
28-
29-
@SuppressWarnings("java:S2187")
30-
public class CsIntegrationTest {
31-
32-
private static final Logger _LOG = LoggerFactory.getLogger(CsIntegrationTest.class);
29+
private static final Logger _LOG = LoggerFactory.getLogger(CsComparisonRunner.class);
3330

3431
// set this to null to process all, or a list of schema filename to process
3532
private static final List<String> _SCHEMA_FILES = Collections.emptyList();
@@ -43,8 +40,17 @@ private static void execute() throws IOException, InterruptedException, URISynta
4340

4441
// only do schema selection test if running all schemas
4542
if (_SCHEMA_FILES.isEmpty()) {
46-
IntegrationUtils.processSchemaSelection(staging, "cs_schema_identification.txt.gz",
47-
new GZIPInputStream(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("cs/integration/schema_selection/cs_schema_identification.txt.gz"))));
43+
IntegrationUtils.processSchemaSelection(
44+
staging,
45+
"cs_schema_identification.txt.gz",
46+
new GZIPInputStream(
47+
Objects.requireNonNull(
48+
Thread.currentThread()
49+
.getContextClassLoader()
50+
.getResourceAsStream("cs/integration/schema_selection/cs_schema_identification.txt.gz")
51+
)
52+
)
53+
);
4854

4955
_LOG.info("-----------------------------------------------");
5056
}
@@ -55,8 +61,18 @@ private static void execute() throws IOException, InterruptedException, URISynta
5561
// NOTE: some of these files are REALLY large; so they are not included in the project for now; all files larger than 2MB (40 of them) are not
5662
// part of the repository and can be found at \\omni\btp\csb\Staging\CS
5763
List<String> schemaFiles;
58-
try (BufferedReader buffer = new BufferedReader(
59-
new InputStreamReader(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("cs/integration/schemas/index.txt")), StandardCharsets.UTF_8))) {
64+
try (
65+
BufferedReader buffer = new BufferedReader(
66+
new InputStreamReader(
67+
Objects.requireNonNull(
68+
Thread.currentThread()
69+
.getContextClassLoader()
70+
.getResourceAsStream("cs/integration/schemas/index.txt")
71+
),
72+
StandardCharsets.UTF_8
73+
)
74+
)
75+
) {
6076
schemaFiles = buffer.lines().toList();
6177
}
6278

@@ -67,26 +83,45 @@ private static void execute() throws IOException, InterruptedException, URISynta
6783
for (String schemaFile : schemaFiles) {
6884
if (_SCHEMA_FILES.isEmpty() || _SCHEMA_FILES.contains(schemaFile)) {
6985
totalFiles += 1;
70-
IntegrationResult result = IntegrationUtils.processSchema(staging, schemaFile,
71-
new GZIPInputStream(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResourceAsStream("cs/integration/schemas/" + schemaFile))));
86+
IntegrationResult result = IntegrationUtils.processSchema(
87+
staging,
88+
schemaFile,
89+
new GZIPInputStream(
90+
Objects.requireNonNull(
91+
Thread.currentThread()
92+
.getContextClassLoader()
93+
.getResourceAsStream("cs/integration/schemas/" + schemaFile)
94+
)
95+
)
96+
);
7297
totalCases += result.getNumCases();
7398
totalFailures += result.getNumFailures();
7499
}
75100
}
76101

77102
stopwatch.stop();
78103

79-
String perMs = String.format("%.3f", ((float)stopwatch.elapsed(TimeUnit.MILLISECONDS) / totalCases));
104+
String perMs = String.format("%.3f", (float) stopwatch.elapsed(TimeUnit.MILLISECONDS) / totalCases);
80105
_LOG.info("");
81-
_LOG.info("Completed {} cases ({} files) in {} ({}ms/case).", NumberFormat.getNumberInstance(Locale.US).format(totalCases), totalFiles, stopwatch, perMs);
82-
if (totalFailures > 0)
83-
_LOG.error("There were {} failing cases.", NumberFormat.getNumberInstance(Locale.US).format(totalFailures));
106+
_LOG.info(
107+
"Completed {} cases ({} files) in {} ({}ms/case).",
108+
NumberFormat.getNumberInstance(Locale.US).format(totalCases),
109+
totalFiles,
110+
stopwatch,
111+
perMs
112+
);
113+
if (totalFailures > 0) _LOG.error(
114+
"There were {} failing cases.",
115+
NumberFormat.getNumberInstance(Locale.US).format(totalFailures)
116+
);
84117
failIfNecessary(totalFailures);
85118
}
86119

87120
static void failIfNecessary(long totalFailures) {
88-
if (totalFailures > 0)
89-
throw new IllegalStateException("CS comparison failed with " + NumberFormat.getNumberInstance(Locale.US).format(totalFailures) + " failing cases.");
121+
if (totalFailures > 0) throw new IllegalStateException(
122+
"CS comparison failed with " +
123+
NumberFormat.getNumberInstance(Locale.US).format(totalFailures) +
124+
" failing cases."
125+
);
90126
}
91-
92127
}

src/test/java/com/imsweb/staging/cs/CsIntegrationTestTest.java renamed to src/cs-comparison/java/com/imsweb/staging/cs/CsComparisonRunnerTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
*/
44
package com.imsweb.staging.cs;
55

6-
import org.junit.jupiter.api.Test;
7-
86
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
97
import static org.junit.jupiter.api.Assertions.assertEquals;
108
import static org.junit.jupiter.api.Assertions.assertThrows;
119

12-
class CsIntegrationTestTest {
10+
import org.junit.jupiter.api.Test;
11+
12+
class CsComparisonRunnerTest {
1313

1414
@Test
1515
void testNoFailures() {
16-
assertDoesNotThrow(() -> CsIntegrationTest.failIfNecessary(0));
16+
assertDoesNotThrow(() -> CsComparisonRunner.failIfNecessary(0));
1717
}
1818

1919
@Test
2020
void testFailures() {
21-
IllegalStateException exception = assertThrows(IllegalStateException.class, () -> CsIntegrationTest.failIfNecessary(1234));
21+
IllegalStateException exception = assertThrows(IllegalStateException.class, () ->
22+
CsComparisonRunner.failIfNecessary(1234)
23+
);
2224
assertEquals("CS comparison failed with 1,234 failing cases.", exception.getMessage());
2325
}
2426
}

src/test/resources/cs/integration/schema_selection/cs_schema_identification.txt.gz renamed to src/cs-comparison/resources/cs/integration/schema_selection/cs_schema_identification.txt.gz

File renamed without changes.

src/test/resources/cs/integration/schemas/adnexa_uterine_other.gz renamed to src/cs-comparison/resources/cs/integration/schemas/adnexa_uterine_other.gz

File renamed without changes.

src/test/resources/cs/integration/schemas/adrenal_gland.gz renamed to src/cs-comparison/resources/cs/integration/schemas/adrenal_gland.gz

File renamed without changes.

src/test/resources/cs/integration/schemas/ampulla_vater.gz renamed to src/cs-comparison/resources/cs/integration/schemas/ampulla_vater.gz

File renamed without changes.

src/test/resources/cs/integration/schemas/anus.gz renamed to src/cs-comparison/resources/cs/integration/schemas/anus.gz

File renamed without changes.

src/test/resources/cs/integration/schemas/bile_ducts_distal.gz renamed to src/cs-comparison/resources/cs/integration/schemas/bile_ducts_distal.gz

File renamed without changes.

0 commit comments

Comments
 (0)