Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Example Projects

It is time to discover how you can create some interesting projects. These best practices provide different styles of projects for Web and J2EE development. You can extend and customize these examples to fit your needs. The examples we'll discuss are a basic enterprise application, dividing a Web module into multiple projects, and using Maven for Web application development.

Basic Enterprise Application

Using the J2EE application deployment specification as a template, you will create an enterprise application with multiple modules. This is recommended if you do not have a compelling reason to do it another way. These projects map to the J2EE specification in a straightforward way and can be created using wizard defaults. Adherence to standards reduces the behavioral discrepancies between the runtime and the development environments.

In this example, each architectural application layer will correspond to a project. For example, the presentation layers will correspond to a dynamic Web project with a Web application module and the business logic layer to an EJB project with an EJB module. The enterprise application project will be used to assemble the modules as a single coherent unit.

To create this structure, you will use a J2EE Enterprise Application Project (see Figure 6.28). The EAR project has two modules: LeaguePlanetWebProject, a Web application module; and LeaguePlanetEJBProject, an EJB module. The Web application module is going to be a dynamic Web project with the same name. The EJB module is divided into an EJB project and the EJB client project. The EJB client JAR is a Java utility project named LeaguePlanetEJBClientProject.

Figure 6.28

Figure 6.28 Module Dependencies for League Planet Application

To demonstrate the use of Web application libraries, the Web application will use the Struts MVC framework. In order to use Struts, all Struts and supporting libraries, that is, struts*.jar, commons*.jar, jakarta*.jar, log4j.jar, and antlr.jar, are kept in the WEB-INF/lib directory. The Struts configuration file, struts-config.xml, is in the WEB-INF directory. The business model for League Planet is provided by the EJBs. The Web application delegates the business behavior to this layer.

To create an EAR project with this structure, do the following:

  1. Start as we described earlier in this chapter to create a new Enterprise Application Project. Name it LeaguePlanetEar. Select the default facets, continue to the J2EE Modules page, and click Finish to create an empty EAR. In the next steps you will create the Web and EJB projects.
  2. Repeat the steps we described earlier in this chapter to create a new Dynamic Web Project. Name it LeaguePlanetWebProject. Choose the LeaguePlanetEar as the EAR for the Web project (see Figure 6.29). Continue to the other pages to select the default facets, and click Finish to create the Web project. The EAR project will be automatically updated to reflect the addition of the new Web module.
    Figure 6.29

    Figure 6.29 Web Project Added to an EAR

  3. To do this step, you must have the Struts framework installed someplace on your machine. You can obtain Struts from

    http://struts.apache.org

    Import all the Struts libraries and their supporting libraries into

    WebContent/WEB-INF/lib
    Refer to the Struts documentation for the exact list of libraries. Once the JARs are copied into the lib folder, they will be automatically added to the build path under the Web App Libraries category (see Figure 6.30).
    Figure 6.30

    Figure 6.30 Web App Library

  4. Repeat the steps we described earlier in this chapter to create a new EJB project. Name it LeaguePlanetEJBProject. Choose the LeaguePlanetEar as the EAR for the EJB project (see Figure 6.31). You can choose one of the default facet configurations for development, such as the EJB Project with XDoclet. You do not need to change the default choices. If you do choose one, you should make sure that your workspace is set up to use it (that is, the XDoclet settings are valid). Click Next to go to the other pages to select the default facets. Click Next to go to the EJB Module page.
    Figure 6.31

    Figure 6.31 EJB Project Added to an EAR

  5. The Web application will be a client of the EJB module. Create an EJB client module named LeaguePlanetEJBClientProject (see Figure 6.32). Click Finish to create the EJB and EJB client projects. The EAR project will be automatically updated to reflect the addition of the two new modules.
    Figure 6.32

    Figure 6.32 EJB Client Module

  6. WTP updates the EAR project and the deployment descriptor, application.xml (see Figure 6.33).
    Figure 6.33

    Figure 6.33 Project Explorer—EAR Project

To create these projects, you used the same wizards described earlier in this chapter.

Later, you can extend this model by adding more Web projects—an administration site, for example. The business model can be extended with more EJBs.

