You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/04/03 06:28:10 UTC

[incubator-servicecomb-java-chassis] 05/05: SCB-441 fix pr comment

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

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 538bebfd242fa0633f19aabfb7a71e6d847d577c
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Thu Mar 29 09:14:27 2018 +0800

    SCB-441 fix pr comment
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 archetypes/README.md                               |  4 +-
 archetypes/business-service-jaxrs/README.md        |  7 +--
 archetypes/business-service-jaxrs/pom.xml          |  9 +--
 .../servicecomb/archetypes/HelloConsumer.java      | 30 ++++++++++
 .../servicecomb/archetypes/TestConsumer.java       | 65 ----------------------
 .../src/test/resources/localregistry.yaml          | 26 ---------
 6 files changed, 35 insertions(+), 106 deletions(-)

diff --git a/archetypes/README.md b/archetypes/README.md
index 1e0d4fe..e71f2d0 100644
--- a/archetypes/README.md
+++ b/archetypes/README.md
@@ -2,9 +2,7 @@
 ### What's maven archetypes
 From http://maven.apache.org/guides/introduction/introduction-to-archetypes.html :
 
-"*In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The name fits as we are trying to provide a system that provides a consistent means of generating Maven projects. Archetype will help authors create Maven project templates for users, and provides users with the means to generate parameterized versions of those project templates.*"
-
-"*Using archetypes provides a great way to enable developers quickly in a way consistent with best practices employed by your project or organization. Within the Maven project, we use archetypes to try and get our users up and running as quickly as possible by providing a sample project that demonstrates many of the features of Maven, while introducing new users to the best practices employed by Maven. In a matter of seconds, a new user can have a working Maven project to use as a jumpin [...]
+>In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The name fits as we are trying to provide a system that provides a consistent means of generating Maven projects. Archetype will help authors create Maven project templates for users, and provides users with the means to generate parameterized versions of those project templates.
 
 ### What we provide
 1. business-service-jaxrs  
diff --git a/archetypes/business-service-jaxrs/README.md b/archetypes/business-service-jaxrs/README.md
index 9d47cfe..43c1dac 100644
--- a/archetypes/business-service-jaxrs/README.md
+++ b/archetypes/business-service-jaxrs/README.md
@@ -1,13 +1,10 @@
 ## Welcome to use ServiceComb Java Chassis
-This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-jaxrs-archetype*, it use **jaxrs provider** to develop service endpoint, you can run test directly.  
-```bash
-mvn test
-```
+This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-jaxrs-archetype*, it use **jaxrs provider** to develop service endpoint.  
 
 ### More works can be done further:
 1. Modify "HelloEndpoint", add your business service logic, or create some new endpoints to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-jax-rs/
 2. Modify "microservice.yaml", change APPLICATION_ID, service_description.name, version, and service center address, endpoints publish address etc. More details can be found : http://servicecomb.incubator.apache.org/users/service-definition/
-3. Add unit test for your endpoints like what we had done in "TestConsumer".
+3. Modify setting value of "mainClass" in pom.xml for package.
 
 ### Package your service
 Under project(module) root folder, run 
diff --git a/archetypes/business-service-jaxrs/pom.xml b/archetypes/business-service-jaxrs/pom.xml
index 836c2f7..00f6f5d 100644
--- a/archetypes/business-service-jaxrs/pom.xml
+++ b/archetypes/business-service-jaxrs/pom.xml
@@ -41,6 +41,7 @@
   </dependencyManagement>
 
   <dependencies>
+    <!--for provider-->
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>transport-rest-vertx</artifactId>
@@ -58,16 +59,10 @@
       <artifactId>slf4j-log4j12</artifactId>
     </dependency>
 
-    <!--only for consumer under test-->
+    <!--for consumer-->
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>provider-springmvc</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
     </dependency>
   </dependencies>
 
diff --git a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java b/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java
new file mode 100644
index 0000000..7007c11
--- /dev/null
+++ b/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.archetypes;
+
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.springframework.web.client.RestTemplate;
+
+public class HelloConsumer {
+  private final RestTemplate restTemplate = RestTemplateBuilder.create();
+
+  public void invokeHello(){
+    String result = restTemplate.getForObject("cse://business-service/hello", String.class);
+  }
+
+}
diff --git a/archetypes/business-service-jaxrs/src/test/java/org/apache/servicecomb/archetypes/TestConsumer.java b/archetypes/business-service-jaxrs/src/test/java/org/apache/servicecomb/archetypes/TestConsumer.java
deleted file mode 100644
index 230c556..0000000
--- a/archetypes/business-service-jaxrs/src/test/java/org/apache/servicecomb/archetypes/TestConsumer.java
+++ /dev/null
@@ -1,65 +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.
- */
-
-package org.apache.servicecomb.archetypes;
-
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
-import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
-import org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
-
-@Component
-public class TestConsumer {
-
-  private static String setting;
-
-  private final RestTemplate restTemplate = RestTemplateBuilder.create();
-
-  //use local registry for test consumer
-  //more details can be found :
-  // http://servicecomb.incubator.apache.org/users/develop-with-rest-template/
-  // http://servicecomb.incubator.apache.org/users/develop-with-rpc/
-  @BeforeClass
-  public static void setUp() {
-    setting = System.getProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY);
-    System.setProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY,
-        TestConsumer.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "localregistry.yaml");
-  }
-
-  @Test
-  public void test() throws Exception {
-    //start provider
-    Log4jUtils.init();
-    BeanUtils.init();
-
-    //consumer call
-    String result = restTemplate.getForObject("cse://business-service/hello", String.class);
-    Assert.assertEquals("Hello World!", result);
-  }
-
-  //recovery local.registry.file setting
-  @AfterClass
-  public static void tearDown() {
-    System.setProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY, setting == null ? "" : setting);
-  }
-}
diff --git a/archetypes/business-service-jaxrs/src/test/resources/localregistry.yaml b/archetypes/business-service-jaxrs/src/test/resources/localregistry.yaml
deleted file mode 100644
index 728ac91..0000000
--- a/archetypes/business-service-jaxrs/src/test/resources/localregistry.yaml
+++ /dev/null
@@ -1,26 +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.
-## ---------------------------------------------------------------------------
-
-# test service invocation between microservices without service center
-business-service:
-  - id: "001"
-    version: "1.0.0"
-    appid: business
-    instances:
-      - endpoints:
-        - rest://127.0.0.1:8080
-        - highway://127.0.0.1:7070

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.