Tags » Java 2

Unit Testing Common Requirements

Suppose you wanted to unit test java.util.Map. How would you verify each implementation? Take a quick look at the Map javadoc, and you’ll find 20 implementing classes. 1,032 more words

Java

How to Indent XML String in Java (Pretty)

Hello Guys,

This is a cool way to prettify your XML (String format) in Java Language:

public static String format(String xml, Boolean ommitXmlDeclaration) throws IOException, SAXException, ParserConfigurationException {

DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.parse(new InputSource(new StringReader(xml)));

OutputFormat format = new OutputFormat(doc);
format.setIndenting(true);
format.setIndent(2);
format.setOmitXMLDeclaration(ommitXmlDeclaration);
format.setLineWidth(Integer.MAX_VALUE);
Writer outxml = new StringWriter();
XMLSerializer serializer = new XMLSerializer(outxml, format);
serializer.serialize(doc);

return outxml.toString();

}
Java

Get Enum type with id

Here is a simple technique to retrieve Enum type using custom ‘id’ property instead of name.

Define Contract

/**
 * Contract that will allow Types with id to have generic implementation. 164 more words
Java

Get column's metadata

Recently I had to do rounding within hibernate dao classes in my project. I had to get column’s scale in hibernate custom user type we created and then use Round_Half_Up. 25 more words

Java

ControllerAdvice ve ExceptionHandler

Merhabalar,

Bu yazımda size SpringMVC uygulamalarınızda kullanabileceğiniz exception handle etme yöntemlerinden bahsedeceğim.

İlk olarak  @ControllerAdvice annotation’ını kullanan bir handler sınıfı oluşturarak başlayalım. Oluşturduğumuz sınıfda handleCustomException adında bir metod oluşturalım.Metodun görevi CustomException tipinde fırlatılmış ama try catch ile yakalanmamış exceptionları yakalamak olsun. 185 more words

JAVA

Data Confidentiality with OpenDJ LDAP Directory Services

Directory Servers have been used and continue to be used to store and retrieve identity information, including some data that is sensitive and should be protected. 491 more words

Directory Services

Weblogic 12.1.3 opens a transaction even with TransactionAttributeType.NEVER or NOT_SUPPORTED

The problem

An stateless EJB is used to process lot of records, one by one, without using a global transaction that envelopes everything.

Well, here the initial solution is to annotate the EJB with: 351 more words

Development