Skip to content

Commit

Permalink
Merge pull request #224 from trydofor/develop
Browse files Browse the repository at this point in the history
listen TokenClient, log stacktrace
  • Loading branch information
trydofor authored Mar 21, 2024
2 parents be9fd98 + 7085c7b commit 983c7cc
Show file tree
Hide file tree
Showing 28 changed files with 330 additions and 191 deletions.
2 changes: 1 addition & 1 deletion observe/docs
2 changes: 1 addition & 1 deletion observe/mirana
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<commons-text.version>1.11.0</commons-text.version> <!-- https://commons.apache.org/proper/commons-text/ -->
<joda-convert.version>2.2.3</joda-convert.version> <!-- https://github.com/JodaOrg/joda-convert/releases -->
<!-- wings project -->
<mirana.version>2.7.1</mirana.version> <!-- https://github.com/trydofor/pro.fessional.mirana -->
<mirana.version>2.7.2</mirana.version> <!-- https://github.com/trydofor/pro.fessional.mirana -->
<meepo.version>1.5.1</meepo.version> <!-- https://github.com/trydofor/pro.fessional.meepo -->
<kaptcha.version>2.3.3</kaptcha.version> <!-- https://github.com/trydofor/kaptcha -->
<fastjson2.version>2.0.47</fastjson2.version> <!-- https://github.com/alibaba/fastjson2/releases -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import pro.fessional.wings.faceless.flywave.SchemaRevisionManager;
import pro.fessional.wings.faceless.flywave.WingsRevision;
import pro.fessional.wings.testing.faceless.database.TestingDatabaseHelper;

