-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple WAR test that does not use Spring
Signed-off-by: Daniel Mikusa <[email protected]>
- Loading branch information
Showing
25 changed files
with
589 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/** | ||
!**/src/test/** | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,119 @@ | ||
package war_test | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/paketo-buildpacks/samples/tests" | ||
|
||
"github.com/paketo-buildpacks/occam" | ||
"github.com/sclevine/spec" | ||
"github.com/sclevine/spec/report" | ||
|
||
. "github.com/onsi/gomega" | ||
. "github.com/paketo-buildpacks/occam/matchers" | ||
) | ||
|
||
var builders tests.BuilderFlags | ||
|
||
func init() { | ||
flag.Var(&builders, "name", "the name a builder to test with") | ||
} | ||
func TestWARSpring(t *testing.T) { | ||
Expect := NewWithT(t).Expect | ||
|
||
Expect(len(builders)).NotTo(Equal(0)) | ||
|
||
SetDefaultEventuallyTimeout(60 * time.Second) | ||
|
||
suite := spec.New("Java - WAR Spring", spec.Parallel(), spec.Report(report.Terminal{})) | ||
for _, builder := range builders { | ||
suite(fmt.Sprintf("WAR Spring with %s builder", builder), testWARWithBuilder(builder), spec.Sequential()) | ||
} | ||
suite.Run(t) | ||
} | ||
|
||
func testWARWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { | ||
return func(t *testing.T, context spec.G, it spec.S) { | ||
var ( | ||
Expect = NewWithT(t).Expect | ||
Eventually = NewWithT(t).Eventually | ||
|
||
pack occam.Pack | ||
docker occam.Docker | ||
) | ||
|
||
it.Before(func() { | ||
pack = occam.NewPack().WithVerbose().WithNoColor() | ||
docker = occam.NewDocker() | ||
}) | ||
|
||
context("detects a Java app", func() { | ||
var ( | ||
image occam.Image | ||
container occam.Container | ||
|
||
name string | ||
source string | ||
) | ||
|
||
it.Before(func() { | ||
var err error | ||
name, err = occam.RandomName() | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
it.After(func() { | ||
err := docker.Container.Remove.Execute(container.ID) | ||
if err != nil { | ||
Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) | ||
} else { | ||
Expect(err).ToNot(HaveOccurred()) | ||
} | ||
|
||
Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) | ||
|
||
err = docker.Image.Remove.Execute(image.ID) | ||
if err != nil { | ||
Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) | ||
} else { | ||
Expect(err).ToNot(HaveOccurred()) | ||
} | ||
|
||
Expect(os.RemoveAll(source)).To(Succeed()) | ||
}) | ||
|
||
context("app uses war", func() { | ||
it("builds successfully", func() { | ||
var err error | ||
source, err = occam.Source(filepath.Join("../")) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
var logs fmt.Stringer | ||
image, logs, err = pack.Build. | ||
WithPullPolicy("never"). | ||
WithBuilder(builder). | ||
WithEnv(map[string]string{"BP_TOMCAT_VERSION": "10.1"}). | ||
Execute(name, source) | ||
Expect(err).ToNot(HaveOccurred(), logs.String) | ||
|
||
Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) | ||
Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Apache Tomcat"))) | ||
|
||
container, err = docker.Container.Run. | ||
WithPublish("8080"). | ||
Execute(image.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) | ||
}) | ||
}) | ||
}) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,9 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
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,31 +1,5 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/** | ||
!**/src/test/** | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
# Ignore Gradle build output directory | ||
build |
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,26 @@ | ||
plugins { | ||
id 'war' | ||
} | ||
|
||
group = 'io.paketo' | ||
version = '0.0.1-SNAPSHOT' | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
repositories { | ||
// Use Maven Central for resolving dependencies. | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
providedCompile 'jakarta.platform:jakarta.jakartaee-api:10.0.0' | ||
providedCompile 'org.eclipse.microprofile:microprofile:6.1' | ||
|
||
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.3' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
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,2 @@ | ||
org.gradle.parallel=true | ||
org.gradle.caching=true |
Binary file not shown.
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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.