Recent Notes
Displaying keyword search results 1 - 10
Created by Dr. Xi on March 08, 2013 11:40:49
Last update: March 08, 2013 11:40:49
From Version Control with Subversion, Chapter 4. Branching and Merging In Subversion, a global revision number N names a tree in the repository: it's the way the repository looked after the N th commit. It's also the name of an implicit changeset: if you compare tree N with tree N-1 , you can derive the exact patch that was committed. For this reason, it's easy to think of revision N as not just a tree, but a changeset as well. If you use an issue tracker to manage bugs, you can use the revision numbers to refer to particular patches that fix bugs—for example, “this issue was fixed by r9238.” Somebody can then run svn log -r 9238 to read about the exact changeset that...
Created by Dr. Xi on March 01, 2013 16:09:00
Last update: March 04, 2013 12:28:23
This is probably the easiest way to create a web service in JAX-WS. There are no external dependencies other than Java EE. Assuming that you build the web service as a webapp (say jaxws-example.war), the pom.xml can be as simple as:
<project xmlns="http://maven.apache.org/POM/4.0.0"... You can implement and deploy the web service in 3 easy steps: Code the service as a POJO (annotate class to expose it as a web service) package jaxws; import javax.jws.WebMethod; ... Declare the POJO as a servlet in WEB-INF/web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app... Build the webapp, and deploy the resulting war: mvn package The only catch is, this only works for a Java EE 5+ compliant container such as WebLogic or JBoss. It does not work for a simple servlet...
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 14:16:58
Last update: January 04, 2013 14:16:58
Junit does not support specifying execution order of tests until 4.11. The methods were simply invoked in the order returned by the reflection API. So, the tests are executed in a unspecified but deterministic order, i.e., you have no control over the order of execution, but if you repeat the tests, they are run in the same sequence each time. For version 4.11, you can specify the order with the FixMethodOrder annotation:
import org.junit.runners.MethodSorters; imp... From the release notes : Test execution order By design, JUnit does not specify the execution order of test method invocations. Until now, the methods were simply invoked in the order returned by the reflection API. However, using the JVM order is unwise since the Java platform does not specify...
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:
<project
xmlns="http://maven.apache.org/PO...
Output:
$ mvn validate
[INFO] Scanning for projects.....
Created by woolf on September 07, 2011 08:16:10
Last update: November 26, 2012 20:50:39
Follow these steps to restore the Gnome panel if you deleted it by accident:
Open a terminal by bringing up the Run dialog and entering gnome-terminal
In the terminal enter:
$ gconftool-2 --shutdown
$ rm -rf ~/.gconf/apps...
For Unity, use:
unity --reset
unity --replace
Created by voodoo on September 25, 2012 19:33:02
Last update: September 25, 2012 19:33:02
This a step-by-step example of how to create the files for GNU automake. Put the C source file in directory src ( cat src/hello.c ):
#include <config.h> #include <stdio.h> ... Run autoscan to generate configure.scan . Rename configure.scan : mv configure.scan configure.ac Edit autoscan.ac . Update this line: AC_INIT([FULL-PACKAGE-NAME], [VERSION] , [BUG-REP... Add this line after AC_INIT : AM_INIT_AUTOMAKE([foreign -Wall -Werror]) Add this line before AC_OUTPUT : AC_CONFIG_FILES([Makefile src/Makefile]) Create file Makefile.am ( cat Makefile.am ): SUBDIRS = src Create file src/Makefile.am ( cat src/Makefile.am ): bin_PROGRAMS = hello hello_SOURCES = hello.c Run these commands: $ aclocal $ autoheader $ automake --add-miss... The file configure is generated after autoconf is run. Build with: $ ./configure $ make Create tarball for distribution with: $ make dist...
Created by voodoo on September 25, 2012 19:10:19
Last update: September 25, 2012 19:10:19
Here is a list of the most useful targets that the GNU Coding Standards specify (from automake manual ). make all Build programs, libraries, documentation, etc. (same as make). make install Install what needs to be installed, copying the files from the package's tree to system-wide directories. make install-strip Same as make install, then strip debugging symbols. Some users like to trade space for useful bug reports... make uninstall The opposite of make install: erase the installed files. (This needs to be run from the same build tree that was installed.) make clean Erase from the build tree the files built by make all. make distclean Additionally erase anything ./configure created. make check Run the test suite, if any. make installcheck Check the installed programs...
Created by Fang on March 06, 2012 12:24:53
Last update: March 06, 2012 12:24:53
Validation groups can be used to control which rules validation rules to run. A validation group can be identified by any Java interface (not class!). Multiple validation groups may be specified when validating.
In this example, I added a validation group named MyValidationGroup ( src/main/java/com/example/MyValidationGroup.java in Maven project):
package com.example;
public interface MyVal...
and added a @Size rule for a person's name, because my database can only store up to 15 characters for a person's name:
package com.example;
import javax.validatio...
Now validate Person with a JUnit test ( src/test/java/com/example/TestPersonWithGroup.java in Maven project):
package com.example;
import java.util.Set;
...
Test with " mvn clean test ". The rules where groups is not specified, which belong to the javax.validation.groups.Default group, are not executed with these tests.
Created by Fang on March 05, 2012 20:32:37
Last update: March 05, 2012 20:32:37
In this simple example, I create a simple validating bean and create a JUnit test to test the validation.
The bean ( src/main/java/com/example/Person.java ):
package com.example;
import javax.validatio...
The test ( src/test/java/com/example/TestPerson.java ):
package com.example;
import java.util.Set;
...
Run the test:
mvn clean test
You'll notice that one test passed and the other failed.
The tests require that a person must have a name and the name cannot be empty, so @NotNull is not the right rule to use here. To make sure that the name is not empty, we need to use @Pattern . But since a null String matches any pattern, @NotNull is also needed:
package com.example;
import javax.validatio...