Millions of members get involved Java community to make Java strong and change the world

Ant – how to get current directory in Ant

24Feb2013 In: Ant

how to get current directory in Ant ?

To get the current directory, you can directly use ant build-in property ${basedir}, it  gives us the actual directory where ant is ran from (also the parent directory of the buildfile).

<target name="print-directory">
  <echo>current directory: ${basedir}</echo>
</target>

how to get user working directory in Ant ?

To get the user working directory, you can directly use ant build-in property ${user.dir}, it is actually exposed by Java System.getProperties(). so it’s the JVM currently working directory. it is usually located C:\Users\user_name.

<target name="print-directory">
  <echo>current directory: ${user.dir}</echo>
</target>

If you store the date in milliseconds since January 1, 1970, 00:00:00 GMT in Oracle, For example, the date is ’1126483200000′, you see, even a second convert to a thousand milliseconds, the number is really huge which means nothing when reading. we have to write the Oracle SQL query statement to get milliseconds and convert to a date string format: Read the rest of this entry »

How to deploy a war file to jetty

18Jan2013 In: Jetty

Like in tomcat, we can still static or hot deploy war file(packed or unpacked) to Jetty, this tutorial demonstrates how to deploy a war file to jetty? Read the rest of this entry »

Fiddler tutorial – How to use Fiddler

15Jan2013 In: Tools

Fiddler is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education. Fiddler captures HTTP and HTTPS traffic data between the browser and the server. This data is helpful to troubleshoot HTTP errors, java script errors, and performance issues related to browser page rendering, this article is a step by step tutorial to guide you how to use Fiddler and how to capture HTTP Traffic. Read the rest of this entry »

This tutorial demonstrates how to dump the stack track of current thread in Java, this is very useful troubleshoot or debug skill to identify the states of the current running thread.

Use Thread.currentThread().getStackTrace() to retrieve an array of StackTraceElements that represent the current stack trace . Read the rest of this entry »

How to change Jetty default port

9Jan2013 In: Jetty

In Jetty, most of the configuration information is by default maintained in file jetty.xml, it is located under $JETTY_HOME/etc/. The jetty default port is 8080. Read the rest of this entry »

Cobertura is a open source coverage tool which calculates the percentage of code accessed by test and generate source code coverage report. Read the rest of this entry »

A test suite is a collection of test cases that are intended to test a behaviour or set of behaviours of software program.

In TestNG, we cannot define a suite in testing source code, for better, it is represented by one XML file, because suite is the feature of execution, this also allows flexible configuration of the tests to be run and keep no change to code base once suite is changed. A suite can contain one or more tests and is defined by the <suite> tag. Read the rest of this entry »

Dependency is common need in unit testing, because the test cases may share some state, data and conditions, in order to write repeatable cases and run them in isolation, TestNG supports the declaration of explicit dependencies between test methods, it is enabled with two attributes of the @Test annotation, dependsOnGroups and dependsOnMethods. Read the rest of this entry »

The group test is a new innovative feature in TestNG, it doesn’t exist in Junit framework, it permits you dispatch methods into proper portions and preform sophisticated groupings of test methods. In TestNG, you can declare one method belong to one or more groups, even a certain set of groups can be included or excluded in groups. Read the rest of this entry »