Dividing a Web Module into Multiple Projects

Size, structure, and the geographical and sociological aspects of a development team are significant factors in determining the project layout. When these are important to a project, they can determine the structure. The key constraints for this template are the manageability and divisibility of work. Manageability relates to aspects such as ownership of code, development responsibilities and tasks, configuration and version control, integration, and release management. Divisibility relates to dividing the work between members of the development team.

In this example, you will extend the project structure described in the previous example. LeaguePlanetWebProject is a large Web application module. It will contain many large, loosely coupled subsystems. League management, player management, sponsorship, and advertising are some of these subsystems that will be developed by different teams. You will divide and manage subsystems as separate projects. Each subsystem can be released on different schedules. You will therefore start by dividing the Web module into two projects (see Figure 6.35). You can increase the number of subsystems following the same pattern later on. The dynamic Web project in the previous example contains the Web application module and will have common Web components such as menus, navigation bars, and so forth. There is a new subsystem for league management. This is a Java utility project on steroids. The league management module has its own presentation layer with JSPs and Struts configuration files in addition to its own Java classes.

Figure 6.35

Figure 6.35 Dividing a Web Module into Multiple Projects

To create this structure, you will need to create a new basic Java Utility Project named LeaguePlanetManagementWebProject. Java utility projects can be used to refactor reusable components of applications into separate projects. J2EE module dependencies will help assemble these components automatically.

To create the Java Utility Project and divide the module, the following steps must be performed:

  1. Create a new Java Utility Project using the wizard.
  2. Add the Web application libraries to its build path.
  3. Add the utility project to the list of J2EE dependencies for the Web project.
  4. Create a new WebContent folder in the utility project and add this to the structural model.

Do the following:

  1. In the Project Explorer view, right click and invoke the New u25b8 Other u25b8 J2EE menu item (see Figure 6.36). Select Utility Project.
    Figure 6.36

    Figure 6.36 Select Wizard

    Click Next. The New Java Utility Project wizard opens (see Figure 6.37).
    Figure 6.37

    Figure 6.37 New Java Utility Project

  2. Enter LeaguePlanetManagementWebProject for the project name. Use the same target runtime for all your projects. Use the default configuration. Click the Next button. The Project Facets selection page is displayed (see Figure 6.38).
    Figure 6.38

    Figure 6.38 Select Project Facets

    Accept the defaults here and click Finish. WTP creates the empty utility project.
  3. You need to add this submodule to the J2EE dependencies of the Web project. To do this, select LeaguePlanetWebProject in the Project Explorer, right click, and invoke the Properties menu item. Select the J2EE Dependencies page. In this page, go the Web Libraries tab and add LeaguePlanetManagementWebProject from the list (see Figure 6.39).
    Figure 6.39

    Figure 6.39 Web Project Depends on Utility Project

  4. This is an optional step. The league management module is a part of the Web module, but it may need some external libraries to be on its build path. You can do this by adding the external JARs to the build path of the Java utility project. Select LeaguePlanetManagementWebProject in the Project Explorer, right click, and invoke the Properties menu item. Select the Java Build Path page. Click on the Libraries tab. In this tab, click Add External JARs (see Figure 6.40).
    Figure 6.40

    Figure 6.40 Utility Project Java Build Path

    The JAR Selection wizard will open (see Figure 6.41). This wizard allows you to browse your local file system for JARs.
    Figure 6.41

    Figure 6.41 Add External JARs Library

    Select all the same external libraries, like Struts, that you have used for the Web project here, too. Click Finish. Apply and close the Properties window.
  5. Next you will create a new WebContent folder in the league management project. In the Project Explorer, select LeaguePlanetManagementWebProject, right click, and invoke the File u25b8 New u25b8 Folder menu item. The New Folder wizard will open (see Figure 6.42).
    Figure 6.42

    Figure 6.42 WebContent Folder

  6. Enter WebContent as the folder name. Repeat the same process to create a new WEB-INF folder inside the WebContent folder.
  7. Next you will link the new WebContent folder to the main Web project and add it to the structural model so that publishers will assemble the contents of the WebContent folder from the league management project into the overall project. In the Project Explorer, select LeaguePlanetWebProject, right click, and invoke File u25b8 New u25b8 Folder. The New Folder wizard will open (see Figure 6.43).
    Figure 6.43

    Figure 6.43 Link to Management WebContent Folder

  8. Enter Management as the folder name. Click on Link to folder in the file system. Click Browse to select the WebContent folder created in the previous step.

    You will need to specify that the WebContent folder in LeagueManagementWebProject gets copied into the deployable Web application module. Currently, there are no nice graphical tools to map these resources, so you will need to edit some files. You need to create the link to the WebContent folder before editing the module definition file. You already completed this step. Therefore, you can modify the XML component file to specify that this content folder is to be published with the Web module. This involves manually editing the

    org.eclipse.wst.common.component

    definition in the .settings folder. Edit the file as shown in Example 6.3.

