Premature end of file when running junits


Premature end of file error when running Junits

[junitreport] [Fatal Error] :-1:-1: Premature end of file.
[junitreport] The file /tmp/repository/Yogesh/task2652_story1984/modulesmgr/junit_report/out/xml/TEST-com.coresecurity.ctrlsvc.modules.ModulesImportAndBasicCRUDTest.xml is not a valid XML document. It is possibly corrupted.

1) TESTS-testsuites.xml was coming out to be empty.
2) The resulting xml file was getting too large in size.

Hibernate logging was enabled which was leading to large size of XML.
We disabled logging in config.xml as given below
Earlier it was true, we made it false


Equals and hashCode mystery resolved

Equals and hashCode mystery resolved


Try executing the code in the attached files first by commenting the hashcode() method in and then by uncommenting.

The output differs.

In first case the objects are equal based in the criteria defined in the overridden equals method but when u try to put these two “equal” objects in a hashtable it allows you inspite of the fact the keys (objects) are equal.

Here: both objects are equal but hashtable consider them different so allows two entries.

In second case when we have overridden the hashcode() method for objects of class Test1 uncommented then the hashtable doesn’t allow to put the equal objects twice.

Here: both objects are equal and hashtable consider them equal because of overridden hashtable method so allow only one entry

import java.util.Hashtable;
public class RunTest
public static void main (String args[])
Test1 test1= new Test1("start", 10);
Test1 test2= new Test1("start", 10);
Hashtable ht = new Hashtable();
System.out.println("test1.hashCode=" + test1.hashCode());
System.out.println("test2.hashCode=" + test2.hashCode());
System.out.println("test1.equals(test2) = " + test1.equals(test2));
System.out.println("hashCodes are different --> means Objects are unequal");
System.out.println("Please note test1.equals(test2) returns " + test1.equals(test2));
System.out.println("Still it considers the objects to be unequal");
System.out.println("and adds it to hashTable");
System.out.println("hashCodes are same");
System.out.println("Objects can be equal or unequal");
System.out.println("Now it'll check equals method");
System.out.println("test1.equals(test2) = " + test1.equals(test2));
System.out.println("Since equals method returns true, it'll not allow 2 equal elements to be added");
System.out.println("the size of ht is :" + ht.size());
public class Test1
String s;
int t ;
public Test1(String s, int t)
this.s= s;

public boolean equals(Object obj)
if(this == obj)
return true;
if(!(obj instanceof Test1))
return false;
Test1 test = (Test1)obj;

return (s.equalsIgnoreCase(test.s) && t==test.t);

public int hashCode()
return (this.s.hashCode() + this.t);

How to wrap longer lines in SQL file…

A post by Aashu Aggarwal…

More i learn UNIX, more i feel its miraculous 🙂

1. There is a direct way to split the lines in unix. Command is “fold” It can directly split the huge lines into multiple

Syntax>> fold -200 input_file > output_file

This will split all the lines in input_file to lines less than equal to 200 characters. Like say if there is aline with 500 characters, that will be split into 3 lines with 200 character s in 2 lines and 100 in 1 line.

2. If i need to split a line around some character or word then below is the command Syntax >> perl -pe ‘s/(.{1,199}[,])/1n/g’ input_file > output_file

In this command will insert newline character after last comma in next 200 characters .{1,199} is telling to see after 200 character [,] is the character to split around. Multiple character can be given like [,:]. It will use both comma and colon to split.
1n will copy the result of first part is (.{1,199}[,]) and insert n after this s/input_pattern/output_pattern/g will replace all such entries in file

I was in love with JAVA, now i love UNIX also.. 🙂


A VB Script to run outlook and send some specified keys to it.

To send Ctrl+n, use “^{n}” as given below, for Alt use %

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "Outlook"
WScript.Sleep 2500 ' Give Notepad some time to load
WshShell.SendKeys "^{n}"
WScript.Sleep 1000
WshShell.SendKeys ""
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " Hi Yogesh, I accept that I am a FOOL ...and you made a fool out of me today ... I don’t think God planted brains in my head!!!!...otherwise I would have checked out the code first! you are great. hats off for you. With Regards"
WshShell.SendKeys "%{s}"

Quick batch file to check OS version…

How to check the Operation System version
if OS is 32 bit or 64 bit

Quick batch file to check OS version…

@echo off

Set RegQry=HKLMHardwareDescriptionSystemCentralProcessor

REG.exe Query %RegQry% > checkOS.txt

Find /i “x86” StringCheck.txt

If %ERRORLEVEL% == 0 (

Echo “This is 32 Bit Operating system”

) ELSE (

Echo “This is 64 Bit Operating System”



use OnClick with caution

JSP Code :

<a href="abc.jsp" onclick='’>LOGOUT

The above statement gets converted to Servlet CODE :

out.write("<a href="abc.jsp" onclick='");




What ever scriplet you write in onclick, will get executed every time the JSP is called. Not only on onclick as can be wrongly assumed.

BUG in struts2

Actually I used

Now, I have specified type as button, so I expected that it will not go to action on click on the button.

But what happens is

when I click on button, it asks if I want to close the window,
Now, even I click NO, it still goes to action specified in form.

Solution : This is a BUG in struts2.

the HTML tag that is generated is something like:

<button type="submit” id=”test_0″ value=”Submit” class=”button positive save”>Submit

Please note that we have given type=button in s:submit tag, and the HTML generated still contains type=submit.

Can get some information from

Internationalization tips for JSP

In order to display the complex script characters like Japanese, Chinese, etc in the browser window, the following changes need to be made at the beginning of each JSP file:

<%@ page language="java" 
contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

Wherever input controls are present, the following additional steps need to be taken:
Add the following code before reading any parameters in the previous JSP file:

request.setCharacterEncoding("UTF-8"); // Set the request encoding

While sending output to a browser:

response.setContentType ("charset=UTF-8");

VB with Access 2000

Problem :
How to make VB 6.0 work with Access 2000

Solution :
Select Microsoft DAO 3.6 Object Library in Project References