Java Code Examples for io.micronaut.context.ApplicationContext#build()

The following examples show how to use io.micronaut.context.ApplicationContext#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MicronautAwsProxyTest.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
@Test
public void errors_unknownRoute_expect404() throws ContainerInitializationException {
    MicronautLambdaContainerHandler handler = new MicronautLambdaContainerHandler(
            ApplicationContext.build(CollectionUtils.mapOf(
                    "spec.name", "MicronautAwsProxyTest",
                    "micronaut.security.enabled", false,
                    "micronaut.views.handlebars.enabled", true,
                    "micronaut.router.static-resources.lorem.paths", "classpath:static-lorem/",
                    "micronaut.router.static-resources.lorem.mapping", "/static-lorem/**"
            ))
    );
    AwsProxyRequest request = getRequestBuilder("/echo/test33", "GET").build();

    AwsProxyResponse output = handler.proxy(request, lambdaContext);
    assertEquals(404, output.getStatusCode());
}
 
Example 2
Source File: MicronautAwsProxyTest.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
@Test
public void error_statusCode_methodNotAllowed() throws ContainerInitializationException {
    MicronautLambdaContainerHandler handler = new MicronautLambdaContainerHandler(
            ApplicationContext.build(CollectionUtils.mapOf(
                    "spec.name", "MicronautAwsProxyTest",
                    "micronaut.security.enabled", false,
                    "micronaut.views.handlebars.enabled", true,
                    "micronaut.router.static-resources.lorem.paths", "classpath:static-lorem/",
                    "micronaut.router.static-resources.lorem.mapping", "/static-lorem/**"
            ))
    );
    AwsProxyRequest request = getRequestBuilder("/echo/status-code", "POST")
            .json()
            .queryString("status", "201")
            .build();

    AwsProxyResponse output = handler.proxy(request, lambdaContext);
    assertEquals(405, output.getStatusCode());
}
 
Example 3
Source File: MicronautAwsProxyTest.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
@Test
public void stripBasePath_route_shouldReturn404() throws ContainerInitializationException {
    MicronautLambdaContainerHandler handler = new MicronautLambdaContainerHandler(
            ApplicationContext.build(CollectionUtils.mapOf(
                    "spec.name", "MicronautAwsProxyTest",
                    "micronaut.security.enabled", false,
                    "micronaut.views.handlebars.enabled", true,
                    "micronaut.router.static-resources.lorem.paths", "classpath:static-lorem/",
                    "micronaut.router.static-resources.lorem.mapping", "/static-lorem/**"
            ))
    );
    handler.stripBasePath("/custom");
    try {
        AwsProxyRequest request = getRequestBuilder("/custompath/echo/status-code", "GET")
                .json()
                .queryString("status", "201")
                .build();
        AwsProxyResponse output = handler.proxy(request, lambdaContext);
        assertEquals(404, output.getStatusCode());
    } finally {

        handler.stripBasePath("");
    }
}
 
Example 4
Source File: MicronautLambdaContainerHandler.java    From micronaut-aws with Apache License 2.0 2 votes vote down vote up
/**
 * Default constructor.
 *
 * @throws ContainerInitializationException The exception
 */
public MicronautLambdaContainerHandler() throws ContainerInitializationException {
    this(new LambdaContainerState(), ApplicationContext.build());
}
 
Example 5
Source File: MicronautLambdaContainerHandler.java    From micronaut-aws with Apache License 2.0 2 votes vote down vote up
/**
 * constructor.
 *
 * @param lambdaContainerEnvironment The environment
 * @throws ContainerInitializationException if the container couldn't be started
 */
private MicronautLambdaContainerHandler(LambdaContainerState lambdaContainerEnvironment) throws ContainerInitializationException {
    this(lambdaContainerEnvironment, ApplicationContext.build());
}