You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by il...@apache.org on 2019/07/09 03:51:35 UTC

[dubbo-samples] branch master updated: adjust timeout to make integration test pass

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

iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new 47f340d  adjust timeout to make integration test pass
47f340d is described below

commit 47f340dc15c8beea3f3c398e18c72abbf14042cc
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Tue Jul 9 11:49:39 2019 +0800

    adjust timeout to make integration test pass
---
 .../annotation/AnnotationProviderBootstrap.java    |  1 -
 .../samples/annotation/EmbeddedZooKeeper.java      | 44 ++++++++++------------
 .../impl/AnnotationGreetingServiceImpl.java        |  2 +-
 .../resources/spring/dubbo-consumer.properties     |  2 +-
 .../samples/annotation/AnnotationServicesIT.java   |  2 +-
 5 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationProviderBootstrap.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationProviderBootstrap.java
index 5bce155..a22cb60 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationProviderBootstrap.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationProviderBootstrap.java
@@ -34,7 +34,6 @@ public class AnnotationProviderBootstrap {
 
     public static void main(String[] args) throws Exception {
         new EmbeddedZooKeeper(2181, false).start();
-        Thread.sleep(1000);
 
         AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
         context.start();
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/EmbeddedZooKeeper.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/EmbeddedZooKeeper.java
index 0018215..83deb50 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/EmbeddedZooKeeper.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/EmbeddedZooKeeper.java
@@ -1,11 +1,12 @@
 /*
- * Copyright 2014 the original author or authors.
+ * 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
  *
- * Licensed 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
+ *     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,
@@ -15,11 +16,6 @@
  */
 package org.apache.dubbo.samples.annotation;
 
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.Properties;
-import java.util.UUID;
-
 import org.apache.zookeeper.server.ServerConfig;
 import org.apache.zookeeper.server.ZooKeeperServerMain;
 import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
@@ -29,11 +25,16 @@ import org.springframework.context.SmartLifecycle;
 import org.springframework.util.ErrorHandler;
 import org.springframework.util.SocketUtils;
 
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Properties;
+import java.util.UUID;
+
 /**
  * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
- *
+ * <p>
  * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper.
- *
+ * <p>
  * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for
  * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication}
  *
@@ -90,7 +91,7 @@ public class EmbeddedZooKeeper implements SmartLifecycle {
     /**
      * Construct an EmbeddedZooKeeper with the provided port.
      *
-     * @param clientPort  port for ZooKeeper server to bind to
+     * @param clientPort port for ZooKeeper server to bind to
      */
     public EmbeddedZooKeeper(int clientPort, boolean daemon) {
         this.clientPort = clientPort;
@@ -176,9 +177,7 @@ public class EmbeddedZooKeeper implements SmartLifecycle {
                 Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
                 shutdown.setAccessible(true);
                 shutdown.invoke(zkServer);
-            }
-
-            catch (Exception e) {
+            } catch (Exception e) {
                 throw new RuntimeException(e);
             }
 
@@ -188,8 +187,7 @@ public class EmbeddedZooKeeper implements SmartLifecycle {
             try {
                 zkServerThread.join(5000);
                 zkServerThread = null;
-            }
-            catch (InterruptedException e) {
+            } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
                 logger.warn("Interrupted while waiting for embedded ZooKeeper to exit");
                 // abandoning zk thread
@@ -227,7 +225,7 @@ public class EmbeddedZooKeeper implements SmartLifecycle {
             try {
                 Properties properties = new Properties();
                 File file = new File(System.getProperty("java.io.tmpdir")
-                    + File.separator + UUID.randomUUID());
+                        + File.separator + UUID.randomUUID());
                 file.deleteOnExit();
                 properties.setProperty("dataDir", file.getAbsolutePath());
                 properties.setProperty("clientPort", String.valueOf(clientPort));
@@ -240,12 +238,10 @@ public class EmbeddedZooKeeper implements SmartLifecycle {
                 configuration.readFrom(quorumPeerConfig);
 
                 zkServer.runFromConfig(configuration);
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 if (errorHandler != null) {
                     errorHandler.handleError(e);
-                }
-                else {
+                } else {
                     logger.error("Exception running embedded ZooKeeper", e);
                 }
             }
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationGreetingServiceImpl.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationGreetingServiceImpl.java
index d9c7489..257e5ec 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationGreetingServiceImpl.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationGreetingServiceImpl.java
@@ -38,7 +38,7 @@ public class AnnotationGreetingServiceImpl implements GreetingService {
 
     private void sleepWhile() {
         try {
-            Thread.sleep(300);
+            Thread.sleep(3000);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
diff --git a/dubbo-samples-annotation/src/main/resources/spring/dubbo-consumer.properties b/dubbo-samples-annotation/src/main/resources/spring/dubbo-consumer.properties
index ea1d2c0..a09945a 100644
--- a/dubbo-samples-annotation/src/main/resources/spring/dubbo-consumer.properties
+++ b/dubbo-samples-annotation/src/main/resources/spring/dubbo-consumer.properties
@@ -19,4 +19,4 @@
 
 dubbo.application.name=samples-annotation-consumer
 dubbo.registry.address=zookeeper://${zookeeper.address:127.0.0.1}:2181
-dubbo.consumer.timeout=3000
+dubbo.consumer.timeout=1000
diff --git a/dubbo-samples-annotation/src/test/java/org/apache/dubbo/samples/annotation/AnnotationServicesIT.java b/dubbo-samples-annotation/src/test/java/org/apache/dubbo/samples/annotation/AnnotationServicesIT.java
index d60a41e..ce5e191 100644
--- a/dubbo-samples-annotation/src/test/java/org/apache/dubbo/samples/annotation/AnnotationServicesIT.java
+++ b/dubbo-samples-annotation/src/test/java/org/apache/dubbo/samples/annotation/AnnotationServicesIT.java
@@ -49,6 +49,6 @@ public class AnnotationServicesIT {
 
     @Test
     public void testReplyGreeting() throws Exception {
-        Assert.assertEquals("Annotation, fine dubbo", annotationAction.replyGreeting("dubbo"));
+        Assert.assertEquals("Throw Exception", annotationAction.replyGreeting("dubbo"));
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org