Notes by Fang
Displaying keyword search results 1 - 10
Created by Fang on January 04, 2013 14:35:14 Last update: January 04, 2013 14:35:41
You can use the runOrder parameter to control the test execution order for Maven surefire tests:
<build> <plugins> <plugin> ...Other options are: Option Meaning alphabetical Alphabetical reversealphabetical Reverse Alphabetical random Randomized hourly alphabetical on even hours, reverse alphabetical on odd hours failedfirst Failed first will run tests that failed on previous run first, as well as new tests for this run. balanced Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests to make all tests complete at the same time, reducing the overall execution time. filesystem This is the default. I guess this is the order returned by the file system: uncontrolled but deterministic.
Created by Fang on January 04, 2013 09:02:44 Last update: January 04, 2013 09:02:44
This snippet sets system properties from Maven surefire test plugin. This is useful when you want to set logging (for example, log4j) properties based on Maven project properties. Example that sets system property testlog.dir :
<plugins> <plugin> <groupId>org.apach...Example log4j.xml that uses system property testlog.dir :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYP...
Created by Fang on January 04, 2013 08:00:37 Last update: January 04, 2013 08:00:37
This is a Maven POM that prints out some built-in project properties:
$ mvn validate [INFO] Scanning for projects.....
Created by Fang on June 05, 2012 09:12:36 Last update: June 05, 2012 09:13:03
The apache.commons.lang package has a nice utility to escape strings for various language environments. Simply include the dependency in pom.xml :
<dependency> <groupId>org.apache.commons</...and use it:
// import org.apache.commons.lang3.StringEscapeUti...
Created by Fang on March 05, 2012 20:11:56 Last update: March 05, 2012 20:11:56
This is a bare bones Maven project to get started with Java JSR 303 bean validation. Directory structure:
./pom.xml ./src ./src/main ./src/main/jav...pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0"...which includes dependencies on JUnit, Java bean validation API and the Hibernate validator reference implementation.
Created by Fang on February 15, 2012 21:26:46 Last update: February 15, 2012 21:26:46
Add configuration variables for the surefire plugin to use system properties in Maven test:
<build> <plugins> <plugin> <group...
Created by Fang on January 31, 2012 15:40:34 Last update: January 31, 2012 15:41:28
This is a simple Hello World application with Spring 3 MVC. Like the default Apache HTTPd welcome page, it displays " It works! " when successfully deployed. The sole purpose is to show the minimum elements needed to setup Spring 3 MVC. I use Maven since it's so much easier than downloading the dependencies manually. Directory layout:
./src ./src/main ./src/main/webapp ./src/...pom.xml :
<?xml version="1.0" encoding="UTF-8"?> <project...WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app...WEB-INF/applicationContext.xml (empty, but needed):
<?xml version="1.0" encoding="UTF-8"?> <beans x...WEB-INF/spring-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?> <beans x...WEB-INF/jsp/home.jsp :
<!DOCTYPE html> <html> <head> <title>H...Build with:
mvn clean packageThe resulting webapp is target/springmvc.war .
Created by Fang on January 28, 2012 13:24:09 Last update: January 28, 2012 13:31:22
This is a simple JSP custom tags library with tag body. Just like the JSF counterpart , it splits a string and repeats the body for each word, i.e., with this markup:
<%@ taglib uri="http://custom.tag.com/demo" prefix...output:
<html> <body> <p>Hello Tigger!</p> <p>H...With Maven, this is the directory structure:
./src ./src/main ./src/main/resources ./s...There are three files to write: pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0"...src/main/java/tagdemo/IterateTag.java :
package tagdemo; import java.io.IOException...src/main/resources/META-INF/demotag.tld :
<?xml version="1.0" encoding="UTF-8"?> <!DO...Build with:
mvn clean installTo use it as a dependency in other Maven projects:
<dependency> <groupId>tag-demo</groupId> ...
Created by Fang on January 16, 2012 13:03:28 Last update: January 16, 2012 14:58:13
Apache commons validator provides a class to validate emails. Code:
import org.apache.commons.validator.EmailValidator...Maven dependency:
Created by Fang on January 04, 2012 08:56:13 Last update: January 04, 2012 09:01:08
You need both the bean validation API and implementation for JSR303 bean validations to work with Tomcat. Add both as dependencies in Maven pom.xml ( hibernate-validator is the reference impl):
<dependencies> <dependency> <groupId>o...