Search in sources :

Example 1 with UIHttpRequestProcessor

use of io.crnk.ui.internal.UIHttpRequestProcessor in project crnk-framework by crnk-project.

the class UIModuleTest method processorNotUsedForNonBrowsePath.

@Test
public void processorNotUsedForNonBrowsePath() throws IOException {
    UIHttpRequestProcessor processor = new UIHttpRequestProcessor(new UIModuleConfig());
    HttpRequestContext context = Mockito.mock(HttpRequestContext.class);
    Mockito.when(context.getMethod()).thenReturn("POST");
    Mockito.when(context.getPath()).thenReturn("somethingDifferent/index.html");
    processor.process(context);
    Mockito.verify(context, Mockito.times(0)).setResponse(Mockito.anyInt(), Mockito.any(byte[].class));
}
Also used : UIHttpRequestProcessor(io.crnk.ui.internal.UIHttpRequestProcessor) HttpRequestContext(io.crnk.core.engine.http.HttpRequestContext) Test(org.junit.Test)

Example 2 with UIHttpRequestProcessor

use of io.crnk.ui.internal.UIHttpRequestProcessor in project crnk-framework by crnk-project.

the class UIModuleTest method processorReturnsFile.

@Test
public void processorReturnsFile() throws IOException {
    UIHttpRequestProcessor processor = new UIHttpRequestProcessor(new UIModuleConfig());
    HttpRequestContext context = Mockito.mock(HttpRequestContext.class);
    Mockito.when(context.getPath()).thenReturn("browse/index.html");
    Mockito.when(context.getMethod()).thenReturn("GET");
    processor.process(context);
    Mockito.verify(context, Mockito.times(1)).setResponse(Mockito.eq(200), Mockito.any(byte[].class));
    Mockito.verify(context, Mockito.times(1)).setContentType(Mockito.eq("text/html"));
}
Also used : UIHttpRequestProcessor(io.crnk.ui.internal.UIHttpRequestProcessor) HttpRequestContext(io.crnk.core.engine.http.HttpRequestContext) Test(org.junit.Test)

Example 3 with UIHttpRequestProcessor

use of io.crnk.ui.internal.UIHttpRequestProcessor in project crnk-framework by crnk-project.

the class UIModuleTest method processorNotUsedForPost.

@Test
public void processorNotUsedForPost() throws IOException {
    UIHttpRequestProcessor processor = new UIHttpRequestProcessor(new UIModuleConfig());
    HttpRequestContext context = Mockito.mock(HttpRequestContext.class);
    Mockito.when(context.getMethod()).thenReturn("POST");
    Mockito.when(context.getPath()).thenReturn("browse/index.html");
    processor.process(context);
    Mockito.verify(context, Mockito.times(0)).setResponse(Mockito.anyInt(), Mockito.any(byte[].class));
}
Also used : UIHttpRequestProcessor(io.crnk.ui.internal.UIHttpRequestProcessor) HttpRequestContext(io.crnk.core.engine.http.HttpRequestContext) Test(org.junit.Test)

Example 4 with UIHttpRequestProcessor

use of io.crnk.ui.internal.UIHttpRequestProcessor in project crnk-framework by crnk-project.

the class UIModuleTest method processorReturnsIndexHtmlForRootPage.

@Test
public void processorReturnsIndexHtmlForRootPage() throws IOException {
    UIHttpRequestProcessor processor = new UIHttpRequestProcessor(new UIModuleConfig());
    HttpRequestContext context = Mockito.mock(HttpRequestContext.class);
    Mockito.when(context.getMethod()).thenReturn("GET");
    Mockito.when(context.getPath()).thenReturn("browse/");
    processor.process(context);
    Mockito.verify(context, Mockito.times(1)).setResponse(Mockito.eq(200), Mockito.any(byte[].class));
}
Also used : UIHttpRequestProcessor(io.crnk.ui.internal.UIHttpRequestProcessor) HttpRequestContext(io.crnk.core.engine.http.HttpRequestContext) Test(org.junit.Test)

Aggregations

HttpRequestContext (io.crnk.core.engine.http.HttpRequestContext)4 UIHttpRequestProcessor (io.crnk.ui.internal.UIHttpRequestProcessor)4 Test (org.junit.Test)4