Skip to content

Commit b191dd0

Browse files
authored
Merge pull request #43 from OpenLiberty/qa
Qa to Master: dev mode
2 parents 025e913 + c02ad4b commit b191dd0

File tree

6 files changed

+93
-183
lines changed

6 files changed

+93
-183
lines changed

README.adoc

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -87,36 +87,30 @@ include::{common-includes}/gitclone.adoc[]
8787
Before you begin the implementation, start the provided REST service so that
8888
the artist JSON is available to you.
8989

90-
To start the REST service, navigate to the `start` directory and run the Maven
91-
`install` and `liberty:start-server` goals:
92-
93-
[role='command']
94-
----
95-
mvn install liberty:start-server
96-
----
97-
98-
After you start the server, you can find your artist JSON at the
99-
http://localhost:9080/artists[http://localhost:9080/artists^] URL.
90+
Navigate to the `start` directory to begin.
10091

101-
You can rebuild the front end at any time. To do so, run Maven with the
102-
`generate-resources` goal:
92+
First, you need to build the front end by running the Maven `generate-resources` goal:
10393
[role='command']
10494
----
10595
mvn generate-resources
10696
----
10797

98+
Note that you can rebuild the front end at any time with the Maven `generate-resources` goal.
10899
Any local changes to your TypeScript and HTML are picked up when you build the
109-
front end. After you start the Open Liberty server, you don't need to restart it.
100+
front end.
110101

102+
[role='command']
103+
include::{common-includes}/devmode-start.adoc[]
104+
105+
You can find your artist JSON at the
106+
http://localhost:9080/artists[http://localhost:9080/artists^] URL.
111107

112108
// =================================================================================================
113109
// Guide
114110
// =================================================================================================
115111

116112
== Importing the HTTP client
117113

118-
Navigate to the `start` directory to begin.
119-
120114
Your application needs a way to communicate with RESTful web services to retrieve their
121115
resources. In this case, the provided Angular application needs to communicate with the
122116
artists service to retrieve the artists JSON. While there are various ways to perform
@@ -158,19 +152,19 @@ data from the REST API. The component file contains two classes: the service, wh
158152
handles data access, and the component itself, which handles the presentation of the
159153
data. The provided Angular application already contains a component.
160154

161-
app.component.ts
162-
[source, javascript, linenums, role="code_column"]
163-
----
164-
include::finish/src/main/frontend/src/app/app.component.ts[]
165-
----
166-
167155
=== Defining a service to fetch data
168156

169157
Services are classes in Angular that are designed to share their functionality across
170158
entire applications. A good service performs only one function, and it performs this
171159
function well. In this case, the `ArtistsService` class requests artists data from the
172160
REST service.
173161

162+
app.component.ts
163+
[source, javascript, linenums, role="code_column hide_tags=providersProperty,importOnInitAndAngularCorePackage"]
164+
----
165+
include::finish/src/main/frontend/src/app/app.component.ts[]
166+
----
167+
174168
[role="code_command hotspot", subs="quotes"]
175169
----
176170
#Update the `app.component.ts` file.#
@@ -227,13 +221,19 @@ Components are made up of a TypeScript class annotated with the
227221
Update the [hotspot=appComponentClass]`AppComponent` class to use the artists service
228222
to fetch the artists data and save it so the component can display it.
229223

224+
app.component.ts
225+
[source, javascript, linenums, role="code_column"]
226+
----
227+
include::finish/src/main/frontend/src/app/app.component.ts[]
228+
----
229+
230230
[role="code_command hotspot", subs="quotes"]
231231
----
232232
#Update the `app.component.ts` file.#
233233
`src/main/frontend/src/app/app.component.ts`
234234
----
235235
[role="edit_command_text"]
236-
Replace the entire [hotspot=appComponentClass]`AppComponent` class with the
236+
Replace the entire [hotspot=appComponentClass]`AppComponent` class along with the
237237
[hotspot=atComponent]`@Component` annotation. Add
238238
[hotspot=importOnInitAndAngularCorePackage]`OnInit` to the list of imported classes at
239239
the top.
@@ -285,9 +285,9 @@ app.component.html
285285
include::finish/src/main/frontend/src/app/app.component.html[]
286286
----
287287

