Example usage for java.lang NoClassDefFoundError NoClassDefFoundError

List of usage examples for java.lang NoClassDefFoundError NoClassDefFoundError

Introduction

In this page you can find the example usage for java.lang NoClassDefFoundError NoClassDefFoundError.

Prototype

public NoClassDefFoundError() 

Source Link

Document

Constructs a NoClassDefFoundError with no detail message.

Usage

From source file:org.pentaho.di.baserver.utils.web.HttpConnectionHelperTest.java

@Test
public void testInvokePlatformEndpoint() throws Exception {
    Response r;/*from w w  w  .j  a v  a  2s .c om*/

    String endpointPath = "myEndpoint", httpMethod = "GET";
    Map<String, String> queryParameters = new HashMap<String, String>();
    queryParameters.put("param1", "value1");
    queryParameters.put("param2", "value2");
    queryParameters.put("param3", "value3");

    RequestDispatcher requestDispatcher = mock(RequestDispatcher.class);
    ServletContext context = mock(ServletContext.class);
    doThrow(new NoClassDefFoundError()).when(httpConnectionHelperSpy).getContext();
    r = httpConnectionHelperSpy.invokePlatformEndpoint(endpointPath, httpMethod, queryParameters);
    assertTrue(r.getResult().equals(new Response().getResult()));

    doReturn(context).when(httpConnectionHelperSpy).getContext();
    doReturn(requestDispatcher).when(context).getRequestDispatcher("/api" + endpointPath);
    doThrow(new MalformedURLException()).when(httpConnectionHelperSpy).getUrl();
    r = httpConnectionHelperSpy.invokePlatformEndpoint(endpointPath, httpMethod, queryParameters);
    assertTrue(r.getResult().equals(new Response().getResult()));

    String serverUrl = "http://localhost:8080/pentaho";
    URL url = new URL(serverUrl);
    doReturn(url).when(httpConnectionHelperSpy).getUrl();
    doThrow(new ServletException()).when(requestDispatcher).forward(any(InternalHttpServletRequest.class),
            any(InternalHttpServletResponse.class));
    r = httpConnectionHelperSpy.invokePlatformEndpoint(endpointPath, httpMethod, queryParameters);
    assertTrue(r.getResult().equals(new Response().getResult()));

    doThrow(new IOException()).when(requestDispatcher).forward(any(InternalHttpServletRequest.class),
            any(InternalHttpServletResponse.class));
    r = httpConnectionHelperSpy.invokePlatformEndpoint(endpointPath, httpMethod, queryParameters);
    assertTrue(r.getResult().equals(new Response().getResult()));

    doNothing().when(requestDispatcher).forward(any(InternalHttpServletRequest.class),
            any(InternalHttpServletResponse.class));
    r = httpConnectionHelperSpy.invokePlatformEndpoint(endpointPath, httpMethod, queryParameters);
    assertEquals(r.getStatusCode(), 204);

}