This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 328054616 add shenyu-common dto unit test (#4539) (#4549)
328054616 is described below
commit 32805461633fc39101899eecd1060c7a71bbe7ee
Author: Xudong Fu <[email protected]>
AuthorDate: Wed Apr 12 17:34:29 2023 +0800
add shenyu-common dto unit test (#4539) (#4549)
* add shenyu-common dto unit test (#4539)
* add shenyu-common dto unit test, checkstyle (#4539)
---------
Co-authored-by: moremind <[email protected]>
---
.../dto/convert/plugin/BrpcRegisterConfigTest.java | 54 ++++++++++++++++++++++
.../common/dto/convert/rule/MockHandleTest.java | 50 ++++++++++++++++++++
2 files changed, 104 insertions(+)
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/BrpcRegisterConfigTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/BrpcRegisterConfigTest.java
new file mode 100644
index 000000000..b3ff56f69
--- /dev/null
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/plugin/BrpcRegisterConfigTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.shenyu.common.dto.convert.plugin;
+
+import com.google.common.collect.ImmutableSet;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Test case for BrpcRegisterConfig.
+ */
+public class BrpcRegisterConfigTest {
+
+ @Test
+ public void testSetterGetter() {
+ BrpcRegisterConfig config = new BrpcRegisterConfig();
+ config.setThreadpool("threadPool");
+ config.setCorethreads(10);
+ config.setThreads(10);
+ config.setQueues(2);
+
+ assertThat(config.getThreadpool(), is("threadPool"));
+ assertThat(config.getCorethreads(), is(10));
+ assertThat(config.getThreads(), is(10));
+ assertThat(config.getQueues(), is(2));
+ }
+
+ @Test
+ public void testEqualsAndHashCode() {
+ BrpcRegisterConfig config1 = new BrpcRegisterConfig();
+ BrpcRegisterConfig config2 = new BrpcRegisterConfig();
+
+ assertThat(ImmutableSet.of(config1, config2), hasSize(1));
+ }
+
+}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/MockHandleTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/MockHandleTest.java
new file mode 100644
index 000000000..9916d439e
--- /dev/null
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/MockHandleTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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 org.apache.shenyu.common.dto.convert.rule;
+
+import com.google.common.collect.ImmutableSet;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test case for MockHandle.
+ */
+public class MockHandleTest {
+
+ @Test
+ public void testSetterGetter() {
+ MockHandle handle = new MockHandle();
+ handle.setHttpStatusCode(200);
+ handle.setResponseContent("OK");
+
+ assertThat(handle.getHttpStatusCode(), is(200));
+ assertThat(handle.getResponseContent(), is("OK"));
+ }
+
+ @Test
+ public void testEqualsAndHashCode() {
+ MockHandle handle1 = new MockHandle();
+ MockHandle handle2 = new MockHandle();
+
+ assertThat(ImmutableSet.of(handle1, handle2), hasSize(1));
+ }
+
+}