Skip to content

Commit 46b040f

Browse files
Update README.adoc (#79)
* Update README.adoc * Update README.adoc * Update README.adoc * Update README.adoc * Update README.adoc * Update README.adoc Co-authored-by: Austin Seto <[email protected]>
1 parent 61081c7 commit 46b040f

File tree

1 file changed

+53
-8
lines changed

1 file changed

+53
-8
lines changed

README.adoc

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,23 @@ include::finish/src/test/java/io/openliberty/guides/testing/PersonServiceIT.java
7171

7272
To try out the application, go to the `finish` directory and run the following Maven
7373
goal to build the application and run the integration tests on an Open Liberty server in a container:
74+
75+
// static guide instructions:
76+
ifndef::cloud-hosted[]
7477
[role='command']
7578
```
7679
mvn verify
7780
```
81+
endif::[]
82+
83+
// cloud-hosted guide instructions:
84+
ifdef::cloud-hosted[]
85+
```
86+
cd /home/project/guide-microshed-testing/finish
87+
mvn verify
88+
```
89+
{: codeblock}
90+
endif::[]
7891

7992
This command might take some time to run the first time because the dependencies and the Docker image for Open Liberty must download. If you
8093
run the same command again, it will be faster.
@@ -87,6 +100,14 @@ an already running Open Liberty server. Run the following Maven goal to start Op
87100
mvn liberty:dev
88101
```
89102

103+
After you see the following message, your application server in dev mode is ready:
104+
105+
[role="no_copy"]
106+
----
107+
************************************************************************
108+
* Liberty is running in dev mode.
109+
----
110+
90111
After the Open Liberty server starts and you see the `Press the Enter key to run tests on demand.` message, you can press the
91112
`enter/return` key to run the integration tests. After the tests finish, you can press the `enter/return` key to run the tests again, or you
92113
can make code changes to the application or tests. Development mode automatically
@@ -97,10 +118,22 @@ where you ran the server, or by typing `q` and then pressing the `enter/return`
97118

98119
== Bootstrapping your application for testing
99120

121+
// static guide instructions:
122+
ifndef::cloud-hosted[]
100123
Navigate to the `start` directory to begin.
124+
endif::[]
125+
126+
// cloud-hosted guide instructions:
127+
ifdef::cloud-hosted[]
128+
To begin, run the following command to navigate to the **start** directory:
129+
```
130+
cd /home/project/guide-microprofile-metrics/start
131+
```
132+
{: codeblock}
133+
endif::[]
101134

102135
[role=command]
103-
include::{common-includes}/devmode-start.adoc[]
136+
include::{common-includes}/devmode-lmp33-start.adoc[]
104137

105138
Wait for the `Press the Enter key to run tests on demand.` message, and then press the `enter/return` key to run the tests. You see that one test runs:
106139

@@ -166,29 +199,41 @@ server.xml
166199
include::finish/src/main/liberty/config/server.xml[]
167200
----
168201
169-
The [hotspot=withReadinessPath file=1]`withReadinessPath(String)` method indicates what path is polled by HTTP to determine application readiness. MicroShed Testing automatically starts the ApplicationContainer application and waits for it to be ready before the tests start running. In this case, you are using the default application readiness check at the http://localhost:9080/health/ready[http://localhost:9080/health/ready^] URL, which is enabled by the [hotspot=mpHealth file=2]`MicroProfile Health` feature in our server.xml configuration file. When the readiness URL returns `HTTP 200`, the application is considered ready and the tests begin running.
202+
The [hotspot=withReadinessPath file=1]`withReadinessPath(String)` method indicates what path is polled by HTTP to determine application readiness.
203+
MicroShed Testing automatically starts the ApplicationContainer application and waits for it to be ready before the tests start running.
204+
In this case, you are using the default application readiness check at the http://localhost:9080/health/ready[http://localhost:9080/health/ready^] URL, which is enabled by the [hotspot=mpHealth file=2]`MicroProfile Health` feature in our server.xml configuration file. When the readiness URL returns `HTTP 200`, the application is considered ready and the tests begin running.
170205
171-
Save your changes to the `PersonServiceIT` class and press the `enter/return` key in your console window to rerun the tests. You still see only one test running, but the output is different. Notice that MicroShed Testing is using a `hollow` configuration mode. This configuration mode means that MicroShed Testing is reusing an existing application runtime for the test, not starting up a new application instance each time you initiate a test run.
206+
Save your changes to the `PersonServiceIT` class and press the `enter/return` key in your console window to rerun the tests.
207+
You still see only one test running, but the output is different.
208+
Notice that MicroShed Testing is using a `hollow` configuration mode.
209+
This configuration mode means that MicroShed Testing is reusing an existing application runtime for the test,
210+
not starting up a new application instance each time you initiate a test run.
172211
173212
== Talking to your application with a REST client
174213
175-
With MicroShed Testing, applications are exercised in a black box fashion. Black box means the tests cannot access the application internals. Instead, the application is exercised from the outside, usually with HTTP requests. To simplify the HTTP interactions, inject a REST client into the tests.
214+
With MicroShed Testing, applications are exercised in a black box fashion. Black box means the tests cannot access the application internals.
215+
Instead, the application is exercised from the outside, usually with HTTP requests. To simplify the HTTP interactions, inject a REST client into the tests.
176216
177217
[role="code_command hotspot file=0", subs="quotes"]
178218
----
179219
#Update the `PersonServiceIT` class.#
180220
`src/test/java/io/openliberty/guides/testing/PersonServiceIT.java`
181221
----
182222
[role="edit_command_text"]
183-
Import the [hotspot=importInject file=0]`org.microshed.testing.jaxrs.RESTClient` annotation, create a [hotspot=personSvc file=0]`PersonService` REST client, and annotate the REST client with [hotspot=inject file=0]`@RESTClient`.
223+
Import the [hotspot=importInject file=0]`org.microshed.testing.jaxrs.RESTClient` annotation,
224+
create a [hotspot=personSvc file=0]`PersonService` REST client, and annotate the REST client with [hotspot=inject file=0]`@RESTClient`.
184225
185226
PersonServiceIT.java
186227
[source, java, linenums, role='code_column hide_tags=copyright,importAssertNotNull,importSharedContainerConfig,sharedContainerConfig,testCreatePerson']
187228
----
188229
include::hotspots/src/test/java/io/openliberty/guides/testing/PersonServiceIT.2.java[]
189230
----
190231
191-
In this example, the [hotspot=personSvc file=0]`PersonService` injected type is the same [hotspot file=1]`io.openliberty.guides.testing.PersonService` class that is used in your application. However, the _instance_ that gets injected is a REST client proxy. So, if you call `personSvc.createPerson("Bob", 42)`, the REST client makes an HTTP POST request to the application that is running at http://localhost:9080/guide-microshed-testing/people[http://localhost:9080/guide-microshed-testing/people^], which triggers the corresponding Java method in the application.
232+
In this example, the [hotspot=personSvc file=0]`PersonService` injected type is the same
233+
[hotspot file=1]`io.openliberty.guides.testing.PersonService` class that is used in your application.
234+
However, the _instance_ that gets injected is a REST client proxy.
235+
So, if you call `personSvc.createPerson("Bob", 42)`, the REST client makes an HTTP POST request to the application
236+
that is running at `\http://localhost:9080/guide-microshed-testing/people`, which triggers the corresponding Java method in the application.
192237
193238
PersonService.java
194239
[source, java, linenums, role='code_column hide_tags=copyright']
@@ -219,8 +264,8 @@ Save the changes. Then, press the `enter/return` key in your console window to r
219264
220265
[role="no_copy"]
221266
----
222-
INFO org.microshed.testing.jaxrs.RestClientBuilder - Building rest client for class io.openliberty.guides.testing.PersonService with base path: http://localhost:9080/guide-microshed-testing/ and providers: [class org.microshed.testing.jaxrs.JsonBProvider]
223-
INFO org.microshed.testing.jaxrs.JsonBProvider - Response from server: 1809686877352335426
267+
[INFO] Building rest client for class io.openliberty.guides.testing.PersonService with base path: http://localhost:9080/guide-microshed-testing/ and providers: [class org.microshed.testing.jaxrs.JsonBProvider]
268+
[INFO] Response from server: 1809686877352335426
224269
----
225270
226271
Next, add more tests.

0 commit comments

Comments
 (0)