Skip to content

Commit

Permalink
Payara Micro and Payara Server adapter. Fixes #60
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebusscher committed Sep 15, 2019
1 parent f941f81 commit 22a76a2
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/payara-micro/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id 'maven-publish'
}

publishing {
publications {
maven(MavenPublication) {
artifactId = 'microshed-testing-payara-micro'
from components.java
}
}
}

description = "MicroShed Testing framework :: Payara Micro extensions"

dependencies {
compile project(':microshed-testing-testcontainers')
}

publishToMavenLocal.dependsOn ':microshed-testing-testcontainers:publishToMavenLocal'
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2019 Payara Services Corporation and others
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* 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.testcontainers.containers.payara;

import org.microshed.testing.testcontainers.spi.ServerAdapter;
import org.testcontainers.images.builder.ImageFromDockerfile;

import java.io.File;

public class PayaraMicroAdapter implements ServerAdapter {
@Override
public int getDefaultHttpPort() {
return 8080;
}

@Override
public int getDefaultHttpsPort() {
return 8181;
}

@Override
public ImageFromDockerfile getDefaultImage(File appFile) {
String appName = appFile.getName();
// Compose a docker image equivalent to doing:
// FROM payara/micro:5.193
// CMD ["--deploymentDir", "/opt/payara/deployments", "--noCluster"]
// ADD target/myservice.war /opt/payara/deployments
ImageFromDockerfile image = new ImageFromDockerfile()
.withDockerfileFromBuilder(builder -> builder.from("payara/micro:5.193")
.cmd("--deploymentDir", "/opt/payara/deployments", "--noCluster")
.add(appName, "/opt/payara/deployments")
.build())
.withFileFromFile(appName, appFile);
return image;

}

@Override
public String getReadinessPath() {
return "/health";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.testcontainers.containers.payara.PayaraMicroAdapter
10 changes: 10 additions & 0 deletions modules/payara-micro/src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
log4j.rootLogger=INFO, stdout

log4j.appender=org.apache.log4j.ConsoleAppender
log4j.appender.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%r %p %c %x - %m%n

log4j.logger.org.aguibert.liberty=DEBUG
20 changes: 20 additions & 0 deletions modules/payara-server/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id 'maven-publish'
}

publishing {
publications {
maven(MavenPublication) {
artifactId = 'microshed-testing-payara-server'
from components.java
}
}
}

description = "MicroShed Testing framework :: Payara Server extensions"

dependencies {
compile project(':microshed-testing-testcontainers')
}

publishToMavenLocal.dependsOn ':microshed-testing-testcontainers:publishToMavenLocal'
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2019 Payara Services Corporation and others
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* 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.testcontainers.containers.payara;

import org.microshed.testing.testcontainers.spi.ServerAdapter;
import org.testcontainers.images.builder.ImageFromDockerfile;

import java.io.File;

public class PayaraServerAdapter implements ServerAdapter {
@Override
public int getDefaultHttpPort() {
return 8080;
}

@Override
public int getDefaultHttpsPort() {
return 8181;
}

@Override
public ImageFromDockerfile getDefaultImage(File appFile) {
String appName = appFile.getName();
// Compose a docker image equivalent to doing:
// FROM payara/server-full:5.193
// ADD target/myservice.war /opt/payara/deployments
ImageFromDockerfile image = new ImageFromDockerfile()
.withDockerfileFromBuilder(builder -> builder.from("payara/server-full:5.193")
.add(appName, "/opt/payara/deployments")
.build())
.withFileFromFile(appName, appFile);
return image;

}

@Override
public String getReadinessPath() {
return "/health";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.testcontainers.containers.payara.PayaraServerAdapter
10 changes: 10 additions & 0 deletions modules/payara-server/src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
log4j.rootLogger=INFO, stdout

log4j.appender=org.apache.log4j.ConsoleAppender
log4j.appender.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%r %p %c %x - %m%n

log4j.logger.org.aguibert.liberty=DEBUG

0 comments on commit 22a76a2

Please sign in to comment.