Skip to content

Commit

Permalink
Fix test case not stable (#4440)
Browse files Browse the repository at this point in the history
  • Loading branch information
liubao68 authored Jul 31, 2024
1 parent e4b8b95 commit b3b8042
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,20 @@ private static void runImpl() throws Exception {
String microserviceName = "springmvc";

try {
// this test class is intended for retry hanging issue JAV-127
// only works in rest, highway does not have name param, because not defined.
templateUrlWithServiceName.getForObject(prefix + "/controller/sayhi?name=throwexception", String.class);
TestMgr.check("true", "false");
} catch (Exception e) {
TestMgr.check("true", "true");
}
try {
// only works in rest, highway does not have name param, because not defined.
templateUrlWithServiceName.getForObject(prefix + "/controller/sayhi?name=throwexception", String.class);
TestMgr.check("true", "false");
} catch (Exception e) {
TestMgr.check("true", "true");
}

testHandler(microserviceName);
CodeFirstRestTemplateSpringmvc codeFirstClient =
BeanUtils.getContext().getBean(CodeFirstRestTemplateSpringmvc.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.servicecomb.demo.springmvc;

import org.apache.servicecomb.demo.TestMgr;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -35,5 +36,6 @@ public void setUp() {
@Test
public void clientGetsNoError() {
SpringmvcClient.run();
Assertions.assertTrue(TestMgr.isSuccess());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import java.util.Arrays;

import org.apache.servicecomb.core.CoreConst;
import org.apache.servicecomb.core.annotation.Transport;
import org.apache.servicecomb.demo.controller.Person;
import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
Expand Down Expand Up @@ -60,7 +62,7 @@ public String saySomething(String prefix, @RequestBody Person user) {
return prefix + " " + user.getName();
}

// Parameters defined in controller.yaml. The code definition do not have any parameters.
@Transport(name = CoreConst.RESTFUL)
@RequestMapping(path = "/sayhi", method = RequestMethod.GET)
public String sayHi(HttpServletRequest request) throws Exception {
String addr = request.getRemoteAddr();
Expand Down

0 comments on commit b3b8042

Please sign in to comment.