List of usage examples for org.springframework.http MediaType APPLICATION_JSON
MediaType APPLICATION_JSON
To view the source code for org.springframework.http MediaType APPLICATION_JSON.
Click Source Link
From source file:com.applechip.android.showcase.rest.HttpGetParametersActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.http_get_parameters_activity_layout); // Initiate the request for JSON data when the JSON button is pushed final Button buttonJson = (Button) findViewById(R.id.button_json); buttonJson.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new DownloadStateTask().execute(MediaType.APPLICATION_JSON); }//from w w w . j a va 2 s . co m }); // Initiate the request for XML data when the XML button is pushed final Button buttonXml = (Button) findViewById(R.id.button_xml); buttonXml.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new DownloadStateTask().execute(MediaType.APPLICATION_XML); } }); }
From source file:io.pivotal.strepsirrhini.chaoslemur.task.TaskManagerTest.java
@Test public void readAll() throws Exception { this.mockMvc.perform(get("/task").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andExpect(jsonPath("$").value(hasSize(2))) .andExpect(jsonPath("$[*].links[?(@.rel == 'self')].href") .value(hasItems("http://localhost/task/0", "http://localhost/task/1"))); }
From source file:fi.helsinki.opintoni.server.OodiServer.java
public void expectStudentEnrollmentsRequest(String studentNumber, String responseFile) { server.expect(requestTo(enrollmentsUrl(studentNumber))).andExpect(method(HttpMethod.GET)).andRespond( withSuccess(SampleDataFiles.toText("oodi/" + responseFile), MediaType.APPLICATION_JSON)); }
From source file:biz.dfch.activiti.wrapper.controller.ProcessInvocationControllerTest.java
@Test public void invokeProcessWithValidPayloadReturnsHttpStatusOk() throws Exception { mvc.perform(MockMvcRequestBuilders.post("/process-invocation").accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) .content("{" + " \"assetId\": \"123\"," + " \"assetType\": \"System\"," + " \"action\": \"create\"," + " \"decisionId\": \"1234\"," + " \"userId\": \"12345\"," + " \"tenantId\": \"123456\"," + " \"type\": \"PRE-ACTION\"," + " \"bpeURI\": \"http://localhost\"" + "}")) .andExpect(status().isOk()); }
From source file:com.example.message.MessageEndpoint.java
private Mono<ServerResponse> getMessages(final ServerRequest request) { final GetMessageRequest getMessageRequest = GetMessageRequest.create(request); final Mono<PageResult<Message>> result = messageRepository.findAll().as(getMessageRequest::filterPages) .collectList().map(getMessageRequest::toResult); return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(result, new ParameterizedTypeReference<PageResult<Message>>() { });/*from w w w . jav a 2 s. c o m*/ }
From source file:monkeys.StepDefs.java
@When("^I do a get all$") public void I_do_a_get_all() throws Throwable { mvcResult = this.mockMvc.perform(get("/monkeys").contentType(MediaType.APPLICATION_JSON)); }
From source file:com.greglturnquist.spring.social.ecobee.api.impl.ThermostatTemplateTest.java
@Test public void testGetThermostat() throws Exception { final Selection selection = Selection.thermostats("161775386723"); selection.getSelection().setIncludeRuntime(true); selection.getSelection().setIncludeSettings(true); selection.getSelection().setIncludeSensors(true); final String selectionStr = UriUtils.encodeQueryParam(this.getObjectMapper().writeValueAsString(selection), "UTF-8"); mockServer.expect(requestTo("https://api.ecobee.com/1/thermostat?json=" + selectionStr)) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(jsonResource("thermostats"), MediaType.APPLICATION_JSON)); final Thermostat thermostat = ecobee.thermostatOperations().getThermostat("161775386723"); assertThat(thermostat, notNullValue()); assertThat(thermostat.getIdentifier(), equalTo("161775386723")); assertThat(thermostat.getName(), equalTo("My Test Thermostat")); assertThat(thermostat.getLastModified(), equalTo("2011-01-28 23:40:25")); assertThat(thermostat.getSettings().getHvacMode(), equalTo("heat")); assertThat(thermostat.getSettings().getVent(), is(nullValue())); }
From source file:com.marklogic.samplestack.testing.QnADocumentControllerTestImpl.java
public void testAnonymousCanSearch() throws UnsupportedEncodingException, Exception { String questionResponse = this.mockMvc.perform(get("/questions").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); logger.debug(questionResponse);//from w w w . j a v a 2s . co m assertTrue("response from mock controller question is search response", questionResponse.contains("\"snippet-format\":\"raw\"")); questionResponse = this.mockMvc .perform(post("/search").with(csrf()).contentType(MediaType.APPLICATION_JSON) .content("{\"search\":{\"qtext\":\"true\"}}").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); logger.debug(questionResponse); assertTrue("response from mock controller question is search response", questionResponse.contains("\"snippet-format\":\"raw\"")); }
From source file:com.ushahidi.swiftriver.core.api.controller.DropsControllerTest.java
@Test public void createDropWithMissingFields() throws Exception { String postBody = "[{}]"; this.mockMvc/*from w w w . j a v a 2 s . c om*/ .perform(post("/v1/drops").content(postBody).contentType(MediaType.APPLICATION_JSON) .principal(getAuthentication("admin"))) .andExpect(status().isBadRequest()).andExpect(jsonPath("$.message").exists()) .andExpect(jsonPath("$.errors").exists()).andExpect(jsonPath("$.errors").isArray()) .andExpect(jsonPath("$.errors[0].field").value("[0].title")) .andExpect(jsonPath("$.errors[0].code").value("missing")) .andExpect(jsonPath("$.errors[1].field").value("[0].content")) .andExpect(jsonPath("$.errors[1].code").value("missing")) .andExpect(jsonPath("$.errors[2].field").value("[0].channel")) .andExpect(jsonPath("$.errors[2].code").value("missing")) .andExpect(jsonPath("$.errors[3].field").value("[0].date_published")) .andExpect(jsonPath("$.errors[3].code").value("missing")) .andExpect(jsonPath("$.errors[4].field").value("[0].original_id")) .andExpect(jsonPath("$.errors[4].code").value("missing")) .andExpect(jsonPath("$.errors[5].field").value("[0].identity.origin_id")) .andExpect(jsonPath("$.errors[5].code").value("missing")); }
From source file:com.applechip.android.showcase.rest.HttpPostJsonXmlActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.http_post_json_xml_activity_layout); // Initiate the JSON POST request when the JSON button is clicked final Button buttonJson = (Button) findViewById(R.id.button_post_json); buttonJson.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new PostMessageTask().execute(MediaType.APPLICATION_JSON); }/* w w w.j a v a2 s .co m*/ }); // Initiate the XML POST request when the XML button is clicked final Button buttonXml = (Button) findViewById(R.id.button_post_xml); buttonXml.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new PostMessageTask().execute(MediaType.APPLICATION_XML); } }); }