-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This example is used to experiment about classpath filtering and benchmarking. Issue gh-34
- Loading branch information
Showing
9 changed files
with
132 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
dependencies { | ||
api(project(":core")) | ||
api(project(":modules:logging")) | ||
api("org.springframework:spring-webflux") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
= Minimal webapp | ||
|
||
This is a Spring Fu example of a minimal webapp with filtered classpath. | ||
|
||
Stats are Size of the executable JAR is: | ||
|
||
|
||
* Tomcat: 866 ms startup, 12.1 MB executable JAR, 3400 classes, 10 MB heap, 0 MB Permgen | ||
* Netty: 1058 ms startup, 12.6 MB executable JAR, 3360 classes, 10 MB heap, 0 MB Permgen | ||
* Undertow: TODO when https://github.com/spring-projects/spring-fu/issues/59 will be fixed | ||
* Jetty: TODO when https://github.com/spring-projects/spring-fu/issues/60 will be fixed | ||
|
||
The app could be benchmark with the following command: | ||
|
||
`sudo perf stat -e cpu-clock -r10 java -jar -XX:TieredStopAtLevel=1 -noverify -Djava.security.egd=file:/dev/./urandom samples/minimal-webapp/build/libs/minimal-webapp-1.0.0.BUILD-SNAPSHOT-all.jar` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
import org.jetbrains.kotlin.gradle.dsl.Coroutines | ||
|
||
plugins { | ||
application | ||
id ("com.github.johnrengelman.shadow") | ||
} | ||
|
||
application { | ||
mainClassName = "org.springframework.fu.sample.minimal.ApplicationKt" | ||
} | ||
|
||
dependencies { | ||
implementation(project(":modules:webflux-netty")) | ||
testImplementation(project(":modules:test")) | ||
} | ||
|
||
configurations { | ||
all { | ||
exclude(module = "spring-aop") | ||
} | ||
} | ||
|
||
tasks.withType<ShadowJar> { | ||
exclude("org/springframework/cglib/**", | ||
"org/springframework/beans/factory/groovy/**", | ||
"org/springframework/beans/factory/xml/**", | ||
"org/springframework/cache", | ||
"org/springframework/context/annotation", | ||
"org/springframework/context/support/*Xml*.class", | ||
"org/springframework/context/support/*Groovy*.class", | ||
"org/springframework/ejb/**", | ||
"org/springframework/instrument/classloading/**", | ||
"org/springframework/jmx/**", | ||
"org/springframework/jndi/**", | ||
"org/springframework/remoting/**", | ||
"org/springframework/scheduling/**", | ||
"org/springframework/scripting/**", | ||
"org/springframework/web/accept/**", | ||
"org/springframework/web/bind/**", | ||
"org/springframework/web/client/**", | ||
"org/springframework/web/context/**", | ||
"org/springframework/web/filter/**", | ||
"org/springframework/web/jsf/**", | ||
"org/springframework/web/method/**", | ||
"org/springframework/web/multipart/**", | ||
"org/springframework/util/xml/**") | ||
} |
35 changes: 35 additions & 0 deletions
35
samples/minimal-webapp/src/main/kotlin/org/springframework/fu/sample/minimal/Application.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2002-2018 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.fu.sample.minimal | ||
|
||
import org.springframework.fu.application | ||
import org.springframework.fu.module.webflux.netty.netty | ||
import org.springframework.fu.module.webflux.webflux | ||
|
||
val app = application { | ||
webflux { | ||
server(netty()) { | ||
routes { | ||
GET("/") { | ||
ok().syncBody("Hello world!") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun main(args: Array<String>) = app.run(await = true) |
29 changes: 29 additions & 0 deletions
29
.../minimal-webapp/src/test/kotlin/org/springframework/fu/sample/minimal/IntegrationTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.springframework.fu.sample.minimal | ||
|
||
import org.junit.jupiter.api.AfterAll | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.test.web.reactive.server.* | ||
import org.springframework.test.web.reactive.server.WebTestClient | ||
|
||
class IntegrationTests { | ||
|
||
private val client = WebTestClient.bindToServer().baseUrl("http://localhost:8080").build() | ||
|
||
@BeforeAll | ||
fun beforeAll() { | ||
app.run(profiles = "test") | ||
} | ||
|
||
@Test | ||
fun `Request root endpoint`() { | ||
client.get().uri("/").exchange() | ||
.expectStatus().is2xxSuccessful | ||
.expectBody<String>().isEqualTo("Hello world!") | ||
} | ||
|
||
@AfterAll | ||
fun afterAll() { | ||
app.stop() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters