SEARCH WEB


Monday 19 September 2011

Issue in Sonar when Analyse with Ant Task


Had you install the Build Stability Plugin in Sonar and try to run the sonar anlayze( http://docs.codehaus.org/display/SONAR/Analyse+with+Ant+Task) You may Come Across a NullPointerExceptio as below.

build-sonar.xml:56: java.lang.NullPointerException

at org.sonar.plugins.buildstability.BuildStabilitySensor.getCiUrl(BuildStabilitySensor.java:60)

at org.sonar.plugins.buildstability.BuildStabilitySensor.shouldExecuteOnProject(BuildStabilitySensor.java:51)

at org.sonar.api.batch.BatchExtensionDictionnary.shouldKeep(BatchExtensionDictionnary.java:105)

at org.sonar.api.batch.BatchExtensionDictionnary.getFilteredExtensions(BatchExtensionDictionnary.java:95)


To Overcome This you need to define below ant property


<property name="sonar.build-stability.url" value="<ANY String need not to be a Valid URL"/>


I got the same issue last week and was unable to resolve the issue So I jus down load the Code for above plugin and look at it.
This is the actual root cause for this. To integrate sonar with CI Agent using sonar.build-stability.url or CiManagement of pom of the project. Pom is present only if this is a maven project. So if you don't specify the above property then it will try to load CiManagement using POM since ant projets does not have POM this will throw NullPointerException.
CiManagement ci = project.getPom().getCiManagement();


public class BuildStabilitySensor implements Sensor {
..........

..........
..........

public static final String CI_URL_PROPERTY = "sonar.build-stability.url";

..........
..........




protected String getCiUrl(Project project) {

String url = project.getConfiguration().getString(CI_URL_PROPERTY);
if (StringUtils.isNotEmpty(url)) {
return url;
}

CiManagement ci = project.getPom().getCiManagement();
if (ci != null && StringUtils.isNotEmpty(ci.getSystem()) && StringUtils.isNotEmpty(ci.getUrl())) {
return ci.getSystem() + ":" + ci.getUrl();
}
return null;

}


Friday 3 June 2011

Automate Log testing

We have automated java test cases for our project. but we never successfully automate the logging test cases because of the file size.
These logging are done using log4j and each api request has a trace-id Manually when we want to trouble shoot an issue we grep this trace-id and follow the log entries.
So what we do is rather than reading the file and get a FileInputStream we run the grep command and get the input stream of that process and do subsequent evaluation.

Process process = Runtime.getRuntime().exec(String.format("grep -m 1000 %s",traceid));
// get the input Stream of executed process
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

Here we need to remember to specify a maximum line for grep command using -m flag otherwise this cannot be done. we can use a large value for -m to make sure we are reading all the lines.

Monday 28 March 2011

Install and Configure Apache Tomacat 5 to run with java 1.4 SDK in Linux

download apache full version from
http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.17/bin/apache-tomcat-5.5.17.tar.gz
and 1.4 compatible files from
http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.17/bin/apache-tomcat-5.5.17-compat.tar.gz
and copy it to the folder you want to install the tomcat server (I refer to this as APACHE_FOLDER here after.

1. Open the console
2. Go APACHE_FOLDER (cd )
3. Unzip archives
gunzip *
tar -xf apache-tomcat-5.5.17.tar
tar -xf apache-tomcat-5.5.17-compat.tar
4.set CATALINA_HOME and TOMCAT_HOME environment variables as follow
i. open the .bash_profile in home and insert following two lines
export $CATALINA_HOME=/apache-tomcat-5.5.17
export $TOMCAT_HOME=/apache-tomcat-5.5.17

To edit .bash_profile you can use vi editor. Type vi ~/.bash_profile in console. It will open .bash_profile file.
Then type i (this will go to Edit mode)
Then type above two lines in the folder then press Esc button, ( This will go to command mode )
Then type :wq and press enter ( this will save our modifications )
5.To set this variables either you have to type source ~/.bash_profile in every command prompt you open or restart the machine to make the effect permanently

Friday 22 October 2010

“Using RESTful Web Services and Cloud Computing for Next-Generation Mobile Applications” by Jason H. Christensen.

Today I listen to a video presentation on “Using RESTful Web Services and Cloud Computing for Next-Generation Mobile Applications” by Jason H. Christensen. He presents the evolution of the mobile devices over the last decade. Then He talks about Features of mobile devices f the smart phone that can be used for mobile computing; TCP application connection, Multi modal Radio Connectivity (like WI-FI, bluethooth, cellular connection) Sensors for ascertaining context and Programming Language Interface . And limitation of the mobile devices limited input, Minimal Storage, Highly constrained Processing Environment, and Poor quality of multitasking. Using Cloud computing how we can overcome these difficulties . Finally He presents some Guidelines for Using REST to implement mobile applications shows an example and some other aspects of Mobile cloud computing like Security.
This is the link for the presentation http://www.infoq.com/presentations/Mobile-Cloud-REST

The W3C QA Tools for Web Pages

For Last couple of years I have been working on Web services and web sites. I started working on these projects with the impression that it is really easy to develop web pages since those do not involve complex logic. But with the experience I realized that developing UI is also an important and difficult task as much as developing the business logic. Some UI layout does not work correctly and these layouts differ from browser to browser. Still those are hard to detect through Unit testing and very few tools are developed to help identifying UI Layout. I have come across the situation where I made changes to css but web page does not display as indented and then it was a nightmare for me to identify the error with the CSS. If I fixed it to work on IE 6 it tweaks the layout in Firefox and etc... And fixing these takes as much time as the business-logic.
We may able to develop a web site with all the functional requirements and address other non-functional requirements like performance, security, fail over and robustness. But Users who are not IT professional get the first impression of the project by looking at the UI (web pages). UI development plays a very important role in Project.
Firebug was an interesting tool - plugging for Firefox - that helps me to troubleshoot UI layout bugs. But it still it does not validate the CSS file. Today I come across this site http://www.w3.org/QA/Tools/ maintain by W3C group and they have developed four interesting tool to validate bug on web pages.
* Unicorn - W3C's Unified Validator
* The MarkUp Validator - check Web documents in formats like HTML and XHTML, SVG or MathML.
* The Link Checker - Checks anchors (hyperlinks) in a HTML/XHTML document; Useful to find broken links, etc.
* The CSS Validator - validates CSS stylesheets or documents using CSS stylesheets.

I think all these are quite interesting and I should try these out in my next project to ensure the Quality of my work.

Saturday 2 October 2010

Google WebP - New Image Compress Format

Google has announce a new image format WebP (pronounce weppy) to shrink the image size basically in Web Pages. This will improve the user experience on web site, reduce the bandwidth and hosting cost due to small file size. A WebP file consists of VP8 image data, and a container based on RIFF.

WebP team has performed comparative study of three image format WEbP with Jpeg 2000 and re-jpeg over a set of 1 million pages and published the results with the conclution that WebP achieves overall higher compression than either JPEG or JPEG 2000. Gains in file size minimization are particularly high for smaller images which are the most common ones found on the web.
G
oogle provide free open-source tool webpconv that convert images to from webp format .The tool currently support Linux x86 (64-bit) platform and google promise a tool for Windows as well. BMP, JPEG, PNG, WEBP can be used with this tool and user can choose the trade-off between quality and the file size by specifying the -quality parameter.
WeBP home page

Wednesday 11 June 2008

Kill a task/process running in the system using Java

We can use following code line to kill a process currently running in the system
Runtime.getRuntime().exec("taskkill /IM " + + " /F");
E.g. to kill internet exlporer
Runtime.getRuntime().exec("taskkill /IM " + IEXEPLORER.EXE + " /F");