de.smartics.util.test.lang
Class LangTestUtils

Package class diagram package LangTestUtils
java.lang.Object
  extended by de.smartics.util.test.lang.LangTestUtils

public final class LangTestUtils
     
     
extends Object

Provides utility functions on the language level.

Author:
Robert Reiner

Method Summary
static Object createInstanceForPrivateNoArgsConstructor(Class<?> clazz)
          Creates an instance of the private no-args constructor.
static String removeAllWhitespaces(String input)
          Removes all whitespaces from the input string.
static void runPrivateConstructorTest(Class<?> clazz)
          Tests creating an instance for a private constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createInstanceForPrivateNoArgsConstructor

public static Object createInstanceForPrivateNoArgsConstructor(Class<?> clazz)
                                                        throws SecurityException,
                                                               NoSuchMethodException,
                                                               InstantiationException,
                                                               InvocationTargetException,
                                                               ExceptionInInitializerError,
                                                               IllegalStateException
Creates an instance of the private no-args constructor.

This is a kind of dysfunction to get rid of missing test coverage for private constructors of constant or utility classes. To keep the overhead for this dysfuntion small, this method is provided.

Parameters:
clazz - the class to instantiate with the private no-args constructor.
Returns:
the instance of the class.
Throws:
NoSuchMethodException - if there is no private no-args constructor.
SecurityException - if the request to make the private constructor accessible is denied.
InstantiationException - if the class that declares the underlying constructor represents an abstract class.
InvocationTargetException - if the underlying constructor throws an exception.
ExceptionInInitializerError - if the initialization provoked by this method fails.
IllegalStateException - if something strange happens that we did not take into account.
See Also:
runPrivateConstructorTest(Class)

runPrivateConstructorTest

public static void runPrivateConstructorTest(Class<?> clazz)
Tests creating an instance for a private constructor.

This is a kind of dysfunction to get rid of missing test coverage for private constructors of constant or utility classes. To keep the overhead for this dysfuntion small, this method is provided.

Example Usage

public void testPrivateConstructor()
LangTestUtils.runPrivateConstructorTest(FileNameUtils.class); 

Parameters:
clazz - the class to instantiate with the private no-args constructor.
See Also:
createInstanceForPrivateNoArgsConstructor(Class)

removeAllWhitespaces

public static String removeAllWhitespaces(String input)
Removes all whitespaces from the input string.

Parameters:
input - the input string to remove all whitespaces.
Returns:
the input stream without whitespaces or null if the input string is null.


Copyright © 2008-2012 Kronseder & Reiner GmbH - smartics. All Rights Reserved.