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/11 07:04:22 UTC

[incubator-linkis] branch dev-1.3.1 updated: feat: add metadata-query-common unit test (#3555)

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 048c04c4b feat: add metadata-query-common unit test (#3555)
048c04c4b is described below

commit 048c04c4bba3b47b4ac2ebbe83a2b05d142bbf61
Author: ruY <43...@users.noreply.github.com>
AuthorDate: Tue Oct 11 15:04:16 2022 +0800

    feat: add metadata-query-common unit test (#3555)
    
    * feat: add metadata-query-common unit test
---
 .../query/common/MdmConfigurationTest.java         | 37 +++++++++++++++++
 .../query/common/cache/CacheConfigurationTest.java | 40 ++++++++++++++++++
 .../query/common/cache/ConnCacheManagerTest.java   | 48 ++++++++++++++++++++++
 .../exception/MetaMethodInvokeExceptionTest.java   | 34 +++++++++++++++
 .../common/exception/MetaRuntimeExceptionTest.java | 34 +++++++++++++++
 5 files changed, 193 insertions(+)

diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/MdmConfigurationTest.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/MdmConfigurationTest.java
new file mode 100644
index 000000000..b37ea144b
--- /dev/null
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/MdmConfigurationTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.common;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class MdmConfigurationTest {
+
+  @Test
+  @DisplayName("constTest")
+  public void constTest() {
+
+    String metaDataServiceApplication = MdmConfiguration.METADATA_SERVICE_APPLICATION.getValue();
+    String dataSourceServiceApplication =
+        MdmConfiguration.DATA_SOURCE_SERVICE_APPLICATION.getValue();
+
+    Assertions.assertNotNull(metaDataServiceApplication);
+    Assertions.assertNotNull(dataSourceServiceApplication);
+  }
+}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/cache/CacheConfigurationTest.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/cache/CacheConfigurationTest.java
new file mode 100644
index 000000000..0afa7eb16
--- /dev/null
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/cache/CacheConfigurationTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.common.cache;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class CacheConfigurationTest {
+
+  @Test
+  @DisplayName("constTest")
+  public void constTest() {
+
+    Long cacheExpireTimeValue = CacheConfiguration.CACHE_EXPIRE_TIME.getValue();
+    Integer cacheInPoolSizeValue = CacheConfiguration.CACHE_IN_POOL_SIZE.getValue();
+    Long cacheMaxSizeValue = CacheConfiguration.CACHE_MAX_SIZE.getValue();
+    String mysqlRelationshipListValue = CacheConfiguration.MYSQL_RELATIONSHIP_LIST.getValue();
+
+    Assertions.assertTrue(cacheExpireTimeValue.longValue() == 600L);
+    Assertions.assertTrue(cacheInPoolSizeValue == 5);
+    Assertions.assertTrue(cacheMaxSizeValue == 1000L);
+    Assertions.assertNotNull(mysqlRelationshipListValue);
+  }
+}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/cache/ConnCacheManagerTest.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/cache/ConnCacheManagerTest.java
new file mode 100644
index 000000000..b7efa8846
--- /dev/null
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/cache/ConnCacheManagerTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.common.cache;
+
+import com.google.common.cache.Cache;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ConnCacheManagerTest {
+
+  @Test
+  @DisplayName("customTest")
+  public void customTest() {
+
+    CacheManager cacheManager = ConnCacheManager.custom();
+    Assertions.assertNotNull(cacheManager);
+  }
+
+  @Test
+  @DisplayName("buildCacheTest")
+  public void buildCacheTest() {
+
+    CacheManager cacheManager = ConnCacheManager.custom();
+    Cache<String, Object> cache =
+        cacheManager.buildCache(
+            "key",
+            notification -> {
+              assert notification.getValue() != null;
+            });
+    Assertions.assertNotNull(cache);
+  }
+}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/exception/MetaMethodInvokeExceptionTest.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/exception/MetaMethodInvokeExceptionTest.java
new file mode 100644
index 000000000..6af957137
--- /dev/null
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/exception/MetaMethodInvokeExceptionTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.common.exception;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class MetaMethodInvokeExceptionTest {
+
+  @Test
+  @DisplayName("metaMethodInvokeExceptionTest")
+  public void metaMethodInvokeExceptionTest() {
+    String errorMsg = "Load meta service for mysql ail load [mysql] metadata service failed";
+    MetaMethodInvokeException exception =
+        new MetaMethodInvokeException(500, errorMsg, new Exception());
+    Assertions.assertEquals(errorMsg, exception.getDesc());
+  }
+}
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/exception/MetaRuntimeExceptionTest.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/exception/MetaRuntimeExceptionTest.java
new file mode 100644
index 000000000..20b647e1d
--- /dev/null
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/common/src/test/java/org/apache/linkis/metadata/query/common/exception/MetaRuntimeExceptionTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.common.exception;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class MetaRuntimeExceptionTest {
+
+  @Test
+  @DisplayName("metaRuntimeExceptionTest")
+  public void metaRuntimeExceptionTest() {
+
+    String errorMsg = "Cannot find the keytab file in connect parameters";
+    MetaRuntimeException exception = new MetaRuntimeException(errorMsg, new Exception());
+    Assertions.assertEquals(errorMsg, exception.getDesc());
+  }
+}


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