当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponse类代码示例

本文整理汇总了Java中org.jboss.resteasy.spi.HttpResponse的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse类的具体用法?Java HttpResponse怎么用?Java HttpResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpResponse类属于org.jboss.resteasy.spi包,在下文中一共展示了HttpResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createResteasyHttpRequest

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Override
public HttpRequest createResteasyHttpRequest(final String httpMethod,
                                             final HttpServletRequest request,
                                             final ResteasyHttpHeaders headers,
                                             final ResteasyUriInfo uriInfo,
                                             final HttpResponse theResponse,
                                             final HttpServletResponse response)
{
	return new HttpServletInputMessage(request,
	                                   response,
	                                   request.getServletContext(),
	                                   theResponse,
	                                   headers,
	                                   uriInfo,
	                                   httpMethod.toUpperCase(),
	                                   (SynchronousDispatcher) dispatcher.getDispatcher());
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:18,代码来源:ResteasyRequestResponseFactory.java

示例2: testDeleteNote

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testDeleteNote(Context context) throws URISyntaxException {
    // Given that a note with id=1 exists...
    // ... when the user requests the note deleted...
    MockHttpRequest request = MockHttpRequest
            .post("/notes/delete")
            .addFormHeader("id", "1")
            .accept(MediaType.TEXT_HTML);
    HttpResponse response = context.invoke(request);

    // ... Then the note should be deleted, and the client instructed to
    // redirect to the notes list page.
    assertEquals(response.getStatus(), HttpServletResponse.SC_SEE_OTHER);
    URI actualLocation = (URI) response.getOutputHeaders().getFirst("Location");
    URI expectedLocation = URI.create("/notes");
    assertEquals(actualLocation, expectedLocation);
    verify(context.notesService).deleteNote(1L);
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:19,代码来源:BrowserNotesResourceTest.java

示例3: testFinishEditOrCreateNote_Edit

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testFinishEditOrCreateNote_Edit(Context context) throws URISyntaxException {
    // Given that a note with id=1 exists...
    // ... when the user requests the note edited...
    MockHttpRequest request = MockHttpRequest
            .post("/notes")
            .addFormHeader("id", "1")
            .addFormHeader("title", "Example Title")
            .addFormHeader("body", "Example Body")
            .contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .accept(MediaType.TEXT_HTML);
    when(context.notesService.updateAll(any(List.class)))
            .thenReturn(Collections.singletonList(
                    new Note(1, "example-title", "Example Title", "Example Body")));
    HttpResponse response = context.invoke(request);

    // ... Then the note should be edited, and the client instructed to
    // redirect to the notes list page.
    assertEquals(response.getStatus(), HttpServletResponse.SC_SEE_OTHER);
    URI actualLocation = (URI) response.getOutputHeaders().getFirst("Location");
    URI expectedLocation = URI.create("/notes");
    assertEquals(actualLocation, expectedLocation);
    verify(context.notesService).updateAll(any(List.class));
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:25,代码来源:BrowserNotesResourceTest.java

示例4: testFinishEditOrCreateNote_EditNotFound

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testFinishEditOrCreateNote_EditNotFound(Context context) throws URISyntaxException {
    // Given that a note with id=2 does not exist...
    // ... when the user requests the note edited...
    MockHttpRequest request = MockHttpRequest
            .post("/notes")
            .addFormHeader("id", "2")
            .addFormHeader("title", "Example Title")
            .addFormHeader("body", "Example Body")
            .contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .accept(MediaType.TEXT_HTML);
    when(context.notesService.updateAll(any(List.class)))
            .thenThrow(new NotFoundException("Failed to update one or more notes."));
    HttpResponse response = context.invoke(request);

    // ... Then not found status code should be returned.
    assertEquals(response.getStatus(), HttpServletResponse.SC_NOT_FOUND);
    verify(context.notesService).updateAll(any(List.class));
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:20,代码来源:BrowserNotesResourceTest.java

示例5: testFinishEditOrCreateNote_Create

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testFinishEditOrCreateNote_Create(Context context) throws URISyntaxException {
    // Given that the user is on the create note page...
    // ... when the user clicks the button to create the note...
    MockHttpRequest request = MockHttpRequest
            .post("/notes")
            .addFormHeader("id", "0")
            .addFormHeader("title", "Example Title")
            .addFormHeader("body", "Example Body")
            .contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .accept(MediaType.TEXT_HTML);
    when(context.notesService.createAll(any(List.class)))
            .thenReturn(Collections.singletonList(
                    new Note(2, "example-title", "Example Title", "Example Body")));
    HttpResponse response = context.invoke(request);

    // ... Then the note should be edited, and the client instructed to
    // redirect to the notes list page.
    assertEquals(response.getStatus(), HttpServletResponse.SC_SEE_OTHER);
    URI actualLocation = (URI) response.getOutputHeaders().getFirst("Location");
    URI expectedLocation = URI.create("/notes");
    assertEquals(actualLocation, expectedLocation);
    verify(context.notesService).createAll(any(List.class));
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:25,代码来源:BrowserNotesResourceTest.java

示例6: testFinishEditOrCreateNote_Create_NoContentError

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testFinishEditOrCreateNote_Create_NoContentError(Context context) throws URISyntaxException {
    // Given that the user is on the create note page...
    // ... when the user does not fill out any content and
    // clicks the button to create the note...
    MockHttpRequest request = MockHttpRequest
            .post("/notes")
            .addFormHeader("id", "0")
            .addFormHeader("title", "")
            .addFormHeader("body", "")
            .contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .accept(MediaType.TEXT_HTML);
    when(context.notesService.createAll(any(List.class)))
            .thenThrow(new AppClientException("Note must have at least a uri, title, or body."));
    HttpResponse response = context.invoke(request);

    // ... Then the note should not be created and the client receives an
    // error page.
    assertEquals(response.getStatus(), HttpServletResponse.SC_BAD_REQUEST);
    verify(context.notesService).createAll(any(List.class));
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:22,代码来源:BrowserNotesResourceTest.java

示例7: service

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
private void service(int i, Context context, HttpServerRequest req, HttpServerResponse resp, HttpRequest vertxReq,
		HttpResponse vertxResp, boolean handleNotFound) throws IOException {
	if(i < plugins.size())
		plugins.get(i).aroundRequest(vertxReq, () -> service(i+1, context, req, resp, vertxReq, vertxResp, handleNotFound));
	else
		super.service(context, req, resp, vertxReq, vertxResp, handleNotFound);
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:8,代码来源:PluginRequestDispatcher.java

示例8: createResource

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Override
public Object createResource(final HttpRequest request,
                             final HttpResponse response,
                             final ResteasyProviderFactory factory)
{
  final Object resource = entry.getValue();
  propertyInjector.inject(request, response, resource);
  return resource;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:10,代码来源:SisuResourceFactory.java

示例9: createResource

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Override
public Object createResource(HttpRequest request, HttpResponse response, ResteasyProviderFactory factory)
{
    Object resource = provider.get();
    contextPropertyInjector.inject(request, response, resource);
    return resource;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:8,代码来源:GuiceRsApplicationServlet.java

示例10: testListNotes

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testListNotes(Context context) throws URISyntaxException {
    // Given that the service is running...
    // ... When the user views the notes page...
    MockHttpRequest request = MockHttpRequest.get("/notes").accept(MediaType.TEXT_HTML);
    HttpResponse response = context.invoke(request);

    // ... Then the notes list page should be returned.
    assertEquals(response.getStatus(), HttpServletResponse.SC_OK);

    verify(context.notesService).getNotes();
    verify(context.templater).buildFromTemplate(any(), any(String.class));
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:14,代码来源:BrowserNotesResourceTest.java

示例11: testEditNote

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testEditNote(Context context) throws URISyntaxException {
    // Given that a note with id=1 exists...
    // ... when the user requests the note edit page...
    MockHttpRequest request = MockHttpRequest.get("/notes/1/edit").accept(MediaType.TEXT_HTML);
    HttpResponse response = context.invoke(request);

    // ... Then the page should be retrieved, and the notes contents accessed.
    assertEquals(response.getStatus(), HttpServletResponse.SC_OK);

    verify(context.notesService).getNote(1L);
    verify(context.templater).buildFromTemplate(any(), any(String.class));
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:14,代码来源:BrowserNotesResourceTest.java

示例12: testEditNoteNotFound

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testEditNoteNotFound(Context context) throws URISyntaxException {
    // Given there is not a note with id=0...
    // ...when the note id=0 edit page is requested...
    MockHttpRequest request = MockHttpRequest.get("/notes/0/edit").accept(MediaType.TEXT_HTML);
    HttpResponse response = context.invoke(request);

    // ...then a 404 should be returned.
    assertEquals(response.getStatus(), HttpServletResponse.SC_NOT_FOUND);

    verify(context.notesService).getNote(0L);
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:13,代码来源:BrowserNotesResourceTest.java

示例13: testGetNote

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testGetNote(Context context) throws URISyntaxException {
    // Given that a note with id=1 exists...
    // ... when the user requests the note page...
    MockHttpRequest request = MockHttpRequest.get("/notes/1").accept(MediaType.TEXT_HTML);
    HttpResponse response = context.invoke(request);

    // ... Then the page should be retrieved, and the notes contents accessed.
    assertEquals(response.getStatus(), HttpServletResponse.SC_OK);

    verify(context.notesService).getNote(1L);
    verify(context.templater).buildFromTemplate(any(), any(String.class));
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:14,代码来源:BrowserNotesResourceTest.java

示例14: testGetNoteNotFound

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testGetNoteNotFound(Context context) throws URISyntaxException {
    // Given there is not a note with id=0...
    // ...when the note id=0 page is requested...
    MockHttpRequest request = MockHttpRequest.get("/notes/0").accept(MediaType.TEXT_HTML);
    HttpResponse response = context.invoke(request);

    // ...then a 404 should be returned.
    assertEquals(response.getStatus(), HttpServletResponse.SC_NOT_FOUND);

    verify(context.notesService).getNote(0L);
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:13,代码来源:BrowserNotesResourceTest.java

示例15: testCreateNote

import org.jboss.resteasy.spi.HttpResponse; //导入依赖的package包/类
@Test(dataProvider = DEFAULT_DP)
public void testCreateNote(Context context) throws URISyntaxException {
    // Given that the service is running...
    // ... when the user requests the create note page...
    MockHttpRequest request = MockHttpRequest.get("/notes/create").accept(MediaType.TEXT_HTML);
    HttpResponse response = context.invoke(request);

    // ... Then the page should be retrieved.
    assertEquals(response.getStatus(), HttpServletResponse.SC_OK);

    verify(context.templater).buildFromTemplate(any(), any(String.class));
}
 
开发者ID:redsaz,项目名称:deciservice,代码行数:13,代码来源:BrowserNotesResourceTest.java


注:本文中的org.jboss.resteasy.spi.HttpResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。