288-
The template contains a [hotspot=artistsDiv]`div` element that is enumerated using the
288+
The template contains a [hotspot=artistsDiv]`div` element that is enumerated by using the
289289
`*ngFor` directive. The `artist` variable is bound to the `artists` member of the
290-
component. The div element itself and all elements contained within it are repeated for
290+
component. The [hotspot=artistsDiv]`div` element itself and all elements contained within it are repeated for
291291
each artist, and the [hotspot=artistNameAndAlbumsLengthPlaceholders]`{{ artist.name }}`
292292
and [hotspot=artistNameAndAlbumsLengthPlaceholders]`{{ artist.albums.length }}`
293293
placeholders are populated with the information from each artist. The same strategy is
@@ -313,6 +313,11 @@ bar wrote 1 albums:
313313
dj wrote 0 albums:
314314
----
315315

316+
If you use the `curl` command to access the web application root URL,
317+
you see only the application root page in HTML. The Angular framework
318+
uses JavaScript to render the HTML to display the application data.
319+
A web browser runs JavaScript, and the `curl` command doesn't.
320+
316321

317322
== Testing the Angular client
318323

@@ -329,12 +334,9 @@ following command:
329334
mvn generate-resources
330335
```
331336

332-
When you are done checking the application root, stop the Open Liberty server by
333-
running the following command:
334-
[role='command']
335-
```
336-
mvn liberty:stop-server
337-
```
337+
When you are done checking the application root, exit development mode by
338+
pressing `CTRL+C` in the shell session where you ran the server,
339+
or by typing `q` and then pressing the `enter/return` key.
338340

339341
Although the Angular application that this guide shows you how to build is simple,
340342
when you build more complex Angular applications, testing becomes a crucial part

finish/pom.xml

Lines changed: 18 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44

55
<modelVersion>4.0.0</modelVersion>
66

7-
<parent>
8-
<groupId>net.wasdev.wlp.maven.parent</groupId>
9-
<artifactId>liberty-maven-app-parent</artifactId>
10-
<version>RELEASE</version>
11-
</parent>
12-
137
<groupId>io.openliberty.guides</groupId>
14-
<artifactId>io.openliberty.guides.consumingrest-ng</artifactId>
8+
<artifactId>guide-rest-client-angular</artifactId>
159
<version>1.0-SNAPSHOT</version>
1610
<packaging>war</packaging>
1711

@@ -20,89 +14,39 @@
2014
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2115
<maven.compiler.source>1.8</maven.compiler.source>
2216
<maven.compiler.target>1.8</maven.compiler.target>
23-
<app.name>LibertyProject</app.name>
24-
<testServerHttpPort>9080</testServerHttpPort>
25-
<testServerHttpsPort>9443</testServerHttpsPort>
26-
<package.file>${project.build.directory}/${app.name}.zip</package.file>
27-
<packaging.type>usr</packaging.type>
17+
<failOnMissingWebXml>false</failOnMissingWebXml>
18+
<!-- Plugin versions -->
19+
<version.liberty-maven-plugin>3.1</version.liberty-maven-plugin>
20+
<version.maven-war-plugin>3.2.2</version.maven-war-plugin>
2821
</properties>
2922

30-
<dependencyManagement>
31-
<dependencies>
32-
<dependency>
33-
<groupId>io.openliberty.features</groupId>
34-
<artifactId>features-bom</artifactId>
35-
<version>RELEASE</version>
36-
<type>pom</type>
37-
<scope>import</scope>
38-
</dependency>
39-
</dependencies>
40-
</dependencyManagement>
41-
4223
<dependencies>
43-
<!-- Open Liberty features -->
44-
<dependency>
45-
<groupId>io.openliberty.features</groupId>
46-
<artifactId>jaxrs-2.1</artifactId>
47-
<type>esa</type>
48-
<scope>provided</scope>
49-
</dependency>
24+
<!-- Provided dependencies -->
5025
<dependency>
51-
<groupId>io.openliberty.features</groupId>
52-
<artifactId>jsonp-1.1</artifactId>
53-
<type>esa</type>
26+
<groupId>org.eclipse.microprofile</groupId>
27+
<!-- tag::microprofile[] -->
28+
<artifactId>microprofile</artifactId>
29+
<!-- end::microprofile[] -->
30+
<version>3.0</version>
31+
<type>pom</type>
5432
<scope>provided</scope>
5533
</dependency>
34+
5635
</dependencies>
5736

5837
<build>
38+
<finalName>${project.artifactId}</finalName>
5939
<plugins>
6040
<plugin>
6141
<groupId>org.apache.maven.plugins</groupId>
6242
<artifactId>maven-war-plugin</artifactId>
63-
<version>3.2.2</version>
64-
<configuration>
65-
<failOnMissingWebXml>false</failOnMissingWebXml>
66-
<packagingExcludes>pom.xml</packagingExcludes>
67-
</configuration>
43+
<version>${version.maven-war-plugin}</version>
6844
</plugin>
6945
<!-- Enable liberty-maven plugin -->
7046
<plugin>
71-
<groupId>net.wasdev.wlp.maven.plugins</groupId>
47+
<groupId>io.openliberty.tools</groupId>
7248
<artifactId>liberty-maven-plugin</artifactId>
73-
<configuration>
74-
<assemblyArtifact>
75-
<groupId>io.openliberty</groupId>
76-
<artifactId>openliberty-runtime</artifactId>
77-
<version>RELEASE</version>
78-
<type>zip</type>
79-
</assemblyArtifact>
80-
<configFile>src/main/liberty/config/server.xml</configFile>
81-
<packageFile>${package.file}</packageFile>
82-
<include>${packaging.type}</include>
83-
<bootstrapProperties>
84-
<default.http.port>${testServerHttpPort}</default.http.port>
85-
<default.https.port>${testServerHttpsPort}</default.https.port>
86-
</bootstrapProperties>
87-
</configuration>
88-
<executions>
89-
<!-- Package server -->
90-
<execution>
91-
<id>package-server</id>
92-
<configuration>
93-
<outputDirectory>target/wlp-package</outputDirectory>
94-
</configuration>
95-
</execution>
96-
<!-- Install the app via loose config -->
97-
<execution>
98-
<id>install-apps</id>
99-
<configuration>
100-
<looseApplication>true</looseApplication>
101-
<stripVersion>true</stripVersion>
102-
<installAppPackages>project</installAppPackages>
103-
</configuration>
104-
</execution>
105-
</executions>
49+
<version>${version.liberty-maven-plugin}</version>
10650
</plugin>
10751
<plugin>
10852
<groupId>com.github.eirslett</groupId>

finish/src/main/liberty/config/server.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
<feature>jsonp-1.1</feature>
66
</featureManager>
77

8+
<variable name="default.http.port" defaultValue="9080"/>
9+
<variable name="default.https.port" defaultValue="9443"/>
10+
811
<httpEndpoint host="*" httpPort="${default.http.port}" httpsPort="${default.https.port}" id="defaultHttpEndpoint" />
912

10-
<webApplication location="io.openliberty.guides.consumingrest-ng.war" contextRoot="/"/>
13+
<webApplication location="guide-rest-client-angular.war" contextRoot="/"/>
1114
</server>

scripts/travisTest.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,24 @@ set -euxo pipefail
77
##
88
##############################################################################
99

10-
mvn -q clean install
10+
# LMP 3.0+ goals are listed here: https://github.com/OpenLiberty/ci.maven#goals
1111

12-
mvn -q liberty:start-server
12+
## Rebuild the application
13+
# package - Take the compiled code and package it in its distributable format.
14+
# liberty:create - Create a Liberty server.
15+
# liberty:install-feature - Install a feature packaged as a Subsystem Archive (esa) to the Liberty runtime.
16+
# liberty:deploy - Copy applications to the Liberty server's dropins or apps directory.
17+
mvn -q clean package liberty:create liberty:install-feature liberty:deploy
18+
19+
## Run the tests
20+
# These commands are separated because if one of the commands fail, the test script will fail and exit.
21+
# e.g if liberty:start fails, then there is no need to run the failsafe commands.
22+
# liberty:start - Start a Liberty server in the background.
23+
# failsafe:integration-test - Runs the integration tests of an application.
24+
# liberty:stop - Stop a Liberty server.
25+
# failsafe:verify - Verifies that the integration tests of an application passed.
26+
mvn liberty:start
1327

1428
status="$(curl --write-out "%{http_code}\n" --silent --output /dev/null "http://localhost:9080/artists")"; if [ "$status" == "200" ]; then echo ENDPOINT OK; else echo "$status"; echo ENDPOINT NOT OK; exit 1; fi;
1529

16-
mvn -q liberty:stop-server
30+
mvn liberty:stop

0 commit comments

Comments
 (0)