Skip to content

Commit

Permalink
fix: Micronaut Lambda Test compilation with 3.9.2
Browse files Browse the repository at this point in the history
Close: #1742

- Micronaut Framework 3.9.2
- ignore test in tck

fix test
  • Loading branch information
sdelamo committed Jun 1, 2023
1 parent 13897da commit 15bbf41
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,23 @@ class CloudwatchLoggingSpec extends Specification {
mockLogging.getPutLogsRequestList().size() != 0
}

def putLogRequestList = ((MockLogging) logging).getPutLogsRequestList()
List<PutLogEventsRequest> putLogRequestList = ((MockLogging) logging).getPutLogsRequestList()
putLogRequestList.stream().allMatch(x -> x.logGroupName() == applicationConfiguration.getName().get())
putLogRequestList.stream().allMatch(x -> x.logStreamName() == testHost)

ObjectMapper mapper = ObjectMapper.getDefault()

def logEntries = new ArrayList<Map<String, String>>()
List<Map<String, String>> logEntries = new ArrayList<Map<String, String>>()

putLogRequestList.forEach(
x -> {
x.logEvents().stream().forEach(y -> logEntries.add(
mapper.readValue(y.message(), HashMap.class) as Map<String, String>
))
}
)
for (PutLogEventsRequest x : putLogRequestList) {
for (InputLogEvent y : x.logEvents()) {
logEntries.add(mapper.readValue(y.message(), HashMap.class) as Map<String, String>)
}
}

logEntries.stream().anyMatch(x -> x.logger == 'io.micronaut.context.env.DefaultEnvironment')
logEntries.stream().anyMatch(x -> x.logger == 'io.micronaut.aws.cloudwatch.logging.CloudwatchLoggingSpec')
logEntries.stream().anyMatch(x -> x.message == logMessage)
logEntries.any { it['logger'] == 'io.micronaut.context.DefaultApplicationContext$RuntimeConfiguredEnvironment' }
logEntries.any { it['logger'] == 'io.micronaut.aws.cloudwatch.logging.CloudwatchLoggingSpec' }
logEntries.any { it['message'] == logMessage }
MockAppender.getEvents().size() == 0

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ private MicronautTestValue buildValueObject(MicronautLambdaTest micronautTest) {
micronautTest.rebuildContext(),
micronautTest.contextBuilder(),
micronautTest.transactionMode(),
micronautTest.startApplication());
micronautTest.startApplication(),
micronautTest.resolveParameters());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,14 @@
* @return true if {@link io.micronaut.runtime.EmbeddedApplication} should be started
*/
boolean startApplication() default true;

/**
* By default, with JUnit 5 the test method parameters will be resolved to beans if possible.
* This behaviour can be problematic if in combination with the {@code ParameterizedTest} annotation.
* Setting this member to {@code false} will completely disable bean resolution for method parameters.
* <p>
*
* @return Whether to resolve test method parameters as beans.
*/
boolean resolveParameters() default true;
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
micronaut = "3.8.8"
micronaut = "3.9.2"
micronaut-docs = "2.0.0"
micronaut-test = "3.9.1"
groovy = "3.0.13"
Expand All @@ -16,7 +16,7 @@ managed-aws-lambda = '1.2.2'
managed-aws-lambda-events = '3.11.1'
managed-aws-serverless-core = '1.9.2'
managed-aws-cdk-lib='2.73.0'
micronaut-starter = "3.8.8"
micronaut-starter = "3.9.2"
servlet-api = "2.5"
slf4j = "1.7.36"
javapoet = "1.13.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"io.micronaut.http.server.tck.tests.BodyTest",
"io.micronaut.http.server.tck.tests.OctetTest",
"io.micronaut.http.server.tck.tests.endpoints.health.HealthTest",
"io.micronaut.http.server.tck.tests.staticresources.StaticResourceTest"
"io.micronaut.http.server.tck.tests.staticresources.StaticResourceTest",
"io.micronaut.http.server.tck.tests.cors.CrossOriginTest",
"io.micronaut.http.server.tck.tests.constraintshandler.ControllerConstraintHandlerTest"
})
public class MicronautLambdaHandlerHttpServerTestSuite {
}

0 comments on commit 15bbf41

Please sign in to comment.