Skip to content

Commit

Permalink
test: Added session label for test-end
Browse files Browse the repository at this point in the history
FOLLOW UP: 2f07320
  • Loading branch information
hishidama committed Jun 19, 2024
1 parent 2f07320 commit 0f6d0d1
Showing 1 changed file with 35 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public class DbTestTableTester {
protected static TsurugiSession getSession() throws IOException {
synchronized (DbTestTableTester.class) {
if (staticSession == null) {
staticSession = DbTestConnector.createSession();
String baseLabel = DbTestConnector.getSessionLabel();
String label = baseLabel + " (staticSession)";
staticSession = DbTestConnector.createSession(label);
}
}
return staticSession;
Expand Down Expand Up @@ -121,14 +123,17 @@ protected static void logInitStart(Logger log, TestInfo info) {
}

protected static void logInitEnd(Logger log, TestInfo info) {
DbTestConnector.setSessionLabel(null);

if (START_END_LOG_INFO) {
log.info("init all end");
} else {
log.debug("init all end");
setSessionLabel(info, null, "init all end");
try {
if (START_END_LOG_INFO) {
log.info("init all end");
} else {
log.debug("init all end");
}
serverLog(log, null, "init all end");
} finally {
DbTestConnector.setSessionLabel(null);
}
serverLog(log, null, "init all end");
}

protected void logInitStart(TestInfo info) {
Expand All @@ -144,15 +149,19 @@ protected void logInitStart(TestInfo info) {
}

protected void logInitEnd(TestInfo info) {
DbTestConnector.setSessionLabel(null);

String displayName = getDisplayName(info);
if (START_END_LOG_INFO) {
LOG.info("{} init end", displayName);
} else {
LOG.debug("{} init end", displayName);
setSessionLabel(info, displayName, "init end");

try {
if (START_END_LOG_INFO) {
LOG.info("{} init end", displayName);
} else {
LOG.debug("{} init end", displayName);
}
serverLog(LOG, displayName, "init end");
} finally {
DbTestConnector.setSessionLabel(null);
}
serverLog(LOG, displayName, "init end");
}

@BeforeEach
Expand All @@ -170,15 +179,19 @@ void tetsterBeforeEach(TestInfo info) {

@AfterEach
void testerAfterEach(TestInfo info) {
DbTestConnector.setSessionLabel(null);

String displayName = getDisplayName(info);
if (START_END_LOG_INFO) {
LOG.info("{} end", displayName);
} else {
LOG.debug("{} end", displayName);
setSessionLabel(info, displayName, "end");

try {
if (START_END_LOG_INFO) {
LOG.info("{} end", displayName);
} else {
LOG.debug("{} end", displayName);
}
serverLog(LOG, displayName, "end");
} finally {
DbTestConnector.setSessionLabel(null);
}
serverLog(LOG, displayName, "end");
}

private static void setSessionLabel(TestInfo info, String displayName, String suffix) {
Expand Down

0 comments on commit 0f6d0d1

Please sign in to comment.