-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize spring autoconfigure server unit test
- Loading branch information
Showing
10 changed files
with
444 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...test/java/io/seata/spring/boot/autoconfigure/properties/server/MetricsPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.server; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
*/ | ||
public class MetricsPropertiesTest { | ||
|
||
@Test | ||
public void testMetricsProperties() { | ||
MetricsProperties metricsProperties = new MetricsProperties(); | ||
metricsProperties.setRegistryType("type"); | ||
metricsProperties.setExporterList("list"); | ||
metricsProperties.setEnabled(true); | ||
metricsProperties.setExporterPrometheusPort(1); | ||
|
||
Assertions.assertEquals("type", metricsProperties.getRegistryType()); | ||
Assertions.assertEquals("list", metricsProperties.getExporterList()); | ||
Assertions.assertTrue(metricsProperties.getEnabled()); | ||
Assertions.assertEquals(1, metricsProperties.getExporterPrometheusPort()); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../test/java/io/seata/spring/boot/autoconfigure/properties/server/ServerPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.server; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
*/ | ||
public class ServerPropertiesTest { | ||
|
||
@Test | ||
public void testMetricsProperties() { | ||
ServerProperties serverProperties = new ServerProperties(); | ||
serverProperties.setXaerNotaRetryTimeout(1); | ||
serverProperties.setRetryDeadThreshold(1); | ||
serverProperties.setApplicationDataLimit(1); | ||
serverProperties.setServicePort(1); | ||
serverProperties.setEnableCheckAuth(true); | ||
serverProperties.setApplicationDataLimitCheck(true); | ||
serverProperties.setEnableParallelHandleBranch(true); | ||
serverProperties.setEnableParallelRequestHandle(true); | ||
serverProperties.setRollbackRetryTimeoutUnlockEnable(true); | ||
serverProperties.setMaxCommitRetryTimeout(1L); | ||
serverProperties.setMaxRollbackRetryTimeout(1L); | ||
|
||
Assertions.assertEquals(1, serverProperties.getXaerNotaRetryTimeout()); | ||
Assertions.assertEquals(1, serverProperties.getRetryDeadThreshold()); | ||
Assertions.assertEquals(1, serverProperties.getApplicationDataLimit()); | ||
Assertions.assertEquals(1, serverProperties.getServicePort()); | ||
Assertions.assertTrue(serverProperties.getEnableCheckAuth()); | ||
Assertions.assertTrue(serverProperties.getApplicationDataLimitCheck()); | ||
Assertions.assertTrue(serverProperties.getEnableParallelHandleBranch()); | ||
Assertions.assertTrue(serverProperties.getEnableParallelRequestHandle()); | ||
Assertions.assertTrue(serverProperties.getRollbackRetryTimeoutUnlockEnable()); | ||
Assertions.assertEquals(1L, serverProperties.getMaxCommitRetryTimeout()); | ||
Assertions.assertEquals(1L, serverProperties.getMaxRollbackRetryTimeout()); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...t/java/io/seata/spring/boot/autoconfigure/properties/server/ServerRaftPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.server; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
*/ | ||
public class ServerRaftPropertiesTest { | ||
|
||
@Test | ||
public void testServerRaftProperties() { | ||
ServerRaftProperties serverRaftProperties = new ServerRaftProperties(); | ||
serverRaftProperties.setServerAddr("server"); | ||
serverRaftProperties.setGroup("group"); | ||
serverRaftProperties.setCompressor("compressor"); | ||
serverRaftProperties.setSerialization("serialization"); | ||
serverRaftProperties.setApplyBatch(1); | ||
serverRaftProperties.setDisruptorBufferSize(1); | ||
serverRaftProperties.setElectionTimeoutMs(1); | ||
serverRaftProperties.setMaxAppendBufferSize(1); | ||
serverRaftProperties.setMaxReplicatorInflightMsgs(1); | ||
serverRaftProperties.setReporterInitialDelay(1); | ||
serverRaftProperties.setSnapshotInterval(1); | ||
serverRaftProperties.setAutoJoin(true); | ||
serverRaftProperties.setReporterEnabled(true); | ||
serverRaftProperties.setSync(true); | ||
|
||
Assertions.assertEquals("server", serverRaftProperties.getServerAddr()); | ||
Assertions.assertEquals("group", serverRaftProperties.getGroup()); | ||
Assertions.assertEquals("compressor", serverRaftProperties.getCompressor()); | ||
Assertions.assertEquals("serialization", serverRaftProperties.getSerialization()); | ||
Assertions.assertEquals(1, serverRaftProperties.getApplyBatch()); | ||
Assertions.assertEquals(1, serverRaftProperties.getDisruptorBufferSize()); | ||
Assertions.assertEquals(1, serverRaftProperties.getElectionTimeoutMs()); | ||
Assertions.assertEquals(1, serverRaftProperties.getMaxAppendBufferSize()); | ||
Assertions.assertEquals(1, serverRaftProperties.getMaxReplicatorInflightMsgs()); | ||
Assertions.assertEquals(1, serverRaftProperties.getReporterInitialDelay()); | ||
Assertions.assertEquals(1, serverRaftProperties.getSnapshotInterval()); | ||
Assertions.assertTrue(serverRaftProperties.getAutoJoin()); | ||
Assertions.assertTrue(serverRaftProperties.isReporterEnabled()); | ||
Assertions.assertTrue(serverRaftProperties.isSync()); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...va/io/seata/spring/boot/autoconfigure/properties/server/ServerRecoveryPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.server; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
*/ | ||
public class ServerRecoveryPropertiesTest { | ||
|
||
@Test | ||
public void testServerRecoveryProperties() { | ||
ServerRecoveryProperties serverRecoveryProperties = new ServerRecoveryProperties(); | ||
serverRecoveryProperties.setAsyncCommittingRetryPeriod(1L); | ||
serverRecoveryProperties.setCommittingRetryPeriod(1L); | ||
serverRecoveryProperties.setRollbackingRetryPeriod(1L); | ||
serverRecoveryProperties.setTimeoutRetryPeriod(1L); | ||
|
||
Assertions.assertEquals(1L, serverRecoveryProperties.getAsyncCommittingRetryPeriod()); | ||
Assertions.assertEquals(1L, serverRecoveryProperties.getCommittingRetryPeriod()); | ||
Assertions.assertEquals(1L, serverRecoveryProperties.getRollbackingRetryPeriod()); | ||
Assertions.assertEquals(1L, serverRecoveryProperties.getTimeoutRetryPeriod()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...t/java/io/seata/spring/boot/autoconfigure/properties/server/ServerUndoPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.server; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
*/ | ||
public class ServerUndoPropertiesTest { | ||
|
||
@Test | ||
public void testServerUndoProperties() { | ||
ServerUndoProperties serverUndoProperties = new ServerUndoProperties(); | ||
serverUndoProperties.setLogSaveDays((short) 1); | ||
serverUndoProperties.setLogDeletePeriod(1); | ||
|
||
Assertions.assertEquals(1, serverUndoProperties.getLogSaveDays()); | ||
Assertions.assertEquals(1, serverUndoProperties.getLogDeletePeriod()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...a/io/seata/spring/boot/autoconfigure/properties/server/session/SessionPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.server.session; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
*/ | ||
public class SessionPropertiesTest { | ||
|
||
@Test | ||
public void testSessionProperties() { | ||
SessionProperties sessionProperties = new SessionProperties(); | ||
sessionProperties.setEnableBranchAsync(true); | ||
sessionProperties.setBranchAsyncQueueSize(1); | ||
|
||
Assertions.assertTrue(sessionProperties.getEnableBranchAsync()); | ||
Assertions.assertEquals(1, sessionProperties.getBranchAsyncQueueSize()); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ava/io/seata/spring/boot/autoconfigure/properties/server/store/StoreDBPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.server.store; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
*/ | ||
public class StoreDBPropertiesTest { | ||
|
||
@Test | ||
public void testStoreDBProperties() { | ||
StoreDBProperties storeDBProperties = new StoreDBProperties(); | ||
storeDBProperties.setUrl("url"); | ||
storeDBProperties.setUser("user"); | ||
storeDBProperties.setPassword("pwd"); | ||
storeDBProperties.setDatasource("datasource"); | ||
storeDBProperties.setDbType("type"); | ||
storeDBProperties.setGlobalTable("global"); | ||
storeDBProperties.setBranchTable("branch"); | ||
storeDBProperties.setLockTable("lock"); | ||
storeDBProperties.setDistributedLockTable("distribute"); | ||
storeDBProperties.setDriverClassName("driver"); | ||
storeDBProperties.setMinConn(1); | ||
storeDBProperties.setMaxConn(1); | ||
storeDBProperties.setQueryLimit(1); | ||
storeDBProperties.setMaxWait(1L); | ||
|
||
Assertions.assertEquals("url", storeDBProperties.getUrl()); | ||
Assertions.assertEquals("user", storeDBProperties.getUser()); | ||
Assertions.assertEquals("pwd", storeDBProperties.getPassword()); | ||
Assertions.assertEquals("datasource", storeDBProperties.getDatasource()); | ||
Assertions.assertEquals("type", storeDBProperties.getDbType()); | ||
Assertions.assertEquals("global", storeDBProperties.getGlobalTable()); | ||
Assertions.assertEquals("branch", storeDBProperties.getBranchTable()); | ||
Assertions.assertEquals("lock", storeDBProperties.getLockTable()); | ||
Assertions.assertEquals("distribute", storeDBProperties.getDistributedLockTable()); | ||
Assertions.assertEquals("driver", storeDBProperties.getDriverClassName()); | ||
Assertions.assertEquals(1, storeDBProperties.getMinConn()); | ||
Assertions.assertEquals(1, storeDBProperties.getMaxConn()); | ||
Assertions.assertEquals(1, storeDBProperties.getQueryLimit()); | ||
Assertions.assertEquals(1L, storeDBProperties.getMaxWait()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...a/io/seata/spring/boot/autoconfigure/properties/server/store/StoreFilePropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure.properties.server.store; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
*/ | ||
public class StoreFilePropertiesTest { | ||
|
||
@Test | ||
public void testStoreFileProperties() { | ||
StoreFileProperties storeFileProperties = new StoreFileProperties(); | ||
storeFileProperties.setDir("dir"); | ||
storeFileProperties.setFlushDiskMode("disk"); | ||
storeFileProperties.setFileWriteBufferCacheSize(1); | ||
storeFileProperties.setMaxBranchSessionSize(1); | ||
storeFileProperties.setMaxGlobalSessionSize(1); | ||
storeFileProperties.setSessionReloadReadSize(1); | ||
|
||
Assertions.assertEquals("dir", storeFileProperties.getDir()); | ||
Assertions.assertEquals("disk", storeFileProperties.getFlushDiskMode()); | ||
Assertions.assertEquals(1, storeFileProperties.getFileWriteBufferCacheSize()); | ||
Assertions.assertEquals(1, storeFileProperties.getMaxGlobalSessionSize()); | ||
Assertions.assertEquals(1, storeFileProperties.getMaxBranchSessionSize()); | ||
Assertions.assertEquals(1, storeFileProperties.getSessionReloadReadSize()); | ||
} | ||
} |
Oops, something went wrong.