Skip to content

Commit

Permalink
Merge remote-tracking branch 'dubbo/master' into up-dev-issue#7854
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoheng1 committed May 25, 2021
2 parents e342a31 + 028153a commit 660c550
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 42 deletions.
7 changes: 5 additions & 2 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

<!-- Follow this checklist to help us incorporate your contribution quickly and easily: -->

## Checklist
- [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
- [ ] Format the pull request title like `[Dubbo-XXX] Fix UnknownException when host config not exist #XXX`. Each commit in the pull request should have a meaningful subject line and body.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
- [ ] Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project.
- [ ] Run `mvn clean install -DskipTests=false` & `mvn clean test-compile failsafe:integration-test` to make sure unit-test and integration-test pass.
- [ ] Add some description to [dubbo-website](https://github.com/apache/dubbo-website) project if you are requesting to add a feature.
- [ ] GitHub Actions works fine on your own branch.
- [ ] If this contribution is large, please follow the [Software Donation Guide](https://github.com/apache/dubbo/wiki/Software-donation-guide).
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public void constructor(final TestInfo testInfo) throws IOException {
.settingIf(usesAuthentication, "requirepass " + REDIS_PASSWORD)
.build();
this.redisServer.start();
exception = null;
} catch (IOException e) {
e.printStackTrace();
exception = e;
}
if (exception == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,14 @@ public void testAll() {
try {
setUp();
testcase.call();
throwable = null;
break;
} catch (Throwable t) {
t.printStackTrace();
throwable = t;
}
}
if (throwable != null) {
throwable.printStackTrace();
Assertions.fail();
}
Assertions.assertNull(throwable);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public static void setUp() throws Exception {
.settingIf(SystemUtils.IS_OS_WINDOWS, "maxheap 128mb")
.build();
redisServer.start();
exception = null;
} catch (IOException e) {
e.printStackTrace();
exception = e;
}
if (exception == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public void setUp() throws Exception {
.settingIf(SystemUtils.IS_OS_WINDOWS, "maxheap 128mb")
.build();
this.redisServer.start();
exception = null;
} catch (IOException e) {
e.printStackTrace();
exception = e;
}
if (exception == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,8 @@ public Result invoke(Invocation invocation) throws RpcException {
if (invocation instanceof RpcInvocation) {
((RpcInvocation) invocation).setInvoker(this);
}
String mock = null;
if (getUrl().hasMethodParameter(invocation.getMethodName())) {
mock = getUrl().getParameter(invocation.getMethodName() + "." + MOCK_KEY);
}
if (StringUtils.isBlank(mock)) {
mock = getUrl().getParameter(MOCK_KEY);
}

String mock = getUrl().getMethodParameter(invocation.getMethodName(),MOCK_KEY);

if (StringUtils.isBlank(mock)) {
throw new RpcException(new IllegalAccessException("mock can not be null. url :" + url));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import org.apache.dubbo.rpc.InvokeMode;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcInvocation;

import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.ServiceRepository;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -311,6 +311,23 @@ public void testIsOneway() {

@Test
public void testIsAsync() {
Object[] args = new Object[] {"hello", "dubbo", 520};
Class<?> demoServiceClass = DemoService.class;
String serviceName = demoServiceClass.getName();
Invoker invoker = mock(Invoker.class);

URL url = URL.valueOf(
"test://127.0.0.1:1/org.apache.dubbo.rpc.support.DemoService?interface=org.apache.dubbo.rpc.support.DemoService");

RpcInvocation inv = new RpcInvocation("test", serviceName, "",
new Class<?>[] {String.class, String[].class, Object[].class},
new Object[] {"method", new String[] {}, args},
null, invoker, null);

Assertions.assertFalse(RpcUtils.isAsync(url, inv));
inv.setInvokeMode(InvokeMode.ASYNC);
Assertions.assertTrue(RpcUtils.isAsync(url, inv));

URL url1 = URL.valueOf("dubbo://localhost/?test.async=true");
Invocation inv1 = new RpcInvocation("test", "DemoService", "", new Class[]{}, new String[]{});
inv1.setAttachment("test." + ASYNC_KEY, Boolean.FALSE.toString());
Expand Down Expand Up @@ -418,26 +435,6 @@ public void testGetMethodName(String methodName) {
}
}

@Test
public void testIsAsync() {
Object[] args = new Object[] {"hello", "dubbo", 520};
Class<?> demoServiceClass = DemoService.class;
String serviceName = demoServiceClass.getName();
Invoker invoker = mock(Invoker.class);

URL url = URL.valueOf(
"test://127.0.0.1:1/org.apache.dubbo.rpc.support.DemoService?interface=org.apache.dubbo.rpc.support.DemoService");

RpcInvocation inv = new RpcInvocation("test", serviceName, "",
new Class<?>[] {String.class, String[].class, Object[].class},
new Object[] {"method", new String[] {}, args},
null, invoker, null);

Assertions.assertFalse(RpcUtils.isAsync(url, inv));
inv.setInvokeMode(InvokeMode.ASYNC);
Assertions.assertTrue(RpcUtils.isAsync(url, inv));
}

@Test
public void testIsGenericCall() {
Assertions.assertTrue(RpcUtils.isGenericCall("Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;", "$invoke"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public void setUp(final TestInfo testInfo) throws IOException {
.settingIf(usesAuthentication, "requirepass " + REDIS_PASSWORD)
.build();
this.redisServer.start();
exception = null;
} catch (IOException e) {
e.printStackTrace();
exception = e;
}
if (exception == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
*/
package org.apache.dubbo.rpc.protocol.webservice;

import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.extension.ExtensionLoader;
Expand All @@ -30,6 +26,10 @@
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.ProxyFactory;

import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
import org.junit.jupiter.api.Test;

import java.io.File;
Expand Down Expand Up @@ -85,7 +85,7 @@ public void testWebserviceProtocol() throws Exception {

@Test
public void testWebserviceServlet() throws LifecycleException {
int port = 55065;
int port = NetUtils.getAvailablePort();
Tomcat tomcat = buildTomcat("/dubbo-webservice", "/services/*", port);
DemoService service = new DemoServiceImpl();

Expand All @@ -96,7 +96,7 @@ public void testWebserviceServlet() throws LifecycleException {
.setPort(port)
.setPath("dubbo-webservice2/" + DemoService.class.getName())
.addParameter("server", "servlet")
.addParameter("bind.port", 55065)
.addParameter("bind.port", port)
.addParameter("contextpath", "dubbo-webservice2")
.addParameter(SERVICE_PATH_PREFIX, "dubbo-webservice/services")
.addParameter("codec", "exchange")
Expand All @@ -116,15 +116,15 @@ public void testWebserviceServlet() throws LifecycleException {
public void testWebserviceJetty() throws LifecycleException {
Tomcat tomcat = buildTomcat("/dubbo-webservice", "/services/*", 55065);
DemoService service = new DemoServiceImpl();
int port = 55066;
int port = NetUtils.getAvailablePort();

URLBuilder builder = new URLBuilder()
.setProtocol("webservice")
.setHost("127.0.0.1")
.setPort(port)
.setPath("dubbo-webservice3/" + DemoService.class.getName())
.addParameter("server", "jetty")
.addParameter("bind.port", 55066)
.addParameter("bind.port", port)
.addParameter("contextpath", "dubbo-webservice2")
.addParameter("codec", "exchange")
.addParameter("timeout", 3000);
Expand Down

0 comments on commit 660c550

Please sign in to comment.