You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/07/24 13:33:48 UTC

[GitHub] liubao68 closed pull request #835: [SCB-772]fix unit test fail on ubuntu for unknown reasons

liubao68 closed pull request #835: [SCB-772]fix unit test fail on ubuntu for unknown reasons
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/835
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/demo/demo-spring-boot-discovery/demo-spring-boot-discovery-client/src/test/resources/logback-test.xml b/demo/demo-spring-boot-discovery/demo-spring-boot-discovery-client/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..3f394068d
--- /dev/null
+++ b/demo/demo-spring-boot-discovery/demo-spring-boot-discovery-client/src/test/resources/logback-test.xml
@@ -0,0 +1,21 @@
+<?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.
+  -->
+<configuration>
+  <include resource="org/springframework/boot/logging/logback/base.xml"/>
+  <logger name="org.springframework" level="ERROR"/>
+</configuration>
\ No newline at end of file
diff --git a/demo/demo-spring-boot-discovery/demo-spring-boot-discovery-server/src/main/resources/logback-test.xml b/demo/demo-spring-boot-discovery/demo-spring-boot-discovery-server/src/main/resources/logback-test.xml
new file mode 100644
index 000000000..3f394068d
--- /dev/null
+++ b/demo/demo-spring-boot-discovery/demo-spring-boot-discovery-server/src/main/resources/logback-test.xml
@@ -0,0 +1,21 @@
+<?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.
+  -->
+<configuration>
+  <include resource="org/springframework/boot/logging/logback/base.xml"/>
+  <logger name="org.springframework" level="ERROR"/>
+</configuration>
\ No newline at end of file
diff --git a/demo/demo-spring-boot-discovery/demo-spring-boot-zuul-proxy/src/test/resources/logback-test.xml b/demo/demo-spring-boot-discovery/demo-spring-boot-zuul-proxy/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..3f394068d
--- /dev/null
+++ b/demo/demo-spring-boot-discovery/demo-spring-boot-zuul-proxy/src/test/resources/logback-test.xml
@@ -0,0 +1,21 @@
+<?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.
+  -->
+<configuration>
+  <include resource="org/springframework/boot/logging/logback/base.xml"/>
+  <logger name="org.springframework" level="ERROR"/>
+</configuration>
\ No newline at end of file
diff --git a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
index 8a2916737..a0c3c1015 100644
--- a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
+++ b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
@@ -36,10 +36,7 @@
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Test;
-
-import mockit.Expectations;
-import mockit.Injectable;
-import mockit.Mocked;
+import org.mockito.Mockito;
 
 /**
  *
@@ -50,16 +47,16 @@
   @After
   public void teardown() {
     CseContext.getInstance().setTransportManager(null);
-    RegistryUtils.setServiceRegistry(null);
     ArchaiusUtils.resetConfig();
   }
 
   @Test
-  public void testZoneAwareAndIsolationFilterWorks(@Injectable Invocation invocation,
-      @Mocked RegistryUtils registryUtils,
-      @Injectable InstanceCacheManager instanceCacheManager, @Injectable ServiceRegistry serviceRegistry,
-      @Injectable TransportManager transportManager,
-      @Injectable Transport transport) {
+  public void testZoneAwareAndIsolationFilterWorks() {
+    Invocation invocation = Mockito.mock(Invocation.class);
+    InstanceCacheManager instanceCacheManager = Mockito.mock(InstanceCacheManager.class);
+    ServiceRegistry serviceRegistry = Mockito.mock(ServiceRegistry.class);
+    TransportManager transportManager = Mockito.mock(TransportManager.class);
+    Transport transport = Mockito.mock(Transport.class);
     ArchaiusUtils.setProperty("servicecomb.loadbalance.filter.operation.enabled", "false");
 
     // set up data
@@ -107,28 +104,17 @@ public void testZoneAwareAndIsolationFilterWorks(@Injectable Invocation invocati
     DiscoveryTreeNode parent = new DiscoveryTreeNode().name("parent").data(data);
     CseContext.getInstance().setTransportManager(transportManager);
 
-    new Expectations() {
-      {
-        invocation.getAppId();
-        result = "testApp";
-        invocation.getMicroserviceName();
-        result = "testMicroserviceName";
-        invocation.getMicroserviceVersionRule();
-        result = "0.0.0+";
-        invocation.getConfigTransportName();
-        result = "rest";
-        RegistryUtils.getMicroserviceInstance();
-        result = myself;
-        RegistryUtils.getServiceRegistry();
-        result = serviceRegistry;
-        serviceRegistry.getInstanceCacheManager();
-        result = instanceCacheManager;
-        instanceCacheManager.getOrCreateVersionedCache("testApp", "testMicroserviceName", "0.0.0+");
-        result = parent;
-        transportManager.findTransport("rest");
-        result = transport;
-      }
-    };
+    RegistryUtils.setServiceRegistry(serviceRegistry);
+
+    Mockito.when(invocation.getAppId()).thenReturn("testApp");
+    Mockito.when(invocation.getMicroserviceName()).thenReturn("testMicroserviceName");
+    Mockito.when(invocation.getMicroserviceVersionRule()).thenReturn("0.0.0+");
+    Mockito.when(invocation.getConfigTransportName()).thenReturn("rest");
+    Mockito.when(serviceRegistry.getMicroserviceInstance()).thenReturn(myself);
+    Mockito.when(serviceRegistry.getInstanceCacheManager()).thenReturn(instanceCacheManager);
+    Mockito.when(instanceCacheManager.getOrCreateVersionedCache("testApp", "testMicroserviceName", "0.0.0+"))
+        .thenReturn(parent);
+    Mockito.when(transportManager.findTransport("rest")).thenReturn(transport);
 
     LoadbalanceHandler handler = null;
     LoadBalancer loadBalancer = null;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services