diff options
author | 2017-03-14 19:36:20 +0800 | |
---|---|---|
committer | 2017-03-14 19:36:20 +0800 | |
commit | 68d0b52af532f4cde355b642593e76cf737aeb21 (patch) | |
tree | 001111a6823f2c29ab1cb3430cb0c9909c989157 /holmes-actions | |
parent | 29bf80d11209d1c4294cd0738f288e65f1be4a41 (diff) |
Add UT for actions
Change-Id: Ic2dd7c4326111d9d3b8565a6b7e83b4f46bc197d
Issue-ID: HOLMES-50
Signed-off-by: youbowu <wu.youbo@zte.com.cn>
Diffstat (limited to 'holmes-actions')
3 files changed, 8 insertions, 7 deletions
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/msb/MicroserviceBusRest.java b/holmes-actions/src/main/java/org/openo/holmes/common/msb/MicroserviceBusRest.java index eb9deef..c8e03e9 100644 --- a/holmes-actions/src/main/java/org/openo/holmes/common/msb/MicroserviceBusRest.java +++ b/holmes-actions/src/main/java/org/openo/holmes/common/msb/MicroserviceBusRest.java @@ -26,10 +26,11 @@ import org.openo.holmes.common.api.entity.ServiceRegisterEntity; @Path("/openoapi/microservices/v1/services")
public interface MicroserviceBusRest {
+
@Path("")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate,
- ServiceRegisterEntity entity) throws Exception;
+ ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate,
+ ServiceRegisterEntity entity);
}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java index 91e28a6..f7825e7 100644 --- a/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java +++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java @@ -35,7 +35,7 @@ public class MSBRegisterUtil { while (!flag && retry < 20) {
log.info("Holmes microservice register. retry:" + retry);
retry++;
- flag = inner_register(entity);
+ flag = innerRegister(entity);
if (!flag) {
log.warn("micro service register failed, sleep 30S and try again.");
threadSleep(30000);
@@ -47,7 +47,7 @@ public class MSBRegisterUtil { log.info("holmes micro service register end.");
}
- private boolean inner_register(ServiceRegisterEntity entity) {
+ private boolean innerRegister(ServiceRegisterEntity entity) {
try {
log.info("msbServerAddr:" + MicroServiceConfig.getMsbServerAddr());
log.info("entity:" + entity);
@@ -55,7 +55,7 @@ public class MSBRegisterUtil { MicroServiceConfig.getMsbServerAddr(), MicroserviceBusRest.class);
resourceserviceproxy.registerServce("false", entity);
} catch (Exception error) {
- log.error("microservice register failed!" + error.getMessage());
+ log.error("microservice register failed!" + error.getMessage(), error);
return false;
}
return true;
@@ -66,7 +66,7 @@ public class MSBRegisterUtil { try {
Thread.sleep(second);
} catch (InterruptedException error) {
- log.error("thread sleep error.errorMsg:" + error.getMessage());
+ log.error("thread sleep error.errorMsg:" + error.getMessage(), error);
}
log.info("sleep end .");
}
diff --git a/holmes-actions/src/test/java/org/openo/holmes/common/utils/MSBRegisterUtilTest.java b/holmes-actions/src/test/java/org/openo/holmes/common/utils/MSBRegisterUtilTest.java index 0845981..5d04c1a 100644 --- a/holmes-actions/src/test/java/org/openo/holmes/common/utils/MSBRegisterUtilTest.java +++ b/holmes-actions/src/test/java/org/openo/holmes/common/utils/MSBRegisterUtilTest.java @@ -65,7 +65,7 @@ public class MSBRegisterUtilTest { @Override
public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate,
- ServiceRegisterEntity entity) throws Exception {
+ ServiceRegisterEntity entity) {
return null;
}
}
|