diff options
Diffstat (limited to 'rulemgt/src')
-rw-r--r-- | rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java | 24 | ||||
-rw-r--r-- | rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java | 37 |
2 files changed, 34 insertions, 27 deletions
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java index da62a22..b96303a 100644 --- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java +++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineService.java @@ -72,13 +72,7 @@ public class EngineService { }
return httpClient.execute(httpPost);
} finally {
- if (httpClient != null) {
- try {
- httpClient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ httpClient.close();
}
}
@@ -92,13 +86,7 @@ public class EngineService { }
return httpClient.execute(httpPut);
} finally {
- if (httpClient != null) {
- try {
- httpClient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ httpClient.close();
}
}
@@ -109,13 +97,7 @@ public class EngineService { setHeader(httpDelete);
return httpClient.execute(httpDelete);
} finally {
- if (httpClient != null) {
- try {
- httpClient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ httpClient.close();
}
}
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java index d911f9c..596a408 100644 --- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java @@ -18,15 +18,15 @@ package org.openo.holmes.rulemgt.bolt.enginebolt;
-import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.openo.holmes.rulemgt.RuleAppConfig;
+import org.openo.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;
+import org.openo.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
import org.powermock.api.easymock.PowerMock;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.powermock.reflect.Whitebox;
@@ -38,18 +38,18 @@ public class EngineServiceTest { @Rule
public PowerMockRule powerMockRule = new PowerMockRule();
private EngineService engineService;
- private HttpEntity httpEntityMock;
private HttpResponse httpResponseMock;
- private HttpClient httpClient;
private RuleAppConfig ruleAppConfig = new RuleAppConfig();
+ private CorrelationDeployRule4Engine correlationDeployRule4Engine;
@Before
public void setUp() {
engineService = new EngineService();
- httpEntityMock = PowerMock.createMock(HttpEntity.class);
httpResponseMock = PowerMock.createMock(HttpResponse.class);
- httpClient = PowerMock.createMock(HttpClient.class);
Whitebox.setInternalState(engineService, "ruleAppConfig", ruleAppConfig);
+ correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
+ correlationDeployRule4Engine.setContent("{\"package\":\"test\"}");
+ correlationDeployRule4Engine.setEngineId("engine_id");
}
@Test
@@ -61,4 +61,29 @@ public class EngineServiceTest { PowerMock.verifyAll();
}
+
+ @Test
+ public void delete_exception() throws Exception {
+ thrown.expect(Exception.class);
+
+ engineService.delete("test");
+
+ }
+
+ @Test
+ public void deploy_exception() throws Exception {
+
+ thrown.expect(Exception.class);
+
+ engineService.deploy(correlationDeployRule4Engine);
+
+ }
+
+ @Test
+ public void check_normal() throws Exception {
+ thrown.expect(Exception.class);
+
+ engineService.check(new CorrelationCheckRule4Engine());
+
+ }
}
\ No newline at end of file |