Example 6.3. Modified Web Module Definition

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
  <wb-module deploy-name="LeaguePlanetWebProject">
    <wb-resource source-path="/WebContent" deploy-path="/" />
    <wb-resource source-path="/Management" deploy-path="/" />
    <wb-resource source-path="/src" deploy-path="/WEB-INF/classes" />
    <dependent-module deploy-path="/"
      handle="module:/resource/LeaguePlanetEJBProject/
      LeaguePlanetEJBProject">
      <dependency-type>uses</dependency-type>
    </dependent-module>
    <dependent-module deploy-path="/WEB-INF/lib"
      handle="module:/resource/LeaguePlanetManagementWebProject/
      LeaguePlanetManagementWebProject">
      <dependency-type>uses</dependency-type>
    </dependent-module>
    <property name="context-root" value="LeaguePlanetWebProject" />
    <property name="java-output-path" value="build/classes" />
  </wb-module>
</project-modules>

You have now split a Web module into multiple projects. The publisher will add the Java classes developed in the league management project as a JAR in the WEB-INF/lib folder to the original Web application module.

The publisher will also assemble any JSPs and additional Struts configuration files from the league management module, as well as all the Web content in this submodule. This content will be deployed with the Web application automatically. After the WAR is created, it will be assembled into the enterprise application as usual. When you are done, the workbench will have projects that look like Figure 6.44.

Figure 6.44

Figure 6.44 Dependent Module in the Project Explorer

Using Maven for Web Application Development

Maven is a software project management and comprehension tool. It started as a tool developed to build the Turbine project at apache.org and quickly spread to other Apache projects. Today, it is used as the main build tool for many of the Java projects at Apache. For an in-depth description of how to use Maven on your project, refer to Maven: A Developer's Notebook [Massol2005] by Vincent Massol and Timothy O'Brien.

Maven is more than a Java build tool. It provides capabilities to make your life easy as a developer. Some of these capabilities are a well-defined project structure, a well-defined development process to follow, and a coherent body of documentation that keeps developers and users informed of what's happening in the project. This is essential in many team projects where there aren't enough people dedicated to the task of building, documenting, and propagating the information about the project. Maven captures the knowledge embedded in people's heads to do these tasks. For example, the development processes of Eclipse and Apache are evolutionary and resulted from the experiences gained from running many projects. This body of knowledge is typically captured in the tools that are used in building projects. Maven provides a standard environment that encourages the use of development and project best practices, and it disseminates this information to project stakeholders.

Following the success of Maven in Apache projects, many teams adopted Maven for their own use, including some J2EE projects. There is a set of J2EE-specific development best practices and processes captured in Maven. The use of Maven to develop a J2EE project enables the transfer of this knowledge. When a new J2EE project starts, it can immediately copy the build tasks and project know-how. The new project reuses the existing tools and conforms to the established practices. Maven does this by providing a framework and templates. For example, by having a common directory structure, developers are instantly familiar with a new project. To quote Aristotle, "We are what we repeatedly do. Excellence is not an act, but a habit."

There are other, less well-known approaches, such as JOFFAD, that also provide generic development frameworks to facilitate, speed up, and normalize J2EE projects. You can read about JOFFAD at

