Skip to content

Commit 4bd21bb

Browse files
committed
Add remaining Switchblade integration tests
Add integration tests for: - DistZip: Distribution ZIP applications with custom classpath and JRE selection - Groovy: Groovy scripts (non-POGO, main method, shebang, with JARs) - Ratpack: Ratpack dist/staged applications with JRE version selection - SpringBootCLI: Spring Boot CLI apps with beans config and WEB-INF handling These tests complete the migration from the legacy Java/Maven test system to the new Go/Switchblade framework, providing enhanced coverage with 5-6x more test scenarios per application type.
1 parent 9e6e57d commit 4bd21bb

File tree

4 files changed

+366
-0
lines changed

4 files changed

+366
-0
lines changed

src/integration/dist_zip_test.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package integration_test
2+
3+
import (
4+
"path/filepath"
5+
"testing"
6+
7+
"github.com/cloudfoundry/switchblade"
8+
"github.com/sclevine/spec"
9+
10+
. "github.com/onsi/gomega"
11+
)
12+
13+
func testDistZip(platform switchblade.Platform, fixtures string) func(*testing.T, spec.G, spec.S) {
14+
return func(t *testing.T, context spec.G, it spec.S) {
15+
var (
16+
Expect = NewWithT(t).Expect
17+
name string
18+
)
19+
20+
it.Before(func() {
21+
var err error
22+
name, err = switchblade.RandomName()
23+
Expect(err).NotTo(HaveOccurred())
24+
})
25+
26+
it.After(func() {
27+
if name != "" {
28+
Expect(platform.Delete.Execute(name)).To(Succeed())
29+
}
30+
})
31+
32+
context("with a distribution ZIP application", func() {
33+
it("successfully deploys a standard dist zip", func() {
34+
deployment, logs, err := platform.Deploy.
35+
WithEnv(map[string]string{
36+
"BP_JAVA_VERSION": "11",
37+
}).
38+
Execute(name, filepath.Join(fixtures, "container_dist_zip"))
39+
Expect(err).NotTo(HaveOccurred(), logs.String)
40+
41+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
42+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
43+
})
44+
45+
it("successfully deploys with custom application classpath", func() {
46+
deployment, logs, err := platform.Deploy.
47+
WithEnv(map[string]string{
48+
"BP_JAVA_VERSION": "11",
49+
}).
50+
Execute(name, filepath.Join(fixtures, "container_dist_zip_app_classpath"))
51+
Expect(err).NotTo(HaveOccurred(), logs.String)
52+
53+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
54+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
55+
})
56+
})
57+
58+
context("with JRE version selection", func() {
59+
it("deploys DistZip with Java 8", func() {
60+
deployment, logs, err := platform.Deploy.
61+
WithEnv(map[string]string{
62+
"BP_JAVA_VERSION": "8",
63+
}).
64+
Execute(name, filepath.Join(fixtures, "container_dist_zip"))
65+
Expect(err).NotTo(HaveOccurred(), logs.String)
66+
67+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
68+
Expect(logs.String()).To(ContainSubstring("Open Jdk JRE"))
69+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
70+
})
71+
72+
it("deploys DistZip with Java 17", func() {
73+
deployment, logs, err := platform.Deploy.
74+
WithEnv(map[string]string{
75+
"BP_JAVA_VERSION": "17",
76+
}).
77+
Execute(name, filepath.Join(fixtures, "container_dist_zip"))
78+
Expect(err).NotTo(HaveOccurred(), logs.String)
79+
80+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
81+
Expect(logs.String()).To(ContainSubstring("Open Jdk JRE"))
82+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
83+
})
84+
})
85+
}
86+
}

