You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tubemq.apache.org by go...@apache.org on 2020/09/08 07:19:27 UTC
[incubator-tubemq] branch master updated: [TUBEMQ-341] init tubeMQ
manager project (#250)
This is an automated email from the ASF dual-hosted git repository.
gosonzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tubemq.git
The following commit(s) were added to refs/heads/master by this push:
new 8a882ba [TUBEMQ-341] init tubeMQ manager project (#250)
8a882ba is described below
commit 8a882bac3b95c1a9f6a9c0c3ae84ae32287a533a
Author: Yuanbo Liu <yu...@apache.org>
AuthorDate: Tue Sep 8 15:19:18 2020 +0800
[TUBEMQ-341] init tubeMQ manager project (#250)
---
pom.xml | 3 +
tubemq-manager/pom.xml | 78 ++++++++++++++++++++++
.../org/apache/tubemq/manager/TubeMQManager.java | 28 ++++++++
.../apache/tubemq/manager/entry/BusinessEntry.java | 48 +++++++++++++
.../manager/repository/BusinessRepository.java | 27 ++++++++
.../manager/repository/TestBusinessRepository.java | 49 ++++++++++++++
6 files changed, 233 insertions(+)
diff --git a/pom.xml b/pom.xml
index fc7f074..afcdb83 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,9 @@
<gson.version>2.8.5</gson.version>
<docker.organization>apachetubemq</docker.organization>
<dockerfile-maven.version>1.4.13</dockerfile-maven.version>
+ <spring.boot.version>2.3.3.RELEASE</spring.boot.version>
+ <mysql.java.version>8.0.21</mysql.java.version>
+ <junit.platform.version>1.6.2</junit.platform.version>
</properties>
<repositories>
diff --git a/tubemq-manager/pom.xml b/tubemq-manager/pom.xml
new file mode 100644
index 0000000..6021701
--- /dev/null
+++ b/tubemq-manager/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+// 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.3.3.RELEASE</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tubemq-manager</artifactId>
+
+ <name>Apache TubeMQ - Manager</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-validation</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.4.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/TubeMQManager.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/TubeMQManager.java
new file mode 100644
index 0000000..2da5f0a
--- /dev/null
+++ b/tubemq-manager/src/main/java/org/apache/tubemq/manager/TubeMQManager.java
@@ -0,0 +1,28 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class TubeMQManager {
+ public static void main(String[] args) {
+ SpringApplication.run(TubeMQManager.class);
+ }
+}
diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/BusinessEntry.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/BusinessEntry.java
new file mode 100644
index 0000000..425a8e8
--- /dev/null
+++ b/tubemq-manager/src/main/java/org/apache/tubemq/manager/entry/BusinessEntry.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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager.entry;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.validation.constraints.Size;
+
+@Entity
+@Table(name = "business")
+public class BusinessEntry {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ @Size(min = 3, max = 20)
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/BusinessRepository.java b/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/BusinessRepository.java
new file mode 100644
index 0000000..24a22cf
--- /dev/null
+++ b/tubemq-manager/src/main/java/org/apache/tubemq/manager/repository/BusinessRepository.java
@@ -0,0 +1,27 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager.repository;
+
+import org.apache.tubemq.manager.entry.BusinessEntry;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface BusinessRepository extends JpaRepository<BusinessEntry, Long> {
+ public BusinessEntry findByName(String name);
+}
diff --git a/tubemq-manager/src/test/java/org/apache/tubemq/manager/repository/TestBusinessRepository.java b/tubemq-manager/src/test/java/org/apache/tubemq/manager/repository/TestBusinessRepository.java
new file mode 100644
index 0000000..b217018
--- /dev/null
+++ b/tubemq-manager/src/test/java/org/apache/tubemq/manager/repository/TestBusinessRepository.java
@@ -0,0 +1,49 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager.repository;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.apache.tubemq.manager.entry.BusinessEntry;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataJpaTest
+public class TestBusinessRepository {
+ @Autowired
+ private TestEntityManager entityManager;
+
+ @Autowired
+ private BusinessRepository businessRepository;
+
+ @Test
+ public void whenFindByNameThenReturnBusiness() {
+ BusinessEntry businessEntry = new BusinessEntry();
+ businessEntry.setName("alex");
+
+ entityManager.persist(businessEntry);
+ entityManager.flush();
+
+ BusinessEntry businessEntry1 = businessRepository.findByName("alex");
+ assertThat(businessEntry1.getName()).isEqualTo(businessEntry.getName());
+ }
+}