geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [18/50] [abbrv] incubator-geode git commit: GEODE-17: fix PulseControllerJUnitTest
Date Tue, 03 May 2016 21:52:07 GMT
GEODE-17: fix PulseControllerJUnitTest


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/adc885d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/adc885d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/adc885d1

Branch: refs/heads/feature/GEODE-1255
Commit: adc885d1437bb4a0f04600e0ef9d973b637c0da0
Parents: e0549df
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Tue Apr 26 08:19:35 2016 -0700
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Tue Apr 26 08:19:35 2016 -0700

----------------------------------------------------------------------
 .../internal/controllers/PulseController.java   | 35 +++---------
 .../controllers/PulseControllerJUnitTest.java   | 56 ++++++--------------
 2 files changed, 25 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/adc885d1/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java
b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java
index fd71f4a..bbbadf4 100644
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java
+++ b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java
@@ -19,6 +19,13 @@
 
 package com.vmware.gemfire.tools.pulse.internal.controllers;
 
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
@@ -32,19 +39,13 @@ import com.vmware.gemfire.tools.pulse.internal.service.PulseService;
 import com.vmware.gemfire.tools.pulse.internal.service.PulseServiceFactory;
 import com.vmware.gemfire.tools.pulse.internal.service.SystemAlertsService;
 import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
+
 import org.apache.commons.lang.StringEscapeUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * Class PulseController
  * 
@@ -146,26 +147,6 @@ public class PulseController {
     return null != request.getUserPrincipal();
   }
 
-  /* Not used replaced by SpringSecurity Logout tag with LogoutHandler
-  @RequestMapping(value = "/clusterLogout", method = RequestMethod.GET)
-  public void clusterLogout(HttpServletRequest request,
-      HttpServletResponse response) throws IOException {
-    PulseLogWriter LOGGER = PulseLogWriter.getLogger();   
-    LOGGER.info("Inside #clusterLogout...");    
-    if(Repository.get().isUseGemFireCredentials()) {      
-      GemFireAuthentication authentication = (GemFireAuthentication) SecurityContextHolder.getContext()
-          .getAuthentication();
-      authentication.getJmxc().close();
-      LOGGER.info("Closing GemFireAuthentication JMX Connection...");
-    }
-    HttpSession session = request.getSession(false);
-    if (session != null) {
-      // End session and redirect
-      session.invalidate();
-    }
-    response.sendRedirect("../Login.html");
-  }*/
-
   @RequestMapping(value = "/pulseVersion", method = RequestMethod.GET)
   public void pulseVersion(HttpServletRequest request,
       HttpServletResponse response) throws IOException {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/adc885d1/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
index 38bf9c4..2af8fea 100644
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
+++ b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
@@ -16,13 +16,28 @@
  */
 package com.vmware.gemfire.tools.pulse.controllers;
 
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.*;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.powermock.api.mockito.PowerMockito.spy;
+import static org.powermock.api.mockito.PowerMockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+import java.io.File;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.HashMap;
+
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.vmware.gemfire.tools.pulse.internal.PulseAppListener;
 import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
 import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
 import com.vmware.gemfire.tools.pulse.internal.data.PulseConfig;
 import com.vmware.gemfire.tools.pulse.internal.data.Repository;
+
 import org.apache.commons.collections.buffer.CircularFifoBuffer;
 import org.junit.Before;
 import org.junit.Rule;
@@ -37,7 +52,6 @@ import org.powermock.modules.junit4.PowerMockRunner;
 import org.powermock.modules.junit4.PowerMockRunnerDelegate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
-import org.springframework.mock.web.MockHttpSession;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -45,26 +59,6 @@ import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContextListener;
-import java.io.File;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.UUID;
-
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.powermock.api.mockito.PowerMockito.spy;
-import static org.powermock.api.mockito.PowerMockito.when;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-
 /**
  */
 @Category(UnitTest.class)
@@ -111,6 +105,7 @@ public class PulseControllerJUnitTest {
   public void setup() throws Exception {
     this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
 
+
     cluster = Mockito.spy(Cluster.class);
 
     Cluster.Region region = new Cluster.Region();
@@ -704,24 +699,7 @@ public class PulseControllerJUnitTest {
   }
 
   @Test
-  public void clusterLogout() throws Exception {
-    MockHttpSession mockSession = new MockHttpSession(wac.getServletContext(), UUID.randomUUID().toString());
-    assertFalse(mockSession.isInvalid());
-
-    this.mockMvc.perform(get("/clusterLogout").principal(principal)
-        .session(mockSession)
-        .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
-        .andExpect(status().is3xxRedirection())
-        .andExpect(redirectedUrl("../Login.html"));
-
-    assertTrue(mockSession.isInvalid());
-  }
-
-  @Test
   public void pulseVersion() throws Exception {
-    ServletContextListener listener = new PulseAppListener();
-    listener.contextInitialized(null);
-
     this.mockMvc.perform(get("/pulseVersion")
         .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
         .andExpect(status().isOk())


Mime
View raw message