Pages

Friday, September 9, 2011

Cobertura -- Code Coverage Tool

public interface Instrumentation:
This class provides services needed to instrument Java programming language code. Instrumentation is the addition of byte-codes to methods for the purpose of gathering data to be utilized by tools. Since the changes are purely additive, these tools do not modify application state or behavior. Examples of such benign tools include monitoring agents, profilers, coverage analyzers, and event loggers.

coverage analysers fall into three categories:
Insert instrumentation into the source code
Add instrumentation to the Java byte-code
Run the code in a modified JVM.

"Cobertura" add instrumentation to the java byte code.
using Maven 2:


YET TO ADD

Friday, August 19, 2011

Unit Testing

http://docs.jboss.org/arquillian/reference/1.0.0.Alpha1/en-US/html_single/#d0e34

http://publib.boulder.ibm.com/infocenter/rtnlhelp/v6r0m0/index.jsp?topic=%2Fcom.ibm.rational.test.ct.doc%2Ftopics%2Ft_cre_java_stub.html

How to mock JNDI(SimpleNamingContextBuilder)

Simple implementation of a JNDI naming context builder.

Mocking the JNDI naming context with "SimpleNamingContextBuilder" class.

Mainly targeted at test environments, where each test case can configure JNDI appropriately, so that new InitialContext() will expose the required objects. Also usable for standalone applications, e.g. for binding a JDBC DataSource to a well-known JNDI location, to be able to use traditional J2EE data access code outside of a J2EE container.

import javax.naming.NamingException;
import javax.sql.DataSource;

import junit.framework.TestCase;

import org.apache.commons.dbcp.BasicDataSource;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.mock.jndi.SimpleNamingContextBuilder;

import com.code.rfs.common.db.JndiDatasource;
import com.code.ejb.search.util.ApplicationConstants;
import com.code.ejb.search.util.PropertiesUtil;

public class JNDIControllerTest extends TestCase {
private JndiDatasource bean1;
private DataSource ds;

/* protected String[] getConfigLocations() {

return new String[] { "ApplicationContextTest.xml" };
}
*/


public void JNDIControllerTest() throws IllegalStateException, NamingException {
//setDependencyCheck(false);

SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
org.apache.commons.dbcp.BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
dataSource.setUsername("XXXX");
dataSource.setPassword("XXXXXXXX");
dataSource.setUrl("jdbc:oracle:thin:@XYZ.XY.Z.XYZ.net:1111:ABCD");
builder.bind("java:comp/env/jdbc/Keely_DS",dataSource);
builder.bind("url/HLFSAppConfigFolder","file:///c:/ModifWorkspace/keely/fs-ejb/ejbModule");
builder.activate();
// setAutowireMode(AUTOWIRE_BY_TYPE);

}

public void testJNDI() throws Exception {
JNDIControllerTest();
ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContextTest.xml");
bean1 = (JndiDatasource)context.getBean("datacon");
System.out.println(bean1);
PropertiesUtil pUtil = new PropertiesUtil();

}


Saturday, July 9, 2011

Overview:

SAAJ API Overview:
http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.5/saaj/index.html#links
The SOAP with Attachments API for JavaTM (SAAJ) 1.2.1 provides the API for creating and sending SOAP messages by means of the javax.xml.soap package. It is used for the SOAP messaging that goes on behind the scenes in JAX-RPC and JAXR implementations. Developers can also use it to write SOAP messaging applications directly instead of using JAX-RPC.

Axis uses SAX (event-based) parsing to acheive significantly greater speed than earlier versions of Apache SOAP.

Axis is compiled in the JAR file axis.jar; it implements the JAX-RPC API declared in the JAR files jaxrpc.jar and saaj.jar. It needs various helper libraries, for logging, WSDL WebServices - Axis

Axis needs to be able to find an XML parser. If application server or Java runtime does not make one visible to web applications, download and add it.
Java 1.4 includes the Crimson parser, so you can omit this stage, though the Axis team prefer Xerces.

Yet to add....

Note: Courtesy@@@@SUN

Friday, July 8, 2011

Hibernate caching

Session Level
Query Level
Second-Level Cache

courtesy and credit goes to the below site.
http://blog.dynatrace.com/2009/02/16/understanding-caching-in-hibernate-part-one-the-session-cache/

Wednesday, June 8, 2011

Single-Sign-On Policy Data Migration Tool

Export and Import tools allow us to migrate the policy store data from one environment to the other (or) for backup and restore.
1)smobjexport
2)smobjimport
The above tools will produce or consume the following two files
a)smdif Siteminder data interchange format
***The most important fact is that we can export the smdif file from ODBC database
and then import it into the LDAP.
smobjexport will produce the smdif file and .cfg file.
smobjimport will consume the smdif file.
b).cfg environment properties like URL,IPaddress,shared secrets



smobjexport:
We can export the entire
1)policystore
2)and keys
3)policy domain
4)policy domain with the associated system objects.





smobjimport :
.We can import the entire policy store or policy domain or policys domain with keys.