setupDataSrcs() {
ptr = this.notSetupHead;
while (ptr != null && ptr != firstPtrNotSetupYet) {
var next = ptr.next;
- if (! excMap.containsKey(ptr.name)) {
+ if (!excMap.containsKey(ptr.name)) {
this.removeContainerPtrNotSetup(ptr);
this.appendContainerPtrDidSetup(ptr);
}
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index deab0bf..a3cefba 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -6,10 +6,11 @@
/**
* Defines the APIs of Sabi framework.
*
- * This module includes the interfaces that abstracts data accesses to the external data stores
+ * This module includes the interfaces that abstracts data accesses to the external data stores
* and the classes to execute a logic function with or without transaction operations.
*/
module com.github.sttk.sabi {
exports com.github.sttk.sabi;
+
requires transitive com.github.sttk.errs;
}
diff --git a/src/test/java/com/github/sttk/sabi/internal/AsyncGroupImplTest.java b/src/test/java/com/github/sttk/sabi/internal/AsyncGroupImplTest.java
index fef45f9..589c27d 100644
--- a/src/test/java/com/github/sttk/sabi/internal/AsyncGroupImplTest.java
+++ b/src/test/java/com/github/sttk/sabi/internal/AsyncGroupImplTest.java
@@ -2,12 +2,11 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Nested;
import com.github.sttk.errs.Exc;
import com.github.sttk.sabi.Runner;
import java.util.HashMap;
+import org.junit.jupiter.api.Test;
public class AsyncGroupImplTest {
private AsyncGroupImplTest() {}
@@ -26,10 +25,14 @@ void ok() {
var ag = new AsyncGroupImpl();
boolean[] executed = {false};
- Runner fn = () -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- executed[0] = true;
- };
+ Runner fn =
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ executed[0] = true;
+ };
ag.name = "foo";
ag.add(fn);
@@ -48,11 +51,15 @@ void error() {
record FailToDoSomething() {}
boolean[] executed = {false};
- Runner fn = () -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- executed[0] = true;
- throw new Exc(new FailToDoSomething());
- };
+ Runner fn =
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ executed[0] = true;
+ throw new Exc(new FailToDoSomething());
+ };
ag.name = "foo";
ag.add(fn);
@@ -79,21 +86,33 @@ record Reason2() {}
boolean[] executed = {false, false, false};
- Runner fn0 = () -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- executed[0] = true;
- throw new Exc(new Reason0());
- };
- Runner fn1 = () -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- executed[1] = true;
- throw new Exc(new Reason1());
- };
- Runner fn2 = () -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- executed[2] = true;
- throw new Exc(new Reason2());
- };
+ Runner fn0 =
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ executed[0] = true;
+ throw new Exc(new Reason0());
+ };
+ Runner fn1 =
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ executed[1] = true;
+ throw new Exc(new Reason1());
+ };
+ Runner fn2 =
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ executed[2] = true;
+ throw new Exc(new Reason2());
+ };
ag.name = "foo0";
ag.add(fn0);
@@ -109,9 +128,15 @@ record Reason2() {}
assertThat(executed[1]).isTrue();
assertThat(executed[2]).isTrue();
- assertThat(m.get("foo0").toString()).isEqualTo("com.github.sttk.errs.Exc { reason = com.github.sttk.sabi.internal.AsyncGroupImplTest$1Reason0 Reason0[], file = AsyncGroupImplTest.java, line = 85 }");
- assertThat(m.get("foo1").toString()).isEqualTo("com.github.sttk.errs.Exc { reason = com.github.sttk.sabi.internal.AsyncGroupImplTest$1Reason1 Reason1[], file = AsyncGroupImplTest.java, line = 90 }");
- assertThat(m.get("foo2").toString()).isEqualTo("com.github.sttk.errs.Exc { reason = com.github.sttk.sabi.internal.AsyncGroupImplTest$1Reason2 Reason2[], file = AsyncGroupImplTest.java, line = 95 }");
+ assertThat(m.get("foo0").toString())
+ .isEqualTo(
+ "com.github.sttk.errs.Exc { reason = com.github.sttk.sabi.internal.AsyncGroupImplTest$1Reason0 Reason0[], file = AsyncGroupImplTest.java, line = 96 }");
+ assertThat(m.get("foo1").toString())
+ .isEqualTo(
+ "com.github.sttk.errs.Exc { reason = com.github.sttk.sabi.internal.AsyncGroupImplTest$1Reason1 Reason1[], file = AsyncGroupImplTest.java, line = 105 }");
+ assertThat(m.get("foo2").toString())
+ .isEqualTo(
+ "com.github.sttk.errs.Exc { reason = com.github.sttk.sabi.internal.AsyncGroupImplTest$1Reason2 Reason2[], file = AsyncGroupImplTest.java, line = 114 }");
}
@Test
@@ -124,21 +149,33 @@ record Reason2() {}
boolean[] executed = {false, false, false};
- Runner fn0 = () -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- executed[0] = true;
- throw new Exc(new Reason0());
- };
- Runner fn1 = () -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- executed[1] = true;
- throw new Exc(new Reason1());
- };
- Runner fn2 = () -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- executed[2] = true;
- throw new Exc(new Reason2());
- };
+ Runner fn0 =
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ executed[0] = true;
+ throw new Exc(new Reason0());
+ };
+ Runner fn1 =
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ executed[1] = true;
+ throw new Exc(new Reason1());
+ };
+ Runner fn2 =
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ executed[2] = true;
+ throw new Exc(new Reason2());
+ };
ag.name = "foo0";
ag.add(fn0);
diff --git a/src/test/java/com/github/sttk/sabi/internal/DataAccTest.java b/src/test/java/com/github/sttk/sabi/internal/DataAccTest.java
index 4ec221b..97cef1b 100644
--- a/src/test/java/com/github/sttk/sabi/internal/DataAccTest.java
+++ b/src/test/java/com/github/sttk/sabi/internal/DataAccTest.java
@@ -2,21 +2,21 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Nested;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.AfterEach;
import com.github.sttk.errs.Exc;
import com.github.sttk.sabi.AsyncGroup;
-import com.github.sttk.sabi.DataConn;
-import com.github.sttk.sabi.DataSrc;
import com.github.sttk.sabi.DataAcc;
+import com.github.sttk.sabi.DataConn;
import com.github.sttk.sabi.DataHub;
-import com.github.sttk.sabi.Sabi;
+import com.github.sttk.sabi.DataSrc;
import com.github.sttk.sabi.Logic;
-import java.util.List;
+import com.github.sttk.sabi.Sabi;
import java.util.ArrayList;
+import java.util.List;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
public class DataAccTest {
DataAccTest() {}
@@ -35,6 +35,7 @@ static class FooDataSrc implements DataSrc {
this.logger = logger;
this.willFail = willFail;
}
+
@Override
public void setup(AsyncGroup ag) throws Exc {
if (this.willFail) {
@@ -43,10 +44,12 @@ public void setup(AsyncGroup ag) throws Exc {
}
this.logger.add(String.format("FooDataSrc %d setupped", this.id));
}
+
@Override
public void close() {
this.logger.add(String.format("FooDataSrc %d closed", this.id));
}
+
@Override
public DataConn createDataConn() throws Exc {
this.logger.add(String.format("FooDataSrc %d created FooDataConn", this.id));
@@ -65,34 +68,42 @@ static class FooDataConn implements DataConn {
this.text = text;
this.logger = logger;
}
+
String getText() {
return this.text;
}
+
@Override
public void commit(AsyncGroup ag) throws Exc {
this.committed = true;
this.logger.add(String.format("FooDataConn %d committed", this.id));
}
+
@Override
public void preCommit(AsyncGroup ag) throws Exc {
this.logger.add(String.format("FooDataConn %d pre committed", this.id));
}
+
@Override
public void postCommit(AsyncGroup ag) {
this.logger.add(String.format("FooDataConn %d post committed", this.id));
}
+
@Override
public boolean shouldForceBack() {
return this.committed;
}
+
@Override
public void rollback(AsyncGroup ag) {
this.logger.add(String.format("FooDataConn %d rollbacked", this.id));
}
+
@Override
public void forceBack(AsyncGroup ag) {
this.logger.add(String.format("FooDataConn %d forced back", this.id));
}
+
@Override
public void close() {
this.logger.add(String.format("FooDataConn %d closed", this.id));
@@ -111,6 +122,7 @@ static class BarDataSrc implements DataSrc {
this.logger = logger;
this.willFail = willFail;
}
+
@Override
public void setup(AsyncGroup ag) throws Exc {
if (this.willFail) {
@@ -119,11 +131,13 @@ public void setup(AsyncGroup ag) throws Exc {
}
this.logger.add(String.format("BarDataSrc %d setupped", this.id));
}
+
@Override
public void close() {
this.logger.add(String.format("BarDataSrc.text = %s", this.text));
this.logger.add(String.format("BarDataSrc %d closed", this.id));
}
+
@Override
public DataConn createDataConn() throws Exc {
this.logger.add(String.format("BarDataSrc %d created BarDataConn", this.id));
@@ -145,35 +159,43 @@ static class BarDataConn implements DataConn {
this.logger = logger;
this.ds = ds;
}
+
void setText(String s) {
this.text = s;
}
+
@Override
public void commit(AsyncGroup ag) throws Exc {
this.committed = true;
this.ds.text = this.text;
this.logger.add(String.format("BarDataConn %d committed", this.id));
}
+
@Override
public void preCommit(AsyncGroup ag) throws Exc {
this.logger.add(String.format("BarDataConn %d pre committed", this.id));
}
+
@Override
public void postCommit(AsyncGroup ag) {
this.logger.add(String.format("BarDataConn %d post committed", this.id));
}
+
@Override
public boolean shouldForceBack() {
return this.committed;
}
+
@Override
public void rollback(AsyncGroup ag) {
this.logger.add(String.format("BarDataConn %d rollbacked", this.id));
}
+
@Override
public void forceBack(AsyncGroup ag) {
this.logger.add(String.format("BarDataConn %d forced back", this.id));
}
+
@Override
public void close() {
this.logger.add(String.format("BarDataConn.text = %s", this.text));
@@ -185,6 +207,7 @@ public void close() {
static interface SampleData {
String getValue() throws Exc;
+
void setValue(String text) throws Exc;
}
@@ -233,6 +256,7 @@ class TestLogicArgument {
void beforeEach() {
DataHubInnerTest.resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
DataHubInnerTest.resetGlobalVariables();
@@ -256,18 +280,18 @@ void test() {
fail(e);
}
- assertThat(logger).containsExactly(
- "FooDataSrc 1 setupped",
- "BarDataSrc 2 setupped",
- "FooDataSrc 1 created FooDataConn",
- "BarDataSrc 2 created BarDataConn",
- "BarDataConn.text = hello",
- "BarDataConn 2 closed",
- "FooDataConn 1 closed",
- "BarDataSrc.text = null",
- "BarDataSrc 2 closed",
- "FooDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "FooDataSrc 1 setupped",
+ "BarDataSrc 2 setupped",
+ "FooDataSrc 1 created FooDataConn",
+ "BarDataSrc 2 created BarDataConn",
+ "BarDataConn.text = hello",
+ "BarDataConn 2 closed",
+ "FooDataConn 1 closed",
+ "BarDataSrc.text = null",
+ "BarDataSrc 2 closed",
+ "FooDataSrc 1 closed");
}
}
@@ -277,6 +301,7 @@ class TestDataHubRunUsingGlobal {
void beforeEach() {
DataHubInnerTest.resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
DataHubInnerTest.resetGlobalVariables();
@@ -300,18 +325,18 @@ void test() {
fail(e);
}
- assertThat(logger).containsExactly(
- "FooDataSrc 1 setupped",
- "BarDataSrc 2 setupped",
- "FooDataSrc 1 created FooDataConn",
- "BarDataSrc 2 created BarDataConn",
- "BarDataConn.text = hello",
- "BarDataConn 2 closed",
- "FooDataConn 1 closed",
- "BarDataSrc.text = null",
- "BarDataSrc 2 closed",
- "FooDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "FooDataSrc 1 setupped",
+ "BarDataSrc 2 setupped",
+ "FooDataSrc 1 created FooDataConn",
+ "BarDataSrc 2 created BarDataConn",
+ "BarDataConn.text = hello",
+ "BarDataConn 2 closed",
+ "FooDataConn 1 closed",
+ "BarDataSrc.text = null",
+ "BarDataSrc 2 closed",
+ "FooDataSrc 1 closed");
}
}
@@ -321,6 +346,7 @@ class TestDataHubRunUsingLocal {
void beforeEach() {
DataHubInnerTest.resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
DataHubInnerTest.resetGlobalVariables();
@@ -344,18 +370,18 @@ void test() {
fail(e);
}
- assertThat(logger).containsExactly(
- "FooDataSrc 1 setupped",
- "BarDataSrc 2 setupped",
- "FooDataSrc 1 created FooDataConn",
- "BarDataSrc 2 created BarDataConn",
- "BarDataConn.text = hello",
- "BarDataConn 2 closed",
- "FooDataConn 1 closed",
- "BarDataSrc.text = null",
- "BarDataSrc 2 closed",
- "FooDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "FooDataSrc 1 setupped",
+ "BarDataSrc 2 setupped",
+ "FooDataSrc 1 created FooDataConn",
+ "BarDataSrc 2 created BarDataConn",
+ "BarDataConn.text = hello",
+ "BarDataConn 2 closed",
+ "FooDataConn 1 closed",
+ "BarDataSrc.text = null",
+ "BarDataSrc 2 closed",
+ "FooDataSrc 1 closed");
}
@Test
@@ -384,9 +410,7 @@ void test_not_run_logic_if_fail_to_setup_local_data_src() {
fail(e);
}
- assertThat(logger).containsExactly(
- "FooDataSrc 1 failed to setup"
- );
+ assertThat(logger).containsExactly("FooDataSrc 1 failed to setup");
}
}
@@ -396,6 +420,7 @@ class TestDataHubRunUsingGlobalAndLocal {
void beforeEach() {
DataHubInnerTest.resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
DataHubInnerTest.resetGlobalVariables();
@@ -420,18 +445,18 @@ void test() {
fail(e);
}
- assertThat(logger).containsExactly(
- "BarDataSrc 1 setupped",
- "FooDataSrc 2 setupped",
- "FooDataSrc 2 created FooDataConn",
- "BarDataSrc 1 created BarDataConn",
- "BarDataConn.text = Hello",
- "BarDataConn 1 closed",
- "FooDataConn 2 closed",
- "FooDataSrc 2 closed",
- "BarDataSrc.text = null",
- "BarDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "BarDataSrc 1 setupped",
+ "FooDataSrc 2 setupped",
+ "FooDataSrc 2 created FooDataConn",
+ "BarDataSrc 1 created BarDataConn",
+ "BarDataConn.text = Hello",
+ "BarDataConn 1 closed",
+ "FooDataConn 2 closed",
+ "FooDataSrc 2 closed",
+ "BarDataSrc.text = null",
+ "BarDataSrc 1 closed");
}
}
@@ -441,6 +466,7 @@ class TestDataHubTxnUsingGlobal {
void beforeEach() {
DataHubInnerTest.resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
DataHubInnerTest.resetGlobalVariables();
@@ -464,24 +490,24 @@ void test() {
fail(e);
}
- assertThat(logger).containsExactly(
- "FooDataSrc 1 setupped",
- "BarDataSrc 2 setupped",
- "FooDataSrc 1 created FooDataConn",
- "BarDataSrc 2 created BarDataConn",
- "FooDataConn 1 pre committed",
- "BarDataConn 2 pre committed",
- "FooDataConn 1 committed",
- "BarDataConn 2 committed",
- "FooDataConn 1 post committed",
- "BarDataConn 2 post committed",
- "BarDataConn.text = Hello",
- "BarDataConn 2 closed",
- "FooDataConn 1 closed",
- "BarDataSrc.text = Hello",
- "BarDataSrc 2 closed",
- "FooDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "FooDataSrc 1 setupped",
+ "BarDataSrc 2 setupped",
+ "FooDataSrc 1 created FooDataConn",
+ "BarDataSrc 2 created BarDataConn",
+ "FooDataConn 1 pre committed",
+ "BarDataConn 2 pre committed",
+ "FooDataConn 1 committed",
+ "BarDataConn 2 committed",
+ "FooDataConn 1 post committed",
+ "BarDataConn 2 post committed",
+ "BarDataConn.text = Hello",
+ "BarDataConn 2 closed",
+ "FooDataConn 1 closed",
+ "BarDataSrc.text = Hello",
+ "BarDataSrc 2 closed",
+ "FooDataSrc 1 closed");
}
}
@@ -491,6 +517,7 @@ class TestDataHubTxnUsingLocal {
void beforeEach() {
DataHubInnerTest.resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
DataHubInnerTest.resetGlobalVariables();
@@ -514,24 +541,24 @@ void test() {
fail(e);
}
- assertThat(logger).containsExactly(
- "FooDataSrc 1 setupped",
- "BarDataSrc 2 setupped",
- "FooDataSrc 1 created FooDataConn",
- "BarDataSrc 2 created BarDataConn",
- "FooDataConn 1 pre committed",
- "BarDataConn 2 pre committed",
- "FooDataConn 1 committed",
- "BarDataConn 2 committed",
- "FooDataConn 1 post committed",
- "BarDataConn 2 post committed",
- "BarDataConn.text = Hello",
- "BarDataConn 2 closed",
- "FooDataConn 1 closed",
- "BarDataSrc.text = Hello",
- "BarDataSrc 2 closed",
- "FooDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "FooDataSrc 1 setupped",
+ "BarDataSrc 2 setupped",
+ "FooDataSrc 1 created FooDataConn",
+ "BarDataSrc 2 created BarDataConn",
+ "FooDataConn 1 pre committed",
+ "BarDataConn 2 pre committed",
+ "FooDataConn 1 committed",
+ "BarDataConn 2 committed",
+ "FooDataConn 1 post committed",
+ "BarDataConn 2 post committed",
+ "BarDataConn.text = Hello",
+ "BarDataConn 2 closed",
+ "FooDataConn 1 closed",
+ "BarDataSrc.text = Hello",
+ "BarDataSrc 2 closed",
+ "FooDataSrc 1 closed");
}
@Test
@@ -560,9 +587,7 @@ void test_not_run_logic_if_fail_to_setup_local_data_src() {
fail(e);
}
- assertThat(logger).containsExactly(
- "FooDataSrc 1 failed to setup"
- );
+ assertThat(logger).containsExactly("FooDataSrc 1 failed to setup");
}
@Test
@@ -585,13 +610,13 @@ void test_not_run_logic_in_txn_and_rollback() {
fail(e);
}
- assertThat(logger).containsExactly(
- "FooDataSrc 1 setupped",
- "BarDataSrc 2 setupped",
- "BarDataSrc.text = null",
- "BarDataSrc 2 closed",
- "FooDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "FooDataSrc 1 setupped",
+ "BarDataSrc 2 setupped",
+ "BarDataSrc.text = null",
+ "BarDataSrc 2 closed",
+ "FooDataSrc 1 closed");
}
}
@@ -601,6 +626,7 @@ class TestDataHubTxnUsingGlobalAndLocal {
void beforeEach() {
DataHubInnerTest.resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
DataHubInnerTest.resetGlobalVariables();
@@ -625,24 +651,24 @@ void test() {
fail(e);
}
- assertThat(logger).containsExactly(
- "BarDataSrc 1 setupped",
- "FooDataSrc 2 setupped",
- "FooDataSrc 2 created FooDataConn",
- "BarDataSrc 1 created BarDataConn",
- "FooDataConn 2 pre committed",
- "BarDataConn 1 pre committed",
- "FooDataConn 2 committed",
- "BarDataConn 1 committed",
- "FooDataConn 2 post committed",
- "BarDataConn 1 post committed",
- "BarDataConn.text = Hello",
- "BarDataConn 1 closed",
- "FooDataConn 2 closed",
- "FooDataSrc 2 closed",
- "BarDataSrc.text = Hello",
- "BarDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "BarDataSrc 1 setupped",
+ "FooDataSrc 2 setupped",
+ "FooDataSrc 2 created FooDataConn",
+ "BarDataSrc 1 created BarDataConn",
+ "FooDataConn 2 pre committed",
+ "BarDataConn 1 pre committed",
+ "FooDataConn 2 committed",
+ "BarDataConn 1 committed",
+ "FooDataConn 2 post committed",
+ "BarDataConn 1 post committed",
+ "BarDataConn.text = Hello",
+ "BarDataConn 1 closed",
+ "FooDataConn 2 closed",
+ "FooDataSrc 2 closed",
+ "BarDataSrc.text = Hello",
+ "BarDataSrc 1 closed");
}
}
}
diff --git a/src/test/java/com/github/sttk/sabi/internal/DataConnListTest.java b/src/test/java/com/github/sttk/sabi/internal/DataConnListTest.java
index d13f52d..c2dcf70 100644
--- a/src/test/java/com/github/sttk/sabi/internal/DataConnListTest.java
+++ b/src/test/java/com/github/sttk/sabi/internal/DataConnListTest.java
@@ -1,15 +1,13 @@
package com.github.sttk.sabi.internal;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Nested;
import com.github.sttk.errs.Exc;
import com.github.sttk.sabi.AsyncGroup;
import com.github.sttk.sabi.DataConn;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
+import org.junit.jupiter.api.Test;
public class DataConnListTest {
private DataConnListTest() {}
@@ -18,13 +16,25 @@ static class SampleDataConn implements DataConn {
private int id;
private List logger;
- public SampleDataConn(int id, List logger) { this.id = id; this.logger = logger; }
+ public SampleDataConn(int id, List logger) {
+ this.id = id;
+ this.logger = logger;
+ }
+
public void commit(AsyncGroup ag) throws Exc {}
+
public void preCommit(AsyncGroup ag) throws Exc {}
+
public void postCommit(AsyncGroup ag) {}
- public boolean shouldForceBack() { return false; }
+
+ public boolean shouldForceBack() {
+ return false;
+ }
+
public void rollback(AsyncGroup ag) {}
+
public void forceBack(AsyncGroup ag) {}
+
public void close() {
this.logger.add(String.format("SampleDataConn %d closed", this.id));
}
@@ -79,10 +89,8 @@ void test_appendContainer() {
assertThat(dcList.head).isNull();
assertThat(dcList.last).isNull();
- assertThat(logger).containsExactly(
- "SampleDataConn 3 closed",
- "SampleDataConn 2 closed",
- "SampleDataConn 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SampleDataConn 3 closed", "SampleDataConn 2 closed", "SampleDataConn 1 closed");
}
}
diff --git a/src/test/java/com/github/sttk/sabi/internal/DataHubInnerTest.java b/src/test/java/com/github/sttk/sabi/internal/DataHubInnerTest.java
index aba0b71..a85dc09 100644
--- a/src/test/java/com/github/sttk/sabi/internal/DataHubInnerTest.java
+++ b/src/test/java/com/github/sttk/sabi/internal/DataHubInnerTest.java
@@ -2,27 +2,27 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Nested;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.AfterEach;
import com.github.sttk.errs.Exc;
import com.github.sttk.sabi.AsyncGroup;
import com.github.sttk.sabi.DataConn;
-import com.github.sttk.sabi.DataSrc;
import com.github.sttk.sabi.DataHub;
-import java.util.List;
+import com.github.sttk.sabi.DataSrc;
import java.util.ArrayList;
+import java.util.List;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
public class DataHubInnerTest {
private DataHubInnerTest() {}
- final static int FAIL__NOT = 0;
- final static int FAIL__SETUP = 1;
- final static int FAIL__CREATE_DATA_CONN = 2;
- final static int FAIL__COMMIT = 3;
- final static int FAIL__PRE_COMMIT = 4;
+ static final int FAIL__NOT = 0;
+ static final int FAIL__SETUP = 1;
+ static final int FAIL__CREATE_DATA_CONN = 2;
+ static final int FAIL__COMMIT = 3;
+ static final int FAIL__PRE_COMMIT = 4;
final void suppressWarnings_unused(Object a) {}
@@ -36,6 +36,7 @@ static class SyncDataSrc implements DataSrc {
this.fail = fail;
this.logger = logger;
}
+
@Override
public void setup(AsyncGroup ag) throws Exc {
if (this.fail == FAIL__SETUP) {
@@ -44,10 +45,12 @@ public void setup(AsyncGroup ag) throws Exc {
}
this.logger.add(String.format("SyncDataSrc %d setupped", this.id));
}
+
@Override
public void close() {
this.logger.add(String.format("SyncDataSrc %d closed", this.id));
}
+
@Override
public DataConn createDataConn() throws Exc {
if (this.fail == FAIL__CREATE_DATA_CONN) {
@@ -70,21 +73,28 @@ static class AsyncDataSrc implements DataSrc {
this.fail = fail;
this.logger = logger;
}
+
@Override
public void setup(AsyncGroup ag) throws Exc {
- ag.add(() -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- if (this.fail == FAIL__SETUP) {
- this.logger.add(String.format("AsyncDataSrc %d failed to setup", this.id));
- throw new Exc("YYY");
- }
- this.logger.add(String.format("AsyncDataSrc %d setupped", this.id));
- });
+ ag.add(
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ if (this.fail == FAIL__SETUP) {
+ this.logger.add(String.format("AsyncDataSrc %d failed to setup", this.id));
+ throw new Exc("YYY");
+ }
+ this.logger.add(String.format("AsyncDataSrc %d setupped", this.id));
+ });
}
+
@Override
public void close() {
this.logger.add(String.format("AsyncDataSrc %d closed", this.id));
}
+
@Override
public DataConn createDataConn() throws Exc {
if (this.fail == FAIL__CREATE_DATA_CONN) {
@@ -108,6 +118,7 @@ static class SyncDataConn implements DataConn {
this.fail = fail;
this.logger = logger;
}
+
@Override
public void commit(AsyncGroup ag) throws Exc {
if (this.fail == FAIL__COMMIT) {
@@ -117,6 +128,7 @@ public void commit(AsyncGroup ag) throws Exc {
this.committed = true;
this.logger.add(String.format("SyncDataConn %d committed", this.id));
}
+
@Override
public void preCommit(AsyncGroup ag) throws Exc {
if (this.fail == FAIL__PRE_COMMIT) {
@@ -125,22 +137,27 @@ public void preCommit(AsyncGroup ag) throws Exc {
}
this.logger.add(String.format("SyncDataConn %d pre committed", this.id));
}
+
@Override
public void postCommit(AsyncGroup ag) {
this.logger.add(String.format("SyncDataConn %d post committed", this.id));
}
+
@Override
public boolean shouldForceBack() {
return this.committed;
}
+
@Override
public void rollback(AsyncGroup ag) {
this.logger.add(String.format("SyncDataConn %d rollbacked", this.id));
}
+
@Override
public void forceBack(AsyncGroup ag) {
this.logger.add(String.format("SyncDataConn %d forced back", this.id));
}
+
@Override
public void close() {
this.logger.add(String.format("SyncDataConn %d closed", this.id));
@@ -158,6 +175,7 @@ static class AsyncDataConn implements DataConn {
this.fail = fail;
this.logger = logger;
}
+
@Override
public void commit(AsyncGroup ag) throws Exc {
if (this.fail == FAIL__COMMIT) {
@@ -167,6 +185,7 @@ public void commit(AsyncGroup ag) throws Exc {
this.committed = true;
this.logger.add(String.format("AsyncDataConn %d committed", this.id));
}
+
@Override
public void preCommit(AsyncGroup ag) throws Exc {
if (this.fail == FAIL__PRE_COMMIT) {
@@ -175,22 +194,27 @@ public void preCommit(AsyncGroup ag) throws Exc {
}
this.logger.add(String.format("AsyncDataConn %d pre committed", this.id));
}
+
@Override
public void postCommit(AsyncGroup ag) {
this.logger.add(String.format("AsyncDataConn %d post committed", this.id));
}
+
@Override
public boolean shouldForceBack() {
return this.committed;
}
+
@Override
public void rollback(AsyncGroup ag) {
this.logger.add(String.format("AsyncDataConn %d rollbacked", this.id));
}
+
@Override
public void forceBack(AsyncGroup ag) {
this.logger.add(String.format("AsyncDataConn %d forced back", this.id));
}
+
@Override
public void close() {
this.logger.add(String.format("AsyncDataConn %d closed", this.id));
@@ -208,6 +232,7 @@ class TestOfGlobalFunctions {
void beforeEach() {
resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
resetGlobalVariables();
@@ -253,12 +278,12 @@ void setup_and_shutdown() {
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.notSetupHead).isNull();
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.didSetupHead).isNull();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -301,10 +326,8 @@ void fail_to_setup() {
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.notSetupHead).isNull();
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.didSetupHead).isNull();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 failed to setup",
- "AsyncDataSrc 1 failed to setup"
- );
+ assertThat(logger)
+ .containsExactly("SyncDataSrc 2 failed to setup", "AsyncDataSrc 1 failed to setup");
}
@Test
@@ -351,10 +374,7 @@ void cannot_add_global_data_srcs_after_setup() {
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.notSetupHead).isNull();
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.didSetupHead).isNull();
- assertThat(logger).containsExactly(
- "AsyncDataSrc 1 setupped",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger).containsExactly("AsyncDataSrc 1 setupped", "AsyncDataSrc 1 closed");
}
@Test
@@ -401,10 +421,7 @@ void do_nothing_if_executing_setup_twice() {
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.notSetupHead).isNull();
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.didSetupHead).isNull();
- assertThat(logger).containsExactly(
- "AsyncDataSrc 1 setupped",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger).containsExactly("AsyncDataSrc 1 setupped", "AsyncDataSrc 1 closed");
}
}
@@ -414,6 +431,7 @@ class TestOfDataHubLocal {
void beforeEach() {
resetGlobalVariables();
}
+
@AfterEach
void afterEach() {
resetGlobalVariables();
@@ -481,12 +499,12 @@ void new_and_close_with_global_data_srcs() {
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.notSetupHead).isNull();
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.didSetupHead).isNull();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -534,8 +552,8 @@ void uses_and_disuses() {
assertThat(hub.dataConnMap).hasSize(0);
assertThat(hub.fixed).isFalse();
- hub.disuses("foo"); // do nothing because of global
- hub.disuses("bar"); // do nothing because of global
+ hub.disuses("foo"); // do nothing because of global
+ hub.disuses("bar"); // do nothing because of global
ptr = hub.localDataSrcList.notSetupHead;
assertThat(ptr).isNotNull();
@@ -582,14 +600,14 @@ void uses_and_disuses() {
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.notSetupHead).isNull();
assertThat(DataHubInner.GLOBAL_DATA_SRC_LIST.didSetupHead).isNull();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 3 closed",
- "AsyncDataSrc 4 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 3 closed",
+ "AsyncDataSrc 4 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -715,10 +733,7 @@ void cannot_add_and_remove_data_src_between_begin_and_end() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 1 setupped",
- "SyncDataSrc 1 closed"
- );
+ assertThat(logger).containsExactly("SyncDataSrc 1 setupped", "SyncDataSrc 1 closed");
}
@Test
@@ -790,16 +805,16 @@ void begin_and_end() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 3 setupped",
- "AsyncDataSrc 4 setupped",
- "AsyncDataSrc 4 closed",
- "SyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 3 setupped",
+ "AsyncDataSrc 4 setupped",
+ "AsyncDataSrc 4 closed",
+ "SyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -866,15 +881,15 @@ void begin_and_end_but_fail_sync() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 failed to setup",
- "AsyncDataSrc 3 setupped",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 failed to setup",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -941,15 +956,15 @@ void begin_and_end_but_fail_async() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 failed to setup",
- "SyncDataSrc 4 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 failed to setup",
+ "SyncDataSrc 4 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1005,37 +1020,32 @@ void commit() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 pre committed",
- "AsyncDataConn 3 pre committed",
- "SyncDataConn 4 pre committed",
-
- "AsyncDataConn 1 committed",
- "SyncDataConn 2 committed",
- "AsyncDataConn 3 committed",
- "SyncDataConn 4 committed",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 pre committed",
+ "AsyncDataConn 3 pre committed",
+ "SyncDataConn 4 pre committed",
+ "AsyncDataConn 1 committed",
+ "SyncDataConn 2 committed",
+ "AsyncDataConn 3 committed",
+ "SyncDataConn 4 committed",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1064,7 +1074,7 @@ void fail_to_cast_new_data_conn() {
case DataHub.FailToCastDataConn rsn -> {
assertThat(rsn.name()).isEqualTo("foo");
assertThat(rsn.castToType())
- .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$SyncDataConn");
+ .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$SyncDataConn");
}
default -> fail(e);
}
@@ -1080,7 +1090,7 @@ void fail_to_cast_new_data_conn() {
case DataHub.FailToCastDataConn rsn -> {
assertThat(rsn.name()).isEqualTo("bar");
assertThat(rsn.castToType())
- .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$AsyncDataConn");
+ .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$AsyncDataConn");
}
default -> fail(e);
}
@@ -1095,14 +1105,14 @@ void fail_to_cast_new_data_conn() {
fail(e);
}
- assertThat(logger).containsExactly(
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1137,7 +1147,7 @@ void fail_to_cast_reused_data_conn() {
case DataHub.FailToCastDataConn rsn -> {
assertThat(rsn.name()).isEqualTo("foo");
assertThat(rsn.castToType())
- .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$SyncDataConn");
+ .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$SyncDataConn");
}
default -> fail(e);
}
@@ -1153,7 +1163,7 @@ void fail_to_cast_reused_data_conn() {
case DataHub.FailToCastDataConn rsn -> {
assertThat(rsn.name()).isEqualTo("bar");
assertThat(rsn.castToType())
- .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$AsyncDataConn");
+ .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$AsyncDataConn");
}
default -> fail(e);
}
@@ -1166,16 +1176,16 @@ void fail_to_cast_reused_data_conn() {
fail(e);
}
- assertThat(logger).containsExactly(
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1207,7 +1217,7 @@ void fail_to_create_data_conn() {
case DataHub.FailToCreateDataConn rsn -> {
assertThat(rsn.name()).isEqualTo("bar");
assertThat(rsn.dataConnType())
- .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$AsyncDataConn");
+ .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$AsyncDataConn");
}
default -> fail(e);
}
@@ -1220,15 +1230,15 @@ void fail_to_create_data_conn() {
fail(e);
}
- assertThat(logger).containsExactly(
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 failed to create a DataConn",
- "AsyncDataConn 1 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 failed to create a DataConn",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1257,7 +1267,7 @@ void fail_to_create_data_conn_because_of_no_data_src() {
case DataHub.NoDataSrcToCreateDataConn rsn -> {
assertThat(rsn.name()).isEqualTo("baz");
assertThat(rsn.dataConnType())
- .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$SyncDataConn");
+ .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$SyncDataConn");
}
default -> fail(e);
}
@@ -1273,7 +1283,7 @@ void fail_to_create_data_conn_because_of_no_data_src() {
case DataHub.NoDataSrcToCreateDataConn rsn -> {
assertThat(rsn.name()).isEqualTo("qux");
assertThat(rsn.dataConnType())
- .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$AsyncDataConn");
+ .isEqualTo("com.github.sttk.sabi.internal.DataHubInnerTest$AsyncDataConn");
}
default -> fail(e);
}
@@ -1286,12 +1296,12 @@ void fail_to_create_data_conn_because_of_no_data_src() {
fail(e);
}
- assertThat(logger).containsExactly(
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 2 setupped",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 2 setupped",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1321,17 +1331,16 @@ void commit_when_no_data_conn() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1384,35 +1393,30 @@ void commit_but_fail_global_sync() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 pre committed",
- "AsyncDataConn 3 pre committed",
- "SyncDataConn 4 pre committed",
-
- "AsyncDataConn 1 committed",
- "SyncDataConn 2 failed to commit",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 pre committed",
+ "AsyncDataConn 3 pre committed",
+ "SyncDataConn 4 pre committed",
+ "AsyncDataConn 1 committed",
+ "SyncDataConn 2 failed to commit",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1465,34 +1469,29 @@ void commit_but_fail_global_async() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 pre committed",
- "AsyncDataConn 3 pre committed",
- "SyncDataConn 4 pre committed",
-
- "AsyncDataConn 1 failed to commit",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 pre committed",
+ "AsyncDataConn 3 pre committed",
+ "SyncDataConn 4 pre committed",
+ "AsyncDataConn 1 failed to commit",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1545,37 +1544,32 @@ void commit_but_fail_local_sync() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 pre committed",
- "AsyncDataConn 3 pre committed",
- "SyncDataConn 4 pre committed",
-
- "AsyncDataConn 1 committed",
- "SyncDataConn 2 committed",
- "AsyncDataConn 3 committed",
- "SyncDataConn 4 failed to commit",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 pre committed",
+ "AsyncDataConn 3 pre committed",
+ "SyncDataConn 4 pre committed",
+ "AsyncDataConn 1 committed",
+ "SyncDataConn 2 committed",
+ "AsyncDataConn 3 committed",
+ "SyncDataConn 4 failed to commit",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1628,36 +1622,31 @@ void commit_but_fail_local_async() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 pre committed",
- "AsyncDataConn 3 pre committed",
- "SyncDataConn 4 pre committed",
-
- "AsyncDataConn 1 committed",
- "SyncDataConn 2 committed",
- "AsyncDataConn 3 failed to commit",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 pre committed",
+ "AsyncDataConn 3 pre committed",
+ "SyncDataConn 4 pre committed",
+ "AsyncDataConn 1 committed",
+ "SyncDataConn 2 committed",
+ "AsyncDataConn 3 failed to commit",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1710,30 +1699,26 @@ void pre_commit_but_fail_global_sync() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 failed to pre commit",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 failed to pre commit",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1786,30 +1771,26 @@ void pre_commit_but_fail_global_async() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 failed to pre commit",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 failed to pre commit",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1862,32 +1843,28 @@ void pre_commit_but_fail_local_sync() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 pre committed",
- "AsyncDataConn 3 pre committed",
- "SyncDataConn 4 failed to pre commit",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 pre committed",
+ "AsyncDataConn 3 pre committed",
+ "SyncDataConn 4 failed to pre commit",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -1940,31 +1917,27 @@ void pre_commit_but_fail_local_async() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 pre committed",
- "AsyncDataConn 3 failed to pre commit",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 pre committed",
+ "AsyncDataConn 3 failed to pre commit",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -2003,32 +1976,28 @@ void rollback() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 rollbacked",
- "SyncDataConn 2 rollbacked",
- "AsyncDataConn 3 rollbacked",
- "SyncDataConn 4 rollbacked",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 rollbacked",
+ "SyncDataConn 2 rollbacked",
+ "AsyncDataConn 3 rollbacked",
+ "SyncDataConn 4 rollbacked",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -2068,42 +2037,36 @@ void force_back() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 pre committed",
- "SyncDataConn 2 pre committed",
- "AsyncDataConn 3 pre committed",
- "SyncDataConn 4 pre committed",
-
- "AsyncDataConn 1 committed",
- "SyncDataConn 2 committed",
- "AsyncDataConn 3 committed",
- "SyncDataConn 4 committed",
-
- "AsyncDataConn 1 forced back",
- "SyncDataConn 2 forced back",
- "AsyncDataConn 3 forced back",
- "SyncDataConn 4 forced back",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 pre committed",
+ "SyncDataConn 2 pre committed",
+ "AsyncDataConn 3 pre committed",
+ "SyncDataConn 4 pre committed",
+ "AsyncDataConn 1 committed",
+ "SyncDataConn 2 committed",
+ "AsyncDataConn 3 committed",
+ "SyncDataConn 4 committed",
+ "AsyncDataConn 1 forced back",
+ "SyncDataConn 2 forced back",
+ "AsyncDataConn 3 forced back",
+ "SyncDataConn 4 forced back",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -2142,32 +2105,28 @@ void post_commit() {
fail(e);
}
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "SyncDataSrc 4 setupped",
- "AsyncDataSrc 3 setupped",
-
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "AsyncDataSrc 3 created DataConn",
- "SyncDataSrc 4 created DataConn",
-
- "AsyncDataConn 1 post committed",
- "SyncDataConn 2 post committed",
- "AsyncDataConn 3 post committed",
- "SyncDataConn 4 post committed",
-
- "SyncDataConn 4 closed",
- "AsyncDataConn 3 closed",
- "SyncDataConn 2 closed",
- "AsyncDataConn 1 closed",
-
- "SyncDataSrc 4 closed",
- "AsyncDataSrc 3 closed",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "SyncDataSrc 4 setupped",
+ "AsyncDataSrc 3 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "AsyncDataSrc 3 created DataConn",
+ "SyncDataSrc 4 created DataConn",
+ "AsyncDataConn 1 post committed",
+ "SyncDataConn 2 post committed",
+ "AsyncDataConn 3 post committed",
+ "SyncDataConn 4 post committed",
+ "SyncDataConn 4 closed",
+ "AsyncDataConn 3 closed",
+ "SyncDataConn 2 closed",
+ "AsyncDataConn 1 closed",
+ "SyncDataSrc 4 closed",
+ "AsyncDataSrc 3 closed",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
}
}
diff --git a/src/test/java/com/github/sttk/sabi/internal/DataSrcListTest.java b/src/test/java/com/github/sttk/sabi/internal/DataSrcListTest.java
index 58cbdbc..d37bb71 100644
--- a/src/test/java/com/github/sttk/sabi/internal/DataSrcListTest.java
+++ b/src/test/java/com/github/sttk/sabi/internal/DataSrcListTest.java
@@ -2,17 +2,15 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Nested;
import com.github.sttk.errs.Exc;
-import com.github.sttk.sabi.Runner;
import com.github.sttk.sabi.AsyncGroup;
import com.github.sttk.sabi.DataConn;
import com.github.sttk.sabi.DataSrc;
-import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import org.junit.jupiter.api.Test;
public class DataSrcListTest {
private DataSrcListTest() {}
@@ -63,14 +61,18 @@ static class AsyncDataSrc implements DataSrc {
@Override
public void setup(AsyncGroup ag) throws Exc {
- ag.add(() -> {
- try { Thread.sleep(50); } catch (Exception e) {}
- if (this.willFail) {
- logger.add(String.format("AsyncDataSrc %d failed to setup", this.id));
- throw new Exc("XXX");
- }
- logger.add(String.format("AsyncDataSrc %d setupped", this.id));
- });
+ ag.add(
+ () -> {
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ }
+ if (this.willFail) {
+ logger.add(String.format("AsyncDataSrc %d failed to setup", this.id));
+ throw new Exc("XXX");
+ }
+ logger.add(String.format("AsyncDataSrc %d setupped", this.id));
+ });
}
@Override
@@ -87,23 +89,53 @@ public DataConn createDataConn() throws Exc {
}
static class SyncDataConn implements DataConn {
- @Override public void commit(AsyncGroup ag) throws Exc {}
- @Override public void preCommit(AsyncGroup ag) throws Exc {}
- @Override public void postCommit(AsyncGroup ag) {}
- @Override public boolean shouldForceBack() { return false; }
- @Override public void rollback(AsyncGroup ag) {}
- @Override public void forceBack(AsyncGroup ag) {}
- @Override public void close() {}
+ @Override
+ public void commit(AsyncGroup ag) throws Exc {}
+
+ @Override
+ public void preCommit(AsyncGroup ag) throws Exc {}
+
+ @Override
+ public void postCommit(AsyncGroup ag) {}
+
+ @Override
+ public boolean shouldForceBack() {
+ return false;
+ }
+
+ @Override
+ public void rollback(AsyncGroup ag) {}
+
+ @Override
+ public void forceBack(AsyncGroup ag) {}
+
+ @Override
+ public void close() {}
}
static class AsyncDataConn implements DataConn {
- @Override public void commit(AsyncGroup ag) throws Exc {}
- @Override public void preCommit(AsyncGroup ag) throws Exc {}
- @Override public void postCommit(AsyncGroup ag) {}
- @Override public boolean shouldForceBack() { return false; }
- @Override public void rollback(AsyncGroup ag) {}
- @Override public void forceBack(AsyncGroup ag) {}
- @Override public void close() {}
+ @Override
+ public void commit(AsyncGroup ag) throws Exc {}
+
+ @Override
+ public void preCommit(AsyncGroup ag) throws Exc {}
+
+ @Override
+ public void postCommit(AsyncGroup ag) {}
+
+ @Override
+ public boolean shouldForceBack() {
+ return false;
+ }
+
+ @Override
+ public void rollback(AsyncGroup ag) {}
+
+ @Override
+ public void forceBack(AsyncGroup ag) {}
+
+ @Override
+ public void close() {}
}
@Test
@@ -464,12 +496,12 @@ void test_removeAndCloseLocalContainerPtrNotSetupByName() {
dsList.closeDataSrcs();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 closed",
- "SyncDataSrc 1 closed",
- "SyncDataSrc 4 closed",
- "SyncDataSrc 3 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 closed",
+ "SyncDataSrc 1 closed",
+ "SyncDataSrc 4 closed",
+ "SyncDataSrc 3 closed");
}
@Test
@@ -819,12 +851,12 @@ void test_removeAndCloseLocalContainerPtrDidSetupByName() {
dsList.closeDataSrcs();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 closed",
- "SyncDataSrc 1 closed",
- "SyncDataSrc 4 closed",
- "SyncDataSrc 3 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 closed",
+ "SyncDataSrc 1 closed",
+ "SyncDataSrc 4 closed",
+ "SyncDataSrc 3 closed");
}
@Test
@@ -893,14 +925,14 @@ void test_setupAndCreateDataConnAndClose() {
dsList.closeDataSrcs();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 setupped",
- "AsyncDataSrc 1 created DataConn",
- "SyncDataSrc 2 created DataConn",
- "SyncDataSrc 2 closed",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped",
+ "AsyncDataSrc 1 setupped",
+ "AsyncDataSrc 1 created DataConn",
+ "SyncDataSrc 2 created DataConn",
+ "SyncDataSrc 2 closed",
+ "AsyncDataSrc 1 closed");
}
@Test
@@ -923,11 +955,9 @@ void test_failToSetupSyncAndClose() {
dsList.closeDataSrcs();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 failed to setup",
- "AsyncDataSrc 1 setupped",
- "AsyncDataSrc 1 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 failed to setup", "AsyncDataSrc 1 setupped", "AsyncDataSrc 1 closed");
}
@Test
@@ -950,11 +980,9 @@ void test_failToSetupAsyncAndClose() {
dsList.closeDataSrcs();
- assertThat(logger).containsExactly(
- "SyncDataSrc 2 setupped",
- "AsyncDataSrc 1 failed to setup",
- "SyncDataSrc 2 closed"
- );
+ assertThat(logger)
+ .containsExactly(
+ "SyncDataSrc 2 setupped", "AsyncDataSrc 1 failed to setup", "SyncDataSrc 2 closed");
}
@Test