You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by ni...@apache.org on 2023/12/01 11:34:19 UTC

(incubator-paimon-webui) branch main updated: [Bugfix] Fix testing error in ControllerTestBase with alignment with backend interface (#101)

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

nicholasjiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-paimon-webui.git


The following commit(s) were added to refs/heads/main by this push:
     new 834b09a  [Bugfix] Fix testing error in ControllerTestBase with alignment with backend interface (#101)
834b09a is described below

commit 834b09ab81de0a29354ae4e74af728169e1993f2
Author: yangyang zhong <35...@users.noreply.github.com>
AuthorDate: Fri Dec 1 19:34:14 2023 +0800

    [Bugfix] Fix testing error in ControllerTestBase with alignment with backend interface (#101)
---
 paimon-web-server/pom.xml                          |  12 ++
 .../src/main/resources/application-dev-h2.yml      |   4 +-
 paimon-web-server/src/main/resources/db/ddl-h2.sql | 128 ---------------------
 paimon-web-server/src/main/resources/db/dml-h2.sql |  73 ------------
 .../server/controller/CatalogControllerTest.java   |   3 -
 .../web/server/controller/ControllerTestBase.java  | 128 +++++++++++++--------
 .../resources/application-dev-h2.yml               |   4 +-
 .../src/test/resources/application.yml             |  67 +++++++++++
 8 files changed, 166 insertions(+), 253 deletions(-)

diff --git a/paimon-web-server/pom.xml b/paimon-web-server/pom.xml
index b6f30d6..4596682 100644
--- a/paimon-web-server/pom.xml
+++ b/paimon-web-server/pom.xml
@@ -111,6 +111,7 @@ under the License.
             <scope>runtime</scope>
         </dependency>
 
+
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter</artifactId>
@@ -180,6 +181,17 @@ under the License.
     </dependencies>
 
     <build>
+        <testResources>
+            <testResource>
+                <directory>${project.basedir}/../scripts</directory>
+                <includes>
+                    <include>sql/**</include>
+                </includes>
+            </testResource>
+            <testResource>
+                <directory>${project.basedir}/src/test/resources</directory>
+            </testResource>
+        </testResources>
         <finalName>${project.artifactId}-${project.version}</finalName>
         <resources>
             <resource>
diff --git a/paimon-web-server/src/main/resources/application-dev-h2.yml b/paimon-web-server/src/main/resources/application-dev-h2.yml
index 3a4532d..2ad5d08 100644
--- a/paimon-web-server/src/main/resources/application-dev-h2.yml
+++ b/paimon-web-server/src/main/resources/application-dev-h2.yml
@@ -19,12 +19,12 @@ spring:
       enabled: true
   datasource:
     driver-class-name: org.h2.Driver
-    url: jdbc:h2:mem:paimon;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;;NON_KEYWORDS=USER;INIT=runscript from 'classpath:db/ddl-h2.sql'
+    url: jdbc:h2:mem:paimon;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;NON_KEYWORDS=USER;
     username: root
     password: root
   sql:
     init:
-      data-locations: classpath:db/dml-h2.sql
+      data-locations: classpath:sql/paimon-h2.sql
       continue-on-error: true
       username: root
       password: root
diff --git a/paimon-web-server/src/main/resources/db/ddl-h2.sql b/paimon-web-server/src/main/resources/db/ddl-h2.sql
deleted file mode 100644
index f4b06e1..0000000
--- a/paimon-web-server/src/main/resources/db/ddl-h2.sql
+++ /dev/null
@@ -1,128 +0,0 @@
---  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.
-
-CREATE TABLE if not exists `user`
-(
-    `id`          int(11)      NOT NULL PRIMARY KEY COMMENT 'ID',
-    `username`    varchar(50)  NOT NULL COMMENT 'username',
-    `password`    varchar(50)  NULL     DEFAULT NULL COMMENT 'password',
-    `nickname`    varchar(50)  NULL     DEFAULT NULL COMMENT 'nickname',
-    `user_type`   int          NOT NULL DEFAULT 0 COMMENT 'login type (0:LOCAL,1:LDAP)',
-    `url`         varchar(100) NULL     DEFAULT NULL COMMENT 'avatar url',
-    `mobile`      varchar(20)  NULL     DEFAULT NULL COMMENT 'mobile phone',
-    `email`       varchar(100) NULL     DEFAULT NULL COMMENT 'email',
-    `enabled`     tinyint(1)   NOT NULL DEFAULT 1 COMMENT 'is enable',
-    `is_delete`   tinyint(1)   NOT NULL DEFAULT 0 COMMENT 'is delete',
-    `create_time` datetime(0)  NULL     DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0)  NULL     DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) ENGINE = InnoDB;
-
-CREATE TABLE if not exists `tenant`
-(
-    `id`          int(11)      NOT NULL PRIMARY KEY COMMENT 'ID',
-    `name`        varchar(64)  NULL     DEFAULT NULL COMMENT 'tenant name',
-    `description` varchar(255) NULL     DEFAULT NULL COMMENT 'tenant description',
-    `is_delete`   tinyint(1)   NOT NULL DEFAULT 0 COMMENT 'is delete',
-    `create_time` datetime(0)  NULL     DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0)  NULL     DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) ENGINE = InnoDB;
-
-CREATE TABLE if not exists `user_tenant`
-(
-    `id`          int(11)     NOT NULL PRIMARY KEY COMMENT 'ID',
-    `user_id`     int(11)     NOT NULL COMMENT 'user id',
-    `tenant_id`   int(11)     NOT NULL COMMENT 'tenant id',
-    `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) ENGINE = InnoDB;
-
-CREATE TABLE if not exists `sys_role`
-(
-    `id`          int(11)      not null primary key comment 'id',
-    `role_name`   varchar(30)  not null comment 'role name',
-    `role_key`    varchar(100) not null comment 'role key',
-    `sort`        int(4)       not null comment 'sort',
-    `enabled`     tinyint(1)   NOT NULL DEFAULT 1 COMMENT 'is enable',
-    `is_delete`   tinyint(1)   NOT NULL DEFAULT 0 COMMENT 'is delete',
-    `remark`      varchar(500)          default null comment 'remark',
-    `create_time` datetime(0)  NULL     DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0)  NULL     DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) engine = innodb;
-
-CREATE TABLE if not exists `sys_menu`
-(
-    `id`          int(11)  not null primary key comment 'id',
-    `menu_name`   varchar(50) not null comment 'menu name',
-    `parent_id`   int(11)           default 0 comment 'parent id',
-    `sort`        int(4)               default 0 comment 'sort',
-    `path`        varchar(200)         default '' comment 'route path',
-    `query`       varchar(255)         default null comment 'route params',
-    `is_cache`    int(1)               default 0 comment 'is cache(0:cache 1:no_cache)',
-    `type`        char(1)              default '' comment 'menu type(M:directory C:menu F:button)',
-    `visible`     char(1)              default 0 comment 'is visible(0:display 1:hide)',
-    `component`   varchar(255)         default null comment 'component path',
-    `is_frame`    int(1)               default 0 comment 'is frame',
-    `enabled`     tinyint(1)  NOT NULL DEFAULT 1 COMMENT 'is enable',
-    `is_delete`   tinyint(1)  NOT NULL DEFAULT 0 COMMENT 'is delete',
-    `perms`       varchar(100)         default null comment 'menu perms',
-    `icon`        varchar(100)         default '#' comment 'menu icon',
-    `remark`      varchar(500)         default '' comment 'remark',
-    `create_time` datetime(0) NULL     DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0) NULL     DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) engine = innodb;
-
-CREATE TABLE if not exists `user_role`
-(
-    `id`          int(11)     not null primary key comment 'id',
-    `user_id`     int(11)     not null comment 'user id',
-    `role_id`     int(11)     not null comment 'role id',
-    `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time',
-    unique key `idx_user_role` (`user_id`, `role_id`)
-) engine = innodb;
-
-CREATE TABLE if not exists `role_menu`
-(
-    `id`          int(11)     not null primary key comment 'id',
-    `role_id`     int(11)     not null comment 'role id',
-    `menu_id`     int(11)     not null comment 'menu id',
-    `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time',
-    unique key `idx_role_menu` (`role_id`, `menu_id`)
-) engine = innodb;
-
-CREATE TABLE if not exists `catalog`
-(
-    `id`          int(11)     not null primary key comment 'id',
-    `catalog_type`     varchar(50)  not null comment 'catalog type',
-    `catalog_name`     varchar(100)     not null comment 'catalog name',
-    `warehouse`     varchar(200)     not null comment 'warehouse',
-    `hive_uri`     varchar(200)     comment 'hive uri',
-    `hive_conf_dir`     varchar(100)   comment 'catalog name',
-    `is_delete`   tinyint(1)   NOT NULL DEFAULT 0 COMMENT 'is delete',
-    `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) engine = innodb;
-
-CREATE TABLE if not exists `databases`
-(
-    `id`          int(11)     not null primary key comment 'id',
-    `database_name`     varchar(50)  not null comment 'database name',
-    `catalog_id`     int(11)     not null comment 'catalog id',
-    `description`     varchar(200)  comment 'description',
-    `is_delete`   tinyint(1)   NOT NULL DEFAULT 0 COMMENT 'is delete',
-    `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
-    `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) engine = innodb;
diff --git a/paimon-web-server/src/main/resources/db/dml-h2.sql b/paimon-web-server/src/main/resources/db/dml-h2.sql
deleted file mode 100644
index 77d10ae..0000000
--- a/paimon-web-server/src/main/resources/db/dml-h2.sql
+++ /dev/null
@@ -1,73 +0,0 @@
---  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.
-
-INSERT INTO `user` ( id, username, password, nickname, mobile
-                   , email, enabled, is_delete)
-VALUES ( 1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Admin', 0
-       , 'admin@paimon.com', 1, 0);
-INSERT INTO `user` (id, username, password, nickname, mobile, email, enabled, is_delete)
-VALUES (2, 'common', '21232f297a57a5a743894a0e4a801fc3', 'common', 0, 'common@paimon.com', 1, 0);
-
-INSERT INTO `tenant` (id, name, description)
-VALUES (1, 'DefaultTenant', 'DefaultTenant');
-
-INSERT INTO `user_tenant` (`id`, `user_id`, `tenant_id`)
-VALUES (1, 1, 1);
-
-insert into sys_role (id, role_name, role_key, sort)
-values (1, 'admin', 'admin', 1),
-       (2, 'common', 'common', 2);
-
-insert into sys_menu (id, menu_name, parent_id, sort, path, component, is_frame, type, perms, icon, remark)
-values (1, 'all', 0, 1, 'system', null, 1, 'M', 'system', 'admin', 'system root path'),
-       (100, 'user manager', 1, 1, 'user', 'user/index', 1, 'C', 'system:user:list', 'user', 'user manager'),
-       (1000, 'user query', 100, 1, '', '', 1, 'F', 'system:user:query', '#', ''),
-       (1001, 'user add', 100, 2, '', '', 1, 'F', 'system:user:add', '#', ''),
-       (1002, 'user edit', 100, 3, '', '', 1, 'F', 'system:user:edit', '#', ''),
-       (1003, 'user del', 100, 4, '', '', 1, 'F', 'system:user:remove', '#', ''),
-       (1004, 'user reset', 100, 5, '', '', 1, 'F', 'system:user:resetPwd', '#', ''),
-       (200, 'role manager', 1, 1, 'role', 'role/index', 1, 'C', 'system:role:list', 'role', 'role manager'),
-       (2000, 'role query', 200, 1, '', '', 1, 'F', 'system:role:query', '#', ''),
-       (2001, 'role add', 200, 2, '', '', 1, 'F', 'system:role:add', '#', ''),
-       (2002, 'role edit', 200, 3, '', '', 1, 'F', 'system:role:edit', '#', ''),
-       (2003, 'role del', 200, 4, '', '', 1, 'F', 'system:role:remove', '#', ''),
-       (300, 'menu manager', 1, 1, 'menu', 'menu/index', 1, 'C', 'system:menu:list', 'menu', 'menu manager'),
-       (3000, 'menu query', 300, 1, '', '', 1, 'F', 'system:menu:query', '#', ''),
-       (3001, 'menu add', 300, 2, '', '', 1, 'F', 'system:menu:add', '#', ''),
-       (3002, 'menu edit', 300, 3, '', '', 1, 'F', 'system:menu:edit', '#', ''),
-       (3003, 'menu del', 300, 4, '', '', 1, 'F', 'system:menu:remove', '#', '');
-
-insert into user_role (id, user_id, role_id)
-values (1, 1, 1), (2, 2, 2);
-
-insert into role_menu (role_id, menu_id)
-values (1, 1),
-       (1, 100),
-       (1, 1000),
-       (1, 1001),
-       (1, 1002),
-       (1, 1003),
-       (1, 1004);
-
-/*insert into `catalog` (catalog_type, catalog_name, warehouse)
-values ('filesystem', 'paimon', 'file:///D:/path/'),
-       ('filesystem', 'fts', 'file:///D:/path/'),
-       ('filesystem', 'streaming_warehouse', 'file:///D:/path/');
-
-insert into `databases` (database_name, catalog_id, description)
-values ('ods', 1, 'description'),
-       ('ods', 2, 'description'),
-       ('ods', 3, 'description')*/
-
diff --git a/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/CatalogControllerTest.java b/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/CatalogControllerTest.java
index 642659f..0d0557a 100644
--- a/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/CatalogControllerTest.java
+++ b/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/CatalogControllerTest.java
@@ -26,7 +26,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
 import org.junit.jupiter.api.MethodOrderer;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestMethodOrder;
-import org.junit.jupiter.api.io.TempDir;
 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.http.MediaType;
@@ -44,8 +43,6 @@ public class CatalogControllerTest extends ControllerTestBase {
 
     private static final String catalogPath = "/api/catalog";
 
-    @TempDir java.nio.file.Path tempFile;
-
     private static final String catalogName = "testCatalog";
 
     @Test
diff --git a/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/ControllerTestBase.java b/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/ControllerTestBase.java
index ce0a2cc..6a0f833 100644
--- a/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/ControllerTestBase.java
+++ b/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/ControllerTestBase.java
@@ -41,6 +41,7 @@ import org.springframework.http.MediaType;
 import org.springframework.mock.web.MockCookie;
 import org.springframework.mock.web.MockHttpServletResponse;
 import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.ResultActions;
 import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
 import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
 import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
@@ -84,7 +85,6 @@ public class ControllerTestBase {
         LoginDTO login = new LoginDTO();
         login.setUsername("admin");
         login.setPassword("admin");
-
         MockHttpServletResponse response =
                 mockMvc.perform(
                                 MockMvcRequestBuilders.post(loginPath)
@@ -110,25 +110,30 @@ public class ControllerTestBase {
         catalog.setWarehouse(tempFile.toUri().toString());
         catalog.setDelete(false);
 
-        mockMvc.perform(
-                MockMvcRequestBuilders.post(catalogPath + "/create")
-                        .cookie(cookie)
-                        .content(ObjectMapperUtils.toJSON(catalog))
-                        .contentType(MediaType.APPLICATION_JSON_VALUE)
-                        .accept(MediaType.APPLICATION_JSON_VALUE));
+        ResultActions createCatalogRa =
+                mockMvc.perform(
+                        MockMvcRequestBuilders.post(catalogPath + "/create")
+                                .cookie(cookie)
+                                .content(ObjectMapperUtils.toJSON(catalog))
+                                .contentType(MediaType.APPLICATION_JSON_VALUE)
+                                .accept(MediaType.APPLICATION_JSON_VALUE));
+        R<?> createCatalogR = getR(createCatalogRa);
+        assertEquals(200, createCatalogR.getCode());
 
         // create default database
         DatabaseDTO database = new DatabaseDTO();
-        database.setCatalogId(catalogId);
         database.setName(databaseName);
         database.setCatalogName(catalogName);
 
-        mockMvc.perform(
-                MockMvcRequestBuilders.post(databasePath + "/create")
-                        .cookie(cookie)
-                        .content(ObjectMapperUtils.toJSON(database))
-                        .contentType(MediaType.APPLICATION_JSON_VALUE)
-                        .accept(MediaType.APPLICATION_JSON_VALUE));
+        ResultActions createDatabaseRa =
+                mockMvc.perform(
+                        MockMvcRequestBuilders.post(databasePath + "/create")
+                                .cookie(cookie)
+                                .content(ObjectMapperUtils.toJSON(database))
+                                .contentType(MediaType.APPLICATION_JSON_VALUE)
+                                .accept(MediaType.APPLICATION_JSON_VALUE));
+        R<?> createDatabaseR = getR(createDatabaseRa);
+        assertEquals(200, createDatabaseR.getCode());
 
         // create default table
         List<TableColumn> tableColumns = new ArrayList<>();
@@ -149,12 +154,20 @@ public class ControllerTestBase {
                         .tableOptions(Maps.newHashMap())
                         .build();
 
-        mockMvc.perform(
-                MockMvcRequestBuilders.post(tablePath + "/create")
-                        .cookie(cookie)
-                        .content(ObjectMapperUtils.toJSON(table))
-                        .contentType(MediaType.APPLICATION_JSON_VALUE)
-                        .accept(MediaType.APPLICATION_JSON_VALUE));
+        MockHttpServletResponse createTableResultAction =
+                mockMvc.perform(
+                                MockMvcRequestBuilders.post(tablePath + "/create")
+                                        .cookie(cookie)
+                                        .content(ObjectMapperUtils.toJSON(table))
+                                        .contentType(MediaType.APPLICATION_JSON_VALUE)
+                                        .accept(MediaType.APPLICATION_JSON_VALUE))
+                        .andExpect(MockMvcResultMatchers.status().isOk())
+                        .andDo(MockMvcResultHandlers.print())
+                        .andReturn()
+                        .getResponse();
+        String createTableResult = createTableResultAction.getContentAsString();
+        R<?> createTableR = ObjectMapperUtils.fromJSON(createTableResult, R.class);
+        assertEquals(200, createTableR.getCode());
     }
 
     @AfterEach
@@ -173,30 +186,55 @@ public class ControllerTestBase {
         R<?> r = ObjectMapperUtils.fromJSON(result, R.class);
         assertEquals(200, r.getCode());
 
-        mockMvc.perform(
-                MockMvcRequestBuilders.delete(
-                                tablePath
-                                        + "/drop/"
-                                        + catalogName
-                                        + "/"
-                                        + databaseName
-                                        + "/"
-                                        + tableName)
-                        .cookie(cookie)
-                        .contentType(MediaType.APPLICATION_JSON_VALUE)
-                        .accept(MediaType.APPLICATION_JSON_VALUE));
-
-        mockMvc.perform(
-                MockMvcRequestBuilders.delete(
-                                databasePath + "/drop/" + databaseName + "/" + catalogName)
-                        .cookie(cookie)
-                        .contentType(MediaType.APPLICATION_JSON_VALUE)
-                        .accept(MediaType.APPLICATION_JSON_VALUE));
-
-        mockMvc.perform(
-                MockMvcRequestBuilders.delete(catalogPath + "/remove/" + catalogName)
-                        .cookie(cookie)
-                        .contentType(MediaType.APPLICATION_JSON_VALUE)
-                        .accept(MediaType.APPLICATION_JSON_VALUE));
+        ResultActions dropTableRa =
+                mockMvc.perform(
+                        MockMvcRequestBuilders.delete(
+                                        tablePath
+                                                + "/drop/"
+                                                + catalogName
+                                                + "/"
+                                                + databaseName
+                                                + "/"
+                                                + tableName)
+                                .cookie(cookie)
+                                .contentType(MediaType.APPLICATION_JSON_VALUE)
+                                .accept(MediaType.APPLICATION_JSON_VALUE));
+        R<?> dropDatabaseR = getR(dropTableRa);
+        assertEquals(200, dropDatabaseR.getCode());
+
+        DatabaseDTO database = new DatabaseDTO();
+        database.setName(databaseName);
+        database.setCatalogName(catalogName);
+        ResultActions dropDatabasesRa =
+                mockMvc.perform(
+                        MockMvcRequestBuilders.post(databasePath + "/drop")
+                                .cookie(cookie)
+                                .content(ObjectMapperUtils.toJSON(database))
+                                .contentType(MediaType.APPLICATION_JSON_VALUE)
+                                .accept(MediaType.APPLICATION_JSON_VALUE));
+        R<?> dropDatabasesR = getR(dropDatabasesRa);
+        assertEquals(200, dropDatabasesR.getCode());
+
+        CatalogDTO catalog = new CatalogDTO();
+        catalog.setName(catalogName);
+        ResultActions removeCatalogRa =
+                mockMvc.perform(
+                        MockMvcRequestBuilders.post(catalogPath + "/remove")
+                                .cookie(cookie)
+                                .content(ObjectMapperUtils.toJSON(catalog))
+                                .contentType(MediaType.APPLICATION_JSON_VALUE)
+                                .accept(MediaType.APPLICATION_JSON_VALUE));
+        R<?> removeCatalogResult = getR(removeCatalogRa);
+        assertEquals(200, removeCatalogResult.getCode());
+    }
+
+    protected R<?> getR(ResultActions perform) throws Exception {
+        MockHttpServletResponse response =
+                perform.andExpect(MockMvcResultMatchers.status().isOk())
+                        .andDo(MockMvcResultHandlers.print())
+                        .andReturn()
+                        .getResponse();
+        String result = response.getContentAsString();
+        return ObjectMapperUtils.fromJSON(result, R.class);
     }
 }
diff --git a/paimon-web-server/src/main/resources/application-dev-h2.yml b/paimon-web-server/src/test/resources/application-dev-h2.yml
similarity index 91%
copy from paimon-web-server/src/main/resources/application-dev-h2.yml
copy to paimon-web-server/src/test/resources/application-dev-h2.yml
index 3a4532d..cad8f92 100644
--- a/paimon-web-server/src/main/resources/application-dev-h2.yml
+++ b/paimon-web-server/src/test/resources/application-dev-h2.yml
@@ -19,12 +19,12 @@ spring:
       enabled: true
   datasource:
     driver-class-name: org.h2.Driver
-    url: jdbc:h2:mem:paimon;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;;NON_KEYWORDS=USER;INIT=runscript from 'classpath:db/ddl-h2.sql'
+    url: jdbc:h2:mem:paimon;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;NON_KEYWORDS=USER;
     username: root
     password: root
   sql:
     init:
-      data-locations: classpath:db/dml-h2.sql
+      data-locations: classpath:sql/paimon-mysql.sql
       continue-on-error: true
       username: root
       password: root
diff --git a/paimon-web-server/src/test/resources/application.yml b/paimon-web-server/src/test/resources/application.yml
new file mode 100644
index 0000000..337c0fb
--- /dev/null
+++ b/paimon-web-server/src/test/resources/application.yml
@@ -0,0 +1,67 @@
+# 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.
+
+# Paimon Web Service Port
+server:
+  port: 10088
+
+spring:
+  # Paimon Web Service Name
+  application:
+    name: Paimon-Web-UI
+  profiles:
+    active: dev-h2
+  messages:
+    basename: i18n/messages
+    encoding: UTF-8
+
+  # mvc config
+  mvc:
+    pathmatch:
+      # Path matching strategy, default ant_path_matcher, support ant_path_matcher and path_pattern_parser
+      matching-strategy: ant_path_matcher
+    format:
+      date: yyyy-MM-dd HH:mm:ss # date format
+      time: HH:mm:ss # time format
+      date-time: yyyy-MM-dd HH:mm:ss # date-time format
+
+  # json format global configuration
+  jackson:
+    time-zone: GMT+8 # Time zone, default is GMT+8
+    date-format: yyyy-MM-dd HH:mm:ss # Date format, the default is yyyy-MM-dd HH:mm:ss
+
+mybatis-plus:
+  mapperLocations: classpath*:mapper/*Mapper.xml
+  global-config:
+    banner: false
+    db-config:
+      logic-delete-field: is_delete
+  configuration:
+    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
+    # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+sa-token:
+  token-name: ${spring.application.name}
+  timeout: 2592000
+  active-timeout: -1
+  is-concurrent: true
+  is-share: true
+  token-style: uuid
+  is-log: false
+  is-print: false
+  is-read-cookie: true
+  is-write-header: true
+  is-read-header: true
+  is-read-body: true
\ No newline at end of file