http://joffad.sourceforge.net/structure.html

In Example 6.4 you will use the advanced WTP Web project features to develop a Web application using Maven. Maven has a default, but customizable, process that gets a project started using these J2EE best practices quickly. Although both are named a project, a Maven project is conceptually very different from a WTP project.

Maven and Eclipse have overlapping functionality such as compiling, building, and testing. However, Eclipse is normally used for developer-centric coding, testing, and debugging activities, whereas Maven is used for team-centric build management, reporting, and deployment. The primary purpose of Maven is to create a documented, repeatable, and modeled build process that is inclusive of all these activities. It complements the development activities in Eclipse.

You will start by defining a new Web project and organizing the resources in this project according to the best practices suggested by Maven. See

http://maven.apache.org/reference/conventions.html

for a description of Maven conventions. Maven recommends a standard project directory structure, which is referenced in the Maven Project Object Model (POM). The directory structure of your project will follow Maven conventions (see Example 6.4).

Example 6.4. Maven Project Layout

/LeaguePlanetWebProject
+- src/
|  +- main/
|  |  +- java/
|  |  |  +- ...[classes and packages]
|  |  +- resources/
|  |     +- ...
|  |  +- webapp/
|  |  |  +- web-inf/
|  |  |  |  +- classes/
|  |  |     |  +- ...[compiled classes]
|  |  |  |  +- lib/
|  |  |     |  +- ...[external libraries]
|  |  |  |  +- web.xml
|  |  |  |  +- ...
|  |  |  +- ...[other web files]
|  +- test/
|  |  +- java/
|  |  |  +- ...[test classes and packages]
|  |  +- resources/
|  |     +- ...
|  +- site/
|     +- xdoc/
|        +- ...
+- target/
|  +- ...
+- pom.xml

All sources are grouped under the src directory. src/main/java contains your primary Java classes and packages. src/test/java contains your classes and packages for unit tests. src/main/webapp, similar to the WTP WebContent folder, contains your Web content, such as the JSP and HTML files, and their supporting resources. src/site/xdoc has sources for the project Web site.

To create the Maven project, do the following:

  1. Repeat the steps described earlier in this chapter to create a new dynamic Web project named LeaguePlanetWebProject. Select a target runtime and default configuration for facets. Click the Next button to proceed to the Web module settings (see Figure 6.45).
    Figure 6.45

    Figure 6.45 Maven Web Module

  2. The Web Module page lets you specify the directory for Java resources. This is where you will define locations for the Java sources and Web content. Enter src/main/webapp for Content Directory and src/main/java for Java Source Directory. Click Finish.
  3. WTP creates the Web project, configuration files, deployment descriptor, and so forth.

Once the project is created, the structural model for the Web project is defined as Example 6.5.

Example 6.5. Structural Model for Maven-Style Web Project

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
  <wb-module deploy-name="LeaguePlanetWebProject">
    <wb-resource source-path="/src/main/webapp" deploy-path="/" />
    <wb-resource source-path="/src/main/java"
      deploy-path="/WEB-INF/classes" />
    <wb-resource source-path="/src/test/java"
      deploy-path="/WEB-INF/classes" />
    <property name="context-root" value="LeaguePlanetWebProject" />
    <property name="java-output-path" value="build/classes" />
  </wb-module>
</project-modules>

Let's review what you accomplished so far. You have created a dynamic Web project using the project layout conventions suggested by Maven (see Figure 6.46).

Figure 6.46

Figure 6.46 Project Explorer—Maven Web Project

Mavenizing the Project

The next step is defining the Maven POM that will automate builds, unit tests, documentation, project reporting, and so on.

The POM is defined by an XML file named pom.xml (see Example 6.6). This file tells Maven everything that it needs to know about your project. Maven has tools that can create skeleton POMs, but we will create the POM from scratch. The snippet shown in Example 6.6 is the start of a POM for your Web application.

Example 6.6. Content of POM

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>leagueplanet</artifactId>
  <groupId>com.leagueplanet</groupId>
  <name>LeaguePlanet.com Web Project</name>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>[...]</build>
  <dependencies>[...]</dependencies>