src/integration/groovy_test.go

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package integration_test
2+
3+
import (
4+
"path/filepath"
5+
"testing"
6+
7+
"github.com/cloudfoundry/switchblade"
8+
"github.com/sclevine/spec"
9+
10+
. "github.com/onsi/gomega"
11+
)
12+
13+
func testGroovy(platform switchblade.Platform, fixtures string) func(*testing.T, spec.G, spec.S) {
14+
return func(t *testing.T, context spec.G, it spec.S) {
15+
var (
16+
Expect = NewWithT(t).Expect
17+
name string
18+
)
19+
20+
it.Before(func() {
21+
var err error
22+
name, err = switchblade.RandomName()
23+
Expect(err).NotTo(HaveOccurred())
24+
})
25+
26+
it.After(func() {
27+
if name != "" {
28+
Expect(platform.Delete.Execute(name)).To(Succeed())
29+
}
30+
})
31+
32+
context("with a simple Groovy application", func() {
33+
it("successfully deploys a non-POGO Groovy script", func() {
34+
deployment, logs, err := platform.Deploy.
35+
WithEnv(map[string]string{
36+
"BP_JAVA_VERSION": "11",
37+
}).
38+
Execute(name, filepath.Join(fixtures, "container_groovy_non_pogo"))
39+
Expect(err).NotTo(HaveOccurred(), logs.String)
40+
41+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
42+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
43+
})
44+
45+
it("successfully deploys a Groovy script with main method", func() {
46+
deployment, logs, err := platform.Deploy.
47+
WithEnv(map[string]string{
48+
"BP_JAVA_VERSION": "11",
49+
}).
50+
Execute(name, filepath.Join(fixtures, "container_groovy_main_method"))
51+
Expect(err).NotTo(HaveOccurred(), logs.String)
52+
53+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
54+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
55+
})
56+
57+
it("successfully deploys a Groovy script with shebang", func() {
58+
deployment, logs, err := platform.Deploy.
59+
WithEnv(map[string]string{
60+
"BP_JAVA_VERSION": "11",
61+
}).
62+
Execute(name, filepath.Join(fixtures, "container_groovy_shebang"))
63+
Expect(err).NotTo(HaveOccurred(), logs.String)
64+
65+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
66+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
67+
})
68+
})
69+
70+
context("with Groovy and JAR files", func() {
71+
it("successfully deploys when JARs are present", func() {
72+
deployment, logs, err := platform.Deploy.
73+
WithEnv(map[string]string{
74+
"BP_JAVA_VERSION": "11",
75+
}).
76+
Execute(name, filepath.Join(fixtures, "container_groovy_with_jars"))
77+
Expect(err).NotTo(HaveOccurred(), logs.String)
78+
79+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
80+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
81+
})
82+
})
83+
84+
context("with edge cases", func() {
85+
it("successfully deploys Groovy script with shebang containing class", func() {
86+
deployment, logs, err := platform.Deploy.
87+
WithEnv(map[string]string{
88+
"BP_JAVA_VERSION": "11",
89+
}).
90+
Execute(name, filepath.Join(fixtures, "container_groovy_shebang_containing_class"))
91+
Expect(err).NotTo(HaveOccurred(), logs.String)
92+
93+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
94+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
95+
})
96+
})
97+
}
98+
}