import static pro.fessional.wings.faceless.flywave.WingsRevision.V90_22_0601_01_TestSchema;
import static pro.fessional.wings.faceless.util.FlywaveRevisionScanner.REVISION_PATH_MASTER;
Expand All @@ -24,10 +25,14 @@ public class TestWingsInitDatabaseSample {

@Setter(onMethod_ = {@Autowired})
private SchemaRevisionManager schemaRevisionManager;

@Setter(onMethod_ = {@Autowired})
protected TestingDatabaseHelper testingDatabaseHelper;

@Test
@TmsLink("C12024")
public void init060101() {
testingDatabaseHelper.cleanTable();
// init
var sqls = scan(REVISION_PATH_MASTER, WingsRevision.V01_19_0521_01_EnumI18n.classpath());
schemaRevisionManager.publishRevision(WingsRevision.V00_19_0512_01_Schema.revision(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import pro.fessional.wings.faceless.util.FlywaveRevisionScanner;
import pro.fessional.wings.testing.faceless.database.TestingDatabaseHelper;

import java.util.SortedMap;

import static pro.fessional.wings.faceless.flywave.WingsRevision.V90_22_0601_02_TestRecord;

/**
Expand All @@ -32,18 +30,17 @@
public class TestWingsSchemaGeneratorSample {

@Setter(onMethod_ = {@Autowired})
private TestingDatabaseHelper testingDatabaseHelper;
private SchemaRevisionManager schemaRevisionManager;

@Setter(onMethod_ = {@Autowired})
private SchemaRevisionManager schemaRevisionManager;
private TestingDatabaseHelper testingDatabaseHelper;

@Test
@TmsLink("C12026")
public void init060102() {
testingDatabaseHelper.cleanTable();
final SortedMap<Long, SchemaRevisionManager.RevisionSql> sqls = FlywaveRevisionScanner
.scan(FlywaveRevisionScanner.REVISION_PATH_MASTER,
WingsRevision.V01_19_0521_01_EnumI18n.classpath());
var sqls = FlywaveRevisionScanner.scan(FlywaveRevisionScanner.REVISION_PATH_MASTER,
WingsRevision.V01_19_0521_01_EnumI18n.classpath());
schemaRevisionManager.checkAndInitSql(sqls, 0, true);
schemaRevisionManager.publishRevision(V90_22_0601_02_TestRecord.revision(), 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.SortedMap;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -51,7 +50,7 @@ public class WingsJooqDaoAliasImplTest {
private SchemaRevisionManager schemaRevisionManager;

@Setter(onMethod_ = {@Autowired})
private TstShardingDao dao;
private TstShardingDao tstShardingDao;

private final TstShardingTable tbl = TstShardingTable.TstSharding;
private final LocalDateTime now = LocalDateTime.now();
Expand All @@ -60,7 +59,7 @@ public class WingsJooqDaoAliasImplTest {
@TmsLink("C12081")
public void test0DropAndInit() {
testingDatabaseHelper.cleanTable();
final SortedMap<Long, SchemaRevisionManager.RevisionSql> sqls = FlywaveRevisionScanner.scan(REVISION_PATH_MASTER, WingsRevision.V01_19_0521_01_EnumI18n.classpath());
var sqls = FlywaveRevisionScanner.scan(REVISION_PATH_MASTER, WingsRevision.V01_19_0521_01_EnumI18n.classpath());
schemaRevisionManager.checkAndInitSql(sqls, 0, true);
schemaRevisionManager.publishRevision(V90_22_0601_02_TestRecord.revision(), -1);
}
Expand All @@ -79,9 +78,9 @@ public void test1BatchLoadSeeLog() {
new TstShardingRecord(303L, now, now, now, 9L, "batch load 303", "", ZH_CN)
);
testcaseNotice("batch load, check log, ignore, 301-303, use `from dual where exists` check, then insert");
dao.batchLoad(rds, true);
tstShardingDao.batchLoad(rds, true);
testcaseNotice("batch load, check log, replace, 301-303, use on duplicate key update");
dao.batchLoad(rds, false);
tstShardingDao.batchLoad(rds, false);
}

@Test
Expand All @@ -93,7 +92,7 @@ public void test2BatchInsertSeeLog() {
new TstShardingRecord(306L, now, now, now, 9L, "batch load 306", "", ZH_CN)
);
testcaseNotice("batch Insert, check log, 304-306, in 2 batch");
final var rs = dao.batchInsert(rds, 2);
final var rs = tstShardingDao.batchInsert(rds, 2);
assertArrayEquals(new int[]{1, 1, 1}, rs);
}

Expand All @@ -106,16 +105,16 @@ public void test3BatchMergeSeeLog() {
new TstShardingRecord(309L, now, now, now, 9L, "batch load 309", "", ZH_CN)
);
testcaseNotice("batch Insert, check log, ignore, 307-309, in 2 batch, insert ignore");
final var rs1 = dao.batchInsert(rds, 2, true);
final var rs1 = tstShardingDao.batchInsert(rds, 2, true);
assertArrayEquals(new int[]{1, 1, 1}, rs1);

testcaseNotice("batch Insert, check log, replace, 307-309, in 2 batch, replace into", "BUG https://github.com/apache/shardingsphere/issues/8226\n");
final var rs2 = dao.batchInsert(rds, 2, false);
final var rs2 = tstShardingDao.batchInsert(rds, 2, false);
assertArrayEquals(new int[]{1, 1, 1}, rs2);

testcaseNotice("batch Merge, check log, on dupkey, 307-309, in 2 batch, duplicate");
testcaseNotice("insert into `tst_sharding` (`id`, .., `other_info`) values (?,..., ?) on duplicate key update `login_info` = ?, `other_info` = ?");
final var rs3 = dao.batchMerge(tbl, rds, 2, tbl.LoginInfo, tbl.OtherInfo);
final var rs3 = tstShardingDao.batchMerge(tbl, rds, 2, tbl.LoginInfo, tbl.OtherInfo);
assertArrayEquals(new int[]{1, 1, 1}, rs3);
}

Expand All @@ -128,7 +127,7 @@ public void test4BatchStoreSeeLog() {
new TstShardingRecord(312L, now, now, now, 9L, "batch load 312", "merge", ZH_CN)
);
testcaseNotice("batch Insert, check log, ignore, 307-309, in 2 batch");
final var rs = dao.batchStore(rds, 2);
final var rs = tstShardingDao.batchStore(rds, 2);
assertArrayEquals(new int[]{1, 1, 1}, rs);
}

Expand All @@ -141,10 +140,10 @@ public void test5BatchUpdateSeeLog() {
new TstShardingRecord(311L, now, now, now, 9L, "batch load 311", "update", ZH_CN)
);
testcaseNotice("batch Update, check log, 307-309, in 2 batch");
final var rs1 = dao.batchUpdate(rds, 2);
final var rs1 = tstShardingDao.batchUpdate(rds, 2);
assertArrayEquals(new int[]{1, 1, 1}, rs1);

final var rs2 = dao.batchUpdate(tbl, new Field[]{tbl.Id}, rds, 2, tbl.LoginInfo, tbl.OtherInfo);
final var rs2 = tstShardingDao.batchUpdate(tbl, new Field[]{tbl.Id}, rds, 2, tbl.LoginInfo, tbl.OtherInfo);
assertArrayEquals(new int[]{1, 1, 1}, rs2);
}

Expand All @@ -153,7 +152,7 @@ public void test5BatchUpdateSeeLog() {
public void test6SingleMergeSeeLog() {
testcaseNotice("insert into `tst_sharding` (`id`, .., `other_info`) values (?,..., ?) on duplicate key update `login_info` = ?, `other_info` = ?");
TstSharding pojo = new TstSharding(312L, now, now, now, 9L, "batch load 312", "update-bymerge", ZH_CN);
final var rs = dao.mergeInto(tbl, pojo, tbl.LoginInfo, tbl.OtherInfo);
final var rs = tstShardingDao.mergeInto(tbl, pojo, tbl.LoginInfo, tbl.OtherInfo);
assertEquals(2, rs);
}

Expand All @@ -166,17 +165,17 @@ public void test7BatchMergeSeeLog() {
new TstShardingRecord(311L, now, now, now, 9L, "batch 311-merge", "update-merge", ZH_CN)
);
testcaseNotice("313 insert, 310,311 update");
final var rs = dao.batchMerge(tbl, new Field[]{tbl.Id}, rds, 2, tbl.LoginInfo, tbl.OtherInfo);
final var rs = tstShardingDao.batchMerge(tbl, new Field[]{tbl.Id}, rds, 2, tbl.LoginInfo, tbl.OtherInfo);
assertArrayEquals(new int[]{1, 1, 1}, rs);
}

@Test
@TmsLink("C12089")
public void test8LogicDeleteSeeLog() {
dao.fetchById(1L);
dao.fetchOneById(1L);
dao.count();
final TstShardingTable tbl = dao.getTable();
dao.count(tbl, tbl.getOnlyLive());
tstShardingDao.fetchById(1L);
tstShardingDao.fetchOneById(1L);
tstShardingDao.count();
final TstShardingTable tbl = tstShardingDao.getTable();
tstShardingDao.count(tbl, tbl.getOnlyLive());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.SortedMap;

import static pro.fessional.wings.faceless.convention.EmptyValue.DATE_TIME;
import static pro.fessional.wings.faceless.enums.autogen.StandardLanguage.ZH_CN;
Expand Down Expand Up @@ -60,7 +59,7 @@ public class JooqDeleteListenerTest {
@TmsLink("C12095")
public void test0CleanTables() {
testingDatabaseHelper.cleanTable();
final SortedMap<Long, SchemaRevisionManager.RevisionSql> sqls = FlywaveRevisionScanner.scan(REVISION_PATH_MASTER);
var sqls = FlywaveRevisionScanner.scan(REVISION_PATH_MASTER);
schemaRevisionManager.checkAndInitSql(sqls, 0, true);
schemaRevisionManager.publishRevision(V90_22_0601_02_TestRecord.revision(), -1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ public class JooqMapperCompatibleTest {
private TestingDatabaseHelper testingDatabaseHelper;

@Setter(onMethod_ = {@Autowired})
private TstShardingDao dao;
private TstShardingDao tstShardingDao;

@Test
@TmsLink("C12098")
public void test0Init() {
testingDatabaseHelper.cleanTable();
final var sqls = FlywaveRevisionScanner.scanMaster();
var sqls = FlywaveRevisionScanner.scanMaster();
schemaRevisionManager.checkAndInitSql(sqls, 0, false);
schemaRevisionManager.publishRevision(WingsRevision.V90_22_0601_02_TestRecord.revision(), 0);
}

@Test
@TmsLink("C12099")
public void test1Exist() {
final boolean b = dao.notTableExist();
final boolean b = tstShardingDao.notTableExist();
Assertions.assertFalse(b);
}

Expand All @@ -67,8 +67,8 @@ public static class SameName {
@Test
@TmsLink("C12100")
public void test1Lower() {
DSLContext ctx = dao.ctx();
TstShardingTable t = dao.getTable();
DSLContext ctx = tstShardingDao.ctx();
TstShardingTable t = tstShardingDao.getTable();
Condition c = t.Id.gt(1L).and(t.Id.le(105L));

testcaseNotice("Case-sensitive alias, not supported by jooq, supported by sfm");
Expand All @@ -85,8 +85,8 @@ public void test1Lower() {
@Test
@TmsLink("C12101")
public void test1Snake() {
DSLContext ctx = dao.ctx();
TstShardingTable t = dao.getTable();
DSLContext ctx = tstShardingDao.ctx();
TstShardingTable t = tstShardingDao.getTable();
Condition c = t.Id.gt(1L).and(t.Id.le(105L));

testcaseNotice("Underscore alias, supported by both jooq and sfm");
Expand All @@ -109,8 +109,8 @@ public void test1Array() {
vo.setId(101L);
vo.setLoginInfo("login-info test");

final TstShardingRecord rd = dao.newRecord(vo);
final Field<?>[] fld = dao.getTable().fields();
final TstShardingRecord rd = tstShardingDao.newRecord(vo);
final Field<?>[] fld = tstShardingDao.getTable().fields();
final Object[] arr = rd.intoArray();

Assertions.assertNotNull(rd.getLoginInfo());
Expand All @@ -120,16 +120,16 @@ public void test1Array() {
@Test
@TmsLink("C12103")
public void test2Array() {
TstShardingTable t = dao.getTable();
TstShardingTable t = tstShardingDao.getTable();
Condition c = t.Id.eq(105L);
final TstShardingRecord rd = dao.ctx()
.selectFrom(t)
.where(c)
.fetchOne();
final TstShardingRecord rd = tstShardingDao.ctx()
.selectFrom(t)
.where(c)
.fetchOne();
Assertions.assertNotNull(rd);
Assertions.assertNotNull(rd.getLoginInfo());
final Object[] arr = rd.intoArray();
final Field<?>[] fld = dao.getTable().fields();
final Field<?>[] fld = tstShardingDao.getTable().fields();
Assertions.assertEquals(fld.length, arr.length, "Sfm bug https://github.com/arnaudroger/SimpleFlatMapper/issues/764");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;

Expand Down Expand Up @@ -79,7 +78,7 @@ public class JooqTableCudListenerTest {
@TmsLink("C12104")
public void test0Init() {
testingDatabaseHelper.cleanTable();
final SortedMap<Long, SchemaRevisionManager.RevisionSql> sqls = FlywaveRevisionScanner.scan(REVISION_PATH_MASTER);
var sqls = FlywaveRevisionScanner.scan(REVISION_PATH_MASTER);
schemaRevisionManager.checkAndInitSql(sqls, 0, true);
schemaRevisionManager.publishRevision(V90_22_0601_02_TestRecord.revision(), -1);
}
Expand Down
Loading

0 comments on commit 983c7cc

Please sign in to comment.