本文整理匯總了Java中org.springframework.web.util.NestedServletException類的典型用法代碼示例。如果您正苦於以下問題:Java NestedServletException類的具體用法?Java NestedServletException怎麽用?Java NestedServletException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NestedServletException類屬於org.springframework.web.util包,在下文中一共展示了NestedServletException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetSwitchInfo
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testGetSwitchInfo()
throws Throwable
{
try
{
this.mockMvc.perform( get( "http://localhost:8080/napi/switches/S1" ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}
示例2: asyncRequestThatThrowsUncheckedException
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test
public void asyncRequestThatThrowsUncheckedException() throws Exception {
final MvcResult result = mvc.perform(get("/api/c1/completableFutureException"))
.andExpect(request().asyncStarted())
.andReturn();
// once the async dispatch is complete, it should no longer contribute to the activeTasks count
assertThat(registry.find("my.long.request.exception")
.longTaskTimer()
.activeTasks())
.isEqualTo(1);
assertThatExceptionOfType(NestedServletException.class)
.isThrownBy(() -> mvc.perform(asyncDispatch(result)))
.withRootCauseInstanceOf(RuntimeException.class);
assertThat(registry.find("http.server.requests")
.tags("uri", "/api/c1/completableFutureException").timer().count()).isEqualTo(1);
// once the async dispatch is complete, it should no longer contribute to the activeTasks count
assertThat(registry.find("my.long.request.exception")
.longTaskTimer().activeTasks()).isEqualTo(0);
}
示例3: handleRequest
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
/**
* Processes the incoming Burlap request and creates a Burlap response.
*/
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (!"POST".equals(request.getMethod())) {
throw new HttpRequestMethodNotSupportedException(request.getMethod(),
new String[] {"POST"}, "BurlapServiceExporter only supports POST requests");
}
try {
invoke(request.getInputStream(), response.getOutputStream());
}
catch (Throwable ex) {
throw new NestedServletException("Burlap skeleton invocation failed", ex);
}
}
示例4: handleRequest
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
/**
* Processes the incoming Hessian request and creates a Hessian response.
*/
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (!"POST".equals(request.getMethod())) {
throw new HttpRequestMethodNotSupportedException(request.getMethod(),
new String[] {"POST"}, "HessianServiceExporter only supports POST requests");
}
response.setContentType(CONTENT_TYPE_HESSIAN);
try {
invoke(request.getInputStream(), response.getOutputStream());
}
catch (Throwable ex) {
throw new NestedServletException("Hessian skeleton invocation failed", ex);
}
}
示例5: mergeTemplate
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
/**
* Merge the template with the context.
* Can be overridden to customize the behavior.
* @param template the template to merge
* @param context the Velocity context to use for rendering
* @param response servlet response (use this to get the OutputStream or Writer)
* @throws Exception if thrown by Velocity
* @see org.apache.velocity.Template#merge
*/
protected void mergeTemplate(
Template template, Context context, HttpServletResponse response) throws Exception {
try {
template.merge(context, response.getWriter());
}
catch (MethodInvocationException ex) {
Throwable cause = ex.getWrappedThrowable();
throw new NestedServletException(
"Method invocation failed during rendering of Velocity view with name '" +
getBeanName() + "': " + ex.getMessage() + "; reference [" + ex.getReferenceName() +
"], method '" + ex.getMethodName() + "'",
cause==null ? ex : cause);
}
}
示例6: ConcurrentResultHandlerMethod
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
public ConcurrentResultHandlerMethod(final Object result, ConcurrentResultMethodParameter returnType) {
super(new Callable<Object>() {
@Override
public Object call() throws Exception {
if (result instanceof Exception) {
throw (Exception) result;
}
else if (result instanceof Throwable) {
throw new NestedServletException("Async processing failed", (Throwable) result);
}
return result;
}
}, CALLABLE_METHOD);
setHandlerMethodReturnValueHandlers(ServletInvocableHandlerMethod.this.returnValueHandlers);
this.returnType = returnType;
}
示例7: equivalentMappingsWithSameMethodName
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test
public void equivalentMappingsWithSameMethodName() throws Exception {
initServlet(ChildController.class);
servlet.init(new MockServletConfig());
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/child/test");
request.addParameter("childId", "100");
MockHttpServletResponse response = new MockHttpServletResponse();
try {
servlet.service(request, response);
fail("Didn't fail with due to ambiguous method mapping");
}
catch (NestedServletException ex) {
assertTrue(ex.getCause() instanceof IllegalStateException);
assertTrue(ex.getCause().getMessage().contains("doGet"));
}
}
示例8: testGetSwitchBgpConfig
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testGetSwitchBgpConfig()
throws Throwable
{
try
{
this.mockMvc.perform( get( "http://localhost:8080/napi/switches/S1/bgp" ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}
示例9: testCreateOrUpdateSwitchBgpConfig
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testCreateOrUpdateSwitchBgpConfig()
throws Throwable
{
try
{
this.mockMvc.perform( put( "http://localhost:8080/napi/switches/S1/bgp" ).content( mapper.writeValueAsString( HmsAggregatorDummyDataProvider.getNBSwitchBgpConfig() ).getBytes() ).accept( MediaType.APPLICATION_JSON ).contentType( MediaType.APPLICATION_JSON ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}
示例10: testDeleteSwitchBgpConfig
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testDeleteSwitchBgpConfig()
throws Throwable
{
try
{
this.mockMvc.perform( delete( "http://localhost:8080/napi/switches/S1/bgp" ).accept( MediaType.APPLICATION_JSON ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}
示例11: testGetSwitchOspfv2Config
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testGetSwitchOspfv2Config()
throws Throwable
{
try
{
this.mockMvc.perform( get( "http://localhost:8080/napi/switches/S1/ospfv2" ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}
示例12: testCreateOrUpdateSwitchOspfv2Config
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testCreateOrUpdateSwitchOspfv2Config()
throws Throwable
{
try
{
this.mockMvc.perform( put( "http://localhost:8080/napi/switches/S1/ospfv2" ).content( mapper.writeValueAsString( HmsAggregatorDummyDataProvider.getNBSwitchOspfv2Config() ).getBytes() ).accept( MediaType.APPLICATION_JSON ).contentType( MediaType.APPLICATION_JSON ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}
示例13: testDeleteSwitchOspfv2Config
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testDeleteSwitchOspfv2Config()
throws Throwable
{
try
{
this.mockMvc.perform( delete( "http://localhost:8080/napi/switches/S1/ospfv2" ).accept( MediaType.APPLICATION_JSON ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}
示例14: testGetSwitchMcLagConfig
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testGetSwitchMcLagConfig()
throws Throwable
{
try
{
this.mockMvc.perform( get( "http://localhost:8080/napi/switches/S1/mclag" ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}
示例15: testDeleteSwitchMcLagConfig
import org.springframework.web.util.NestedServletException; //導入依賴的package包/類
@Test( expected = NullPointerException.class )
public void testDeleteSwitchMcLagConfig()
throws Throwable
{
try
{
this.mockMvc.perform( delete( "http://localhost:8080/napi/switches/S1/mclag" ).accept( MediaType.APPLICATION_JSON ) ).andReturn();
}
catch ( NestedServletException e )
{
assertNotNull( e );
assertNotNull( e.getCause() );
assertTrue( e.getCause() instanceof NullPointerException );
throw e.getCause();
}
throw new Exception( "failed" );
}