Posted by: bgopi | January 20, 2014

JUnit Method Execution order

Fianlly Junit4.11 introduced @FixMethodOrder annotation for executing test methods in defined order or we can specify the order.
please take a look at below link for more information:
https://github.com/junit-team/junit/blob/master/doc/ReleaseNotes4.11.md#test-execution-order

Posted by: bgopi | August 22, 2012

Send email from unix command line or shell script

We can use mutt or uuencode in linux to send mail from command line or shell script, here are examples:

mutt -s “Test Attachement” -a /folder//logs/yourfile.csv — your_mail_id@your_mail_host.com </dev/null

uuencode /test/folder/file-$DATE.xls | mailx […]

Note: mutt or uuencode should be installed on linux if not, install using yum.

Posted by: bgopi | August 22, 2012

Drools regular expression – matcher example

You can use “and” or “&&” / “or” or “||” but && and || are deprecated, from 5.2 onwards use and/or

This matches exception class like com.test.exception.BADException

<yourvariable> matches “^.*com.test.exception.BADException.*$”

This matches pattern some thing like “test-service-cashflow”, “test-service-business”, “test-service-credit”

<yourvariable> matches “^.*test-service.*.*$”

This matches exactly “MyError”

<yourvariable> == “MyError”

when
$msg: <YourClass>(<variable> == “MyError”) and <YourClass>(<yourvariable> matches “^.*test-service.*.*$”)
then
System.out.println(“Rule Executed “);
$msg.setSomething(“do something here if you want”);
end

when
$msg: <YourClass>(<variable> == “MyError”)  && <YourClass>(<yourvariable> matches “^.*test-service.*.*$”)
then
System.out.println(“Rule Executed “);
$msg.setSomething(“do something here if you want”);
end

This can be used for matching two sub string in the string i.e., it has BADException and USER_NOT_FOUND_ERROR

<YourClass>(<yourvariable> matches “(?s).*BADException.*USER_NOT_FOUND_ERROR.*”)

(?s) – is single line modifier, you can use (?i) – for ignoring case : matches “(?i).*BADException.*USER_NOT_FOUND_ERROR.*”)

We can use both: <YourClass>(<yourvariable> matches “(?i)(?s).*BADException.*USER_NOT_FOUND_ERROR.*”)

Go here for complete understanding of rules and expressions: http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html/ch05.html

Posted by: bgopi | August 13, 2012

Google Analytics issue

Most Common Google Analytics issues.

We can use traditional or modern codes snippet provided by Google.

1. ga.js script is getting downloaded but no utm.gif call is made

make sure ga.js is downloaded before you make call. To do this, add an alert in the catch and see. if you see error like _gaf not found, your script file is not loaded yet. Change the including script or adjust the placement (script include in the beginning of body and script call in the bottom of the body.

2. utm.gif call is aborted

It happens if we use multiple GA code (UA-xxxxx-x) in pages. Add script to include ga.js in the beginning of body tag and call this script at the bottom of body.

 

Resource Bundles can be updated dynamically,  in case of labels it will happen immediately once you flush. When a mail id or some property read into java class from a resource bundle, it will not get updated dynamically after you flush resource bundle. It happens only on the restart of servers.  This is because, spring singletons are loaded during startup,  they read properties during this phase and cached in memory. Though I update bundle dynamically and flush it, cached class is not going to read it again from property file, unless you reload classes into context. We can write code to reload to context again.

But I suggest below simple and elegant way to do it.

ResourceBundle.clearCache();
ResourceBundle myBundle = ResourceBundle.getBundle(“com.test.myBundle”);

Note: Check my other post in solutions category for how to create a page that can be used to flush resource bundle content and update them dynamically.


					
Posted by: bgopi | February 13, 2012

Flush Resource Bundles in your application

You can use below code to flush resource bundles in your application. You can create a jsp/jspx page, provide access to your deployment team,  so they can call it after they deploy bundles.

try {

ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader());

} catch (Exception e) {

e.printStackTrace();

}

 

 

Posted by: bgopi | February 13, 2012

IE 7 – CSS not applied issue – file size

I have a 97KB CSS file  but IE7 somehow can not load entire content. I split that CSS file into multiple fiels, it magically started working. Microsoft says that IE 7 has size issues but it can read upto 150KB but in my case it cant read 97KB 🙂

Use the following steps to create a wlfullclient.jar file for a JDK 1.6 client application:

  1. Change directories to the server/lib directory.
                   cd WL_HOME/server/lib
       2.Use the following command to create wlfullclient.jar in the server/lib directory:
    1. java -jar wljarbuilder.jar
    2. You can now copy and bundle the wlfullclient.jar with client applications.
    3. Add the wlfullclient.jar to the client application’s classpath.

MyWebService  serviceToUse = new MyWebService();

Object stub = serviceToUse.getPort(new QName(“http://www.xxx.com/xx/service/schema/xx/interface/v1&#8243;,”web-port”), WebPort.class);

WSBindingProvider bp = (WSBindingProvider)stub;
HeaderHandlerResolver handlerResolver = new HeaderHandlerResolver();
serviceToUse.setHandlerResolver(handlerResolver);

myService = serviceToUse.getWebPort();

//call your web method here

myService.yourWebMethod(request);

For HeaderHandlerResolver and HeaderHandler please refer below:

http://www.java.net/external?url=http://javadb.com/using-a-message-handler-to-alter-the-soap-header-in-a-web-service-client

Posted by: bgopi | December 3, 2011

standalone spring jaxws webservice client

I got following error, struggled little bit because whatever I do its keep coming. Finally I found a way to get away from this exception, its simple remove all weblogic related jars and use javax.xx jars.

Exception in thread “main” java.lang.NullPointerException
at weblogic.wsee.jaxws.framework.policy.WSDLParserExtension.definitionsElements(WSDLParserExtension.java:294)
at com.sun.xml.ws.wsdl.parser.DelegatingParserExtension.definitionsElements(DelegatingParserExtension.java:91)
at com.sun.xml.ws.wsdl.parser.FoolProofParserExtension.definitionsElements(FoolProofParserExtension.java:96)
at com.sun.xml.ws.wsdl.parser.WSDLParserExtensionFacade.definitionsElements(WSDLParserExtensionFacade.java:136)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:357)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:168)

« Newer Posts - Older Posts »

Categories