You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/10/10 09:29:51 UTC

[incubator-linkis] branch dev-1.3.1 updated: feat: metadata-query-server unit test (#3554)

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new 30728db3e feat: metadata-query-server unit test (#3554)
30728db3e is described below

commit 30728db3eb2fa09ead10c564f461e0448f31681d
Author: ruY <43...@users.noreply.github.com>
AuthorDate: Mon Oct 10 17:29:46 2022 +0800

    feat: metadata-query-server unit test (#3554)
---
 .../server/loader/MetaClassLoaderManagerTest.java  | 36 +++++++++++++
 .../server/receiver/BaseMetaReceiverTest.java      | 61 ++++++++++++++++++++++
 .../src/test/resources/application.properties      | 30 +++++------
 3 files changed, 111 insertions(+), 16 deletions(-)

diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/java/org/apache/linkis/metadata/query/server/loader/MetaClassLoaderManagerTest.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/java/org/apache/linkis/metadata/query/server/loader/MetaClassLoaderManagerTest.java
new file mode 100644
index 000000000..1bb965420
--- /dev/null
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/java/org/apache/linkis/metadata/query/server/loader/MetaClassLoaderManagerTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.linkis.metadata.query.server.loader;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class MetaClassLoaderManagerTest {
+
+  @Test
+  @DisplayName("constTest")
+  public void constTest() {
+
+    Integer instanceExpireTimeValue = MetaClassLoaderManager.INSTANCE_EXPIRE_TIME.getValue();
+    String libDirValue = MetaClassLoaderManager.LIB_DIR.getValue();
+
+    Assertions.assertTrue(instanceExpireTimeValue.intValue() == 60);
+    Assertions.assertNotNull(libDirValue);
+  }
+}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/java/org/apache/linkis/metadata/query/server/receiver/BaseMetaReceiverTest.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/java/org/apache/linkis/metadata/query/server/receiver/BaseMetaReceiverTest.java
new file mode 100644
index 000000000..64acfc6d1
--- /dev/null
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/java/org/apache/linkis/metadata/query/server/receiver/BaseMetaReceiverTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.linkis.metadata.query.server.receiver;
+
+import org.apache.linkis.metadata.query.common.protocol.MetadataConnect;
+import org.apache.linkis.metadata.query.common.protocol.MetadataResponse;
+import org.apache.linkis.metadata.query.server.WebApplicationServer;
+import org.apache.linkis.metadata.query.server.service.impl.MetadataQueryServiceImpl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import java.util.HashMap;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mockito;
+
+@ExtendWith({SpringExtension.class})
+@AutoConfigureMockMvc
+@SpringBootTest(classes = {WebApplicationServer.class})
+public class BaseMetaReceiverTest {
+
+  @Autowired private BaseMetaReceiver baseMetaReceiver;
+
+  @MockBean(name = "metadataQueryServiceImpl")
+  MetadataQueryServiceImpl metadataQueryServiceImpl;
+
+  @Test
+  @DisplayName("dealMetadataConnectRequestTest")
+  public void dealMetadataConnectRequestTest() throws Exception {
+
+    MetadataConnect metadataConnect = new MetadataConnect("mysql", "query", new HashMap<>(), "1");
+    Mockito.doNothing()
+        .when(metadataQueryServiceImpl)
+        .getConnection(Mockito.anyString(), Mockito.anyString(), Mockito.anyMap());
+    MetadataResponse response = baseMetaReceiver.dealMetadataConnectRequest(metadataConnect);
+
+    Assertions.assertTrue(response.status());
+  }
+}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/resources/application.properties b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/resources/application.properties
index 886ae24f3..5572769a6 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/resources/application.properties
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/server/src/test/resources/application.properties
@@ -1,19 +1,17 @@
-/*
-* 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.
-*/
+#
+# 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.
+#
 
 #disable eureka discovery client
 spring.cloud.service-registry.auto-registration.enabled=false


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org