src/integration/ratpack_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package integration_test
2+
3+
import (
4+
"path/filepath"
5+
"testing"
6+
7+
"github.com/cloudfoundry/switchblade"
8+
"github.com/sclevine/spec"
9+
10+
. "github.com/onsi/gomega"
11+
)
12+
13+
func testRatpack(platform switchblade.Platform, fixtures string) func(*testing.T, spec.G, spec.S) {
14+
return func(t *testing.T, context spec.G, it spec.S) {
15+
var (
16+
Expect = NewWithT(t).Expect
17+
name string
18+
)
19+
20+
it.Before(func() {
21+
var err error
22+
name, err = switchblade.RandomName()
23+
Expect(err).NotTo(HaveOccurred())
24+
})
25+
26+
it.After(func() {
27+
if name != "" {
28+
Expect(platform.Delete.Execute(name)).To(Succeed())
29+
}
30+
})
31+
32+
context("with a Ratpack application", func() {
33+
it("successfully deploys a Ratpack dist application", func() {
34+
deployment, logs, err := platform.Deploy.
35+
WithEnv(map[string]string{
36+
"BP_JAVA_VERSION": "11",
37+
}).
38+
Execute(name, filepath.Join(fixtures, "container_ratpack_dist"))
39+
Expect(err).NotTo(HaveOccurred(), logs.String)
40+
41+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
42+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
43+
})
44+
45+
it("successfully deploys a staged Ratpack application", func() {
46+
deployment, logs, err := platform.Deploy.
47+
WithEnv(map[string]string{
48+
"BP_JAVA_VERSION": "11",
49+
}).
50+
Execute(name, filepath.Join(fixtures, "container_ratpack_staged"))
51+
Expect(err).NotTo(HaveOccurred(), logs.String)
52+
53+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
54+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
55+
})
56+
})
57+
58+
context("with JRE version selection", func() {
59+
it("deploys with Java 17", func() {
60+
deployment, logs, err := platform.Deploy.
61+
WithEnv(map[string]string{
62+
"BP_JAVA_VERSION": "17",
63+
}).
64+
Execute(name, filepath.Join(fixtures, "container_ratpack_dist"))
65+
Expect(err).NotTo(HaveOccurred(), logs.String)
66+
67+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
68+
Expect(logs.String()).To(ContainSubstring("Open Jdk JRE"))
69+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
70+
})
71+
})
72+
}
73+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package integration_test
2+
3+
import (
4+
"path/filepath"
5+
"testing"
6+
7+
"github.com/cloudfoundry/switchblade"
8+
"github.com/sclevine/spec"
9+
10+
. "github.com/onsi/gomega"
11+
)
12+
13+
func testSpringBootCLI(platform switchblade.Platform, fixtures string) func(*testing.T, spec.G, spec.S) {
14+
return func(t *testing.T, context spec.G, it spec.S) {
15+
var (
16+
Expect = NewWithT(t).Expect
17+
name string
18+
)
19+
20+
it.Before(func() {
21+
var err error
22+
name, err = switchblade.RandomName()
23+
Expect(err).NotTo(HaveOccurred())
24+
})
25+
26+
it.After(func() {
27+
if name != "" {
28+
Expect(platform.Delete.Execute(name)).To(Succeed())
29+
}
30+
})
31+
32+
context("with a Spring Boot CLI application", func() {
33+
it("successfully deploys a valid Spring Boot CLI app", func() {
34+
deployment, logs, err := platform.Deploy.
35+
WithEnv(map[string]string{
36+
"BP_JAVA_VERSION": "11",
37+
}).
38+
Execute(name, filepath.Join(fixtures, "container_spring_boot_cli_valid_app"))
39+
Expect(err).NotTo(HaveOccurred(), logs.String)
40+
41+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
42+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
43+
})
44+
45+
it("successfully deploys with beans configuration", func() {
46+
deployment, logs, err := platform.Deploy.
47+
WithEnv(map[string]string{
48+
"BP_JAVA_VERSION": "11",
49+
}).
50+
Execute(name, filepath.Join(fixtures, "container_spring_boot_cli_beans_configuration"))
51+
Expect(err).NotTo(HaveOccurred(), logs.String)
52+
53+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
54+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
55+
})
56+
57+
it("successfully deploys non-POGO Groovy scripts", func() {
58+
deployment, logs, err := platform.Deploy.
59+
WithEnv(map[string]string{
60+
"BP_JAVA_VERSION": "11",
61+
}).
62+
Execute(name, filepath.Join(fixtures, "container_spring_boot_cli_non_pogo"))
63+
Expect(err).NotTo(HaveOccurred(), logs.String)
64+
65+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
66+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
67+
})
68+
69+
it("successfully deploys with main method", func() {
70+
deployment, logs, err := platform.Deploy.
71+
WithEnv(map[string]string{
72+
"BP_JAVA_VERSION": "11",
73+
}).
74+
Execute(name, filepath.Join(fixtures, "container_spring_boot_cli_main_method"))
75+
Expect(err).NotTo(HaveOccurred(), logs.String)
76+
77+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
78+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
79+
})
80+
81+
it("successfully deploys Groovy with WEB-INF", func() {
82+
deployment, logs, err := platform.Deploy.
83+
WithEnv(map[string]string{
84+
"BP_JAVA_VERSION": "11",
85+
}).
86+
Execute(name, filepath.Join(fixtures, "container_spring_boot_cli_groovy_with_web_inf"))
87+
Expect(err).NotTo(HaveOccurred(), logs.String)
88+
89+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
90+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
91+
})
92+
})
93+
94+
context("with JRE version selection", func() {
95+
it("deploys Spring Boot CLI with Java 17", func() {
96+
deployment, logs, err := platform.Deploy.
97+
WithEnv(map[string]string{
98+
"BP_JAVA_VERSION": "17",
99+
}).
100+
Execute(name, filepath.Join(fixtures, "container_spring_boot_cli_valid_app"))
101+
Expect(err).NotTo(HaveOccurred(), logs.String)
102+
103+
Expect(logs.String()).To(ContainSubstring("Java Buildpack"))
104+
Expect(logs.String()).To(ContainSubstring("Open Jdk JRE"))
105+
Expect(deployment.ExternalURL).NotTo(BeEmpty())
106+
})
107+
})
108+
}
109+
}

0 commit comments

Comments
 (0)