</project>

The project artifactId corresponds to the Web application module in your project. Dependencies will define external libraries needed by your Web application. You will use the Struts framework, so struts*.jar and commons*.jar libraries must be present in this list. The build section tells Maven how the Java sources and other resources are organized. Maven project definition allows you to define filters for including or excluding source files.

The build section is quite simple to set up, as shown in Example 6.7.

Example 6.7. Maven Build Section

<?xml version="1.0" encoding="UTF-8"?>
<project>
  [...]
  <build>
    <finalName>${artifactId}-${version}</finalName>
  </build>
</project>

The build section can be used to customize your project. Since you used the default location, you do not have to modify anything here. The finalName element automatically constructs the name of the exported WAR from other information provided in the POM.

The dependency section is probably the longest (see Example 6.8).

Example 6.8. Maven Dependencies Section

<?xml version="1.0" encoding="UTF-8"?>
<project>
  [...]
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>struts</groupId>
      <artifactId>struts</artifactId>
      <version>1.2.7</version>
    </dependency>
    <dependency>
      <groupId>struts</groupId>
      <artifactId>struts-el</artifactId>
      <version>1.2.7</version>
    </dependency>
    <dependency>
      <groupId>commons-validator</groupId>
      <artifactId>commons-validator</artifactId>
      <version>1.1.4</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.0.3</version>
    </dependency>
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>antlr</groupId>
      <artifactId>antlr</artifactId>
      <version>2.7.5</version>
    </dependency>
    <dependency>
      <groupId>commons-digester</groupId>
      <artifactId>commons-digester</artifactId>
      <version>1.7</version>
    </dependency>
    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils</artifactId>
      <version>1.7.0</version>
    </dependency>
    <dependency>
      <groupId>oro</groupId>
      <artifactId>oro</artifactId>
      <version>2.0.8</version>
    </dependency>
    <dependency>
      <groupId>servletapi</groupId>
      <artifactId>servletapi</artifactId>
      <version>2.3</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

Each entry corresponds to an external JAR that is needed by your project. The Struts framework requires a few of these dependencies to be set. Some of these JARs are needed to compile your code; others, such as JUnit, are for testing. The JARs have a scope tag that defines when they are used. For example, by default all Struts JARs will be included with the Web application module, but JUnit has the scope test, so it will not be included.

Remember that Maven gets the libraries defined in the dependencies from a repository. However, for WTP to function properly, you need to keep a copy of these libraries inside the src/webapp/WEB_INF/lib folder instead of the repository. Unfortunately, there is no tool to synchronize the dependencies and libraries.

You have defined the minimal Maven POM to build your Web application. Maven is typically run from the command line. Maven commands are also called goals. Goals are high-level tasks that can include other subtasks. Mevenide is an Eclipse plug-in for Maven that allows you to run Maven goals from the Eclipse IDE. Here you will use the command line. You can build a deployable Web module and a project site by running the maven clean package site goals. The package goal depends on other goals such as compile and test, so Maven will run them automatically. During the build, Maven creates a folder named target to store the generated files. The name and location of the generated files can be modified by additional settings. When you run Maven, you will get an output like that shown in Example 6.9.

Example 6.9. Maven Console Output

C:\workspace\LeaguePlanetWebProject>mvn clean package site
[INFO] Scanning for projects...
[INFO] ---------------------------------
[INFO] Building LeaguePlanet.com Web Project
[INFO]    task-segment: [clean, package]
[INFO] ---------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory
  C:\workspace\LeaguePlanetWebProject\target
[INFO] Deleting directory
  C:\workspace\LeaguePlanetWebProject\target\classes
[INFO] Deleting directory
  C:\workspace\LeaguePlanetWebProject\target\test-classes
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[WARNING] While downloading servletapi:servletapi:2.3
  This artifact has been relocated to javax.servlet:servlet-api:2.3.

[INFO] [compiler:compile]
Compiling 1 source file to
C:\workspace\LeaguePlanetWebProject\target\classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
Compiling 1 source file to
  C:\workspace\LeaguePlanetWebProject\target\test-classes
