diff --git a/http-server-jetty/src/test/groovy/io/micronaut/servlet/jetty/JettyStaticResourceResolutionSpec.groovy b/http-server-jetty/src/test/groovy/io/micronaut/servlet/jetty/JettyStaticResourceResolutionSpec.groovy
index e0504769a..df6505ece 100644
--- a/http-server-jetty/src/test/groovy/io/micronaut/servlet/jetty/JettyStaticResourceResolutionSpec.groovy
+++ b/http-server-jetty/src/test/groovy/io/micronaut/servlet/jetty/JettyStaticResourceResolutionSpec.groovy
@@ -253,4 +253,41 @@ class JettyStaticResourceResolutionSpec extends Specification implements TestPro
embeddedServer?.stop()
embeddedServer?.close()
}
+
+ void "test resources with multiple nested mapping automatically resolves index.html"() {
+ given:
+ EmbeddedServer embeddedServer = ApplicationContext.run(EmbeddedServer, [
+ 'micronaut.router.static-resources.nest-test.paths': ['classpath:nest-test'],
+ 'micronaut.router.static-resources.nest-test.mapping': '/nest-test/**',
+ 'micronaut.router.static-resources.nest.paths': ['classpath:nest-test/nested'],
+ 'micronaut.router.static-resources.nest.mapping': '/nest/**'
+ ])
+ def client = embeddedServer.applicationContext.createBean(HttpClient, embeddedServer.getURL()).toBlocking()
+
+ when:
+ def nestTestResponse = client.exchange(HttpRequest.GET("/nest-test"), String)
+ def nestTestText = JettyStaticResourceResolutionSpec.classLoader.getResource("nest-test/index.html").text
+
+ def nestResponse = client.exchange(HttpRequest.GET("/nest"), String)
+ def nestText = JettyStaticResourceResolutionSpec.classLoader.getResource("nest-test/nested/index.html").text
+
+ then:
+ with(nestTestResponse) {
+ code() == HttpStatus.OK.code
+ header(CONTENT_TYPE) == "text/html"
+ Integer.parseInt(header(CONTENT_LENGTH)) > 0
+ body() == nestTestText
+ }
+
+ with(nestResponse) {
+ code() == HttpStatus.OK.code
+ header(CONTENT_TYPE) == "text/html"
+ Integer.parseInt(header(CONTENT_LENGTH)) > 0
+ body() == nestText
+ }
+
+ cleanup:
+ embeddedServer.stop()
+ embeddedServer.close()
+ }
}
diff --git a/http-server-jetty/src/test/resources/nest-test/index.html b/http-server-jetty/src/test/resources/nest-test/index.html
new file mode 100644
index 000000000..d44613946
--- /dev/null
+++ b/http-server-jetty/src/test/resources/nest-test/index.html
@@ -0,0 +1 @@
+
Test
diff --git a/http-server-jetty/src/test/resources/nest-test/nested/index.html b/http-server-jetty/src/test/resources/nest-test/nested/index.html
new file mode 100644
index 000000000..87b44891e
--- /dev/null
+++ b/http-server-jetty/src/test/resources/nest-test/nested/index.html
@@ -0,0 +1,5 @@
+
+
+Nest
+
+
diff --git a/http-server-tomcat/src/test/groovy/io/micronaut/servlet/tomcat/TomcatStaticResourceResolutionSpec.groovy b/http-server-tomcat/src/test/groovy/io/micronaut/servlet/tomcat/TomcatStaticResourceResolutionSpec.groovy
index 01f2e7d9c..d99243eaa 100644
--- a/http-server-tomcat/src/test/groovy/io/micronaut/servlet/tomcat/TomcatStaticResourceResolutionSpec.groovy
+++ b/http-server-tomcat/src/test/groovy/io/micronaut/servlet/tomcat/TomcatStaticResourceResolutionSpec.groovy
@@ -251,4 +251,41 @@ class TomcatStaticResourceResolutionSpec extends Specification implements TestPr
embeddedServer?.stop()
embeddedServer?.close()
}
+
+ void "test resources with multiple nested mapping automatically resolves index.html"() {
+ given:
+ EmbeddedServer embeddedServer = ApplicationContext.run(EmbeddedServer, [
+ 'micronaut.router.static-resources.nest-test.paths': ['classpath:nest-test'],
+ 'micronaut.router.static-resources.nest-test.mapping': '/nest-test/**',
+ 'micronaut.router.static-resources.nest.paths': ['classpath:nest-test/nested'],
+ 'micronaut.router.static-resources.nest.mapping': '/nest/**'
+ ])
+ def client = embeddedServer.applicationContext.createBean(HttpClient, embeddedServer.getURL()).toBlocking()
+
+ when:
+ def nestTestResponse = client.exchange(HttpRequest.GET("/nest-test"), String)
+ def nestTestText = TomcatStaticResourceResolutionSpec.classLoader.getResource("nest-test/index.html").text
+
+ def nestResponse = client.exchange(HttpRequest.GET("/nest"), String)
+ def nestText = TomcatStaticResourceResolutionSpec.classLoader.getResource("nest-test/nested/index.html").text
+
+ then:
+ with(nestTestResponse) {
+ code() == HttpStatus.OK.code
+ header(CONTENT_TYPE) == "text/html"
+ Integer.parseInt(header(CONTENT_LENGTH)) > 0
+ body() == nestTestText
+ }
+
+ with(nestResponse) {
+ code() == HttpStatus.OK.code
+ header(CONTENT_TYPE) == "text/html"
+ Integer.parseInt(header(CONTENT_LENGTH)) > 0
+ body() == nestText
+ }
+
+ cleanup:
+ embeddedServer.stop()
+ embeddedServer.close()
+ }
}
diff --git a/http-server-tomcat/src/test/resources/nest-test/index.html b/http-server-tomcat/src/test/resources/nest-test/index.html
new file mode 100644
index 000000000..d44613946
--- /dev/null
+++ b/http-server-tomcat/src/test/resources/nest-test/index.html
@@ -0,0 +1 @@
+Test
diff --git a/http-server-tomcat/src/test/resources/nest-test/nested/index.html b/http-server-tomcat/src/test/resources/nest-test/nested/index.html
new file mode 100644
index 000000000..87b44891e
--- /dev/null
+++ b/http-server-tomcat/src/test/resources/nest-test/nested/index.html
@@ -0,0 +1,5 @@
+
+
+Nest
+
+
diff --git a/http-server-undertow/src/test/groovy/io/micronaut/servlet/undertow/UndertowStaticResourceResolutionSpec.groovy b/http-server-undertow/src/test/groovy/io/micronaut/servlet/undertow/UndertowStaticResourceResolutionSpec.groovy
index 4fa9647e6..c91cc783c 100644
--- a/http-server-undertow/src/test/groovy/io/micronaut/servlet/undertow/UndertowStaticResourceResolutionSpec.groovy
+++ b/http-server-undertow/src/test/groovy/io/micronaut/servlet/undertow/UndertowStaticResourceResolutionSpec.groovy
@@ -249,4 +249,41 @@ class UndertowStaticResourceResolutionSpec extends Specification implements Test
embeddedServer?.stop()
embeddedServer?.close()
}
+
+ void "test resources with multiple nested mapping automatically resolves index.html"() {
+ given:
+ EmbeddedServer embeddedServer = ApplicationContext.run(EmbeddedServer, [
+ 'micronaut.router.static-resources.nest-test.paths': ['classpath:nest-test'],
+ 'micronaut.router.static-resources.nest-test.mapping': '/nest-test/**',
+ 'micronaut.router.static-resources.nest.paths': ['classpath:nest-test/nested'],
+ 'micronaut.router.static-resources.nest.mapping': '/nest/**'
+ ])
+ def client = embeddedServer.applicationContext.createBean(HttpClient, embeddedServer.getURL()).toBlocking()
+
+ when:
+ def nestTestResponse = client.exchange(HttpRequest.GET("/nest-test"), String)
+ def nestTestText = UndertowStaticResourceResolutionSpec.classLoader.getResource("nest-test/index.html").text
+
+ def nestResponse = client.exchange(HttpRequest.GET("/nest"), String)
+ def nestText = UndertowStaticResourceResolutionSpec.classLoader.getResource("nest-test/nested/index.html").text
+
+ then:
+ with(nestTestResponse) {
+ code() == HttpStatus.OK.code
+ header(CONTENT_TYPE) == "text/html"
+ Integer.parseInt(header(CONTENT_LENGTH)) > 0
+ body() == nestTestText
+ }
+
+ with(nestResponse) {
+ code() == HttpStatus.OK.code
+ header(CONTENT_TYPE) == "text/html"
+ Integer.parseInt(header(CONTENT_LENGTH)) > 0
+ body() == nestText
+ }
+
+ cleanup:
+ embeddedServer.stop()
+ embeddedServer.close()
+ }
}
diff --git a/http-server-undertow/src/test/resources/nest-test/index.html b/http-server-undertow/src/test/resources/nest-test/index.html
new file mode 100644
index 000000000..d44613946
--- /dev/null
+++ b/http-server-undertow/src/test/resources/nest-test/index.html
@@ -0,0 +1 @@
+Test
diff --git a/http-server-undertow/src/test/resources/nest-test/nested/index.html b/http-server-undertow/src/test/resources/nest-test/nested/index.html
new file mode 100644
index 000000000..87b44891e
--- /dev/null
+++ b/http-server-undertow/src/test/resources/nest-test/nested/index.html
@@ -0,0 +1,5 @@
+
+
+Nest
+
+