Sunday, September 13, 2015

Ant built-in Properties

This is a simple example that illustrates how to find the basedir name, file name, project name, ant version, java version, operating system name, ant home directory name, java home directory name, user home directory name and user name. Ant provides you with certain built-in properties that you may find useful during your build process. The following table shows the property name and it's description.
Ant's built-in properties:
Property
Description
ant.file
The absolute path of the build file
ant.project.name
The name of the project as set in the element's name attribute.
ant.home
The root directory of ant
ant.version
The version of this ant installation. This is not just the version number and includes information such as the compilation date.
ant.java.version
The version of the java that ant uses
basedir
The absolute path of the project
os.name
Operating system name
java.home
Java home directory name
user.home
User directory name
user.name
User name
Source code of build.xml:
"1.0"?>

"AntProperties" default="echo" basedir=".">

"echo">
"The operating system is: ${os.name}"/>


"The home path is: ${basedir}"/>


"The file name is: ${ant.file}"/>


"The Project name is: ${ant.project.name}"/>
"The Ant home directory is: ${ant.home}"/>
"The Ant version is: ${ant.version}"/>
"The Java version is: ${ant.java.version}"/>


"The Java home directory is: ${java.home}"/>
"The User home directory is: ${user.home}"/>
"The User name is: ${user.name}"/>


Run this program - the following output will be displayed:

Ant Part 2 build.xml file

This example shows how to generate the build.xml file. You may say that build.xml file is the backbone of ANT (Another Neat Tool) technology. Each build.xml file contains only one project name and at least one target. The project tag has only three attributes:
Project
Attribute
Description
Requirement
name
project name
not necessary
default
target name which called by default
not necessary
basedir
the base directory having all path, it contain absolute path
not necessary
The project tag is used to create our project and its attributes are used to handle further processing of the project. The name attribute is used to specify the project name and the default attribute is used to specify which target will be called as default when the program will run and the basedir attribute is used to calculate the absolute path of the parent directory.
An another tag is Target tag which has following five attributes:
Target
Attribute
Description
Requirement
name
target name
necessary
depends
depends on another target
not necessary
if
the name of the property that must be set in order for this target to execute.
not necessary
unless
the name of the property that must not be set in order for this target to execute.
not necessary
description
short description about target
not necessary

In the target tag, name attribute is used for target name and the depends attribute is used to give sequence of target, i.e., which target will execute first, one target may depend on one or more other targets. The if attribute is used in case of condition, whether property exists or not; then this target will be executed and unless attribute is used as like else condition whether property does not exist, the target will not be executed and the description attribute is used for only giving details about target.
Next tag is property tag which has following four attribute:
Property
Attribute
Description
Requirement
name
name of the property, which is case-sensitive
not necessary
value
name of task attribute, this is done by placing the property name between "${"name }" in the attribute value
necessary
location
it contain property name
not necessary
file
name of the property file
not necessary

In the property tag, name attribute is used for property name; it is case sensitive. The value tag is used to give the task which will be the name of property in this format "${name}", and the location tag is used to specify the location of task where it performs and the file tag is used to import all properties of ant file. The complete build.xml file structure is as follows:
























The above build.xml file is used to create directory, compile source code, create jar file and clean the directory if already exists. To check the program, simply copy and paste the above code and give appropriate path; then run with ant command on the command prompt. The output is as follows:
The output shows that a jar file named roseindia.jar is created but in this jar file only manifest file is created. When you make a java file in the src folder and run with ant command, the jar file is created completely.
class Hello
{
public static void main(String args[]){
System.out.println("sandeep kumar suman");
}
}
To check your program, compile it with ant command on the console; then the following output will be displayed:

Monday, November 21, 2011

Apache Ant

Ant Definition

Apache Ant is an open source, cross-platform based build tool that is used to describe a build process and its dependencies and implemented in XML scripts using Java classes that ensures its extensibility to any development environment (based on Java) and its integrity with other build tools.

Why Ant?