[INFO] [surefire:test]
[INFO] Setting reports dir:
  C:\workspace\LeaguePlanetWebProject\target/surefire-reports

-------------------------------------------------------------
  T E S T S
-------------------------------------------------------------
[surefire] Running com.leagueplanet.tests.LeaguePlanetBVTTest
[surefire] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.01 sec
[INFO] [site:site]
[INFO] Generate "Continuous Integration" report.
[ERROR] VM #displayTree: error : too few arguments to macro. Wanted 2 got 0
[ERROR] VM #menuItem: error : too few arguments to macro. Wanted 1 got 0
[INFO] Generate "Dependencies" report.
[INFO] Generate "Issue Tracking" report.
[INFO] Generate "Project License" report.
[INFO] Generate "Mailing Lists" report.
[INFO] Generate "Source Repository" report.
[INFO] Generate "Project Team" report.
[INFO] Generate "Maven Surefire Report" report.
[INFO] Generate an index file for the English version.
[INFO] ------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------
[INFO] Total time: 11 seconds
[INFO] Finished at: Sat May 13 15:48:09 EEST 2006
[INFO] Final Memory: 9M/17M
[INFO] ------------------------------------------------------

That is all there is to building a WAR with Maven. You will see from the log that package is a composite goal. In addition to assembling a Web application module using the war goal, it runs the java goal to compile the classes and the test goal to compile and run the tests. Once the build is complete, you can browse the results of the build in the target folder (see Figure 6.47).

Figure 6.47

Figure 6.47 Project Site

So far, you could have done most of this using WTP, without the hassle of setting up Maven in the project. Building Web application modules is something WTP does well, and it does it automatically with minimal effort. But you can get more out of Maven. The next section shows you how to automate testing and reporting on the League Planet project using Maven.

Getting More Out of Maven

Now that you can build the Web application module using Maven, you can add tests and more project information to the POM to find out what more Maven can do.

Unit Tests with Maven

To run unit tests with Maven, you will create JUnit test cases and define required libraries, including JUnit in the project dependencies. Since you defined the JUnit dependencies in the previous section, you can start writing a test in the src/tests/java source folder. In the Project Explorer, select LeaguePlanetWebProject, right click, and invoke the File u25b8 New u25b8 Source Folder. The New Source Folder wizard will open (see Figure 6.48).

Figure 6.48

Figure 6.48 Source Folder for Tests

Enter src/test/java as the folder name. Click Finish. A new source folder will be added to the project.

To create a new JUnit test case, invoke the JUnit test case wizard using File u25b8 New u25b8 JUnit Test Case, and then enter package and class names, for example, com.leagueplanet.tests and LeaguePlanetBVTTests. Click Finish. The wizard will prompt you to add junit.jar to the project build path if it is not included there already. Accept it to add the JAR.

A new test class will be created at the location shown in Example 6.11.

Example 6.11. Maven Test Directory

/LeaguePlanetWebProject
+- src/
|  +- test/
|  |  +- java/
|  |  |  +- com
|  |  |  |  +- leagueplanet
|  |  |  |  |  +- tests
|  |  |  |  |  |  +- LeaguePlanetBVTTests.java
|  |  |  |  |  |  +- [...] other unit tests
|  [...]

Execute the Maven package site goals to run the tests. If you want to run the tests only, you just execute the test goal. Running the Maven test goal creates output as shown in Example 6.12.

Example 6.12. Maven Test Output

[INFO] Scanning for projects...
[INFO] ---------------------------------
[INFO] Building LeaguePlanet.com Web Project
[INFO]    task-segment: [test]
[INFO] ---------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[WARNING] While downloading servletapi:servletapi:2.3
  This artifact has been relocated to javax.servlet:servlet-api:2.3.

