001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006package org.fcrepo.http.commons.exceptionhandlers; 007 008import org.junit.Before; 009import org.junit.Test; 010 011import javax.ws.rs.core.Response; 012 013import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; 014import static org.junit.Assert.assertEquals; 015import static org.junit.Assert.assertNull; 016import static org.junit.Assert.assertTrue; 017 018/** 019 * <p>WildcardExceptionMapperTest class.</p> 020 * 021 * @author awoods 022 */ 023public class WildcardExceptionMapperTest { 024 025 private WildcardExceptionMapper testObj; 026 027 @Before 028 public void setUp() { 029 testObj = new WildcardExceptionMapper(); 030 } 031 032 @Test 033 public void testToResponse() { 034 testObj.setShowStackTrace(true); 035 final Exception input = new Exception(); 036 Response actual = testObj.toResponse(input); 037 assertEquals(INTERNAL_SERVER_ERROR.getStatusCode(), actual.getStatus()); 038 assertTrue(actual.getEntity() != null); 039 testObj.showStackTrace = false; 040 actual = testObj.toResponse(input); 041 assertEquals(INTERNAL_SERVER_ERROR.getStatusCode(), actual.getStatus()); 042 assertNull(actual.getEntity()); 043 } 044}