Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fiqare-emergya-dev committed Jan 23, 2020
1 parent 05982ba commit 61b8a4c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
} catch (IOException exception) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}


}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
logger.debug("getting log level");
synchronized (mutex) {
try {
String currentLevel = LogManager.getRootLogger().getLevel().toString();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_OK);
response.getOutputStream().print(String.format("{\"level\":\"%s\"}",Encode.forHtmlContent(currentLevel)));
try {
String currentLevel = LogManager.getRootLogger().getLevel().toString();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_OK);
response.getOutputStream().print(String.format("{\"level\":\"%s\"}",Encode.forHtmlContent(currentLevel)));
} catch (IOException e) {
logger.error("IOException in log level");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
response.setContentType("application/json;charset=UTF-8");

try {
String body = Utils.getBodyAsString(request);
String body = Utils.getBodyAsString(request);

// Save temporary rules, not triggered by events external to the core
TimeRulesStore.getInstance().saveTimeRules(body);
Expand Down Expand Up @@ -143,8 +143,7 @@ protected void doPut(HttpServletRequest request, HttpServletResponse response)
Utils.putCorrelatorAndTrans(request);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json;charset=UTF-8");
try {

try {
String body = Utils.getBodyAsString(request);

// Save timed rules, which are not activated by events external to the core
Expand All @@ -154,11 +153,9 @@ protected void doPut(HttpServletRequest request, HttpServletResponse response)
response.setStatus(r.getStatusCode());
response.getOutputStream().print(Encode.forHtmlContent(r.getMessage()));
} catch (Exception je) {
logger.error(String.format("error: %s" ,je));
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
logger.error(String.format("error: %s" ,je));
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}


}

/**
Expand All @@ -175,9 +172,7 @@ protected void doDelete(HttpServletRequest request, HttpServletResponse response
Utils.putCorrelatorAndTrans(request);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json;charset=UTF-8");

try {

try {
logger.info(String.format("delete rule %s", request.getPathInfo()));
//request.getPathInfo() returns null or the extra path information
//that follows the servlet path but precedes the query string and will
Expand All @@ -198,7 +193,6 @@ protected void doDelete(HttpServletRequest request, HttpServletResponse response
} catch (Exception je) {
logger.error(String.format("error: %s" ,je));
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void tearDown() {
*/
@Test
public void testDoPost() throws Exception {
logger.info("doPost");
logger.info("doPost");
Server server = Help.getServer(EventsServlet.class);
server.start();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void tearDown() {
*/
@Test
public void testUpdate() {
logger.info("update");
logger.info("update");
EventBean[] newEvents = new EventBean[0];
EventBean[] oldEvents = new EventBean[0];
GenericListener instance = new GenericListener();
Expand All @@ -83,7 +83,7 @@ public void testUpdate() {
*/
@Test
public void testUpdateTimerRule() {
logger.info("update with timed rule");
logger.info("update with timed rule");
// Add RuleTest in TimeRulesStore Singleton
TimeRulesStore tRInfoInstance = TimeRulesStore.getInstance();
tRInfoInstance.cleanAllRules();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void tearDown() {
*/
@Test
public void testDoPutOK() throws Exception {
logger.info("doPut log level valid");
logger.info("doPut log level valid");
Server server = Help.getServer(LogLevelServlet.class);
server.start();
try {
Expand All @@ -87,7 +87,7 @@ public void testDoPutOK() throws Exception {
*/
@Test
public void testDoPutBad() throws Exception {
logger.info("doPut log level invalid");
logger.info("doPut log level invalid");
Server server = Help.getServer(LogLevelServlet.class);
server.start();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void tearDown() {
*/
@Test
public void testGet() {
logger.info("get");
logger.info("get");
String ruleName = "ccc";
String epl = Help.ExampleRules()[0];
EPStatement st = epService.getEPAdministrator().createEPL(epl, ruleName);
Expand All @@ -96,7 +96,7 @@ public void testGet() {
*/
@Test
public void testMake() {
logger.info("make");
logger.info("make");
String ruleName = "ccc";
String epl = Help.ExampleRules()[0];
String text = String.format("{\"name\":\"%s\",\"text\":\"%s\"}", ruleName, epl);
Expand All @@ -113,7 +113,7 @@ public void testMake() {
*/
@Test
public void testUpdateAll() {
logger.info("updateAll");
logger.info("updateAll");
String ruleName = "ccc";
String epl = Help.ExampleRules()[0];
String text = String.format("[{\"name\":\"%s\",\"text\":\"%s\"}]", ruleName, epl);
Expand All @@ -133,7 +133,7 @@ public void testUpdateAll() {
*/
@Test
public void testDelete() {
logger.info("delete");
logger.info("delete");
String ruleName = "ccc";
String epl = Help.ExampleRules()[0];
EPStatement st = epService.getEPAdministrator().createEPL(epl, ruleName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void tearDown() {
*/
@Test
public void testDoGet() throws Exception {
logger.info("doGet");
logger.info("doGet");
Server server = Help.getServer(RulesServlet.class);
server.start();
try {
Expand All @@ -86,7 +86,7 @@ public void testDoGet() throws Exception {
*/
@Test
public void testDoPost() throws Exception {
logger.info("doPost");
logger.info("doPost");
Server server = Help.getServer(RulesServlet.class);
server.start();
try {
Expand Down Expand Up @@ -114,7 +114,7 @@ public void testDoPost() throws Exception {
*/
@Test
public void testDoPut() throws Exception {
logger.info("doPut");
logger.info("doPut");
Server server = Help.getServer(RulesServlet.class);
server.start();
try {
Expand Down Expand Up @@ -142,7 +142,7 @@ public void testDoPut() throws Exception {
*/
@Test
public void testDoPutLongSet() throws Exception {
logger.info("doPutLongSet");
logger.info("doPutLongSet");
Server server = Help.getServer(RulesServlet.class);
server.start();
try {
Expand All @@ -162,7 +162,7 @@ public void testDoPutLongSet() throws Exception {
*/
@Test
public void testDoDelete() throws Exception {
logger.info("doDelete");
logger.info("doDelete");
Server server = Help.getServer(RulesServlet.class);
server.start();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void tearDown() {
*/
@Test
public void testInitEPService() {
logger.info("initEPService");
logger.info("initEPService");
ServletContext sc = new ServletContextMock();
EPServiceProvider result = Utils.initEPService(sc);
assertEquals(sc.getAttribute("epService"), result);
Expand All @@ -93,7 +93,7 @@ public void testInitEPService() {
*/
@Test
public void testDestroyEPService() {
logger.info("destroyEPService");
logger.info("destroyEPService");
ServletContextMock sc = new ServletContextMock();
//Empty sc
Utils.destroyEPService(sc);
Expand All @@ -109,7 +109,7 @@ public void testDestroyEPService() {
*/
@Test
public void testJSONObject2Map() {
logger.info("JSONObject2Map");
logger.info("JSONObject2Map");
HashMap<String, Object> m = new HashMap();
m.put("one", "1");
m.put("two", 2);
Expand All @@ -123,7 +123,7 @@ public void testJSONObject2Map() {
*/
@Test
public void testEvent2JSONObject() {
logger.info("Event2JSONObject");
logger.info("Event2JSONObject");
HashMap<String, Object> m = new HashMap();
m.put("one", "1");
m.put("two", 2);
Expand Down Expand Up @@ -163,7 +163,7 @@ public void testStatement2JSONObject() {
*/
@Test
public void testDoHTTPPost() {
logger.info("DoHTTPPost");
logger.info("DoHTTPPost");
InetSocketAddress address = new InetSocketAddress(Help.PORT);
HttpServer httpServer = null;
try {
Expand All @@ -190,7 +190,7 @@ public void handle(HttpExchange exchange) throws IOException {
assertEquals(false, result);

} catch (IOException ex) {
logger.error(ex.toString());
logger.error(ex.toString());
fail(ex.toString());
} finally {
if (httpServer != null) {
Expand Down

0 comments on commit 61b8a4c

Please sign in to comment.