MCPcopy Create free account
hub / github.com/cloudfoundry/java-buildpack / testTomcat

Function testTomcat

src/integration/tomcat_test.go:14–445  ·  view source on GitHub ↗
(platform switchblade.Platform, fixtures string)

Source from the content-addressed store, hash-verified

12)
13
14func testTomcat(platform switchblade.Platform, fixtures string) func(*testing.T, spec.G, spec.S) {
15 return func(t *testing.T, context spec.G, it spec.S) {
16 var (
17 Expect = NewWithT(t).Expect
18 Eventually = NewWithT(t).Eventually
19 name string
20 )
21
22 it.Before(func() {
23 var err error
24 name, err = switchblade.RandomName()
25 Expect(err).NotTo(HaveOccurred())
26 })
27
28 it.After(func() {
29 if t.Failed() && name != "" {
30 t.Logf("❌ FAILED TEST - App/Container: %s", name)
31 t.Logf(" Platform: %s", settings.Platform)
32 }
33 if name != "" && (!settings.KeepFailedContainers || !t.Failed()) {
34 Expect(platform.Delete.Execute(name)).To(Succeed())
35 }
36 })
37
38 context("with a simple servlet app", func() {
39 it("successfully deploys and runs with Java 11 (Javax)", func() {
40 deployment, logs, err := platform.Deploy.
41 WithEnv(map[string]string{
42 "BP_JAVA_VERSION": "11",
43 "JBP_CONFIG_TOMCAT": "{ tomcat: { version: \"9.+\" }, access_logging_support: { access_logging: enabled } }",
44 }).
45 Execute(name, filepath.Join(fixtures, "containers", "tomcat_javax"))
46
47 Expect(err).NotTo(HaveOccurred(), logs.String)
48
49 // Verify embedded Cloud Foundry-optimized Tomcat configuration was installed
50 Expect(logs.String()).To(ContainSubstring("Installing Cloud Foundry-optimized Tomcat configuration defaults"))
51 Expect(logs.String()).To(ContainSubstring("Dynamic port binding (${http.port} from $PORT)"))
52 Expect(logs.String()).To(ContainSubstring("HTTP/2 support enabled"))
53 Expect(logs.String()).To(ContainSubstring("RemoteIpValve for X-Forwarded-* headers"))
54 Expect(logs.String()).To(ContainSubstring("CloudFoundryAccessLoggingValve with vcap_request_id"))
55 Expect(logs.String()).To(ContainSubstring("Stdout logging via CloudFoundryConsoleHandler"))
56
57 Eventually(deployment).Should(matchers.Serve(ContainSubstring("OK")))
58
59 // Verify runtime logs contain CloudFoundry-specific Tomcat features
60 // Use Eventually to wait for logs to be flushed, as they may not appear immediately
61
62 // Check for HTTP/2 support in runtime logs (Tomcat startup messages)
63 // These should appear quickly during Tomcat startup
64 Eventually(func() string {
65 logs, _ := deployment.RuntimeLogs()
66 return logs
67 }, "10s", "1s").Should(Or(
68 ContainSubstring("Http11NioProtocol"),
69 ContainSubstring("Starting ProtocolHandler"),
70 ContainSubstring("HTTP/1.1"),
71 ))

Callers 1

TestIntegrationFunction · 0.85

Calls 2

StringMethod · 0.80
ExecuteMethod · 0.65

Tested by

no test coverage detected