Ant is developed by Apache Foundation specifically to build projects based on java platform. But why to use Ant if there already exists other build tools like make, jam and many. Tool like make uses shell commands that facilitates integration of other tools to extend its functionality on the operating system where it runs. But this limits the functionality of the build tool specific to that OS only, e.g., make is specific to the UNIX platform. Ant has overcome this shortcoming as it uses java classes with XML scripting that makes it portable through cross-platform behavior. Ant is applicable to any integrated development environment based on java technology and therefore easy to use in building java projects across any platform. Ant enables automatic generation of build processes that is more reliable than manual procedures. Ant can also compile source code from version controls and package the compiled code and other resources (JAR, EAR, TAR etc.).

History of Ant

The development of Ant technology originated as an integral component of Tomcat application server based on Java Servlet and Java Server Faces. Ant, as a part of Apache Jakarta Project is an open source solution based on java platform. With the advent of time, it gained popularity and used widely. Its first independent release as a Jakarta subproject was made in the year 2000. Since then, Ant has been used as a major tool in building java projects and now it has become a top-level Apache project for server-side solutions. The latest release of Ant is version 1.7.1.

Introduction to Apache Ant (Another Neat Tool)

Ant is an open source build technology developed by Apache intended to build processes in Java environment. It is a similar kind of tool like make but it does not use shell commands to extend the functionality. The use of shell commands in make brings about the integrity with other languages too but this also makes it platform specific. In contrast, Ant is based on XML and uses java classes in automatic generation of build processes that makes it platform independent. It is applicable to any integrated development environment (IDE) that uses java. A build file is generally named as build.xml.

The best features of the Ant technology can be summarized as below -

· Easy to Use: It is not a programming language, it is an XML based scripting tool, therefore easy to understand and implement.

· Portable and Cross-platform based: Uses of Java classes makes it portable, i.e., it can be run on any operating system.

· Extended Functionality: Ant is based on java platform, that?s why its functionality can be extended to any development environment based on java. It is easier to implement than any specific IDE because it is automated and ubiquitous.

· Build Automation: Ant provides automated build processes that is faster and more efficient than manual procedures and other build tools can also be integrated with it.

· Compilation of Source Code: Ant can use and compile source code from a variety of version controls and packaging of the compiled code and resources can also be done.

· Handling Dependencies between Targets: An Ant Project describes the target and tasks associated with it and also handles dependencies between various targets and tasks.

Installation

In this section, you will learn how to install Ant into your system.

The current version 1.7.1 of Ant was released on 27 June, 2008. It is available for download athttp://ant.apache.org/bindownload.cgi. Here, you have to click on the link apache-ant-1.7.1-bin.zip in the .zip archive to download the zip file. After the download completes, unzip this file and install the apache-ant-1.7.1 folder to the root directory of C:\ drive. Therefore, path for the Ant directory will be C:\apache-ant-1.7.1. Now, we have to set some environment variables. Select the item "System" in the Control Panel of your system and click on the tab named "Advanced". You will see a button named "Environment Variables" appears, click it. Under Environment variables, you will find two user variables, viz., ANT_HOME and CLASS_PATH. Set the path value C:\apache-ant-1.7.1 to ANT_HOME variable and the path value C:\apache-ant-1.7.1\lib; to CLASS_PATH variable. Again in the System Variables, we have to set the value C:\jdk to JAVA_HOME variable and the value C:\apache-ant-1.7.1\bin; to Path variable.

Now, you have to check whether the installation process is done properly or not. To do this, open the Command Prompt and run the command C:\>ant. If the following message appears, then it indicates that your installation is successful; Ant is properly installed in your system.

.

Saturday, August 28, 2010

Quick Test testing process consists of 7 main phases

1.Preparing to record
Test Environment

Test Conditions

2.Recording a session on your application

Navigate according to Test Conditions

3.Enhancing your test

Adding logic and conditional statements

Parameterization

Inserting checkpoints

4.Debugging your test

Check that it operates smoothly and without interruption.


5.Run Test

Check the behavior of your application

6.Analyzing the test results

7. Reporting defects