From 26805fc0810098c4bd8009a35c8719478e74153e Mon Sep 17 00:00:00 2001 From: erik Date: Sat, 31 Jul 2010 17:33:10 +0000 Subject: [PATCH] --- .../classloading/ClassLoaderUtils.java | 4 +- .../wamblee/classloading/package-info.java | 2 +- .../wamblee/collections/CollectionFilter.java | 4 +- .../org/wamblee/collections/package-info.java | 2 +- .../java/org/wamblee/concurrency/JvmLock.java | 2 +- .../java/org/wamblee/concurrency/Lock.java | 2 +- .../wamblee/concurrency/ReadWriteLock.java | 8 +- .../org/wamblee/concurrency/package-info.java | 2 +- .../org/wamblee/conditions/AndCondition.java | 2 +- .../org/wamblee/conditions/Condition.java | 2 +- .../wamblee/conditions/FixedCondition.java | 2 +- .../org/wamblee/conditions/OrCondition.java | 2 +- .../conditions/PropertyRegexCondition.java | 13 +- .../org/wamblee/conditions/package-info.java | 1 + .../wamblee/general/LookupProxyFactory.java | 64 +++++----- .../java/org/wamblee/general/ObjectElem.java | 14 ++- .../general/ObjectSerializationUtils.java | 33 +++-- .../main/java/org/wamblee/general/Pair.java | 2 +- .../ThreadSpecificInvocationHandler.java | 49 ++++---- .../general/ThreadSpecificProxyFactory.java | 10 +- .../java/org/wamblee/general/ValueHolder.java | 40 +++--- .../org/wamblee/io/ClassPathResource.java | 2 +- .../java/org/wamblee/io/DirectoryMonitor.java | 24 ++-- .../java/org/wamblee/io/FileResource.java | 2 +- .../java/org/wamblee/io/InputResource.java | 2 +- .../org/wamblee/io/RegexFilenameFilter.java | 19 +-- .../java/org/wamblee/io/SimpleProcess.java | 15 ++- .../java/org/wamblee/io/StreamResource.java | 2 +- .../java/org/wamblee/io/package-info.java | 3 +- .../java/org/wamblee/ioc/BeanFactory.java | 2 +- .../org/wamblee/ioc/BeanFactoryException.java | 2 +- .../java/org/wamblee/ioc/package-info.java | 3 +- .../observer/DefaultObserverNotifier.java | 2 +- .../java/org/wamblee/observer/Observable.java | 2 +- .../java/org/wamblee/observer/Observer.java | 2 +- .../wamblee/observer/ObserverNotifier.java | 2 +- .../org/wamblee/observer/package-info.java | 3 +- .../persistence/AbstractDetachable.java | 3 +- .../persistence/InMemoryDetachable.java | 7 +- .../wamblee/persistence/JpaDetachable.java | 33 ++--- .../wamblee/persistence/JpaMergeSupport.java | 3 +- .../org/wamblee/persistence/Persistent.java | 6 +- .../org/wamblee/persistence/package-info.java | 3 +- .../java/org/wamblee/reflection/Accessor.java | 21 ++-- .../wamblee/reflection/AnnotationUtils.java | 10 +- .../org/wamblee/reflection/FieldAccessor.java | 27 ++-- .../wamblee/reflection/ObjectTraversal.java | 42 ++++--- .../wamblee/reflection/PropertyAccessor.java | 29 +++-- .../wamblee/reflection/ReflectionUtils.java | 30 ++--- .../org/wamblee/reflection/package-info.java | 3 +- .../org/wamblee/xml/ClasspathUriResolver.java | 2 +- .../main/java/org/wamblee/xml/DomUtils.java | 5 +- .../java/org/wamblee/xml/XMLException.java | 2 +- .../java/org/wamblee/xml/XslTransformer.java | 4 +- .../java/org/wamblee/xml/package-info.java | 3 +- .../org/wamblee/cache/CachedObjectTest.java | 43 ++++--- .../org/wamblee/cache/ComputedValueTest.java | 11 +- .../collections/CollectionFilterTest.java | 2 +- .../concurrency/AbstractLockTestCase.java | 4 +- .../org/wamblee/concurrency/JvmLockTest.java | 2 +- .../concurrency/ReadWriteLockTest.java | 2 +- .../wamblee/conditions/AndConditionTest.java | 2 +- .../conditions/GreaterThanCondition.java | 2 +- .../wamblee/conditions/LessThanCondition.java | 2 +- .../wamblee/conditions/OrConditionTest.java | 2 +- .../PropertyRegexConditionTest.java | 6 +- .../java/org/wamblee/conditions/TestBean.java | 2 +- .../general/LookupProxyFactoryTest.java | 40 +++--- .../org/wamblee/general/ObjectElemTest.java | 24 ++-- .../general/ObjectSerializationUtilsTest.java | 4 +- .../ThreadSpecificProxyFactoryTest.java | 22 ++-- .../org/wamblee/general/ValueHolderTest.java | 22 ++-- .../org/wamblee/io/ClassPathResourceTest.java | 2 +- .../org/wamblee/io/DirectoryMonitorTest.java | 2 +- .../io/DirectoryMonitorTestProgram.java | 5 +- .../java/org/wamblee/io/FileResourceTest.java | 2 +- .../java/org/wamblee/io/FileSystemUtils.java | 10 +- .../org/wamblee/io/StreamResourceTest.java | 2 +- .../test/java/org/wamblee/io/TestData.java | 2 +- .../java/org/wamblee/io/TestResource.java | 2 +- .../java/org/wamblee/ioc/BeanKernelTest.java | 3 +- .../test/java/org/wamblee/ioc/PairTest.java | 2 +- .../java/org/wamblee/ioc/TestBeanFactory.java | 3 +- .../org/wamblee/observer/ObservableTest.java | 2 +- .../persistence/AbstractDetachableTest.java | 49 ++++---- .../persistence/JpaDetachableTest.java | 34 ++--- .../persistence/JpaMergeSupportTest.java | 69 ++++++----- .../persistence/PersistentFactoryTest.java | 116 ++++++++++-------- .../reflection/AnnotationUtilsTest.java | 83 +++++++------ .../reflection/ObjectTraversalTest.java | 106 ++++++++-------- .../reflection/ReflectionUtilsTest.java | 25 ++-- .../java/org/wamblee/test/AssertionUtils.java | 11 +- .../java/org/wamblee/test/EventTracker.java | 5 +- .../java/org/wamblee/test/TimingUtils.java | 2 +- .../wamblee/xml/ClasspathUriResolverTest.java | 6 +- .../test/java/org/wamblee/xml/XmlUtils.java | 2 +- .../org/wamblee/xml/XslTransformerTest.java | 5 +- 97 files changed, 704 insertions(+), 618 deletions(-) diff --git a/support/general/src/main/java/org/wamblee/classloading/ClassLoaderUtils.java b/support/general/src/main/java/org/wamblee/classloading/ClassLoaderUtils.java index 74d177f6..ce962c9f 100644 --- a/support/general/src/main/java/org/wamblee/classloading/ClassLoaderUtils.java +++ b/support/general/src/main/java/org/wamblee/classloading/ClassLoaderUtils.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.classloading; import java.io.File; @@ -24,7 +24,7 @@ import java.net.URL; import java.net.URLClassLoader; /** - * Utility for adding jars to the system class loader. + * Utility for adding jars to the system class loader. */ public class ClassLoaderUtils { // No logging in this class to keep the required class libraries diff --git a/support/general/src/main/java/org/wamblee/classloading/package-info.java b/support/general/src/main/java/org/wamblee/classloading/package-info.java index 585ce695..3138af52 100644 --- a/support/general/src/main/java/org/wamblee/classloading/package-info.java +++ b/support/general/src/main/java/org/wamblee/classloading/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * Various classloading utilities. */ diff --git a/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java b/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java index 95155fa1..cbf9e47a 100644 --- a/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java +++ b/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.collections; import org.wamblee.conditions.Condition; @@ -20,7 +20,7 @@ import org.wamblee.conditions.Condition; import java.util.Collection; /** - * Collection filter for filtering collections based on a certain condition. + * Collection filter for filtering collections based on a certain condition. * * @author Erik Brakkee */ diff --git a/support/general/src/main/java/org/wamblee/collections/package-info.java b/support/general/src/main/java/org/wamblee/collections/package-info.java index c945de81..405c4f02 100644 --- a/support/general/src/main/java/org/wamblee/collections/package-info.java +++ b/support/general/src/main/java/org/wamblee/collections/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * Collection utilities. */ diff --git a/support/general/src/main/java/org/wamblee/concurrency/JvmLock.java b/support/general/src/main/java/org/wamblee/concurrency/JvmLock.java index c7164004..08b02e9a 100644 --- a/support/general/src/main/java/org/wamblee/concurrency/JvmLock.java +++ b/support/general/src/main/java/org/wamblee/concurrency/JvmLock.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.concurrency; import java.util.concurrent.locks.ReentrantLock; diff --git a/support/general/src/main/java/org/wamblee/concurrency/Lock.java b/support/general/src/main/java/org/wamblee/concurrency/Lock.java index ac8eee4b..a43a081b 100644 --- a/support/general/src/main/java/org/wamblee/concurrency/Lock.java +++ b/support/general/src/main/java/org/wamblee/concurrency/Lock.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.concurrency; /** diff --git a/support/general/src/main/java/org/wamblee/concurrency/ReadWriteLock.java b/support/general/src/main/java/org/wamblee/concurrency/ReadWriteLock.java index 8c5abfc4..8afe55ec 100644 --- a/support/general/src/main/java/org/wamblee/concurrency/ReadWriteLock.java +++ b/support/general/src/main/java/org/wamblee/concurrency/ReadWriteLock.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.concurrency; import java.util.HashSet; @@ -23,9 +23,9 @@ import java.util.HashSet; * robustness and simplicity. Users of this class should not synchronize on * objects of this class. * - * This class was originally developed for a Java developer certification. - * It is deprecated now and {@link java.util.concurrent.locks.ReadWriteLock} should be used - * instead. + * This class was originally developed for a Java developer certification. It is + * deprecated now and {@link java.util.concurrent.locks.ReadWriteLock} should be + * used instead. */ @Deprecated public class ReadWriteLock { diff --git a/support/general/src/main/java/org/wamblee/concurrency/package-info.java b/support/general/src/main/java/org/wamblee/concurrency/package-info.java index fe49e18c..68507296 100644 --- a/support/general/src/main/java/org/wamblee/concurrency/package-info.java +++ b/support/general/src/main/java/org/wamblee/concurrency/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * This package provides utilities for dealing with concurrency. * diff --git a/support/general/src/main/java/org/wamblee/conditions/AndCondition.java b/support/general/src/main/java/org/wamblee/conditions/AndCondition.java index 0964b941..6618c659 100644 --- a/support/general/src/main/java/org/wamblee/conditions/AndCondition.java +++ b/support/general/src/main/java/org/wamblee/conditions/AndCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; import java.util.ArrayList; diff --git a/support/general/src/main/java/org/wamblee/conditions/Condition.java b/support/general/src/main/java/org/wamblee/conditions/Condition.java index 8e3de50c..975a3b6d 100644 --- a/support/general/src/main/java/org/wamblee/conditions/Condition.java +++ b/support/general/src/main/java/org/wamblee/conditions/Condition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; /** diff --git a/support/general/src/main/java/org/wamblee/conditions/FixedCondition.java b/support/general/src/main/java/org/wamblee/conditions/FixedCondition.java index 72840b08..18b8d16e 100644 --- a/support/general/src/main/java/org/wamblee/conditions/FixedCondition.java +++ b/support/general/src/main/java/org/wamblee/conditions/FixedCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; /** diff --git a/support/general/src/main/java/org/wamblee/conditions/OrCondition.java b/support/general/src/main/java/org/wamblee/conditions/OrCondition.java index 3d645ad6..d1a12a8d 100644 --- a/support/general/src/main/java/org/wamblee/conditions/OrCondition.java +++ b/support/general/src/main/java/org/wamblee/conditions/OrCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; import java.util.ArrayList; diff --git a/support/general/src/main/java/org/wamblee/conditions/PropertyRegexCondition.java b/support/general/src/main/java/org/wamblee/conditions/PropertyRegexCondition.java index 3b9cfef4..7300e460 100644 --- a/support/general/src/main/java/org/wamblee/conditions/PropertyRegexCondition.java +++ b/support/general/src/main/java/org/wamblee/conditions/PropertyRegexCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; import java.lang.reflect.InvocationTargetException; @@ -21,9 +21,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * Condition to check whether a given property of an object matches a certain regular - * expression. The method name to use of the object passed in to - * {@link #matches(Object)} is obtained using the Javabean conventions. + * Condition to check whether a given property of an object matches a certain + * regular expression. The method name to use of the object passed in to + * {@link #matches(Object)} is obtained using the Javabean conventions. * * @author Erik Brakkee * @@ -69,7 +69,8 @@ public class PropertyRegexCondition implements Condition { */ public boolean matches(T aObject) { try { - String readerName = "get" + property.substring(0, 1).toUpperCase() + property.substring(1); + String readerName = "get" + property.substring(0, 1).toUpperCase() + + property.substring(1); Method reader = aObject.getClass().getMethod(readerName); String value = reader.invoke(aObject) + ""; @@ -86,6 +87,6 @@ public class PropertyRegexCondition implements Condition { throw new RuntimeException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new RuntimeException(e.getMessage(), e); - } + } } } diff --git a/support/general/src/main/java/org/wamblee/conditions/package-info.java b/support/general/src/main/java/org/wamblee/conditions/package-info.java index adc8d148..bbab4b8b 100644 --- a/support/general/src/main/java/org/wamblee/conditions/package-info.java +++ b/support/general/src/main/java/org/wamblee/conditions/package-info.java @@ -17,3 +17,4 @@ * This package provides some basic support classes for checking boolean conditions on objects. */ package org.wamblee.conditions; + diff --git a/support/general/src/main/java/org/wamblee/general/LookupProxyFactory.java b/support/general/src/main/java/org/wamblee/general/LookupProxyFactory.java index 286e5f56..a703e2bf 100644 --- a/support/general/src/main/java/org/wamblee/general/LookupProxyFactory.java +++ b/support/general/src/main/java/org/wamblee/general/LookupProxyFactory.java @@ -34,23 +34,25 @@ import javax.naming.NamingException; * */ public class LookupProxyFactory { - + /** - * Interface to lookup the object to delegate to. + * Interface to lookup the object to delegate to. * * @author Erik Brakkee */ - public static interface Lookup extends Serializable { - /** - * Looks up the object. - * @return Object (non-null) - * @throws Any exception in case the object cannot be found. - */ - Object lookup() throws Exception; + public static interface Lookup extends Serializable { + /** + * Looks up the object. + * + * @return Object (non-null) + * @throws Any + * exception in case the object cannot be found. + */ + Object lookup() throws Exception; } - + /** - * Exception thrown in case an object cannot be retrieved from JNDI. + * Exception thrown in case an object cannot be retrieved from JNDI. * * @author Erik Brakkee */ @@ -65,23 +67,26 @@ public class LookupProxyFactory { } /** - * Invocation handler that does a lookup in JNDI and invokes the method on the - * object it found. + * Invocation handler that does a lookup in JNDI and invokes the method on + * the object it found. * * @author Erik Brakkee */ - private static class LookupInvocationHandler implements InvocationHandler, Serializable { - - private Class clazz; - private Lookup lookup; - + private static class LookupInvocationHandler implements + InvocationHandler, Serializable { + + private Class clazz; + private Lookup lookup; + /** - * Constructs the invocation handler. - * @param aLookup Lookup class. + * Constructs the invocation handler. + * + * @param aLookup + * Lookup class. */ public LookupInvocationHandler(Class aClass, Lookup aLookup) { clazz = aClass; - lookup = aLookup; + lookup = aLookup; } @Override @@ -94,15 +99,15 @@ public class LookupProxyFactory { try { svcObj = lookup.lookup(); } catch (Exception e) { - throw new LookupException( - "Error looking up object", e); + throw new LookupException("Error looking up object", e); } if (svcObj == null) { throw new LookupException("Object is null"); } if (!clazz.isInstance(svcObj)) { - throw new LookupException("Object '" + svcObj + "' is not of type " + clazz.getName() + - " but of type " + svcObj.getClass().getName()); + throw new LookupException("Object '" + svcObj + + "' is not of type " + clazz.getName() + " but of type " + + svcObj.getClass().getName()); } T svc = (T) svcObj; try { @@ -121,7 +126,8 @@ public class LookupProxyFactory { * * @param aClass * Interface class of the service to proxy. - * @param aJndi JNDI name of the object to lookup. + * @param aJndi + * JNDI name of the object to lookup. * */ public LookupProxyFactory(Class aClass, Lookup aLookup) { @@ -130,15 +136,15 @@ public class LookupProxyFactory { " is not an interface"); } clazz = aClass; - lookup = aLookup; + lookup = aLookup; } /** * Gets the proxy that delegates to the thread-specific instance set by * {@link #set(Object)} * - * When at runtime the proxy cannot find lookup the object in JNDI, it - * throws {@link LookupException}. + * When at runtime the proxy cannot find lookup the object in JNDI, it + * throws {@link LookupException}. * * @return Proxy. */ diff --git a/support/general/src/main/java/org/wamblee/general/ObjectElem.java b/support/general/src/main/java/org/wamblee/general/ObjectElem.java index dbc9fed8..66743a3a 100644 --- a/support/general/src/main/java/org/wamblee/general/ObjectElem.java +++ b/support/general/src/main/java/org/wamblee/general/ObjectElem.java @@ -16,18 +16,20 @@ package org.wamblee.general; /** - * This class provided an equality operation based on the object reference - * of the wrapped object. This is required because we cannto assume that the - * equals operation has any meaning for different types of persistent - * objects. This allows us to use the standard collection classes for - * detecting cyclic dependences and avoiding recursion. + * This class provided an equality operation based on the object reference of + * the wrapped object. This is required because we cannto assume that the equals + * operation has any meaning for different types of persistent objects. This + * allows us to use the standard collection classes for detecting cyclic + * dependences and avoiding recursion. */ public class ObjectElem { private Object object; /** * Constructs the wrapper. - * @param aObject Object. + * + * @param aObject + * Object. */ public ObjectElem(Object aObject) { object = aObject; diff --git a/support/general/src/main/java/org/wamblee/general/ObjectSerializationUtils.java b/support/general/src/main/java/org/wamblee/general/ObjectSerializationUtils.java index 1b820f03..db8534a9 100644 --- a/support/general/src/main/java/org/wamblee/general/ObjectSerializationUtils.java +++ b/support/general/src/main/java/org/wamblee/general/ObjectSerializationUtils.java @@ -29,31 +29,38 @@ import java.io.ObjectOutputStream; public class ObjectSerializationUtils { /** - * Serialize an object to a byte array. - * @param aObject Object ot serialize. + * Serialize an object to a byte array. + * + * @param aObject + * Object ot serialize. * @return Byte array. * @throws IOException */ public static byte[] serialize(Object aObject) throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); os.writeObject(aObject); os.flush(); return bos.toByteArray(); } - + /** - * Desrializes an object from a byte array. - * @param Type of the object. - * @param aData Serialized data. - * @param aType Type of the object. - * @return Object. + * Desrializes an object from a byte array. + * + * @param + * Type of the object. + * @param aData + * Serialized data. + * @param aType + * Type of the object. + * @return Object. * @throws IOException * @throws ClassNotFoundException */ - public static T deserialize(byte[] aData, Class aType) throws IOException, ClassNotFoundException { - ByteArrayInputStream bis = new ByteArrayInputStream(aData); - ObjectInputStream os = new ObjectInputStream(bis); - return (T)os.readObject(); + public static T deserialize(byte[] aData, Class aType) + throws IOException, ClassNotFoundException { + ByteArrayInputStream bis = new ByteArrayInputStream(aData); + ObjectInputStream os = new ObjectInputStream(bis); + return (T) os.readObject(); } } diff --git a/support/general/src/main/java/org/wamblee/general/Pair.java b/support/general/src/main/java/org/wamblee/general/Pair.java index 4ea88079..dd78180f 100644 --- a/support/general/src/main/java/org/wamblee/general/Pair.java +++ b/support/general/src/main/java/org/wamblee/general/Pair.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.general; /** diff --git a/support/general/src/main/java/org/wamblee/general/ThreadSpecificInvocationHandler.java b/support/general/src/main/java/org/wamblee/general/ThreadSpecificInvocationHandler.java index 49c2e177..c7c9952b 100644 --- a/support/general/src/main/java/org/wamblee/general/ThreadSpecificInvocationHandler.java +++ b/support/general/src/main/java/org/wamblee/general/ThreadSpecificInvocationHandler.java @@ -24,39 +24,43 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; /** - * Invocation handler for thread-specific proxies. + * Invocation handler for thread-specific proxies. * * @author Erik Brakkee - * + * * @param */ -class ThreadSpecificInvocationHandler implements InvocationHandler, Serializable { - +class ThreadSpecificInvocationHandler implements InvocationHandler, + Serializable { + /** - * We store a map of unique ids of invocation handlers to thread local storage of the - * service. In this way, serialiability of the generated proxy is obtained (required by - * framweorks such as wicket). Also, different factories will still be separate and never - * use the same threadlocal storage. + * We store a map of unique ids of invocation handlers to thread local + * storage of the service. In this way, serialiability of the generated + * proxy is obtained (required by framweorks such as wicket). Also, + * different factories will still be separate and never use the same + * threadlocal storage. */ - private static Map STORAGE = initializeThreadLocal(); - + private static Map STORAGE = initializeThreadLocal(); + private static AtomicInteger COUNTER = new AtomicInteger(); - + private static Map initializeThreadLocal() { - Map map = new ConcurrentHashMap(); + Map map = new ConcurrentHashMap(); return map; } - - private int id; - private Class clazz; - + private int id; + private Class clazz; + /** - * Constructs the handler. - * @param aSvc Thread local for the service. - * @param aClass Service interface class. + * Constructs the handler. + * + * @param aSvc + * Thread local for the service. + * @param aClass + * Service interface class. */ - public ThreadSpecificInvocationHandler(ThreadLocal aSvc, Class aClass) { + public ThreadSpecificInvocationHandler(ThreadLocal aSvc, Class aClass) { id = COUNTER.incrementAndGet(); clazz = aClass; STORAGE.put(id, aSvc); @@ -68,8 +72,9 @@ class ThreadSpecificInvocationHandler implements InvocationHandler, Serializa ThreadLocal local = STORAGE.get(id); T actualSvc = local.get(); - if ( aMethod.getName().equals("toString") && actualSvc == null) { - return "Thread-specific proxy for '" + clazz.getName() + "' id = " + id; + if (aMethod.getName().equals("toString") && actualSvc == null) { + return "Thread-specific proxy for '" + clazz.getName() + "' id = " + + id; } try { return aMethod.invoke(actualSvc, aArgs); diff --git a/support/general/src/main/java/org/wamblee/general/ThreadSpecificProxyFactory.java b/support/general/src/main/java/org/wamblee/general/ThreadSpecificProxyFactory.java index 81127009..db51ba1c 100644 --- a/support/general/src/main/java/org/wamblee/general/ThreadSpecificProxyFactory.java +++ b/support/general/src/main/java/org/wamblee/general/ThreadSpecificProxyFactory.java @@ -37,7 +37,7 @@ import java.lang.reflect.Proxy; * method can be passed at construction of an object that will be used by * multiple threads. *

- * + * *

* This class is mostly used by infrastructure code (utilities) and test tools. *

@@ -86,8 +86,8 @@ public class ThreadSpecificProxyFactory { } /** - * Constructs the factory with a callback to create thread-specific objects - * automatically. + * Constructs the factory with a callback to create thread-specific objects + * automatically. * * @param aClass * Interface class of the service to proxy. @@ -104,10 +104,10 @@ public class ThreadSpecificProxyFactory { svc = new ThreadLocal() { @Override protected T initialValue() { - if ( aCallback != null ) { + if (aCallback != null) { return aCallback.create(); } - return null; + return null; } }; clazz = aClass; diff --git a/support/general/src/main/java/org/wamblee/general/ValueHolder.java b/support/general/src/main/java/org/wamblee/general/ValueHolder.java index 1ec74feb..69ab7b6c 100644 --- a/support/general/src/main/java/org/wamblee/general/ValueHolder.java +++ b/support/general/src/main/java/org/wamblee/general/ValueHolder.java @@ -16,41 +16,45 @@ package org.wamblee.general; /** - * Object that holds a value of some type. This can be used where a mutable final value would - * be preferred. + * Object that holds a value of some type. This can be used where a mutable + * final value would be preferred. * * @author Erik Brakkee - * + * */ public class ValueHolder { - private T value; - + private T value; + /** - * Constructs with null value. + * Constructs with null value. */ - public ValueHolder() { - value = null; + public ValueHolder() { + value = null; } - + /** - * Constructs with given value. - * @param aValue Value. + * Constructs with given value. + * + * @param aValue + * Value. */ - public ValueHolder(T aValue) { - value = aValue; + public ValueHolder(T aValue) { + value = aValue; } - + /** - * @return Current value. + * @return Current value. */ public T getValue() { return value; } - + /** - * Set the value. - * @param aValue New value. + * Set the value. + * + * @param aValue + * New value. */ public void setValue(T aValue) { value = aValue; diff --git a/support/general/src/main/java/org/wamblee/io/ClassPathResource.java b/support/general/src/main/java/org/wamblee/io/ClassPathResource.java index 5cd67853..b3407871 100644 --- a/support/general/src/main/java/org/wamblee/io/ClassPathResource.java +++ b/support/general/src/main/java/org/wamblee/io/ClassPathResource.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.IOException; diff --git a/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java b/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java index a258f098..685a0cb5 100644 --- a/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java +++ b/support/general/src/main/java/org/wamblee/io/DirectoryMonitor.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; - import java.io.File; import java.io.FileFilter; @@ -27,14 +26,14 @@ import java.util.Set; import java.util.logging.Logger; /** - * Monitors a directory for changes. - * The currernt implementation only checks files not directories and does not check for - * modifications in subdirectories. + * Monitors a directory for changes. The currernt implementation only checks + * files not directories and does not check for modifications in subdirectories. * * @author Erik Brakkee */ public class DirectoryMonitor { - private static final Logger LOG = Logger.getLogger(DirectoryMonitor.class.getName()); + private static final Logger LOG = Logger.getLogger(DirectoryMonitor.class + .getName()); private File directory; @@ -112,24 +111,27 @@ public class DirectoryMonitor { } /** - * Listener interface to be provided by users of the directory monitor to get notified of - * changes. + * Listener interface to be provided by users of the directory monitor to + * get notified of changes. * * @author Erik Brakkee */ public static interface Listener { /** - * @param aFile File that has changed. + * @param aFile + * File that has changed. */ void fileChanged(File aFile); /** - * @param aFile File that was created. + * @param aFile + * File that was created. */ void fileCreated(File aFile); /** - * @param aFile File that was deleted. + * @param aFile + * File that was deleted. */ void fileDeleted(File aFile); } diff --git a/support/general/src/main/java/org/wamblee/io/FileResource.java b/support/general/src/main/java/org/wamblee/io/FileResource.java index f62ecc8a..49f040f1 100644 --- a/support/general/src/main/java/org/wamblee/io/FileResource.java +++ b/support/general/src/main/java/org/wamblee/io/FileResource.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.BufferedInputStream; diff --git a/support/general/src/main/java/org/wamblee/io/InputResource.java b/support/general/src/main/java/org/wamblee/io/InputResource.java index 58d61f08..9194d773 100644 --- a/support/general/src/main/java/org/wamblee/io/InputResource.java +++ b/support/general/src/main/java/org/wamblee/io/InputResource.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.IOException; diff --git a/support/general/src/main/java/org/wamblee/io/RegexFilenameFilter.java b/support/general/src/main/java/org/wamblee/io/RegexFilenameFilter.java index 89e3758d..311882a6 100644 --- a/support/general/src/main/java/org/wamblee/io/RegexFilenameFilter.java +++ b/support/general/src/main/java/org/wamblee/io/RegexFilenameFilter.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.File; @@ -20,18 +20,21 @@ import java.io.FileFilter; import java.util.regex.Pattern; /** - * Filename filter based on regular expressions. + * Filename filter based on regular expressions. + * * @author Erik Brakkee */ public class RegexFilenameFilter implements FileFilter { - - private Pattern pattern; - + + private Pattern pattern; + /** - * Constructs the filter. - * @param aRegex Regular expression to filter on. + * Constructs the filter. + * + * @param aRegex + * Regular expression to filter on. */ - public RegexFilenameFilter(String aRegex) { + public RegexFilenameFilter(String aRegex) { pattern = Pattern.compile(aRegex); } diff --git a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java index c08f001d..399d0030 100644 --- a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java +++ b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.BufferedReader; @@ -32,7 +32,8 @@ import java.util.logging.Logger; * @version $Revision$ */ public class SimpleProcess { - private static final Logger LOG = Logger.getLogger(SimpleProcess.class.getName()); + private static final Logger LOG = Logger.getLogger(SimpleProcess.class + .getName()); private File directory; @@ -137,8 +138,11 @@ public class SimpleProcess { aReaderThread.join(); } catch (InterruptedException e) { LOG - .log(Level.WARNING, this + - ": error waiting for output stream reader of process to finish", e); + .log( + Level.WARNING, + this + + ": error waiting for output stream reader of process to finish", + e); } } @@ -166,7 +170,8 @@ public class SimpleProcess { try { br.close(); } catch (IOException e) { - LOG.log(Level.WARNING, "Error closing stream " + aPrefix, e); + LOG.log(Level.WARNING, "Error closing stream " + + aPrefix, e); } } } diff --git a/support/general/src/main/java/org/wamblee/io/StreamResource.java b/support/general/src/main/java/org/wamblee/io/StreamResource.java index 9aae3d32..00c2f08b 100644 --- a/support/general/src/main/java/org/wamblee/io/StreamResource.java +++ b/support/general/src/main/java/org/wamblee/io/StreamResource.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.IOException; diff --git a/support/general/src/main/java/org/wamblee/io/package-info.java b/support/general/src/main/java/org/wamblee/io/package-info.java index fd7ba73a..81da4350 100644 --- a/support/general/src/main/java/org/wamblee/io/package-info.java +++ b/support/general/src/main/java/org/wamblee/io/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * This package provides several support utilities for IO related functionality. * The main classes are: @@ -25,3 +25,4 @@ * */ package org.wamblee.io; + diff --git a/support/general/src/main/java/org/wamblee/ioc/BeanFactory.java b/support/general/src/main/java/org/wamblee/ioc/BeanFactory.java index 8680949e..bc444536 100644 --- a/support/general/src/main/java/org/wamblee/ioc/BeanFactory.java +++ b/support/general/src/main/java/org/wamblee/ioc/BeanFactory.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.ioc; /** diff --git a/support/general/src/main/java/org/wamblee/ioc/BeanFactoryException.java b/support/general/src/main/java/org/wamblee/ioc/BeanFactoryException.java index e56c1a91..78884627 100644 --- a/support/general/src/main/java/org/wamblee/ioc/BeanFactoryException.java +++ b/support/general/src/main/java/org/wamblee/ioc/BeanFactoryException.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.ioc; /** diff --git a/support/general/src/main/java/org/wamblee/ioc/package-info.java b/support/general/src/main/java/org/wamblee/ioc/package-info.java index af3d8674..e77cd85e 100644 --- a/support/general/src/main/java/org/wamblee/ioc/package-info.java +++ b/support/general/src/main/java/org/wamblee/ioc/package-info.java @@ -12,8 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * Several utilities for abstracting the IOC container which is used. */ package org.wamblee.ioc; + diff --git a/support/general/src/main/java/org/wamblee/observer/DefaultObserverNotifier.java b/support/general/src/main/java/org/wamblee/observer/DefaultObserverNotifier.java index e6ba0134..e46505ab 100644 --- a/support/general/src/main/java/org/wamblee/observer/DefaultObserverNotifier.java +++ b/support/general/src/main/java/org/wamblee/observer/DefaultObserverNotifier.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.observer; /** diff --git a/support/general/src/main/java/org/wamblee/observer/Observable.java b/support/general/src/main/java/org/wamblee/observer/Observable.java index dd18e5de..f31ba0dc 100644 --- a/support/general/src/main/java/org/wamblee/observer/Observable.java +++ b/support/general/src/main/java/org/wamblee/observer/Observable.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.observer; import java.util.ArrayList; diff --git a/support/general/src/main/java/org/wamblee/observer/Observer.java b/support/general/src/main/java/org/wamblee/observer/Observer.java index bca6436d..cc83f228 100644 --- a/support/general/src/main/java/org/wamblee/observer/Observer.java +++ b/support/general/src/main/java/org/wamblee/observer/Observer.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.observer; /** diff --git a/support/general/src/main/java/org/wamblee/observer/ObserverNotifier.java b/support/general/src/main/java/org/wamblee/observer/ObserverNotifier.java index e0ffd926..5c26bad6 100644 --- a/support/general/src/main/java/org/wamblee/observer/ObserverNotifier.java +++ b/support/general/src/main/java/org/wamblee/observer/ObserverNotifier.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.observer; /** diff --git a/support/general/src/main/java/org/wamblee/observer/package-info.java b/support/general/src/main/java/org/wamblee/observer/package-info.java index 41ffdfb0..60c96f0f 100644 --- a/support/general/src/main/java/org/wamblee/observer/package-info.java +++ b/support/general/src/main/java/org/wamblee/observer/package-info.java @@ -12,8 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * Support for the observer pattern. */ package org.wamblee.observer; + diff --git a/support/general/src/main/java/org/wamblee/persistence/AbstractDetachable.java b/support/general/src/main/java/org/wamblee/persistence/AbstractDetachable.java index 1e7461bf..cb96d293 100644 --- a/support/general/src/main/java/org/wamblee/persistence/AbstractDetachable.java +++ b/support/general/src/main/java/org/wamblee/persistence/AbstractDetachable.java @@ -39,8 +39,7 @@ public abstract class AbstractDetachable implements Detachable { */ protected AbstractDetachable(T aObject) { if (aObject == null) { - throw new IllegalArgumentException("Object '" + aObject + - "' is null"); + throw new IllegalArgumentException("Object is null"); } object = aObject; reference = null; diff --git a/support/general/src/main/java/org/wamblee/persistence/InMemoryDetachable.java b/support/general/src/main/java/org/wamblee/persistence/InMemoryDetachable.java index f8ba0c33..d89ee108 100644 --- a/support/general/src/main/java/org/wamblee/persistence/InMemoryDetachable.java +++ b/support/general/src/main/java/org/wamblee/persistence/InMemoryDetachable.java @@ -16,8 +16,8 @@ package org.wamblee.persistence; /** - * Inmemory detachable that simply returns the object passed in. Typiocally used for testing. - * It does nothing at detach. + * Inmemory detachable that simply returns the object passed in. Typiocally used + * for testing. It does nothing at detach. * * @param * Type of the detachable. @@ -28,6 +28,7 @@ public class InMemoryDetachable implements Detachable { /** * Constructs the detachable. + * * @param aObject */ public InMemoryDetachable(T aObject) { @@ -36,6 +37,7 @@ public class InMemoryDetachable implements Detachable { /* * (non-Javadoc) + * * @see org.wamblee.persistence.Detachable#detach() */ public void detach() { @@ -44,6 +46,7 @@ public class InMemoryDetachable implements Detachable { /* * (non-Javadoc) + * * @see org.wamblee.persistence.Detachable#get() */ public T get() { diff --git a/support/general/src/main/java/org/wamblee/persistence/JpaDetachable.java b/support/general/src/main/java/org/wamblee/persistence/JpaDetachable.java index ac0912f8..04d60e84 100644 --- a/support/general/src/main/java/org/wamblee/persistence/JpaDetachable.java +++ b/support/general/src/main/java/org/wamblee/persistence/JpaDetachable.java @@ -20,36 +20,41 @@ import java.io.Serializable; import javax.persistence.EntityManager; /** - * Detachable JPA entity. + * Detachable JPA entity. * * @author Erik Brakkee - * - * @param Entity type. + * + * @param + * Entity type. */ public class JpaDetachable extends AbstractDetachable { - - private EntityManager entityManager; - private Class entityType; - + + private EntityManager entityManager; + private Class entityType; + /** - * Constructs the detachable. - * @param aEntity Entity. + * Constructs the detachable. + * + * @param aEntity + * Entity. */ public JpaDetachable(EntityManager aEntityManager, T aEntity) { super(aEntity); entityManager = aEntityManager; - entityType = (Class)aEntity.getClass(); + entityType = (Class) aEntity.getClass(); } - + /* * (non-Javadoc) - * @see org.wamblee.persistence.AbstractDetachable#getReference(java.lang.Object) + * + * @see + * org.wamblee.persistence.AbstractDetachable#getReference(java.lang.Object) */ protected Serializable getReference(T aObject) { Persistent persistent = PersistentFactory.create(aObject); - return persistent.getPrimaryKey(); + return persistent.getPrimaryKey(); } - + @Override protected T load(Serializable aReference) { return entityManager.find(entityType, aReference); diff --git a/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java b/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java index f82f8255..9f5a87dc 100644 --- a/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java +++ b/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java @@ -54,7 +54,8 @@ import org.wamblee.reflection.ReflectionUtils; * @author Erik Brakkee */ public class JpaMergeSupport { - private static final Logger LOG = Logger.getLogger(JpaMergeSupport.class.getName()); + private static final Logger LOG = Logger.getLogger(JpaMergeSupport.class + .getName()); /** * Constructs the object. diff --git a/support/general/src/main/java/org/wamblee/persistence/Persistent.java b/support/general/src/main/java/org/wamblee/persistence/Persistent.java index aadd304f..e573b483 100644 --- a/support/general/src/main/java/org/wamblee/persistence/Persistent.java +++ b/support/general/src/main/java/org/wamblee/persistence/Persistent.java @@ -12,14 +12,14 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.persistence; import java.io.Serializable; /** - * Interface for persistent objects. This defines a generic interface for accessing - * primary key and version of entities. + * Interface for persistent objects. This defines a generic interface for + * accessing primary key and version of entities. */ public interface Persistent { /** diff --git a/support/general/src/main/java/org/wamblee/persistence/package-info.java b/support/general/src/main/java/org/wamblee/persistence/package-info.java index 0051d158..0f6d824c 100644 --- a/support/general/src/main/java/org/wamblee/persistence/package-info.java +++ b/support/general/src/main/java/org/wamblee/persistence/package-info.java @@ -12,8 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * Utilities for (JPA) persistence. */ package org.wamblee.persistence; + diff --git a/support/general/src/main/java/org/wamblee/reflection/Accessor.java b/support/general/src/main/java/org/wamblee/reflection/Accessor.java index f3a4bd50..afdfcd03 100644 --- a/support/general/src/main/java/org/wamblee/reflection/Accessor.java +++ b/support/general/src/main/java/org/wamblee/reflection/Accessor.java @@ -16,31 +16,36 @@ package org.wamblee.reflection; /** - * Abstraction for accessing fields or properties of an object. + * Abstraction for accessing fields or properties of an object. * * @author Erik Brakkee - * + * * @param */ public interface Accessor { /** - * Sets the value. - * @param aObject Object. - * @param aValue Value. + * Sets the value. + * + * @param aObject + * Object. + * @param aValue + * Value. */ void set(Object aObject, T aValue); /** * Gets the value. - * @param aObject Object + * + * @param aObject + * Object * @return Value */ T get(Object aObject); - + /** * Gets the type of the value. + * * @return */ Class getType(); } - diff --git a/support/general/src/main/java/org/wamblee/reflection/AnnotationUtils.java b/support/general/src/main/java/org/wamblee/reflection/AnnotationUtils.java index dad07b5f..3dd4d3ef 100644 --- a/support/general/src/main/java/org/wamblee/reflection/AnnotationUtils.java +++ b/support/general/src/main/java/org/wamblee/reflection/AnnotationUtils.java @@ -22,10 +22,10 @@ import java.util.ArrayList; import java.util.List; /** - * Utlities for working with annotations. + * Utlities for working with annotations. * * @author Erik Brakkee - * + * */ public class AnnotationUtils { @@ -36,12 +36,12 @@ public class AnnotationUtils { * Class to analyse. * @param aAnnotation * Annotation that must be present. - * @return List of accessors. Empty list is returned if no match is found. + * @return List of accessors. Empty list is returned if no match is found. */ public static List analyse(Class aClass, Class aAnnotation) { - List result = new ArrayList(); - + List result = new ArrayList(); + List fields = ReflectionUtils.getAllFields(aClass); for (Field field : fields) { if (field.isAnnotationPresent(aAnnotation)) { diff --git a/support/general/src/main/java/org/wamblee/reflection/FieldAccessor.java b/support/general/src/main/java/org/wamblee/reflection/FieldAccessor.java index bbc0a437..1df4169f 100644 --- a/support/general/src/main/java/org/wamblee/reflection/FieldAccessor.java +++ b/support/general/src/main/java/org/wamblee/reflection/FieldAccessor.java @@ -17,20 +17,22 @@ package org.wamblee.reflection; import java.lang.reflect.Field; - /** - * Utility for interfacing to a field of an object. + * Utility for interfacing to a field of an object. * * @author Erik Brakkee - * - * @param Type of the field. + * + * @param + * Type of the field. */ public class FieldAccessor implements Accessor { private Field field; /** - * Constructs the accessor. - * @param aField Field. + * Constructs the accessor. + * + * @param aField + * Field. */ public FieldAccessor(Field aField) { field = aField; @@ -57,20 +59,21 @@ public class FieldAccessor implements Accessor { } /** - * Gets the field. - * @return Field. + * Gets the field. + * + * @return Field. */ public Field getField() { return field; } - + @Override public Class getType() { - return (Class)field.getType(); + return (Class) field.getType(); } - + @Override public String toString() { - return "fieldInjection(" + field + ")"; + return "fieldInjection(" + field + ")"; } } \ No newline at end of file diff --git a/support/general/src/main/java/org/wamblee/reflection/ObjectTraversal.java b/support/general/src/main/java/org/wamblee/reflection/ObjectTraversal.java index 7b63729e..9c51daa3 100644 --- a/support/general/src/main/java/org/wamblee/reflection/ObjectTraversal.java +++ b/support/general/src/main/java/org/wamblee/reflection/ObjectTraversal.java @@ -49,8 +49,9 @@ import org.wamblee.general.ObjectElem; * @author Erik Brakkee */ public class ObjectTraversal { - - public static final Logger LOGGER = Logger.getLogger(ObjectTraversal.class.getName()); + + public static final Logger LOGGER = Logger.getLogger(ObjectTraversal.class + .getName()); /** * Visitor interface to be implemented for object traversal. @@ -157,10 +158,10 @@ public class ObjectTraversal { public void addExcludedObject(Object aObject) { excluded.add(new ObjectElem(aObject)); } - - private String indent() { + + private String indent() { StringBuffer buf = new StringBuffer(); - for (int i = 1; i < level; i++) { + for (int i = 1; i < level; i++) { buf.append(" "); } return buf.toString(); @@ -183,7 +184,7 @@ public class ObjectTraversal { if (alreadyProcessed(aObject)) { return; } - if ( LOGGER.isLoggable(Level.FINEST)) { + if (LOGGER.isLoggable(Level.FINEST)) { level++; LOGGER.finest(indent() + "obj: " + aObject); } @@ -225,8 +226,9 @@ public class ObjectTraversal { getter.getReturnType() != Void.class) { if (visitor.mustVisit(getter)) { - if ( LOGGER.isLoggable(Level.FINEST)) { - LOGGER.finest(indent() + "method: " + getter.getName()); + if (LOGGER.isLoggable(Level.FINEST)) { + LOGGER + .finest(indent() + "method: " + getter.getName()); } acceptMethod(aObject, getter); } @@ -240,7 +242,7 @@ public class ObjectTraversal { if (!Modifier.isStatic(modifiers) && !Modifier.isFinal(modifiers)) { field.setAccessible(true); if (visitor.mustVisit(field)) { - if ( LOGGER.isLoggable(Level.FINEST)) { + if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest(indent() + "field: " + field.getName()); } acceptField(aObject, field); @@ -275,18 +277,18 @@ public class ObjectTraversal { } } - private void acceptPlainOrCollection(Object value) { - if (value instanceof Set) { - visitor.visitSet((Set) value); - processSet((Set) value); - } else if (value instanceof List) { - processList((List) value); - } else if (value instanceof Map) { - processMap((Map) value); - } else if (value.getClass().isArray()) { - processArray(value); + private void acceptPlainOrCollection(Object aValue) { + if (aValue instanceof Set) { + visitor.visitSet((Set) aValue); + processSet((Set) aValue); + } else if (aValue instanceof List) { + processList((List) aValue); + } else if (aValue instanceof Map) { + processMap((Map) aValue); + } else if (aValue.getClass().isArray()) { + processArray(aValue); } else { - accept(value); + accept(aValue); } } diff --git a/support/general/src/main/java/org/wamblee/reflection/PropertyAccessor.java b/support/general/src/main/java/org/wamblee/reflection/PropertyAccessor.java index 4bf968cf..3583dfcc 100644 --- a/support/general/src/main/java/org/wamblee/reflection/PropertyAccessor.java +++ b/support/general/src/main/java/org/wamblee/reflection/PropertyAccessor.java @@ -17,22 +17,25 @@ package org.wamblee.reflection; import java.lang.reflect.Method; - /** - * Accessing a property of an object. + * Accessing a property of an object. * * @author Erik Brakkee - * - * @param Type of the property. + * + * @param + * Type of the property. */ public class PropertyAccessor implements Accessor { private Method getter; private Method setter; /** - * Constructs the accessor. - * @param aGetter Getter method. - * @param aSetter Setter method. + * Constructs the accessor. + * + * @param aGetter + * Getter method. + * @param aSetter + * Setter method. */ public PropertyAccessor(Method aGetter, Method aSetter) { getter = aGetter; @@ -60,26 +63,26 @@ public class PropertyAccessor implements Accessor { } /** - * @return The getter. + * @return The getter. */ public Method getGetter() { return getter; } /** - * @return The setter. + * @return The setter. */ public Method getSetter() { return setter; } - + @Override public String toString() { - return "propertyInjection(" + getter + ", " + setter + ")"; + return "propertyInjection(" + getter + ", " + setter + ")"; } - + @Override public Class getType() { - return (Class)getter.getReturnType(); + return (Class) getter.getReturnType(); } } \ No newline at end of file diff --git a/support/general/src/main/java/org/wamblee/reflection/ReflectionUtils.java b/support/general/src/main/java/org/wamblee/reflection/ReflectionUtils.java index 0da2d1f2..b5cfb217 100644 --- a/support/general/src/main/java/org/wamblee/reflection/ReflectionUtils.java +++ b/support/general/src/main/java/org/wamblee/reflection/ReflectionUtils.java @@ -24,25 +24,20 @@ import java.util.List; import java.util.Map; /** - * Some utilities for reflection. + * Some utilities for reflection. * * @author Erik Brakkee */ public class ReflectionUtils { - - public static final List PRIMITIVE_WRAPPERS = - createPrimitiveWrappers(); - - private static final List createPrimitiveWrappers() { - Class[] vals = { - Boolean.class, Byte.class, Character.class, Short.class, Integer.class, Long.class, - Float.class, Double.class }; + + public static final List PRIMITIVE_WRAPPERS = createPrimitiveWrappers(); + + private static final List createPrimitiveWrappers() { + Class[] vals = { Boolean.class, Byte.class, Character.class, + Short.class, Integer.class, Long.class, Float.class, Double.class }; return Arrays.asList(vals); } - - - - + /** * Wraps a type by the corresponding wrapper type if it is a primitive type. * @@ -155,15 +150,16 @@ public class ReflectionUtils { getAllFields(superClass, aFound, aExcludedClasses); } } - + /** * Checks if a class is a primitive type or wrapper type. + * * @param aClass * @return */ - public static boolean isPrimitive(Class aClass) { - if ( aClass.isPrimitive()) { - return true; + public static boolean isPrimitive(Class aClass) { + if (aClass.isPrimitive()) { + return true; } return PRIMITIVE_WRAPPERS.contains(aClass); } diff --git a/support/general/src/main/java/org/wamblee/reflection/package-info.java b/support/general/src/main/java/org/wamblee/reflection/package-info.java index 3665c399..610d44d1 100644 --- a/support/general/src/main/java/org/wamblee/reflection/package-info.java +++ b/support/general/src/main/java/org/wamblee/reflection/package-info.java @@ -12,8 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * Utilities for reflection. */ package org.wamblee.reflection; + diff --git a/support/general/src/main/java/org/wamblee/xml/ClasspathUriResolver.java b/support/general/src/main/java/org/wamblee/xml/ClasspathUriResolver.java index 1d53d7dc..61212dc1 100644 --- a/support/general/src/main/java/org/wamblee/xml/ClasspathUriResolver.java +++ b/support/general/src/main/java/org/wamblee/xml/ClasspathUriResolver.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.xml; import org.wamblee.io.ClassPathResource; diff --git a/support/general/src/main/java/org/wamblee/xml/DomUtils.java b/support/general/src/main/java/org/wamblee/xml/DomUtils.java index 8c8128c4..0da97dd4 100644 --- a/support/general/src/main/java/org/wamblee/xml/DomUtils.java +++ b/support/general/src/main/java/org/wamblee/xml/DomUtils.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.xml; import org.apache.xml.serialize.OutputFormat; @@ -59,7 +59,8 @@ import javax.xml.validation.SchemaFactory; * @author Erik Brakkee */ public final class DomUtils { - private static final Logger LOG = Logger.getLogger(DomUtils.class.getName()); + private static final Logger LOG = Logger + .getLogger(DomUtils.class.getName()); /** * Disabled default constructor. diff --git a/support/general/src/main/java/org/wamblee/xml/XMLException.java b/support/general/src/main/java/org/wamblee/xml/XMLException.java index 1d54669e..ac4431a2 100644 --- a/support/general/src/main/java/org/wamblee/xml/XMLException.java +++ b/support/general/src/main/java/org/wamblee/xml/XMLException.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.xml; /** diff --git a/support/general/src/main/java/org/wamblee/xml/XslTransformer.java b/support/general/src/main/java/org/wamblee/xml/XslTransformer.java index 6bd9eb43..b3ab9eda 100644 --- a/support/general/src/main/java/org/wamblee/xml/XslTransformer.java +++ b/support/general/src/main/java/org/wamblee/xml/XslTransformer.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.xml; import org.w3c.dom.Document; @@ -85,7 +85,7 @@ public class XslTransformer { } catch (IOException e) { throw new TransformerException(e.getMessage(), e); } - } + } throw new TransformerException("Cannot read '" + aXslt + "'"); } diff --git a/support/general/src/main/java/org/wamblee/xml/package-info.java b/support/general/src/main/java/org/wamblee/xml/package-info.java index 9ec0a539..2aa6c822 100644 --- a/support/general/src/main/java/org/wamblee/xml/package-info.java +++ b/support/general/src/main/java/org/wamblee/xml/package-info.java @@ -12,8 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * Utilities for XML processing. */ package org.wamblee.xml; + diff --git a/support/general/src/test/java/org/wamblee/cache/CachedObjectTest.java b/support/general/src/test/java/org/wamblee/cache/CachedObjectTest.java index 02d151cb..da7d8d47 100644 --- a/support/general/src/test/java/org/wamblee/cache/CachedObjectTest.java +++ b/support/general/src/test/java/org/wamblee/cache/CachedObjectTest.java @@ -58,10 +58,10 @@ public class CachedObjectTest extends TestCase { computation = mock(CachedObject.Computation.class); when(computation.getObject(anyInt())).thenAnswer(new Answer() { public Integer answer( - org.mockito.invocation.InvocationOnMock invocation) + org.mockito.invocation.InvocationOnMock aInvocation) throws Throwable { ncomputations++; - return compute((Integer) invocation.getArguments()[0]); + return compute((Integer) aInvocation.getArguments()[0]); } }); ncomputations = 0; @@ -192,8 +192,8 @@ public class CachedObjectTest extends TestCase { assertEquals(101, getComputationCount()); } - public void testPreviousValueWhileComputationBeingDone() throws Exception { - final CachedObject cached = createCached(new ZeroCache()); + public void testPreviousValueWhileComputationBeingDone() throws Exception { + final CachedObject cached = createCached(new ZeroCache()); reset(computation); when(computation.getObject(anyInt())).thenReturn(1).thenAnswer( new Answer() { @@ -203,40 +203,43 @@ public class CachedObjectTest extends TestCase { TimingUtils.sleep(1000); return 2; } - } - ).thenReturn(3); - + }).thenReturn(3); + assertEquals(1, cached.get().intValue()); Thread recompute = new Thread(new Runnable() { - + @Override public void run() { - // will sleep for 1 second. + // will sleep for 1 second. assertEquals(2, cached.get().intValue()); } }); recompute.start(); - // Now asking the value should not recompute but should return the old value. + // Now asking the value should not recompute but should return the old + // value. TimingUtils.sleep(500); assertEquals(1, cached.get().intValue()); recompute.join(); } - - public void testNullValueWhenComputationReturnsNull() throws Exception { - final CachedObject cached = createCached(new ZeroCache()); + + public void testNullValueWhenComputationReturnsNull() throws Exception { + final CachedObject cached = createCached(new ZeroCache()); reset(computation); - when(computation.getObject(anyInt())).thenReturn(1).thenReturn(null).thenReturn(2); - + when(computation.getObject(anyInt())).thenReturn(1).thenReturn(null) + .thenReturn(2); + assertEquals(1, cached.get().intValue()); assertNull(cached.get()); assertEquals(2, cached.get().intValue()); } - - public void testPreviousValueWhenComputationThrowsException() throws Exception { - final CachedObject cached = createCached(new ZeroCache()); + + public void testPreviousValueWhenComputationThrowsException() + throws Exception { + final CachedObject cached = createCached(new ZeroCache()); reset(computation); - when(computation.getObject(anyInt())).thenReturn(1).thenThrow(new RuntimeException()).thenReturn(2); - + when(computation.getObject(anyInt())).thenReturn(1).thenThrow( + new RuntimeException()).thenReturn(2); + assertEquals(1, cached.get().intValue()); assertEquals(1, cached.get().intValue()); assertEquals(2, cached.get().intValue()); diff --git a/support/general/src/test/java/org/wamblee/cache/ComputedValueTest.java b/support/general/src/test/java/org/wamblee/cache/ComputedValueTest.java index d13cd41c..d61f879c 100644 --- a/support/general/src/test/java/org/wamblee/cache/ComputedValueTest.java +++ b/support/general/src/test/java/org/wamblee/cache/ComputedValueTest.java @@ -30,7 +30,6 @@ public class ComputedValueTest extends TestCase { private Computation computation; private ComputedValue guard; - @Override protected void setUp() throws Exception { @@ -45,19 +44,19 @@ public class ComputedValueTest extends TestCase { guard = new ComputedValue(this, computation); assertNull(guard.getCached()); - + when(computation.isOutOfDate()).thenReturn(true); when(computation.compute()).thenReturn(10); - + int value = guard.get(); assertEquals(10, value); verify(computation).compute(); reset(computation); } - - public void testGetCached() { + + public void testGetCached() { initGuard(); - assertEquals(10, (int)guard.getCached()); + assertEquals(10, (int) guard.getCached()); verifyNoMoreInteractions(computation); } diff --git a/support/general/src/test/java/org/wamblee/collections/CollectionFilterTest.java b/support/general/src/test/java/org/wamblee/collections/CollectionFilterTest.java index d2cc2560..0c3053ab 100644 --- a/support/general/src/test/java/org/wamblee/collections/CollectionFilterTest.java +++ b/support/general/src/test/java/org/wamblee/collections/CollectionFilterTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.collections; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/concurrency/AbstractLockTestCase.java b/support/general/src/test/java/org/wamblee/concurrency/AbstractLockTestCase.java index b6e5b5bf..51686e42 100644 --- a/support/general/src/test/java/org/wamblee/concurrency/AbstractLockTestCase.java +++ b/support/general/src/test/java/org/wamblee/concurrency/AbstractLockTestCase.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.concurrency; import junit.framework.TestCase; @@ -61,7 +61,7 @@ public abstract class AbstractLockTestCase extends TestCase { public void testLock() throws InterruptedException { Thread t1 = runThread(); Thread t2 = runThread(); - TimingUtils.sleep(SLEEP_TIME/2); // give threads a chance to start + TimingUtils.sleep(SLEEP_TIME / 2); // give threads a chance to start // up. assertEquals(2, tracker.getEventCount(STARTED)); // both threads diff --git a/support/general/src/test/java/org/wamblee/concurrency/JvmLockTest.java b/support/general/src/test/java/org/wamblee/concurrency/JvmLockTest.java index bc8cad3d..ee7d11b5 100644 --- a/support/general/src/test/java/org/wamblee/concurrency/JvmLockTest.java +++ b/support/general/src/test/java/org/wamblee/concurrency/JvmLockTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.concurrency; import org.wamblee.test.TimingUtils; diff --git a/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java b/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java index 4b4bd426..5b0d510e 100644 --- a/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java +++ b/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.concurrency; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/conditions/AndConditionTest.java b/support/general/src/test/java/org/wamblee/conditions/AndConditionTest.java index f9faa729..174e3cd7 100644 --- a/support/general/src/test/java/org/wamblee/conditions/AndConditionTest.java +++ b/support/general/src/test/java/org/wamblee/conditions/AndConditionTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/conditions/GreaterThanCondition.java b/support/general/src/test/java/org/wamblee/conditions/GreaterThanCondition.java index a94a1615..267e3f57 100644 --- a/support/general/src/test/java/org/wamblee/conditions/GreaterThanCondition.java +++ b/support/general/src/test/java/org/wamblee/conditions/GreaterThanCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; /** diff --git a/support/general/src/test/java/org/wamblee/conditions/LessThanCondition.java b/support/general/src/test/java/org/wamblee/conditions/LessThanCondition.java index b112cff2..82081952 100644 --- a/support/general/src/test/java/org/wamblee/conditions/LessThanCondition.java +++ b/support/general/src/test/java/org/wamblee/conditions/LessThanCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; /** diff --git a/support/general/src/test/java/org/wamblee/conditions/OrConditionTest.java b/support/general/src/test/java/org/wamblee/conditions/OrConditionTest.java index 9afadfee..65f421bc 100644 --- a/support/general/src/test/java/org/wamblee/conditions/OrConditionTest.java +++ b/support/general/src/test/java/org/wamblee/conditions/OrConditionTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/conditions/PropertyRegexConditionTest.java b/support/general/src/test/java/org/wamblee/conditions/PropertyRegexConditionTest.java index f69a1e33..d3848ba0 100644 --- a/support/general/src/test/java/org/wamblee/conditions/PropertyRegexConditionTest.java +++ b/support/general/src/test/java/org/wamblee/conditions/PropertyRegexConditionTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; import junit.framework.TestCase; @@ -46,8 +46,8 @@ public class PropertyRegexConditionTest extends TestCase { checkMatch("value", "all", false, bean, false); checkMatch("value", ".a.*o", false, bean, true); checkMatch("value", "hallo", false, bean, false); // no match when not - // converting to lower - // case. + // converting to lower + // case. checkMatch("value", "hallo", true, bean, true); // match! } diff --git a/support/general/src/test/java/org/wamblee/conditions/TestBean.java b/support/general/src/test/java/org/wamblee/conditions/TestBean.java index 0b3461e6..11e56b96 100644 --- a/support/general/src/test/java/org/wamblee/conditions/TestBean.java +++ b/support/general/src/test/java/org/wamblee/conditions/TestBean.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.conditions; /** diff --git a/support/general/src/test/java/org/wamblee/general/LookupProxyFactoryTest.java b/support/general/src/test/java/org/wamblee/general/LookupProxyFactoryTest.java index 5dbf81ad..dd8930c0 100644 --- a/support/general/src/test/java/org/wamblee/general/LookupProxyFactoryTest.java +++ b/support/general/src/test/java/org/wamblee/general/LookupProxyFactoryTest.java @@ -45,9 +45,9 @@ public class LookupProxyFactoryTest { public void setUp() throws Exception { intf = mock(MyInterface.class); lookup = mock(Lookup.class); - + LookupProxyFactory factory = new LookupProxyFactory( - MyInterface.class, lookup); + MyInterface.class, lookup); proxy = factory.getProxy(); } @@ -67,7 +67,8 @@ public class LookupProxyFactoryTest { @Test(expected = LookupException.class) public void testNotFoundAtJndi() throws Exception { - when(lookup.lookup()).thenThrow(new RuntimeException("Object not found")); + when(lookup.lookup()).thenThrow( + new RuntimeException("Object not found")); proxy.execute(); } @@ -95,13 +96,13 @@ public class LookupProxyFactoryTest { assertEquals(NAA_NA_NA_NAA_NA, e.getMessage()); } } - - private static final class MyLookup implements Lookup { - + + private static final class MyLookup implements Lookup { + @Override public Object lookup() throws Exception { return new MyInterface() { - + @Override public int execute() { return 10; @@ -109,24 +110,23 @@ public class LookupProxyFactoryTest { }; } } - - @Test + + @Test public void testProxyMustBerializable() throws Exception { lookup = new MyLookup(); LookupProxyFactory factory = new LookupProxyFactory( - MyInterface.class, lookup); + MyInterface.class, lookup); proxy = factory.getProxy(); - + + assertEquals(10, proxy.execute()); + + assertTrue(proxy instanceof Serializable); + + proxy = ObjectSerializationUtils.deserialize(ObjectSerializationUtils + .serialize(proxy), MyInterface.class); + + // and it should still work assertEquals(10, proxy.execute()); - - assertTrue(proxy instanceof Serializable); - - proxy = ObjectSerializationUtils.deserialize(ObjectSerializationUtils.serialize(proxy), - MyInterface.class); - - // and it should still work - assertEquals(10, proxy.execute()); } - } diff --git a/support/general/src/test/java/org/wamblee/general/ObjectElemTest.java b/support/general/src/test/java/org/wamblee/general/ObjectElemTest.java index ba59c637..63d1b020 100644 --- a/support/general/src/test/java/org/wamblee/general/ObjectElemTest.java +++ b/support/general/src/test/java/org/wamblee/general/ObjectElemTest.java @@ -22,34 +22,34 @@ import static junit.framework.TestCase.*; public class ObjectElemTest { @Test - public void testSameObjectEqual() { - String s = "x"; - ObjectElem s1 = new ObjectElem(s); + public void testSameObjectEqual() { + String s = "x"; + ObjectElem s1 = new ObjectElem(s); ObjectElem s2 = new ObjectElem(s); assertEquals(s1, s2); } - + @Test - public void testDifferentButEqualObjectsNotEqual() { - String s = new String("x"); + public void testDifferentButEqualObjectsNotEqual() { + String s = new String("x"); ObjectElem se = new ObjectElem(s); String t = new String("x"); ObjectElem te = new ObjectElem(t); assertEquals(s, t); - assertNotSame(s,t); + assertNotSame(s, t); assertFalse(se.equals(te)); } - + @Test - public void testNull() { + public void testNull() { ObjectElem se = new ObjectElem("x"); assertFalse(se.equals(null)); } - + @Test - public void testWrongType(){ + public void testWrongType() { ObjectElem se = new ObjectElem("x"); assertFalse(se.equals("x")); } - + } diff --git a/support/general/src/test/java/org/wamblee/general/ObjectSerializationUtilsTest.java b/support/general/src/test/java/org/wamblee/general/ObjectSerializationUtilsTest.java index a558b420..6771a942 100644 --- a/support/general/src/test/java/org/wamblee/general/ObjectSerializationUtilsTest.java +++ b/support/general/src/test/java/org/wamblee/general/ObjectSerializationUtilsTest.java @@ -24,8 +24,8 @@ import org.junit.Test; public class ObjectSerializationUtilsTest { @Test - public void testSerialize() throws Exception { - String s = "hello world"; + public void testSerialize() throws Exception { + String s = "hello world"; byte[] data = ObjectSerializationUtils.serialize(s); assertNotNull(data); String t = ObjectSerializationUtils.deserialize(data, String.class); diff --git a/support/general/src/test/java/org/wamblee/general/ThreadSpecificProxyFactoryTest.java b/support/general/src/test/java/org/wamblee/general/ThreadSpecificProxyFactoryTest.java index bbb39509..0cffd5a0 100644 --- a/support/general/src/test/java/org/wamblee/general/ThreadSpecificProxyFactoryTest.java +++ b/support/general/src/test/java/org/wamblee/general/ThreadSpecificProxyFactoryTest.java @@ -58,18 +58,19 @@ public class ThreadSpecificProxyFactoryTest { assertEquals(50, proxy.execute(10)); verify(svc).execute(10); } - + @Test - public void testCreationCallback() throws Exception { + public void testCreationCallback() throws Exception { CreationCallback callback = mock(CreationCallback.class); - Service initialService = mock(Service.class); + Service initialService = mock(Service.class); when(callback.create()).thenReturn(initialService); - - factory = new ThreadSpecificProxyFactory(Service.class, callback); + + factory = new ThreadSpecificProxyFactory(Service.class, + callback); proxy = factory.getProxy(); Service svc = factory.get(); - - assertSame(initialService, svc); + + assertSame(initialService, svc); verify(callback).create(); } @@ -117,11 +118,12 @@ public class ThreadSpecificProxyFactoryTest { @Test(expected = IllegalArgumentException.class) public void testNotAnInterface() { - ThreadSpecificProxyFactory f = new ThreadSpecificProxyFactory(String.class); + ThreadSpecificProxyFactory f = new ThreadSpecificProxyFactory( + String.class); } - + @Test - public void testProxyToStringWhileUninitialized() { + public void testProxyToStringWhileUninitialized() { String val = proxy.toString(); } } diff --git a/support/general/src/test/java/org/wamblee/general/ValueHolderTest.java b/support/general/src/test/java/org/wamblee/general/ValueHolderTest.java index e52d8be8..7c5af024 100644 --- a/support/general/src/test/java/org/wamblee/general/ValueHolderTest.java +++ b/support/general/src/test/java/org/wamblee/general/ValueHolderTest.java @@ -19,19 +19,19 @@ import junit.framework.TestCase; public class ValueHolderTest extends TestCase { - public void testDefault() { - ValueHolder val = new ValueHolder(); + public void testDefault() { + ValueHolder val = new ValueHolder(); assertNull(val.getValue()); } - - public void testNonDefault() { - ValueHolder val = new ValueHolder(10); - assertEquals(10, (int)val.getValue()); + + public void testNonDefault() { + ValueHolder val = new ValueHolder(10); + assertEquals(10, (int) val.getValue()); } - - public void testSetGet() { - ValueHolder val = new ValueHolder(10); - val.setValue(100); - assertEquals(100, (int)val.getValue()); + + public void testSetGet() { + ValueHolder val = new ValueHolder(10); + val.setValue(100); + assertEquals(100, (int) val.getValue()); } } diff --git a/support/general/src/test/java/org/wamblee/io/ClassPathResourceTest.java b/support/general/src/test/java/org/wamblee/io/ClassPathResourceTest.java index 6baf1f86..37ab98a6 100644 --- a/support/general/src/test/java/org/wamblee/io/ClassPathResourceTest.java +++ b/support/general/src/test/java/org/wamblee/io/ClassPathResourceTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTest.java b/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTest.java index 87675cdb..b148fafe 100644 --- a/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTest.java +++ b/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import static org.mockito.Mockito.*; diff --git a/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTestProgram.java b/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTestProgram.java index 890289c4..eb865f2a 100644 --- a/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTestProgram.java +++ b/support/general/src/test/java/org/wamblee/io/DirectoryMonitorTestProgram.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.File; @@ -25,7 +25,8 @@ import java.io.File; public class DirectoryMonitorTestProgram { public static void main(String[] aArgs) throws Exception { DirectoryMonitor monitor = new DirectoryMonitor(new File("."), - new RegexFilenameFilter(".*\\.txt"), new DirectoryMonitor.Listener() { + new RegexFilenameFilter(".*\\.txt"), + new DirectoryMonitor.Listener() { public void fileChanged(File aFile) { System.out.println("changed " + aFile); } diff --git a/support/general/src/test/java/org/wamblee/io/FileResourceTest.java b/support/general/src/test/java/org/wamblee/io/FileResourceTest.java index 92b0c644..919c3f58 100644 --- a/support/general/src/test/java/org/wamblee/io/FileResourceTest.java +++ b/support/general/src/test/java/org/wamblee/io/FileResourceTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/io/FileSystemUtils.java b/support/general/src/test/java/org/wamblee/io/FileSystemUtils.java index 7145c7f8..bf801980 100644 --- a/support/general/src/test/java/org/wamblee/io/FileSystemUtils.java +++ b/support/general/src/test/java/org/wamblee/io/FileSystemUtils.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.File; @@ -39,7 +39,8 @@ import junit.framework.TestCase; * @author Erik Brakkee */ public final class FileSystemUtils { - private static final Logger LOG = Logger.getLogger(FileSystemUtils.class.getName()); + private static final Logger LOG = Logger.getLogger(FileSystemUtils.class + .getName()); /** * Test output directory relative to the sub project. @@ -136,7 +137,8 @@ public final class FileSystemUtils { path = URLDecoder.decode(location.getPath(), "UTF-8"); } catch (UnsupportedEncodingException e) { // ignore it.. just don't decode - LOG.log(Level.WARNING, "Decoding path failed: '" + location.getPath() + "'", e); + LOG.log(Level.WARNING, "Decoding path failed: '" + + location.getPath() + "'", e); } return new File(new File(path).getParentFile(), aRelativePath); @@ -299,7 +301,7 @@ public final class FileSystemUtils { Assert.assertTrue(aSrc.isDirectory()); Assert.assertTrue(!aTarget.exists()); - if (!aTarget.mkdirs()) { + if (!aTarget.mkdirs()) { Assert.fail("Could not create target directory '" + aTarget + "'"); } diff --git a/support/general/src/test/java/org/wamblee/io/StreamResourceTest.java b/support/general/src/test/java/org/wamblee/io/StreamResourceTest.java index 9bea518a..f3432749 100644 --- a/support/general/src/test/java/org/wamblee/io/StreamResourceTest.java +++ b/support/general/src/test/java/org/wamblee/io/StreamResourceTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/io/TestData.java b/support/general/src/test/java/org/wamblee/io/TestData.java index f7e4b3dc..7f72aad5 100644 --- a/support/general/src/test/java/org/wamblee/io/TestData.java +++ b/support/general/src/test/java/org/wamblee/io/TestData.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.ByteArrayInputStream; diff --git a/support/general/src/test/java/org/wamblee/io/TestResource.java b/support/general/src/test/java/org/wamblee/io/TestResource.java index fd9d5cf0..f2753e94 100644 --- a/support/general/src/test/java/org/wamblee/io/TestResource.java +++ b/support/general/src/test/java/org/wamblee/io/TestResource.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.io; import java.io.File; diff --git a/support/general/src/test/java/org/wamblee/ioc/BeanKernelTest.java b/support/general/src/test/java/org/wamblee/ioc/BeanKernelTest.java index 73b232c7..6e355b4d 100644 --- a/support/general/src/test/java/org/wamblee/ioc/BeanKernelTest.java +++ b/support/general/src/test/java/org/wamblee/ioc/BeanKernelTest.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.ioc; - import junit.framework.TestCase; /** diff --git a/support/general/src/test/java/org/wamblee/ioc/PairTest.java b/support/general/src/test/java/org/wamblee/ioc/PairTest.java index 17de2672..1e447ea8 100644 --- a/support/general/src/test/java/org/wamblee/ioc/PairTest.java +++ b/support/general/src/test/java/org/wamblee/ioc/PairTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.ioc; import org.wamblee.general.Pair; diff --git a/support/general/src/test/java/org/wamblee/ioc/TestBeanFactory.java b/support/general/src/test/java/org/wamblee/ioc/TestBeanFactory.java index 8d20c26a..525c5eb9 100644 --- a/support/general/src/test/java/org/wamblee/ioc/TestBeanFactory.java +++ b/support/general/src/test/java/org/wamblee/ioc/TestBeanFactory.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.ioc; - public class TestBeanFactory implements BeanFactory { @Override public Object find(String aId) { diff --git a/support/general/src/test/java/org/wamblee/observer/ObservableTest.java b/support/general/src/test/java/org/wamblee/observer/ObservableTest.java index f2fc8d7d..a985d433 100644 --- a/support/general/src/test/java/org/wamblee/observer/ObservableTest.java +++ b/support/general/src/test/java/org/wamblee/observer/ObservableTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.observer; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/persistence/AbstractDetachableTest.java b/support/general/src/test/java/org/wamblee/persistence/AbstractDetachableTest.java index 0a342e7b..c5745e47 100644 --- a/support/general/src/test/java/org/wamblee/persistence/AbstractDetachableTest.java +++ b/support/general/src/test/java/org/wamblee/persistence/AbstractDetachableTest.java @@ -54,7 +54,7 @@ public class AbstractDetachableTest { private DetachableMethods methods; private AbstractDetachable detachable; - private X x; + private X x; @Before public void setUp() { @@ -78,18 +78,18 @@ public class AbstractDetachableTest { assertNull(detachable.getObject()); assertEquals(ref, detachable.getReference()); } - + @Test - public void testDetachTwice() { - reset(methods); - testDetach(); - detachable.detach(); - detachable.detach(); + public void testDetachTwice() { + reset(methods); + testDetach(); + detachable.detach(); + detachable.detach(); verifyNoMoreInteractions(methods); } - - @Test(expected = IllegalStateException.class) - public void testDetachWithNullReference() { + + @Test(expected = IllegalStateException.class) + public void testDetachWithNullReference() { x = new X(); Integer ref = 100; when(methods.getReference(any(X.class))).thenReturn(null); @@ -97,30 +97,29 @@ public class AbstractDetachableTest { verifyNoMoreInteractions(methods); detachable.detach(); } - + @Test public void testReattach() { - testDetach(); + testDetach(); reset(methods); - + X x2 = new X(); // the new X loaded from persistent storage. - when(methods.load(detachable.getReference())).thenReturn(x2); - + when(methods.load(detachable.getReference())).thenReturn(x2); + X x3 = detachable.get(); - verify(methods).load(100); - assertSame(x2, x3); - + verify(methods).load(100); + assertSame(x2, x3); + assertSame(x2, detachable.getObject()); } - + @Test - public void testGetInvokedTwiceNoLoads() { - testReattach(); - reset(methods); - detachable.get(); - detachable.get(); + public void testGetInvokedTwiceNoLoads() { + testReattach(); + reset(methods); + detachable.get(); + detachable.get(); verifyNoMoreInteractions(methods); } - } diff --git a/support/general/src/test/java/org/wamblee/persistence/JpaDetachableTest.java b/support/general/src/test/java/org/wamblee/persistence/JpaDetachableTest.java index 0fee2dbe..3c3d629a 100644 --- a/support/general/src/test/java/org/wamblee/persistence/JpaDetachableTest.java +++ b/support/general/src/test/java/org/wamblee/persistence/JpaDetachableTest.java @@ -26,36 +26,36 @@ import org.junit.Test; import static junit.framework.TestCase.*; public class JpaDetachableTest { - - public class X { + + public class X { @Id - private int id; - + private int id; + } - - private EntityManager em; - - @Before - public void setUp() { + + private EntityManager em; + + @Before + public void setUp() { em = mock(EntityManager.class); } - + @Test - public void testDetachAttach() { - X x = new X(); - x.id = 100; - + public void testDetachAttach() { + X x = new X(); + x.id = 100; + JpaDetachable d = new JpaDetachable(em, x); assertNull(d.getReference()); d.detach(); assertEquals(100, d.getReference()); - + X x2 = new X(); x2.id = 100; when(em.find(X.class, 100)).thenReturn(x2); X x3 = d.get(); - assertSame(x2, x3); + assertSame(x2, x3); verify(em).find(X.class, 100); - + } } diff --git a/support/general/src/test/java/org/wamblee/persistence/JpaMergeSupportTest.java b/support/general/src/test/java/org/wamblee/persistence/JpaMergeSupportTest.java index c906fb19..f6ae20bb 100644 --- a/support/general/src/test/java/org/wamblee/persistence/JpaMergeSupportTest.java +++ b/support/general/src/test/java/org/wamblee/persistence/JpaMergeSupportTest.java @@ -33,10 +33,10 @@ public class JpaMergeSupportTest { private static class X1 { @Id - int id; + private int id; @Version - int version; + private int version; private String value; @@ -62,11 +62,16 @@ public class JpaMergeSupportTest { } return value.equals(((X1) aObj).getValue()); } + + @Override + public int hashCode() { + return 0; + } } private static class X2 { @Id - int id; + private int id; private List list; @@ -81,7 +86,7 @@ public class JpaMergeSupportTest { private static class X3 { @Id - int id; + private int id; private Set set; @@ -96,7 +101,7 @@ public class JpaMergeSupportTest { private static class X4 { @Id - int id; + private int id; private Map map; @@ -111,7 +116,7 @@ public class JpaMergeSupportTest { private static class X5 { @Id - int id; + private int id; private X1[] array; @@ -127,25 +132,25 @@ public class JpaMergeSupportTest { return array; } } - - private static class X6 { + + private static class X6 { @Id - int id; - - public X1 getNotaGetter(String aMessage) { - return null; + private int id; + + public X1 getNotaGetter(String aMessage) { + return null; } - - public void getNotaGetter2() { - + + public void getNotaGetter2() { + } } - - private static class X7 { + + private static class X7 { @Id - int id; - - private void getX() { + private int id; + + private void getX() { fail("Private getters should not be used"); } } @@ -383,21 +388,21 @@ public class JpaMergeSupportTest { } @Test - public void testNotAGetter() { - X6 x = new X6(); - x.id = 100; - X6 y = new X6(); - - JpaMergeSupport.merge(x,y); + public void testNotAGetter() { + X6 x = new X6(); + x.id = 100; + X6 y = new X6(); + + JpaMergeSupport.merge(x, y); assertEquals(x.id, y.id); } - - @Test - public void testPrivateGetter() { - X7 x = new X7(); + + @Test + public void testPrivateGetter() { + X7 x = new X7(); x.id = 100; - X7 y = new X7(); - JpaMergeSupport.merge(x,y); + X7 y = new X7(); + JpaMergeSupport.merge(x, y); assertEquals(x.id, y.id); } } diff --git a/support/general/src/test/java/org/wamblee/persistence/PersistentFactoryTest.java b/support/general/src/test/java/org/wamblee/persistence/PersistentFactoryTest.java index b1a7d719..cb1c8acf 100644 --- a/support/general/src/test/java/org/wamblee/persistence/PersistentFactoryTest.java +++ b/support/general/src/test/java/org/wamblee/persistence/PersistentFactoryTest.java @@ -40,13 +40,13 @@ public class PersistentFactoryTest { public void setPk(int aPk) { pk = aPk; } - - private void privateSetter(int aPk) { + + private void privateSetter(int aPk) { pk = aPk; } - - private int privateGetter() { - return pk; + + private int privateGetter() { + return pk; } } @@ -62,7 +62,7 @@ public class PersistentFactoryTest { pk = aPk; } } - + public static class X3 { private int pk; @@ -87,13 +87,13 @@ public class PersistentFactoryTest { public void setVersion(int aVersion) { version = aVersion; } - - private void privateSetter(int aVersion) { + + private void privateSetter(int aVersion) { version = aVersion; } - - private int privateGetter() { - return version; + + private int privateGetter() { + return version; } } @@ -109,7 +109,7 @@ public class PersistentFactoryTest { version = aVersion; } } - + public static class X6 { private int version; @@ -122,13 +122,13 @@ public class PersistentFactoryTest { version = aVersion; } } - - public static class X7 { + + public static class X7 { @Id - public int id; - + public int id; + @Version - public int version; + public int version; } // FieldAccessor test @@ -154,24 +154,25 @@ public class PersistentFactoryTest { accessor.set(x1, 10); assertEquals(10, x1.getPk()); } - + @Test - public void testPropertyAccessorPrivate() throws Exception { + public void testPropertyAccessorPrivate() throws Exception { Accessor accessor = new PropertyAccessor(X1.class - .getDeclaredMethod("privateGetter"), X1.class.getDeclaredMethod("privateSetter", - int.class)); + .getDeclaredMethod("privateGetter"), X1.class.getDeclaredMethod( + "privateSetter", int.class)); X1 x1 = new X1(); assertEquals(0, x1.getPk()); accessor.set(x1, 10); - assertEquals((Integer)10, accessor.get(x1)); - + assertEquals((Integer) 10, accessor.get(x1)); + } // EntityAccessor test @Test public void testEntityAccessorPkField() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(X1.class); + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(X1.class); assertNotNull(accessor); assertTrue(accessor.getPk() instanceof FieldAccessor); assertNull(accessor.getVersion()); @@ -181,7 +182,8 @@ public class PersistentFactoryTest { @Test public void testEntityAccessorPkProperty() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(X2.class); + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(X2.class); assertNotNull(accessor); assertNotNull(accessor.getPk()); assertTrue(accessor.getPk() instanceof PropertyAccessor); @@ -190,10 +192,11 @@ public class PersistentFactoryTest { assertEquals("getPk", property.getGetter().getName()); assertEquals("setPk", property.getSetter().getName()); } - + @Test public void testEntityAccessorPkPropertyPrivate() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(X3.class); + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(X3.class); assertNotNull(accessor); assertNotNull(accessor.getPk()); assertTrue(accessor.getPk() instanceof PropertyAccessor); @@ -205,17 +208,19 @@ public class PersistentFactoryTest { @Test public void testEntityAccessorVersionField() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(X4.class); + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(X4.class); assertNotNull(accessor); assertTrue(accessor.getVersion() instanceof FieldAccessor); assertNull(accessor.getPk()); - assertEquals("version", ((FieldAccessor) accessor.getVersion()).getField() - .getName()); + assertEquals("version", ((FieldAccessor) accessor.getVersion()) + .getField().getName()); } @Test public void testEntityAccessorVersionProperty() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(X5.class); + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(X5.class); assertNotNull(accessor); assertNotNull(accessor.getVersion()); assertTrue(accessor.getVersion() instanceof PropertyAccessor); @@ -224,10 +229,11 @@ public class PersistentFactoryTest { assertEquals("getVersion", property.getGetter().getName()); assertEquals("setVersion", property.getSetter().getName()); } - + @Test public void testEntityAccessorVersionPropertyPrivate() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(X6.class); + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(X6.class); assertNotNull(accessor); assertNotNull(accessor.getVersion()); assertTrue(accessor.getVersion() instanceof PropertyAccessor); @@ -236,47 +242,51 @@ public class PersistentFactoryTest { assertEquals("getVersion", property.getGetter().getName()); assertEquals("setVersion", property.getSetter().getName()); } - + @Test - public void testNoVersionAndNoPk() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(String.class); + public void testNoVersionAndNoPk() { + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(String.class); assertNull(accessor); } @Test - public void testPkAndVersion() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(X7.class); + public void testPkAndVersion() { + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(X7.class); assertNotNull(accessor.getPk()); assertNotNull(accessor.getVersion()); - + X7 x = new X7(); assertEquals(0, x.id); assertEquals(0, x.version); - - accessor.getPk().set(x, 10); + + accessor.getPk().set(x, 10); accessor.getVersion().set(x, 20); - + assertEquals(10, x.id); assertEquals(20, x.version); } - - @Test - public void testEntityAccessorCache() { - EntityAccessor accessor = PersistentFactory.createEntityAccessor(X1.class); - EntityAccessor accessor2 = PersistentFactory.createEntityAccessor(X1.class); - + + @Test + public void testEntityAccessorCache() { + EntityAccessor accessor = PersistentFactory + .createEntityAccessor(X1.class); + EntityAccessor accessor2 = PersistentFactory + .createEntityAccessor(X1.class); + assertSame(accessor, accessor2); } - - // EntityObjectAccessor test for undefined pk and/or version. + + // EntityObjectAccessor test for undefined pk and/or version. @Test - public void testEntityObjectAccessorRobustness() { - EntityObjectAccessor accessor = new EntityObjectAccessor("hello world", + public void testEntityObjectAccessorRobustness() { + EntityObjectAccessor accessor = new EntityObjectAccessor("hello world", new EntityAccessor(null, null)); assertNull(accessor.getPrimaryKey()); assertNull(accessor.getPersistedVersion()); accessor.setPrimaryKey("bla"); accessor.setPersistedVersion(100); - + } } diff --git a/support/general/src/test/java/org/wamblee/reflection/AnnotationUtilsTest.java b/support/general/src/test/java/org/wamblee/reflection/AnnotationUtilsTest.java index 3245d907..03d2922a 100644 --- a/support/general/src/test/java/org/wamblee/reflection/AnnotationUtilsTest.java +++ b/support/general/src/test/java/org/wamblee/reflection/AnnotationUtilsTest.java @@ -23,74 +23,73 @@ import java.util.List; import org.junit.Test; -import static junit.framework.TestCase.*; +import static junit.framework.TestCase.*; public class AnnotationUtilsTest { - + @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.FIELD, ElementType.METHOD}) - public static @interface MyAnnotation { - + @Target( { ElementType.FIELD, ElementType.METHOD }) + public static @interface MyAnnotation { + } - - public static class X1 { + + public static class X1 { @MyAnnotation - public int x; + public int x; } - - public static class X2 { + + public static class X2 { @MyAnnotation private int x; - + } - public static class X3 { + public static class X3 { private int x; - + public void setX(int aX) { x = aX; } - + @MyAnnotation public int getX() { return x; } } - - public static class X4 { + + public static class X4 { private int x; - + private void setX(int aX) { x = aX; } - + @MyAnnotation private int getX() { return x; } } - public static class X5 { + public static class X5 { private int x; - + @MyAnnotation - private int y; - + private int y; + private void setX(int aX) { x = aX; } - + @MyAnnotation private int getX() { return x; } } - - @Test public void testPublicField() { - List accessors = AnnotationUtils.analyse(X1.class, MyAnnotation.class); + List accessors = AnnotationUtils.analyse(X1.class, + MyAnnotation.class); assertEquals(1, accessors.size()); assertTrue(accessors.get(0) instanceof FieldAccessor); assertEquals(int.class, accessors.get(0).getType()); @@ -98,12 +97,13 @@ public class AnnotationUtilsTest { X1 obj = new X1(); assertEquals(0, obj.x); accessors.get(0).set(obj, 100); - assertEquals(100,obj.x); + assertEquals(100, obj.x); } - + @Test - public void testPrivateField() { - List accessors = AnnotationUtils.analyse(X2.class, MyAnnotation.class); + public void testPrivateField() { + List accessors = AnnotationUtils.analyse(X2.class, + MyAnnotation.class); assertEquals(1, accessors.size()); assertTrue(accessors.get(0) instanceof FieldAccessor); X2 obj = new X2(); @@ -111,10 +111,11 @@ public class AnnotationUtilsTest { accessors.get(0).set(obj, 100); assertEquals(100, obj.x); } - + @Test - public void testPublicProperty() { - List accessors = AnnotationUtils.analyse(X3.class, MyAnnotation.class); + public void testPublicProperty() { + List accessors = AnnotationUtils.analyse(X3.class, + MyAnnotation.class); assertEquals(1, accessors.size()); assertTrue(accessors.get(0) instanceof PropertyAccessor); assertEquals(int.class, accessors.get(0).getType()); @@ -123,10 +124,11 @@ public class AnnotationUtilsTest { accessors.get(0).set(obj, 100); assertEquals(100, obj.x); } - + @Test - public void testPrivateProperty() { - List accessors = AnnotationUtils.analyse(X4.class, MyAnnotation.class); + public void testPrivateProperty() { + List accessors = AnnotationUtils.analyse(X4.class, + MyAnnotation.class); assertEquals(1, accessors.size()); assertTrue(accessors.get(0) instanceof PropertyAccessor); X4 obj = new X4(); @@ -134,15 +136,16 @@ public class AnnotationUtilsTest { accessors.get(0).set(obj, 100); assertEquals(100, obj.x); } - + @Test - public void testMultipleMatches() { - List accessors = AnnotationUtils.analyse(X5.class, MyAnnotation.class); + public void testMultipleMatches() { + List accessors = AnnotationUtils.analyse(X5.class, + MyAnnotation.class); assertEquals(2, accessors.size()); X5 obj = new X5(); assertEquals(0, obj.x); assertEquals(0, obj.y); - for (Accessor accessor: accessors) { + for (Accessor accessor : accessors) { accessor.set(obj, 100); } assertEquals(100, obj.x); diff --git a/support/general/src/test/java/org/wamblee/reflection/ObjectTraversalTest.java b/support/general/src/test/java/org/wamblee/reflection/ObjectTraversalTest.java index a97c91f3..6fb35d10 100644 --- a/support/general/src/test/java/org/wamblee/reflection/ObjectTraversalTest.java +++ b/support/general/src/test/java/org/wamblee/reflection/ObjectTraversalTest.java @@ -54,32 +54,31 @@ public class ObjectTraversalTest { when(visitor.mustVisit(any(Class.class))).thenReturn(true); when(visitor.mustVisit(any(Field.class))).thenReturn(true); when(visitor.mustVisit(any(Method.class))).thenReturn(true); - + when(visitor.visitPlainObject(any())).thenReturn(true); when(visitor.visitArray(any())).thenReturn(true); when(visitor.visitList(any(List.class))).thenReturn(true); when(visitor.visitMap(any(Map.class))).thenReturn(true); when(visitor.visitSet(any(Set.class))).thenReturn(true); - + ObjectTraversal.LOGGER.setLevel(Level.FINEST); ConsoleHandler handler = new ConsoleHandler(); handler.setLevel(Level.FINEST); ObjectTraversal.LOGGER.addHandler(handler); } - - public static class X1 { - + + public static class X1 { + } - public static class X2 { - private X1 x; + public static class X2 { + private X1 x; } - - + @Test public void testTraverseFields() throws Exception { X2 x2 = new X2(); - X1 x1 = new X1(); + X1 x1 = new X1(); x2.x = x1; traversal.accept(x2); verify(visitor).mustVisit(X2.class); @@ -89,7 +88,7 @@ public class ObjectTraversalTest { verify(visitor).visitPlainObject(same(x1)); verifyNoMoreInteractions(visitor); } - + public static class TraversalNonTraversedFields { private int x; private Object y = new Object(); @@ -97,24 +96,25 @@ public class ObjectTraversalTest { @Test public void testNonTraversedFields() throws Exception { - TraversalNonTraversedFields obj =new TraversalNonTraversedFields(); + TraversalNonTraversedFields obj = new TraversalNonTraversedFields(); traversal.accept(obj); verify(visitor).mustVisit(TraversalNonTraversedFields.class); - verify(visitor).mustVisit(eq(TraversalNonTraversedFields.class.getDeclaredField("x"))); - verify(visitor).mustVisit(eq(TraversalNonTraversedFields.class.getDeclaredField("y"))); + verify(visitor).mustVisit( + eq(TraversalNonTraversedFields.class.getDeclaredField("x"))); + verify(visitor).mustVisit( + eq(TraversalNonTraversedFields.class.getDeclaredField("y"))); verify(visitor).visitPlainObject(same(obj)); } - - public static class X3 { - + + public static class X3 { + } - - public static class X4 { - public X3 getX3() { + + public static class X4 { + public X3 getX3() { return new X3(); } } - @Test public void testTraverseMethods() throws Exception { @@ -130,7 +130,7 @@ public class ObjectTraversalTest { @Test public void testTraverseList() { - List list = new ArrayList(); + List list = new ArrayList(); list.add(new X1()); list.add(new X3()); traversal.accept(list); @@ -141,7 +141,7 @@ public class ObjectTraversalTest { @Test public void testTraverseMap() { - Map map = new HashMap(); + Map map = new HashMap(); map.put("x1", new X1()); map.put("x3", new X3()); traversal.accept(map); @@ -152,7 +152,7 @@ public class ObjectTraversalTest { @Test public void testTraverseSet() { - Set set = new HashSet(); + Set set = new HashSet(); set.add(new X1()); set.add(new X3()); traversal.accept(set); @@ -163,7 +163,7 @@ public class ObjectTraversalTest { @Test public void testTraverseArray() { - Object[] obj = new Object[2]; + Object[] obj = new Object[2]; obj[0] = new X1(); obj[1] = new X3(); traversal.accept(obj); @@ -174,7 +174,7 @@ public class ObjectTraversalTest { @Test public void testExcludeClasses() { - X2 x2 = new X2(); + X2 x2 = new X2(); x2.x = new X1(); when(visitor.mustVisit(X1.class)).thenReturn(false); traversal.accept(x2); @@ -184,7 +184,7 @@ public class ObjectTraversalTest { @Test public void testExcludeFields() { - X2 x2 = new X2(); + X2 x2 = new X2(); x2.x = new X1(); when(visitor.mustVisit(any(Field.class))).thenReturn(false); traversal.accept(x2); @@ -194,25 +194,25 @@ public class ObjectTraversalTest { @Test public void testExcludeMethods() { - X4 x4 = new X4(); + X4 x4 = new X4(); when(visitor.mustVisit(any(Method.class))).thenReturn(false); traversal.accept(x4); verify(visitor).visitPlainObject(same(x4)); verify(visitor, never()).visitPlainObject(isA(X3.class)); } - - public static class X5 { + + public static class X5 { private X6 x6; } - - public static class X6 { + + public static class X6 { private X5 x5; } - + @Test public void testCyclic() { X6 x6 = new X6(); - X5 x5 = new X5(); + X5 x5 = new X5(); x6.x5 = x5; x5.x6 = x6; traversal.accept(x6); @@ -222,33 +222,33 @@ public class ObjectTraversalTest { @Test public void testCyclicList() { - List list = new ArrayList(); - list.add(list); - traversal.accept(list); + List list = new ArrayList(); + list.add(list); + traversal.accept(list); verify(visitor, times(1)).visitList(same(list)); } @Test public void testCyclicMap() { - Map map = new HashMap(); - map.put("x", map); - traversal.accept(map); + Map map = new HashMap(); + map.put("x", map); + traversal.accept(map); verify(visitor, times(1)).visitMap(same(map)); } @Test public void testCyclicSet() { - Set set = new HashSet(); - set.add(set); - traversal.accept(set); + Set set = new HashSet(); + set.add(set); + traversal.accept(set); verify(visitor, times(1)).visitSet(same(set)); } @Test public void testCyclicArray() { - Object[] obj = new Object[1]; - obj[0] = obj; - traversal.accept(obj); + Object[] obj = new Object[1]; + obj[0] = obj; + traversal.accept(obj); verify(visitor, times(1)).visitArray(same(obj)); } @@ -256,20 +256,20 @@ public class ObjectTraversalTest { public void testVisitNull() { traversal.accept(null); } - + @Test public void testExcludeFieldByReturningFalseInVisit() { - X2 x2 = new X2(); + X2 x2 = new X2(); x2.x = new X1(); when(visitor.visitPlainObject(any())).thenReturn(false); traversal.accept(x2); verify(visitor).visitPlainObject(same(x2)); verify(visitor, never()).visitPlainObject(same(x2.x)); } - + @Test public void testTraverseListExcludeElements() { - List list = new ArrayList(); + List list = new ArrayList(); list.add(new X1()); list.add(new X3()); when(visitor.visitList(any(List.class))).thenReturn(false); @@ -280,7 +280,7 @@ public class ObjectTraversalTest { @Test public void testTraverseMapExcludeElements() { - Map map = new HashMap(); + Map map = new HashMap(); map.put("x1", new X1()); map.put("x3", new X3()); when(visitor.visitMap(any(Map.class))).thenReturn(false); @@ -291,7 +291,7 @@ public class ObjectTraversalTest { @Test public void testTraverseSetExcludeElements() { - Set set = new HashSet(); + Set set = new HashSet(); set.add(new X1()); set.add(new X3()); when(visitor.visitSet(any(Set.class))).thenReturn(false); @@ -303,7 +303,7 @@ public class ObjectTraversalTest { @Test public void testTraverseArrayExcludeElements() { - Object[] obj = new Object[2]; + Object[] obj = new Object[2]; obj[0] = new X1(); obj[1] = new X3(); when(visitor.visitArray(any())).thenReturn(false); diff --git a/support/general/src/test/java/org/wamblee/reflection/ReflectionUtilsTest.java b/support/general/src/test/java/org/wamblee/reflection/ReflectionUtilsTest.java index 1cc6e4b0..d56e2948 100644 --- a/support/general/src/test/java/org/wamblee/reflection/ReflectionUtilsTest.java +++ b/support/general/src/test/java/org/wamblee/reflection/ReflectionUtilsTest.java @@ -37,10 +37,10 @@ public class ReflectionUtilsTest { } } - - public static class X5 extends X2 { - private String field; - private int g; + + public static class X5 extends X2 { + private String field; + private int g; } @Test(expected = IllegalArgumentException.class) @@ -50,19 +50,22 @@ public class ReflectionUtilsTest { @Test public void testBasicClass() { - List res = ReflectionUtils.getAllMethods(X2.class, Object.class); + List res = ReflectionUtils + .getAllMethods(X2.class, Object.class); assertEquals(2, res.size()); } @Test public void testInheritanceAdditionalMethod() { - List res = ReflectionUtils.getAllMethods(X3.class, Object.class); + List res = ReflectionUtils + .getAllMethods(X3.class, Object.class); assertEquals(3, res.size()); } @Test public void testInheritanceOverriddenMethod() { - List res = ReflectionUtils.getAllMethods(X4.class, Object.class); + List res = ReflectionUtils + .getAllMethods(X4.class, Object.class); assertEquals(2, res.size()); for (Method method : res) { if (method.getName().equals("x")) { @@ -70,20 +73,20 @@ public class ReflectionUtilsTest { } } } - + @Test(expected = IllegalArgumentException.class) public void testGetAllFieldsInterface() { ReflectionUtils.getAllFields(X.class); } @Test - public void testFieldsFromBasicClass() { + public void testFieldsFromBasicClass() { List fields = ReflectionUtils.getAllFields(X2.class); assertEquals(1, fields.size()); assertEquals("bla", fields.get(0).getName()); } - - public void testFieldsWithInheritance() { + + public void testFieldsWithInheritance() { List fields = ReflectionUtils.getAllFields(X5.class); assertEquals(3, fields.size()); } diff --git a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java index b23eee93..bd55115b 100644 --- a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java +++ b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test; import java.util.Arrays; @@ -29,7 +29,8 @@ import junit.framework.TestCase; * @author Erik Brakkee */ public final class AssertionUtils { - private static final Logger LOG = Logger.getLogger(AssertionUtils.class.getName()); + private static final Logger LOG = Logger.getLogger(AssertionUtils.class + .getName()); /** * Disabled constructor. @@ -110,9 +111,9 @@ public final class AssertionUtils { TestCase.assertEquals("Map sizes differ", aExpectedMap.size(), aActual .size()); - Set> expectedEntries = aExpectedMap.entrySet(); + Set> expectedEntries = aExpectedMap.entrySet(); - for (Entry entry: expectedEntries) { + for (Entry entry : expectedEntries) { Key key = entry.getKey(); TestCase.assertTrue("Map does not containg entry for key:" + key, aActual.containsKey(key)); @@ -139,7 +140,7 @@ public final class AssertionUtils { LOG.info("Expected exception occured " + t.getMessage()); return; // ok - } + } throw new RuntimeException(t); } } diff --git a/support/general/src/test/java/org/wamblee/test/EventTracker.java b/support/general/src/test/java/org/wamblee/test/EventTracker.java index c2b18f6d..8cbd4ace 100644 --- a/support/general/src/test/java/org/wamblee/test/EventTracker.java +++ b/support/general/src/test/java/org/wamblee/test/EventTracker.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test; import java.util.ArrayList; @@ -39,7 +39,8 @@ import java.util.logging.Logger; * @author Erik Brakkee */ public class EventTracker { - private static final Logger LOG = Logger.getLogger(EventTracker.class.getName()); + private static final Logger LOG = Logger.getLogger(EventTracker.class + .getName()); /** * Map of Thread object to a list of events. diff --git a/support/general/src/test/java/org/wamblee/test/TimingUtils.java b/support/general/src/test/java/org/wamblee/test/TimingUtils.java index 343d564d..bd934bc6 100644 --- a/support/general/src/test/java/org/wamblee/test/TimingUtils.java +++ b/support/general/src/test/java/org/wamblee/test/TimingUtils.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test; import junit.framework.TestCase; diff --git a/support/general/src/test/java/org/wamblee/xml/ClasspathUriResolverTest.java b/support/general/src/test/java/org/wamblee/xml/ClasspathUriResolverTest.java index 97e71758..d0bf723f 100644 --- a/support/general/src/test/java/org/wamblee/xml/ClasspathUriResolverTest.java +++ b/support/general/src/test/java/org/wamblee/xml/ClasspathUriResolverTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.xml; import junit.framework.TestCase; @@ -73,8 +73,8 @@ public class ClasspathUriResolverTest extends TestCase { */ public void testResolveNonExistingFile() { try { - resolver.resolve( - "org/wamblee/xml/reportToHtml-nonexisting.xsl", ""); + resolver + .resolve("org/wamblee/xml/reportToHtml-nonexisting.xsl", ""); } catch (TransformerException e) { return; // ok } diff --git a/support/general/src/test/java/org/wamblee/xml/XmlUtils.java b/support/general/src/test/java/org/wamblee/xml/XmlUtils.java index 5f9755e4..4aea6bfa 100644 --- a/support/general/src/test/java/org/wamblee/xml/XmlUtils.java +++ b/support/general/src/test/java/org/wamblee/xml/XmlUtils.java @@ -156,7 +156,7 @@ public final class XmlUtils { */ private static final class AttributeComparator implements Comparator, Serializable { - + private static final long serialVersionUID = 7897287273519886301L; /* diff --git a/support/general/src/test/java/org/wamblee/xml/XslTransformerTest.java b/support/general/src/test/java/org/wamblee/xml/XslTransformerTest.java index bf46528d..c3cf78b0 100644 --- a/support/general/src/test/java/org/wamblee/xml/XslTransformerTest.java +++ b/support/general/src/test/java/org/wamblee/xml/XslTransformerTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.xml; import java.io.ByteArrayOutputStream; @@ -235,8 +235,7 @@ public class XslTransformerTest extends TestCase { XslTransformer transformer = new XslTransformer(); try { - transformer - .resolve("org/wamblee/xml/utilities-nonexistent.xsl"); + transformer.resolve("org/wamblee/xml/utilities-nonexistent.xsl"); } catch (TransformerException e) { return; // ok } -- 2.31.1