- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.rembx.jeeshop.rest.WebApplicationException.getResponse()
方法的一些代码示例,展示了WebApplicationException.getResponse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebApplicationException.getResponse()
方法的具体详情如下:
包路径:org.rembx.jeeshop.rest.WebApplicationException
类名称:WebApplicationException
方法名:getResponse
暂无
代码示例来源:origin: remibantos/jeeshop
@Test
public void delete_NotExistingEntry_shouldThrowNotFoundEx() {
try {
entityManager.getTransaction().begin();
service.delete(666L);
entityManager.getTransaction().commit();
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void delete_NotExistingEntry_shouldThrowNotFoundEx() {
try {
entityManager.getTransaction().begin();
service.delete(666L);
entityManager.getTransaction().commit();
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void delete_NotExistingEntry_shouldThrowNotFoundEx() {
try {
entityManager.getTransaction().begin();
service.delete(666L);
entityManager.getTransaction().commit();
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void sendTestEmail_shouldThrowNotFoundExWhenNoMailTemplateFoundForGivenParams() throws Exception {
try {
service.sendTestEmail(null, "unknown", "fr_FR", "toto@toto.com");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
return;
}
fail("Should have thrown NOT_FOUND WebApplicationException");
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void delete_NotExistingEntry_shouldThrowNotFoundEx() {
try {
entityManager.getTransaction().begin();
service.delete(666L);
entityManager.getTransaction().commit();
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void find_withUnknownProductId_ShouldThrowNotFoundException() {
try {
service.find(9999L, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void findCategories_shouldReturn404ExWhenCatalogNotFound() {
try {
service.findCategories(9999L, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void findDiscounts_shouldReturn404ExWhenSKUNotFound() {
try {
service.findDiscounts(9999L);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void findProducts_shouldReturn404ExWhenCategoryNotFound() {
try {
service.findChildProducts(9999L, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void resetPassword_shouldReturnUnauthorizedResponse_whenAuthenticatedUserDoesNotMatchLogin() throws Exception {
try {
when(sessionContextMock.isCallerInRole(JeeshopRoles.USER)).thenReturn(true);
when(sessionContextMock.getCallerPrincipal()).thenReturn(new PrincipalImpl(testUser.firstUser().getLogin()));
service.resetPassword("not_matching_login", null, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void modifyUnknown_ShouldThrowNotFoundException() {
MailTemplate detachedMailTemplate = new MailTemplate();
detachedMailTemplate.setId(9999L);
try {
service.modify(detachedMailTemplate);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void modify_ShouldThrowUnauthorizedError_WhenAuthenticatedUserDoesNotMatchLogin() throws Exception {
User detachedUserToModify = new User("test2@test.com", "test", "John", "Doe", "+33616161616", null, new Date(), "fr_FR", null);
try {
when(sessionContextMock.isCallerInRole(JeeshopRoles.USER)).thenReturn(true);
when(sessionContextMock.getCallerPrincipal()).thenReturn(new PrincipalImpl(testUser.firstUser().getLogin()));
service.modify(detachedUserToModify);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void find_withIdOfExpiredProduct_ShouldThrowForbiddenException() {
try {
service.find(testCatalog.anExpiredProduct().getId(), null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.FORBIDDEN);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void find_withUnknownCategoryId_ShouldThrowNotFoundException() {
try {
service.find(9999L, null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void find_withIdOfDisableProduct_ShouldThrowForbiddenException() {
try {
service.find(testCatalog.aDisabledProduct().getId(), null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.FORBIDDEN);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void modifyUnknownCategory_ShouldThrowNotFoundException() {
Category detachedCategoryToModify = new Category(9999L, null, null, null, null, null);
try {
service.modify(detachedCategoryToModify);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void modifyUnknownSKU_ShouldThrowNotFoundException() {
SKU detachedProductToModify = new SKU(9999L, null, null, null, null, null, null, null, null, null);
try {
service.modify(detachedProductToModify);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void find_withIdOfExpiredCategory_ShouldThrowForbiddenException() {
try {
service.find(testCatalog.anExpiredCategory().getId(), null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.FORBIDDEN);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void find_withIdOfDisableCategory_ShouldThrowForbiddenException() {
try {
service.find(testCatalog.aDisabledCategory().getId(), null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.FORBIDDEN);
}
}
代码示例来源:origin: remibantos/jeeshop
@Test
public void find_NotVisibleCatalogItem_ShouldThrowForbiddenException() {
try {
instance.filterVisible(new Catalog(), null);
fail("should have thrown ex");
} catch (WebApplicationException e) {
assertEquals(Response.Status.FORBIDDEN, e.getResponse().getStatusInfo());
}
}
我想捕获所有类型的 Throwable以便在发生异常时客户端不会暴露于我们的内部堆栈跟踪。 我正在使用ExceptionMapper如下: @Provider public class Mappabl
我想知道在映射 WebApplicationExceptions 时,Javax-RS/Jersey ExceptionMapper 类的正确用途是什么 我喜欢以下简单的三状态范例: HTTP 200
在 REST 服务中向客户端返回响应的所有可能性中,我看到了两种看起来等效的可能性:抛出 WebApplicationException(可能使用Response 实例)或返回 Response 实例
我有一个使用 Jersey 和 MOXy 的 JAX-RS 服务。我有一个返回类型 Memo 的 JSON 或 XML(取决于 Accept: header )表示的处理程序,但如果找不到该项目,它应
(这是对原始问题的编辑,以明确该问题不是重复的 - 标记为重复的问题涉及在响应中返回自定义错误消息,而不是官方错误代码的自定义原因短语)。 我正在尝试为 Restful 服务中的给定 Http 错误代
使用 jersey,我抛出一个带有 503 的 WebApplicationException,表明我的服务不可用(因为某些下游服务不可用)。 发生这种情况时,我会得到如下所示的日志记录,其中包含巨大
我正在搜索使用 JSON 和 RESTful 示例时发生的这个问题,但我找不到任何东西。这是我的代码: @Path("students") public class StudentResource {
我创建了实现 implements ExceptionMapper 的类并通过 environment.addProvider(new WebApplicationExceptionMapper())
我将一个 bean 注入(inject)到我的 REST web 服务中,然后从我的 bean 中调用一个方法,在该方法中抛出以下异常: throw new WebApplicationExcepti
我在从 StreamingOutput 实现中抛出 WebApplicationException 时遇到困难。我希望下面的代码返回 501,但curl 报告 curl: (52) Empty rep
在我们的(遗留)代码库中,我们以不同的方式抛出 WebApplicationExceptions。为了对我们处理异常的方式进行排序 - 我想为这些 WAE(和其他)创建一个 ExceptionMapp
我正在使用 JAX-RS API 开发一个 Web 服务,并将 Jersey 1.17 作为我的实现。 我希望客户可以在他们使用 Accept HTTP header 指定的 JSON 和 XML 之
我正在处理 Rest 服务,如果出现故障/错误,我会感到困惑,我应该使用 Response 还是 WebApplicationException? 下面是我使用 Response 返回 400 Bad
我试图了解这是一个功能还是一个错误...... :-) 对于下面的 Controller 和异常映射器,对于将失败并返回 401 响应的其余客户端,我希望为这两种情况调用异常处理程序。但是,不会为 W
JAX-RS Jersey 处理 WebApplicationException 嗨, 我尝试使用 MyWebApplicationExceptionMapper 处理 WebApplicationE
我有基于 Jersey 的 REST 资源类,其中包含多个资源,每个资源都提供一个 JSON 对象。我有一个简单的 HTML+Javascipt 界面,其中使用 jquery ajax 调用获取来自每
在我的应用程序中,我为异常情况抛出 WebApplicationExceptions,这样我就可以用我的 500 传回不错的消息。我遇到的问题是我有一个用于 hibernate 事务的 servlet
我试图用我的javax.ws.rs.ext.ExceptionMapper类捕获WebApplicationException,但我得到了一个奇怪的行为。 这是我简单的休息方法: @GET @Path
public class NotAuthorizedException extends WebApplicationException { public NotAuthorizedExcept
本文整理了Java中org.rembx.jeeshop.rest.WebApplicationException.getResponse()方法的一些代码示例,展示了WebApplicationExc
我是一名优秀的程序员,十分优秀!