Example usage for org.springframework.http MediaType parseMediaType

List of usage examples for org.springframework.http MediaType parseMediaType

Introduction

In this page you can find the example usage for org.springframework.http MediaType parseMediaType.

Prototype

public static MediaType parseMediaType(String mediaType) 

Source Link

Document

Parse the given String into a single MediaType .

Usage

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void pulseUpdateForQueryStatistics() throws Exception {
    this.mockMvc//from   w w  w.j  a  v a 2s  . co m
            .perform(
                    post("/pulseUpdate").param("pulseData", "{\"QueryStatistics\":\"{}\"}").principal(principal)
                            .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.QueryStatistics.queriesList").isEmpty())
            .andExpect(jsonPath("$.QueryStatistics.connectedFlag").value(false))
            .andExpect(jsonPath("$.QueryStatistics.connectedErrorMsg").value(""));
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void pulseUpdateForSystemAlerts() throws Exception {
    this.mockMvc//  w  w w .java2  s  .c  o  m
            .perform(post("/pulseUpdate").param("pulseData", "{\"SystemAlerts\":{\"pageNumber\":\"1\"}}")
                    .principal(principal)
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.SystemAlerts.pageNumber").value(1))
            .andExpect(jsonPath("$.SystemAlerts.connectedFlag").value(false))
            .andExpect(jsonPath("$.SystemAlerts.connectedErrorMsg").value(""))
            .andExpect(jsonPath("$.SystemAlerts.systemAlerts").isEmpty());
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void authenticateUserNotLoggedIn() throws Exception {
    this.mockMvc//from   w  w w  .  j a v  a  2  s .  com
            .perform(get("/authenticateUser")
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.isUserLoggedIn").value(false));
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void authenticateUserLoggedIn() throws Exception {
    this.mockMvc/*  w  w  w  .  j ava 2 s  . co  m*/
            .perform(get("/authenticateUser").principal(principal)
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.isUserLoggedIn").value(true));
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void pulseVersion() throws Exception {
    this.mockMvc/*from ww  w  .j ava  2 s. c  om*/
            .perform(get("/pulseVersion")
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.pulseVersion").isNotEmpty())
            .andExpect(jsonPath("$.buildId").isNotEmpty()).andExpect(jsonPath("$.buildDate").isNotEmpty())
            .andExpect(jsonPath("$.sourceDate").isNotEmpty())
            .andExpect(jsonPath("$.sourceRevision").isNotEmpty())
            .andExpect(jsonPath("$.sourceRepository").isNotEmpty());
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void clearAlerts() throws Exception {
    this.mockMvc/*  ww w . j ava2s. c  o  m*/
            .perform(get("/clearAlerts").param("alertType", "1")
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.pageNumber").value(1))
            .andExpect(jsonPath("$.systemAlerts").isEmpty()).andExpect(jsonPath("$.connectedFlag").value(false))
            .andExpect(jsonPath("$.status").value("deleted"));
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void acknowledgeAlert() throws Exception {
    this.mockMvc//from w  ww. ja va  2  s.  co  m
            .perform(get("/acknowledgeAlert").param("alertId", "1")
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.status").value("deleted"));
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void dataBrowserRegions() throws Exception {
    this.mockMvc/*from  w w  w .ja va 2  s .c om*/
            .perform(get("/dataBrowserRegions")
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.clusterName").value(CLUSTER_NAME))
            .andExpect(jsonPath("$.connectedFlag").value(false))
            .andExpect(jsonPath("$.clusterRegions[0].fullPath").value(REGION_PATH))
            .andExpect(jsonPath("$.clusterRegions[0].regionType").value(REGION_TYPE));
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void dataBrowserQuery() throws Exception {
    doReturn(mapper.createObjectNode().put("foo", "bar")).when(cluster).executeQuery(anyString(), anyString(),
            anyInt());/*www.  ja  v a  2  s  .  c  om*/

    this.mockMvc
            .perform(get("/dataBrowserQuery").param("query", "SELECT * FROM " + REGION_PATH)
                    .param("members", MEMBER_NAME).principal(principal)
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk()).andExpect(jsonPath("$.foo").value("bar"));
}

From source file:com.vmware.gemfire.tools.pulse.controllers.PulseControllerJUnitTest.java

@Test
public void dataBrowserQueryHistory() throws Exception {
    dataBrowserQuery();/* w  ww  .j  av a 2s.  c  o  m*/

    this.mockMvc
            .perform(get("/dataBrowserQueryHistory").param("action", "view").principal(principal)
                    .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$.queryHistory[0].queryText").value("\"SELECT * FROM " + REGION_PATH + "\""));
}