Skip to content
Merged
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
2 changes: 1 addition & 1 deletion java/maven.junit/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

is.eager=true
javac.source=1.8
javac.release=17
javac.compilerargs=-Xlint -Xlint:-serial

test.config.stableBTD.includes=**/*Test.class
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static boolean isFullJavaId(String possibleNewRunningTestClass) {
"surefire.reportNameSuffix"); //NOI81N
testType = TESTTYPE_INTEGRATION; //NOI81N
}
if (null != reportsDirectory) {
if (reportsDirectory != null) {
File outputDir = null;
File absoluteFile = new File(reportsDirectory);
// configuration might be "target/directory", which is relative
Expand Down Expand Up @@ -314,14 +314,15 @@ static boolean isFullJavaId(String possibleNewRunningTestClass) {
}
}
}
if (null != outputDir) {
if (outputDir != null) {
createSession(outputDir);
OutputVisitor.Context context = visitor.getContext();
if (context != null) {
Project currentProject = context.getCurrentProject();
if (currentProject != null) {
project2outputDirs.put(currentProject, outputDir);
}
// may be null when EventSpy is not active
Project project = context != null && context.getCurrentProject() != null
? context.getCurrentProject()
: FileOwnerQuery.getOwner(Utilities.toURI(outputDir));
if (project != null) {
project2outputDirs.put(project, outputDir);
}
}
}
Expand Down Expand Up @@ -351,8 +352,8 @@ private String getReportsDirectory(String groupId, String artifactId, String goa
Object defaultValue = PluginPropertyUtils
.createEvaluator(currentProject)
.evaluate(fallbackExpression);
if (defaultValue instanceof String) {
reportsDirectory = (String) defaultValue;
if (defaultValue instanceof String str) {
reportsDirectory = str;
}
} catch (ExpressionEvaluationException ex) {
// NOP could not resolved default value
Expand All @@ -376,14 +377,14 @@ private String getReportsDirectory(String groupId, String artifactId, String goa
})
private String createSessionName(String projectId) {
String name;
if(testType != null && testType.equals(TESTTYPE_INTEGRATION)) {
if (TESTTYPE_INTEGRATION.equals(testType)) {
name = Bundle.LBL_TESTTYPE_INTEGRATION(projectId);
} else {
name = Bundle.LBL_TESTTYPE_UNIT(projectId);
}
int index = 2;
while (usedNames.contains(name)) {
if (testType != null && testType.equals(TESTTYPE_INTEGRATION)) {
if (TESTTYPE_INTEGRATION.equals(testType)) {
name = Bundle.LBL_TESTTYPE_INTEGRATION_INDEXED(projectId, index);
} else {
name = Bundle.LBL_TESTTYPE_UNIT_INDEXED(projectId, index);
Expand Down Expand Up @@ -590,7 +591,7 @@ private boolean usingJUnit4(MavenProject prj) { // SUREFIRE-724
}
}
return false;
}
}

public @Override void sequenceEnd(String sequenceId, OutputVisitor visitor) {
if (outputDir2sessions.isEmpty()) {
Expand All @@ -599,22 +600,32 @@ private boolean usingJUnit4(MavenProject prj) { // SUREFIRE-724
if (runningTestClass != null) {
generateTest();
}
File outputDir = null;
OutputVisitor.Context context = visitor.getContext();
if (context != null) {
Project currentProject = context.getCurrentProject();
if (currentProject != null) {
File outputDir = project2outputDirs.remove(currentProject);
if (outputDir != null) {
TestSession session = outputDir2sessions.remove(outputDir);
if (session != null) {
CoreManager junitManager = getManagerProvider();
if (junitManager != null) {
junitManager.sessionFinished(session);
}
if (context != null && context.getCurrentProject() != null) {
outputDir = project2outputDirs.remove(context.getCurrentProject());
} else if (runningTestClass != null) {
// fallback if EventSpy is not active
Set<File> dirs = runningTestClass2outputDirs.get(runningTestClass);
if (dirs != null) {
for (File dir : outputDir2sessions.keySet()) {
if (dirs.contains(dir)) {
outputDir = dir;
break;
}
}
}
}
if (outputDir != null) {
TestSession session = outputDir2sessions.remove(outputDir);
if (session != null) {
project2outputDirs.remove(session.getProject());
CoreManager junitManager = getManagerProvider();
if (junitManager != null) {
junitManager.sessionFinished(session);
}
}
}
runningTestClass = null;
}

Expand Down
Loading