forked from RedHatTraining/DO288-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix file mess. Update micro-java endpoints, test, deployment file and…
… pom.
- Loading branch information
Showing
5 changed files
with
81 additions
and
247 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
24 changes: 22 additions & 2 deletions
24
micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java
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,16 +1,36 @@ | ||
package com.redhat.training.openshift.hello; | ||
|
||
import java.util.Optional; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
@Path("/api") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
public class HelloResource { | ||
|
||
@ConfigProperty(name = "HOSTNAME", defaultValue = "unknown") | ||
String hostname; | ||
@ConfigProperty(name = "APP_MSG") | ||
Optional<String> message; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@Path("/hello") | ||
public String hello() { | ||
return "Hello RESTEasy"; | ||
String response = ""; | ||
|
||
if (!message.isPresent()) { | ||
response = "Hello world from host " + hostname + "\n"; | ||
} else { | ||
response = "Hello world from host [" + hostname + "].\n"; | ||
response += "Message received = " + message.get() + "\n"; | ||
} | ||
return response; | ||
} | ||
} |
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,41 @@ | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 2 | ||
selector: | ||
app: micro-java | ||
provider: jkube | ||
group: com.redhat.training.openshift.hello | ||
strategy: | ||
rollingParams: | ||
timeoutSeconds: 3600 | ||
type: Rolling | ||
template: | ||
metadata: | ||
annotations: | ||
app.openshift.io/vcs-ref: master | ||
jkube.io/git-url: git@github.com:maudemor/DO288-apps.git | ||
app.openshift.io/vcs-uri: git@github.com:maudemor/DO288-apps.git | ||
jkube.io/git-commit: 3bffad109a77ebd72831d8f791c38df68db28e60 | ||
jkube.io/git-branch: master | ||
labels: | ||
app: micro-java | ||
provider: jkube | ||
version: 1.0.0-SNAPSHOT | ||
group: com.redhat.training.openshift.hello | ||
spec: | ||
containers: | ||
- envFrom: | ||
- configMapRef: | ||
name: configmap-hello | ||
env: | ||
- name: KUBERNETES_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
image: micro-java:latest | ||
imagePullPolicy: IfNotPresent | ||
name: quarkus | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP |
242 changes: 0 additions & 242 deletions
242
micro-java/src/main/resources/META-INF/resources/index.html
This file was deleted.
Oops, something went wrong.
8 changes: 5 additions & 3 deletions
8
micro-java/src/test/java/com/redhat/training/openshift/hello/HelloResourceTest.java
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,21 +1,23 @@ | ||
package com.redhat.training.openshift.hello; | ||
|
||
import io.quarkus.test.common.http.TestHTTPEndpoint; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
@QuarkusTest | ||
@TestHTTPEndpoint(HelloResource.class) | ||
public class HelloResourceTest { | ||
|
||
@Test | ||
public void testHelloEndpoint() { | ||
given() | ||
.when().get("/api") | ||
.when().get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.body(is("Hello RESTEasy")); | ||
.body(containsString("Hello world from")); | ||
} | ||
|
||
} |