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

Function testSpringBoot

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

Source from the content-addressed store, hash-verified

12)
13
14func testSpringBoot(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 Spring Boot application", func() {
39 it("successfully deploys and runs", func() {
40 deployment, logs, err := platform.Deploy.
41 WithEnv(map[string]string{
42 "BP_JAVA_VERSION": "11",
43 }).
44 Execute(name, filepath.Join(fixtures, "containers", "spring_boot_staged"))
45 Expect(err).NotTo(HaveOccurred(), logs.String)
46
47 Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
48 Eventually(deployment).Should(matchers.Serve(Not(BeEmpty())))
49 })
50 })
51
52 context("with embedded Tomcat", func() {
53 it("starts successfully", func() {
54 deployment, logs, err := platform.Deploy.
55 WithEnv(map[string]string{
56 "BP_JAVA_VERSION": "11",
57 }).
58 Execute(name, filepath.Join(fixtures, "containers", "spring_boot_staged"))
59 Expect(err).NotTo(HaveOccurred(), logs.String)
60
61 Expect(logs.String()).To(Or(
62 ContainSubstring("Tomcat"),
63 ContainSubstring("JRE"),
64 ))
65 Eventually(deployment).Should(matchers.Serve(Not(BeEmpty())))
66 })
67 })
68
69 context("with Java CFEnv", func() {
70 it("includes java-cfenv when Spring Boot is detected", func() {
71 deployment, logs, err := platform.Deploy.

Callers 1

TestIntegrationFunction · 0.85

Calls 2

StringMethod · 0.80
ExecuteMethod · 0.65

Tested by

no test coverage detected