[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Setting reports dir:
  C:\workspace\LeaguePlanetWebProject\target/surefire-reports

-------------------------------------------------------------
  T E S T S
-------------------------------------------------------------
[surefire] Running com.leagueplanet.tests.LeaguePlanetBVTTest
[surefire] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.03 sec
[INFO] ------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Sat May 13 15:58:43 EEST 2006
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------

You will find the Maven JUnit test reports under the target/surefire-reports folder. Of course, XML reports can be transformed into a more human-readable format, but you will see in the next section that Maven also does this for you (see Figure 6.49).

Figure 6.49

Figure 6.49 Maven JUnit Test Reports

Project Information and Reports

The Maven project model can also contain information about the developers, configuration and version control systems, issue tracking, mailing lists, and other process-related project information. This information is used by Maven plug-ins to generate project information and reports. The listing shown in Example 6.13 provides the complete code for a typical Maven project model.

Example 6.13. Listing of pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>leagueplanet</artifactId>
  <groupId>com.leagueplanet</groupId>
  <name>LeaguePlanet.com Web Project</name>
  <version>1.0-SNAPSHOT</version>

  <packaging>war</packaging>

  <organization>
    <name>LeaguePlanet.com</name>
    <url>http://www.leagueplanet.com/</url>
  </organization>

  <description>
     An example project showing how to use eclipse WebTools Platform
     and Maven for Java Web Development.
   </description>

   <licenses>
     <license>
       <comments>Eclipse Public Licence (EPL)v1.0</comments>
       <url>http://www.eclipse.org/legal/epl-v10.html</url>
     </license>
   </licenses>

   <developers>
     <developer>
       <id>ndai</id>
       <name>Naci Dai</name>
       <email>naci.dai@eteration.com</email>
       <organization>Eteration</organization>
     </developer>
     <developer>
       <id>lmandel</id>
       <name>Lawrence Mandel</name>
       <email>lmandel@ca.ibm.com</email>
       <organization>IBM</organization>
     </developer>
     <developer>
       <id>ryman</id>
       <name>Arthur Ryman</name>
       <email>ryman@ca.ibm.com</email>
       <organization>IBM</organization>
     </developer>
     </developers>

     <build>
       <finalName>${artifactId}-${version}</finalName>
     </build>
     <dependencies>
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>3.8.1</version>
         <scope>test</scope>
       </dependency>
       <dependency>
         <groupId>struts</groupId>
         <artifactId>struts</artifactId>
         <version>1.2.7</version>
       </dependency>
       <dependency>
         <groupId>struts</groupId>
         <artifactId>struts-el</artifactId>
         <version>1.2.7</version>
       </dependency>
       <dependency>
         <groupId>commons-validator</groupId>
         <artifactId>commons-validator</artifactId>
         <version>1.1.4</version>
       </dependency>
       <dependency>
         <groupId>commons-logging</groupId>
         <artifactId>commons-logging</artifactId>
         <version>1.0.3</version>
       </dependency>
       <dependency>
         <groupId>commons-fileupload</groupId>
         <artifactId>commons-fileupload</artifactId>
         <version>1.0</version>
       </dependency>

       <dependency>
         <groupId>antlr</groupId>
         <artifactId>antlr</artifactId>
         <version>2.7.5</version>
       </dependency>
       <dependency>
         <groupId>commons-digester</groupId>
         <artifactId>commons-digester</artifactId>
         <version>1.7</version>
       </dependency>
       <dependency>
         <groupId>commons-beanutils</groupId>
         <artifactId>commons-beanutils</artifactId>
         <version>1.7.0</version>
       </dependency>
       <dependency>
         <groupId>oro</groupId>
         <artifactId>oro</artifactId>
         <version>2.0.8</version>
       </dependency>
       <dependency>
         <groupId>servletapi</groupId>
         <artifactId>servletapi</artifactId>
         <version>2.3</version>
       </dependency>
       </dependencies>
       <reporting>
         <plugins>
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>
               maven-project-info-reports-plugin
             </artifactId>
           </plugin>
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-surefire-report-plugin</artifactId>
           </plugin>
         </plugins>
       </reporting>
     </project>

The project reports are generated using the Maven site goal. This goal builds a local copy of the project site for reports, documentation, and reference. The result is generated into the target/site directory in the project's base directory, which contains an entire Web site of documentation (see Figure 6.50).

Figure 6.50

Figure 6.50 Maven Project Reports

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020