Skip to content

Commit

Permalink
Fix file mess. Update micro-java endpoints, test, deployment file and…
Browse files Browse the repository at this point in the history
… pom.
  • Loading branch information
maudemor committed May 7, 2021
1 parent 98139f4 commit 408c991
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 247 deletions.
13 changes: 13 additions & 0 deletions micro-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<resources>
<configMap>
<name>configmap-hello</name>
<entries>
<entry>
<name>APP_MSG</name>
<value>My custom application message.</value>
</entry>
</entries>
</configMap>
</resources>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
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;
}
}
41 changes: 41 additions & 0 deletions micro-java/src/main/jkube/deployment.yml
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 micro-java/src/main/resources/META-INF/resources/index.html

This file was deleted.

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"));
}

}

0 comments on commit 408c991

Please sign in to comment.