Skip to content

Commit

Permalink
optimize spring autoconfigure server unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
l81893521 committed Dec 30, 2023
1 parent a23be3d commit 7860680
Show file tree
Hide file tree
Showing 10 changed files with 444 additions and 0 deletions.
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
Loading

0 comments on commit 7860680

Please sign in to comment.