From: Erik Brakkee Date: Sun, 18 Apr 2010 19:45:54 +0000 (+0000) Subject: checkstyle X-Git-Tag: wamblee-utils-0.7~542 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=5e33a52ba36ac928b9863ddd79d2d09f6a308af6;p=utils checkstyle --- diff --git a/security/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java b/security/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java index 8aab974a..d968c836 100644 --- a/security/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java +++ b/security/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java @@ -42,13 +42,13 @@ public interface AuthorizationRule extends Persistent { * * @param aResource * Resource. - * @param anOperation + * @param aOperation * Operation. * @param aUser * Current user. * * @return Authorization result. */ - AuthorizationResult isAllowed(Object aResource, Operation anOperation, + AuthorizationResult isAllowed(Object aResource, Operation aOperation, User aUser); } diff --git a/security/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java b/security/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java index 1d454e23..adeb93c1 100644 --- a/security/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java +++ b/security/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java @@ -146,14 +146,14 @@ public abstract class UrlAuthorizationRule extends AbstractPersistent implements * .Object, org.wamblee.security.authorization.Operation) */ public AuthorizationResult isAllowed(Object aResource, - Operation anOperation, User aUser) { + Operation aOperation, User aUser) { if (!resourceClass.isInstance(aResource)) { return UNSUPPORTED_RESOURCE; } String path = getResourcePath(aResource); - return isAllowed(path, anOperation, aUser); + return isAllowed(path, aOperation, aUser); } /** diff --git a/security/src/main/java/org/wamblee/usermgt/JaasUserAccessor.java b/security/src/main/java/org/wamblee/usermgt/JaasUserAccessor.java index 8cb65065..ec7a25af 100644 --- a/security/src/main/java/org/wamblee/usermgt/JaasUserAccessor.java +++ b/security/src/main/java/org/wamblee/usermgt/JaasUserAccessor.java @@ -83,7 +83,7 @@ public class JaasUserAccessor implements UserAccessor { /** * Gets the user principal from the subject. * - * @param subject + * @param aSubject * Subject. * * @return User principal. @@ -92,8 +92,8 @@ public class JaasUserAccessor implements UserAccessor { * In case there is a duplicate principal or the principal was * not found. */ - private Principal getUserPrincipal(Subject subject) { - Set principals = subject.getPrincipals(); + private Principal getUserPrincipal(Subject aSubject) { + Set principals = aSubject.getPrincipals(); Principal userPrincipal = null; for (Principal principal : principals) { @@ -101,7 +101,7 @@ public class JaasUserAccessor implements UserAccessor { if (userPrincipal != null) { throw new IllegalArgumentException( "Multiple principals for class '" + userPrincipalClass + - "', subject: " + subject); + "', subject: " + aSubject); } userPrincipal = principal; @@ -111,7 +111,7 @@ public class JaasUserAccessor implements UserAccessor { if (userPrincipal == null) { throw new IllegalArgumentException( "No user principal found for class '" + userPrincipalClass + - "', subject: " + subject); + "', subject: " + aSubject); } return userPrincipal; diff --git a/security/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationComponent.java b/security/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationComponent.java index cc541783..941ecfe5 100644 --- a/security/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationComponent.java +++ b/security/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationComponent.java @@ -15,15 +15,14 @@ */ package org.wamblee.usermgt.hibernate; -import org.springframework.orm.hibernate3.HibernateTemplate; - -import org.springframework.transaction.PlatformTransactionManager; +import java.io.IOException; -import org.wamblee.cache.EhCache; +import javax.sql.DataSource; +import org.springframework.orm.hibernate3.HibernateTemplate; +import org.springframework.transaction.PlatformTransactionManager; import org.wamblee.security.authorization.AuthorizationService; import org.wamblee.security.authorization.hibernate.AuthorizationMappingFiles; - import org.wamblee.system.adapters.DefaultContainer; import org.wamblee.system.adapters.ObjectConfiguration; import org.wamblee.system.components.ORMappingConfig; @@ -31,16 +30,8 @@ import org.wamblee.system.core.Component; import org.wamblee.system.core.DefaultProvidedInterface; import org.wamblee.system.core.DefaultRequiredInterface; import org.wamblee.system.core.ProvidedInterface; -import org.wamblee.system.core.Scope; import org.wamblee.system.spring.component.HibernateComponent; - import org.wamblee.usermgt.UserAccessor; -import org.wamblee.usermgt.UserAdministration; -import org.wamblee.usermgt.UserGroupRepositoryComponent; - -import java.io.IOException; - -import javax.sql.DataSource; /** * @@ -48,13 +39,13 @@ import javax.sql.DataSource; * @version $Revision$ */ public class AuthorizationComponent extends DefaultContainer { - private ProvidedInterface TRANSACTION_MGR = new DefaultProvidedInterface( + private ProvidedInterface transactionMgr = new DefaultProvidedInterface( "transactionManager", PlatformTransactionManager.class); - private ProvidedInterface HIBERNATE_TEMPLATE = new DefaultProvidedInterface( + private ProvidedInterface hibernateTemplate = new DefaultProvidedInterface( "hibernateTemplate", HibernateTemplate.class); - private ProvidedInterface AUTHORIZATION_SERVICE = new DefaultProvidedInterface( + private ProvidedInterface authorizationService = new DefaultProvidedInterface( "authorizationService", AuthorizationService.class); /** @@ -87,10 +78,10 @@ public class AuthorizationComponent extends DefaultContainer { ORMappingConfig.class)); if (aExposeInternals) { - addProvidedInterface(TRANSACTION_MGR); - addProvidedInterface(HIBERNATE_TEMPLATE); + addProvidedInterface(transactionMgr); + addProvidedInterface(hibernateTemplate); } - addProvidedInterface(AUTHORIZATION_SERVICE); + addProvidedInterface(authorizationService); } } diff --git a/security/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationLightComponent.java b/security/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationLightComponent.java index 23004b49..39a37dae 100644 --- a/security/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationLightComponent.java +++ b/security/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationLightComponent.java @@ -15,23 +15,17 @@ */ package org.wamblee.usermgt.hibernate; -import org.springframework.orm.hibernate3.HibernateTemplate; +import java.util.HashMap; +import java.util.Map; +import org.springframework.orm.hibernate3.HibernateTemplate; import org.wamblee.security.authorization.AuthorizationService; - import org.wamblee.system.core.DefaultProvidedInterface; import org.wamblee.system.core.DefaultRequiredInterface; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.spring.SpringComponent; - -import org.wamblee.usermgt.GroupSet; import org.wamblee.usermgt.UserAccessor; -import org.wamblee.usermgt.UserAdministration; -import org.wamblee.usermgt.UserSet; - -import java.util.HashMap; -import java.util.Map; /** * Light version of the user administration component that requires external diff --git a/security/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java b/security/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java index 66211a0d..65ee1e3d 100644 --- a/security/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java +++ b/security/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java @@ -44,16 +44,16 @@ import javax.sql.DataSource; * @version $Revision$ */ public class UserAdministrationComponent extends DefaultContainer { - private ProvidedInterface TRANSACTION_MGR = new DefaultProvidedInterface( + private ProvidedInterface transactionMgr = new DefaultProvidedInterface( "transactionManager", PlatformTransactionManager.class); - private ProvidedInterface USER_CACHE = new DefaultProvidedInterface( + private ProvidedInterface userCache = new DefaultProvidedInterface( "userCache", EhCache.class); - private ProvidedInterface HIBERNATE_TEMPLATE = new DefaultProvidedInterface( + private ProvidedInterface hibernateTemplate = new DefaultProvidedInterface( "hibernateTemplate", HibernateTemplate.class); - private ProvidedInterface USER_MGT = new DefaultProvidedInterface( + private ProvidedInterface userMgt = new DefaultProvidedInterface( "usermgt", UserAdministration.class); /** @@ -88,11 +88,11 @@ public class UserAdministrationComponent extends DefaultContainer { ORMappingConfig.class)); if (aExposeInternals) { - addProvidedInterface(TRANSACTION_MGR); - addProvidedInterface(USER_CACHE); - addProvidedInterface(HIBERNATE_TEMPLATE); + addProvidedInterface(transactionMgr); + addProvidedInterface(userCache); + addProvidedInterface(hibernateTemplate); } - addProvidedInterface(USER_MGT); + addProvidedInterface(userMgt); } } diff --git a/security/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java b/security/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java index 9df7d377..9d6000b9 100644 --- a/security/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java +++ b/security/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java @@ -72,8 +72,8 @@ public class TestAuthorizationRule extends UrlAuthorizationRule { */ @Override public AuthorizationResult isAllowed(Object aResource, - Operation anOperation, User aUser) { - AuthorizationResult result = super.isAllowed(aResource, anOperation, + Operation aOperation, User aUser) { + AuthorizationResult result = super.isAllowed(aResource, aOperation, aUser); if (result.equals(GRANTED) || result.equals(DENIED)) { diff --git a/security/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java b/security/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java index 6aa764a2..a97adcca 100644 --- a/security/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java +++ b/security/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java @@ -26,7 +26,7 @@ import java.util.Set; * implementations of group set. */ public class InMemoryGroupSetTest extends TestCase { - protected GroupSet groups; + private GroupSet groups; /** * This method must be overriden in subclasses. 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 9842cff5..5c2e9a4f 100644 --- a/support/general/src/main/java/org/wamblee/observer/Observable.java +++ b/support/general/src/main/java/org/wamblee/observer/Observable.java @@ -127,23 +127,4 @@ public class Observable { notifier.update(observer, observable, aEvent); } } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#finalize() - */ - @Override - protected void finalize() throws Throwable { - if (observers.size() > 0) { - LOGGER - .error("Still observers registered at finalization of observer!"); - - for (Observer observer : observers.values()) { - LOGGER.error(" observer: " + observer); - } - } - - super.finalize(); - } } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ClassAdapter.java b/system/general/src/main/java/org/wamblee/system/adapters/ClassAdapter.java index 47bce6d7..6bfa03f1 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ClassAdapter.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ClassAdapter.java @@ -26,7 +26,7 @@ import org.wamblee.system.core.Scope; * @author Erik Brakkee */ public class ClassAdapter extends AbstractComponent { - private ClassConfiguration _classConfig; + private ClassConfiguration classConfig; /** * Creates a new ClassAdapter object. @@ -36,13 +36,13 @@ public class ClassAdapter extends AbstractComponent { super(aName, aClassConfig.getProvidedInterfaces().toArray( new ProvidedInterface[0]), aClassConfig.getRequiredInterfaces() .toArray(new RequiredInterface[0])); - _classConfig = aClassConfig; + classConfig = aClassConfig; } @Override protected Object doStart(Scope aScope) { - Object obj = _classConfig.create(aScope); - _classConfig.inject(aScope, obj); + Object obj = classConfig.create(aScope); + classConfig.inject(aScope, obj); for (ProvidedInterface provided : getProvidedInterfaces()) { addInterface(provided, obj, aScope); diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java index f6da6911..31e09f92 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java @@ -30,7 +30,7 @@ import java.util.List; * @author Erik Brakkee */ public class ClassConfiguration { - private Class _class; + private Class clazz; private ConstructorConfiguration constructorConfig; @@ -44,7 +44,7 @@ public class ClassConfiguration { * Class to construct. */ public ClassConfiguration(Class aClass) { - _class = aClass; + clazz = aClass; constructorConfig = new ConstructorConfiguration(aClass); objectConfig = new ObjectConfiguration(aClass); } @@ -83,7 +83,7 @@ public class ClassConfiguration { public List getProvidedInterfaces() { List result = new ArrayList(); - result.add(new DefaultProvidedInterface("provided", _class)); + result.add(new DefaultProvidedInterface("provided", clazz)); return result; } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/FixedValueProvider.java b/system/general/src/main/java/org/wamblee/system/adapters/FixedValueProvider.java index e8056747..4cbe97b2 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/FixedValueProvider.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/FixedValueProvider.java @@ -23,7 +23,7 @@ import org.wamblee.system.core.Scope; * @author Erik Brakkee */ class FixedValueProvider implements ValueProvider { - private Object _value; + private Object value; /** * Constructs the value. @@ -32,11 +32,11 @@ class FixedValueProvider implements ValueProvider { * Value to construct. */ public FixedValueProvider(Object aValue) { - _value = aValue; + value = aValue; } @Override public Object getValue(Scope aScope) { - return _value; + return value; } } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ObjectConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/ObjectConfiguration.java index 2bfe01ef..51a90246 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/ObjectConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/ObjectConfiguration.java @@ -27,7 +27,7 @@ import java.util.List; * @author Erik Brakkee */ public class ObjectConfiguration { - private Class _class; + private Class clazz; private SetterConfiguration setterConfig; @@ -36,7 +36,7 @@ public class ObjectConfiguration { * */ public ObjectConfiguration(Class aClass) { - _class = aClass; + clazz = aClass; setterConfig = new SetterConfiguration(aClass); } @@ -65,6 +65,6 @@ public class ObjectConfiguration { } public boolean appliesTo(Object aObject) { - return _class.isInstance(aObject); + return clazz.isInstance(aObject); } } diff --git a/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java index d66d7636..c8baeafb 100644 --- a/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java +++ b/system/general/src/main/java/org/wamblee/system/adapters/SetterConfiguration.java @@ -51,7 +51,7 @@ import java.util.Set; * @author Erik Brakkee */ public class SetterConfiguration { - private Class _class; + private Class clazz; private boolean publicOnly; @@ -64,7 +64,7 @@ public class SetterConfiguration { * Class which is being configured. */ public SetterConfiguration(Class aClass) { - _class = aClass; + clazz = aClass; publicOnly = true; setters = new HashMap(); } @@ -76,7 +76,7 @@ public class SetterConfiguration { public SetterConfiguration initAllSetters() { setters.clear(); - for (Method method : getAllSetters(_class, publicOnly)) { + for (Method method : getAllSetters(clazz, publicOnly)) { setters.put(method, createParameterValues(method)); } @@ -140,9 +140,9 @@ public class SetterConfiguration { * */ public SetterConfiguration remove(Method aMethod) { - if (!aMethod.getDeclaringClass().isAssignableFrom(_class)) { + if (!aMethod.getDeclaringClass().isAssignableFrom(clazz)) { throw new RuntimeException("Method " + aMethod + - " not found in class " + _class + " or its superclasses"); + " not found in class " + clazz + " or its superclasses"); } for (Method method : setters.keySet()) { @@ -169,7 +169,7 @@ public class SetterConfiguration { public SetterConfiguration add(final String aName) { int oldlen = setters.size(); List methods = new ArrayList(); - CollectionFilter.filter(getAllSetters(_class, publicOnly), methods, + CollectionFilter.filter(getAllSetters(clazz, publicOnly), methods, new Condition() { @Override public boolean matches(Method aObject) { @@ -179,7 +179,7 @@ public class SetterConfiguration { if (methods.size() == 0) { throw new IllegalArgumentException("Method '" + aName + - "' not found in " + _class.getName()); + "' not found in " + clazz.getName()); } // TODO is it possible to get more than one setter here in case the @@ -205,7 +205,7 @@ public class SetterConfiguration { */ public SetterConfiguration addSetter(final Class aType) { List result = new ArrayList(); - CollectionFilter.filter(getAllSetters(_class, publicOnly), result, + CollectionFilter.filter(getAllSetters(clazz, publicOnly), result, new Condition() { @Override public boolean matches(Method aObject) { @@ -217,7 +217,7 @@ public class SetterConfiguration { if (result.size() == 0) { throw new IllegalArgumentException("No setter found in class '" + - _class.getName() + "' that has a setter with argument type '" + + clazz.getName() + "' that has a setter with argument type '" + aType.getName() + "'"); } @@ -229,7 +229,7 @@ public class SetterConfiguration { } throw new IllegalArgumentException( - "Multiple setters found in class '" + _class.getName() + + "Multiple setters found in class '" + clazz.getName() + " that accept type '" + aType.getName() + "': " + setters); } @@ -301,9 +301,9 @@ public class SetterConfiguration { * */ public void inject(Scope aScope, Object aObject) { - if (!_class.isInstance(aObject)) { + if (!clazz.isInstance(aObject)) { throw new IllegalArgumentException("Object '" + aObject + - "' is not an instance of " + _class.getName()); + "' is not an instance of " + clazz.getName()); } for (Method method : setters.keySet()) { diff --git a/system/general/src/main/java/org/wamblee/system/core/DefaultRequiredInterface.java b/system/general/src/main/java/org/wamblee/system/core/DefaultRequiredInterface.java index d7e76df5..aa4a7253 100644 --- a/system/general/src/main/java/org/wamblee/system/core/DefaultRequiredInterface.java +++ b/system/general/src/main/java/org/wamblee/system/core/DefaultRequiredInterface.java @@ -133,18 +133,18 @@ public class DefaultRequiredInterface implements RequiredInterface { } @Override - public boolean equals(Object obj) { - return this == obj; + public boolean equals(Object aObject) { + return this == aObject; } @Override - public boolean covers(RequiredInterface obj) { + public boolean covers(RequiredInterface aObject) { // TODO do more than equals. - if (!(obj instanceof DefaultRequiredInterface)) { + if (!(aObject instanceof DefaultRequiredInterface)) { return false; } - DefaultRequiredInterface descr = (DefaultRequiredInterface) obj; + DefaultRequiredInterface descr = (DefaultRequiredInterface) aObject; if (required.length != descr.required.length) { return false; diff --git a/system/general/src/main/java/org/wamblee/system/core/ProvidedInterfaceImplementation.java b/system/general/src/main/java/org/wamblee/system/core/ProvidedInterfaceImplementation.java index bce21aaa..61c80c7a 100644 --- a/system/general/src/main/java/org/wamblee/system/core/ProvidedInterfaceImplementation.java +++ b/system/general/src/main/java/org/wamblee/system/core/ProvidedInterfaceImplementation.java @@ -21,9 +21,9 @@ package org.wamblee.system.core; * @author Erik Brakkee */ class ProvidedInterfaceImplementation { - private ProvidedInterface _provided; + private ProvidedInterface provided; - private Object _implementation; + private Object implementation; /** * Constructs the object. @@ -35,8 +35,8 @@ class ProvidedInterfaceImplementation { */ public ProvidedInterfaceImplementation(ProvidedInterface aProvided, Object aImplementation) { - _provided = aProvided; - _implementation = aImplementation; + provided = aProvided; + implementation = aImplementation; } /** @@ -44,7 +44,7 @@ class ProvidedInterfaceImplementation { * @return The provided interface. */ public ProvidedInterface getProvided() { - return _provided; + return provided; } /** @@ -57,6 +57,6 @@ class ProvidedInterfaceImplementation { * @return Implementation. */ public T getImplementation(Class aType) { - return (T) _implementation; + return (T) implementation; } } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyProvidedVisitor.java b/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyProvidedVisitor.java index fe6737c0..b68c6003 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyProvidedVisitor.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyProvidedVisitor.java @@ -68,11 +68,11 @@ public class CheckExternallyProvidedVisitor implements Visitor { } private void createDuplicateException(String aMsg, Node aNode, - List edges) { + List aEdges) { StringBuffer buf = new StringBuffer(); buf.append(aNode + ": " + aMsg + ": "); - for (Edge edge : edges) { + for (Edge edge : aEdges) { buf.append(edge.getTo() + "/ "); } diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyRequiredVisitor.java b/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyRequiredVisitor.java index 010205e9..8e90ef4f 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyRequiredVisitor.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/CheckExternallyRequiredVisitor.java @@ -33,7 +33,7 @@ import java.util.List; * @author Erik Brakkee */ public class CheckExternallyRequiredVisitor implements Visitor { - private Log LOG = LogFactory.getLog(CheckExternallyRequiredVisitor.class); + private static final Log LOG = LogFactory.getLog(CheckExternallyRequiredVisitor.class); private Graph graph; diff --git a/system/general/src/main/java/org/wamblee/system/graph/component/CheckRequiredProvidedMultiplicityVisitor.java b/system/general/src/main/java/org/wamblee/system/graph/component/CheckRequiredProvidedMultiplicityVisitor.java index 01a0af90..fc8eaf27 100644 --- a/system/general/src/main/java/org/wamblee/system/graph/component/CheckRequiredProvidedMultiplicityVisitor.java +++ b/system/general/src/main/java/org/wamblee/system/graph/component/CheckRequiredProvidedMultiplicityVisitor.java @@ -84,11 +84,11 @@ public class CheckRequiredProvidedMultiplicityVisitor implements Visitor { } private void createDuplicateException(String aMsg, Node aNode, - List edges) { + List aEdges) { StringBuffer buf = new StringBuffer(); buf.append(aNode + ": " + aMsg + ": "); - for (Edge edge : edges) { + for (Edge edge : aEdges) { buf.append(edge.getTo() + "/ "); } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/AdapterTestCase.java b/system/general/src/test/java/org/wamblee/system/adapters/AdapterTestCase.java index 77a73155..f68e2852 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/AdapterTestCase.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/AdapterTestCase.java @@ -29,10 +29,18 @@ import org.wamblee.test.EventTracker; * @version $Revision$ */ public class AdapterTestCase extends TestCase { - static EventTracker EVENT_TRACKER; + private static EventTracker EVENT_TRACKER; - protected Scope scope; + private Scope scope; + protected Scope getScope() { + return scope; + } + + public static EventTracker getEventTracker() { + return EVENT_TRACKER; + } + @Override protected void setUp() throws Exception { super.setUp(); diff --git a/system/general/src/test/java/org/wamblee/system/adapters/ClassAdapterTest.java b/system/general/src/test/java/org/wamblee/system/adapters/ClassAdapterTest.java index 722adc70..1a6f9b58 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/ClassAdapterTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/ClassAdapterTest.java @@ -45,7 +45,7 @@ public class ClassAdapterTest extends AdapterTestCase { Scope scope = container.start(); AssertionUtils.assertEquals(new String[] { "x1(hello)", "x4(x1)" }, - EVENT_TRACKER.getEvents(Thread.currentThread()).toArray()); + getEventTracker().getEvents(Thread.currentThread()).toArray()); Object obj1 = scope.getRuntime(x1Adapter); assertTrue(obj1 instanceof X1); @@ -80,7 +80,7 @@ public class ClassAdapterTest extends AdapterTestCase { Scope scope = container.start(); AssertionUtils.assertEquals(new String[] { "x1(hello)", "x4(x1)", - "x8(x1)", "x8.setX4(x4)" }, EVENT_TRACKER.getEvents( + "x8(x1)", "x8.setX4(x4)" }, getEventTracker().getEvents( Thread.currentThread()).toArray()); Object obj1 = scope.getRuntime(x1Adapter); diff --git a/system/general/src/test/java/org/wamblee/system/adapters/ClassConfigurationTest.java b/system/general/src/test/java/org/wamblee/system/adapters/ClassConfigurationTest.java index 43eda33e..86e6b077 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/ClassConfigurationTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/ClassConfigurationTest.java @@ -15,16 +15,16 @@ */ package org.wamblee.system.adapters; +import java.util.Collections; +import java.util.List; + import org.wamblee.system.core.DefaultProvidedInterface; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.core.RequiredInterfaceComparator; - +import org.wamblee.system.core.Scope; import org.wamblee.test.AssertionUtils; -import java.util.Collections; -import java.util.List; - /** * * @author $author$ @@ -46,11 +46,11 @@ public class ClassConfigurationTest extends AdapterTestCase { required.get(0).setProvider(provided); - scope.publishInterface(provided, "hello"); - classConfig.create(scope); + getScope().publishInterface(provided, "hello"); + classConfig.create(getScope()); AssertionUtils.assertEquals(new String[] { "x1(hello)" }, - AdapterTestCase.EVENT_TRACKER.getEvents(Thread.currentThread()) + AdapterTestCase.getEventTracker().getEvents(Thread.currentThread()) .toArray()); } @@ -74,6 +74,7 @@ public class ClassConfigurationTest extends AdapterTestCase { required.get(0).setProvider(providedBoolean); required.get(1).setProvider(providedHost); + Scope scope = getScope(); scope.publishInterface(providedBoolean, true); scope.publishInterface(providedHost, "host.name.org"); diff --git a/system/general/src/test/java/org/wamblee/system/adapters/ConstructorConfigurationTest.java b/system/general/src/test/java/org/wamblee/system/adapters/ConstructorConfigurationTest.java index ec7070df..d1ced96f 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/ConstructorConfigurationTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/ConstructorConfigurationTest.java @@ -15,15 +15,15 @@ */ package org.wamblee.system.adapters; +import java.util.List; + import org.wamblee.system.core.DefaultProvidedInterface; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; +import org.wamblee.system.core.Scope; import org.wamblee.system.core.SystemAssemblyException; - import org.wamblee.test.AssertionUtils; -import java.util.List; - /** * * @author $author$ @@ -42,11 +42,12 @@ public class ConstructorConfigurationTest extends AdapterTestCase { required.get(0).setProvider(provided); + Scope scope = getScope(); scope.publishInterface(provided, "hello"); config.create(scope); AssertionUtils.assertEquals(new String[] { "x1(hello)" }, - AdapterTestCase.EVENT_TRACKER.getEvents(Thread.currentThread()) + AdapterTestCase.getEventTracker().getEvents(Thread.currentThread()) .toArray()); } @@ -72,11 +73,12 @@ public class ConstructorConfigurationTest extends AdapterTestCase { assertEquals(1, required.size()); required.get(0).setProvider(provided); + Scope scope = getScope(); scope.publishInterface(provided, "hello"); config.create(scope); AssertionUtils.assertEquals(new String[] { "x2(hello)" }, - AdapterTestCase.EVENT_TRACKER.getEvents(Thread.currentThread()) + AdapterTestCase.getEventTracker().getEvents(Thread.currentThread()) .toArray()); } @@ -85,10 +87,11 @@ public class ConstructorConfigurationTest extends AdapterTestCase { .greedy(); config.getParameters().setValue(0, "bla"); + Scope scope = getScope(); config.create(scope); AssertionUtils.assertEquals(new String[] { "x1(bla)" }, - AdapterTestCase.EVENT_TRACKER.getEvents(Thread.currentThread()) + AdapterTestCase.getEventTracker().getEvents(Thread.currentThread()) .toArray()); } @@ -104,11 +107,12 @@ public class ConstructorConfigurationTest extends AdapterTestCase { assertEquals(1, required.size()); required.get(0).setProvider(provided); + Scope scope = getScope(); scope.publishInterface(provided, "hello"); config.create(scope); AssertionUtils.assertEquals(new String[] { "x1(hello)" }, - AdapterTestCase.EVENT_TRACKER.getEvents(Thread.currentThread()) + AdapterTestCase.getEventTracker().getEvents(Thread.currentThread()) .toArray()); } @@ -118,10 +122,11 @@ public class ConstructorConfigurationTest extends AdapterTestCase { config.getParameters().setOptional(0); assertTrue(config.getRequiredInterfaces().get(0).isOptional()); + Scope scope = getScope(); config.create(scope); AssertionUtils.assertEquals(new String[] { "x1(null)" }, - AdapterTestCase.EVENT_TRACKER.getEvents(Thread.currentThread()) + AdapterTestCase.getEventTracker().getEvents(Thread.currentThread()) .toArray()); } @@ -144,11 +149,12 @@ public class ConstructorConfigurationTest extends AdapterTestCase { required.get(0).setProvider(provided); + Scope scope = getScope(); scope.publishInterface(provided, "hello"); config.create(scope); AssertionUtils.assertEquals(new String[] { "x3(hello)" }, - AdapterTestCase.EVENT_TRACKER.getEvents(Thread.currentThread()) + AdapterTestCase.getEventTracker().getEvents(Thread.currentThread()) .toArray()); } } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/DefaultContainerTest.java b/system/general/src/test/java/org/wamblee/system/adapters/DefaultContainerTest.java index 8990d83b..e405b565 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/DefaultContainerTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/DefaultContainerTest.java @@ -38,7 +38,7 @@ public class DefaultContainerTest extends AdapterTestCase { Scope scope = container.start(); AssertionUtils.assertEquals(new String[] { "x1(hello)", "x4(x1)" }, - EVENT_TRACKER.getEvents(Thread.currentThread()).toArray()); + getEventTracker().getEvents(Thread.currentThread()).toArray()); Object obj = scope.getRuntime("x1"); assertTrue(obj instanceof X1); @@ -52,7 +52,7 @@ public class DefaultContainerTest extends AdapterTestCase { x1Config.getObjectConfig().getSetterConfig().initAllSetters(); X8 x8 = new X8(null); - EVENT_TRACKER.clear(); + getEventTracker().clear(); ClassConfiguration x4Config = new ClassConfiguration(X4.class); x4Config.getObjectConfig().getSetterConfig().initAllSetters(); @@ -66,7 +66,7 @@ public class DefaultContainerTest extends AdapterTestCase { Scope scope = container.start(); AssertionUtils.assertEquals(new String[] { "x1(hello)", "x4(x1)", - "x8.setX4(x4)" }, EVENT_TRACKER.getEvents(Thread.currentThread()) + "x8.setX4(x4)" }, getEventTracker().getEvents(Thread.currentThread()) .toArray()); Object obj1 = scope.getRuntime("x1"); diff --git a/system/general/src/test/java/org/wamblee/system/adapters/ObjectAdapterTest.java b/system/general/src/test/java/org/wamblee/system/adapters/ObjectAdapterTest.java index d5e233cc..23c3bd9c 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/ObjectAdapterTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/ObjectAdapterTest.java @@ -56,11 +56,11 @@ public class ObjectAdapterTest extends AdapterTestCase { x4Adapter, x8Adapter }, new ProvidedInterface[0], new RequiredInterface[0]); - EVENT_TRACKER.clear(); + getEventTracker().clear(); Scope scope = container.start(); AssertionUtils.assertEquals(new String[] { "x1(hello)", "x4(x1)", - "x8.setX4(x4)" }, EVENT_TRACKER.getEvents(Thread.currentThread()) + "x8.setX4(x4)" }, getEventTracker().getEvents(Thread.currentThread()) .toArray()); Object obj1 = scope.getRuntime(x1Adapter); diff --git a/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java b/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java index 9a956c35..87855d9f 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/SetterConfigurationTest.java @@ -15,15 +15,7 @@ */ package org.wamblee.system.adapters; -import org.wamblee.system.core.DefaultProvidedInterface; -import org.wamblee.system.core.ProvidedInterface; -import org.wamblee.system.core.RequiredInterface; -import org.wamblee.system.core.RequiredInterfaceComparator; - -import org.wamblee.test.AssertionUtils; - import java.lang.reflect.Method; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -31,6 +23,13 @@ import java.util.List; import javax.sql.DataSource; +import org.wamblee.system.core.DefaultProvidedInterface; +import org.wamblee.system.core.ProvidedInterface; +import org.wamblee.system.core.RequiredInterface; +import org.wamblee.system.core.RequiredInterfaceComparator; +import org.wamblee.system.core.Scope; +import org.wamblee.test.AssertionUtils; + /** * * @author $author$ @@ -48,6 +47,7 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided); + Scope scope = getScope(); scope.publishInterface(provided, "hello"); X5 obj = new X5(); @@ -77,6 +77,7 @@ public class SetterConfigurationTest extends AdapterTestCase { "janse", String.class); assertTrue(required.get(0).implementedBy(providedString)); required.get(0).setProvider(providedString); + Scope scope = getScope(); scope.publishInterface(providedString, "hello"); ProvidedInterface providedInt = new DefaultProvidedInterface("xxx", @@ -115,6 +116,7 @@ public class SetterConfigurationTest extends AdapterTestCase { "janse", Boolean.class); assertTrue(required.get(0).implementedBy(providedBoolean)); required.get(0).setProvider(providedBoolean); + Scope scope = getScope(); scope.publishInterface(providedBoolean, true); ProvidedInterface providedString = new DefaultProvidedInterface( @@ -151,6 +153,7 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); + Scope scope = getScope(); scope.publishInterface(provided0, "hello"); ProvidedInterface provided1 = new DefaultProvidedInterface("port", @@ -177,6 +180,7 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided); + final Scope scope = getScope(); scope.publishInterface(provided, "hello"); final X6 obj = new X6(); @@ -198,6 +202,7 @@ public class SetterConfigurationTest extends AdapterTestCase { X5 obj = new X5(); assertNull(obj.getValue()); + Scope scope = getScope(); config.inject(scope, obj); assertEquals("bladibla", obj.getValue()); } @@ -214,6 +219,7 @@ public class SetterConfigurationTest extends AdapterTestCase { assertNull(obj.getHost()); assertNull(obj.getPort()); + Scope scope = getScope(); config.inject(scope, obj); assertNull(obj.getHost()); @@ -232,6 +238,7 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); + Scope scope = getScope(); scope.publishInterface(provided0, "hello"); X6 obj = new X6(); @@ -255,6 +262,7 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); + Scope scope = getScope(); scope.publishInterface(provided0, "hello"); X6 obj = new X6(); @@ -324,6 +332,7 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); + Scope scope = getScope(); scope.publishInterface(provided0, "hello"); X6 obj = new X6(); @@ -348,6 +357,7 @@ public class SetterConfigurationTest extends AdapterTestCase { ProvidedInterface provided0 = new DefaultProvidedInterface("janse", String.class); required.get(0).setProvider(provided0); + Scope scope = getScope(); scope.publishInterface(provided0, "hello"); X6 obj = new X6(); diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X1.java b/system/general/src/test/java/org/wamblee/system/adapters/X1.java index 4bba7640..62226834 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X1.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X1.java @@ -25,7 +25,7 @@ public class X1 { * Creates a new X1 object. */ public X1() { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x1()"); + AdapterTestCase.getEventTracker().eventOccurred("x1()"); } /** @@ -33,6 +33,6 @@ public class X1 { * */ public X1(String aValue) { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x1(" + aValue + ")"); + AdapterTestCase.getEventTracker().eventOccurred("x1(" + aValue + ")"); } } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X2.java b/system/general/src/test/java/org/wamblee/system/adapters/X2.java index 0a96e84e..987a4ee0 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X2.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X2.java @@ -26,7 +26,7 @@ public class X2 { * */ public X2(Integer aInteger) { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x2(" + aInteger + ")"); + AdapterTestCase.getEventTracker().eventOccurred("x2(" + aInteger + ")"); } /** @@ -34,6 +34,6 @@ public class X2 { * */ public X2(String aValue) { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x2(" + aValue + ")"); + AdapterTestCase.getEventTracker().eventOccurred("x2(" + aValue + ")"); } } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X3.java b/system/general/src/test/java/org/wamblee/system/adapters/X3.java index 7e9015e8..60f9e10e 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X3.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X3.java @@ -25,7 +25,7 @@ public class X3 { * Creates a new X3 object. */ public X3() { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x3()"); + AdapterTestCase.getEventTracker().eventOccurred("x3()"); } /** @@ -33,6 +33,6 @@ public class X3 { * */ protected X3(String aValue) { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x3(" + aValue + ")"); + AdapterTestCase.getEventTracker().eventOccurred("x3(" + aValue + ")"); } } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X4.java b/system/general/src/test/java/org/wamblee/system/adapters/X4.java index d3995f2e..25ab5394 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X4.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X4.java @@ -28,7 +28,7 @@ public class X4 { * */ public X4(X1 aX1) { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x4(x1)"); + AdapterTestCase.getEventTracker().eventOccurred("x4(x1)"); x1 = aX1; } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X5.java b/system/general/src/test/java/org/wamblee/system/adapters/X5.java index 58dfb96e..3efd316a 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X5.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X5.java @@ -32,7 +32,7 @@ public class X5 { } public void setValue(String aValue) { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x5.setValue(" + aValue + + AdapterTestCase.getEventTracker().eventOccurred("x5.setValue(" + aValue + ")"); value = aValue; } diff --git a/system/general/src/test/java/org/wamblee/system/adapters/X8.java b/system/general/src/test/java/org/wamblee/system/adapters/X8.java index 2c4ff9f4..5b507e1b 100644 --- a/system/general/src/test/java/org/wamblee/system/adapters/X8.java +++ b/system/general/src/test/java/org/wamblee/system/adapters/X8.java @@ -30,12 +30,12 @@ public class X8 { * */ public X8(X1 aX1) { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x8(x1)"); + AdapterTestCase.getEventTracker().eventOccurred("x8(x1)"); x1 = aX1; } public void setX4(X4 aX4) { - AdapterTestCase.EVENT_TRACKER.eventOccurred("x8.setX4(x4)"); + AdapterTestCase.getEventTracker().eventOccurred("x8.setX4(x4)"); x4 = aX4; } diff --git a/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java b/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java index 909c3792..3f169531 100644 --- a/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java +++ b/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java @@ -52,8 +52,8 @@ public class CompositeEdgeFilterTest extends TestCase { .get(0)))); } - private void configureRestriction(EdgeFilter base, boolean aResult) { - stub(base.isViolated((Edge) anyObject())).toReturn(aResult); + private void configureRestriction(EdgeFilter aBase, boolean aResult) { + stub(aBase.isViolated((Edge) anyObject())).toReturn(aResult); } public void testOneRestriction() { diff --git a/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java b/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java index b2db7373..133e3aa2 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java @@ -29,7 +29,7 @@ import java.util.List; * @author Erik Brakkee */ class RequiredServiceBean implements FactoryBean { - private RequiredInterface _required; + private RequiredInterface required; /** * Constructs the bean. @@ -38,12 +38,12 @@ class RequiredServiceBean implements FactoryBean { * Id of the bean in the service registry. */ public RequiredServiceBean(String aId) { - List required = SpringComponent.THIS.get() + List requiredInterfaces = SpringComponent.THIS.get() .getRequiredInterfaces(); - for (RequiredInterface intf : required) { + for (RequiredInterface intf : requiredInterfaces) { if (intf.getName().equals(aId)) { - _required = intf; + required = intf; return; } @@ -56,7 +56,7 @@ class RequiredServiceBean implements FactoryBean { @Override public Object getObject() throws Exception { return SpringComponent.SCOPE.get().getInterfaceImplementation( - _required.getProvider(), Object.class); + required.getProvider(), Object.class); } @Override diff --git a/system/spring/src/main/java/org/wamblee/system/spring/StringResource.java b/system/spring/src/main/java/org/wamblee/system/spring/StringResource.java index 5f2597c1..2f5cbb5d 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/StringResource.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/StringResource.java @@ -30,14 +30,14 @@ import java.net.URL; * @version $Revision$ */ class StringResource implements Resource { - private String _value; + private String value; /** * Creates a new StringResource object. * */ public StringResource(String aValue) { - _value = aValue; + value = aValue; } @Override @@ -77,6 +77,6 @@ class StringResource implements Resource { @Override public InputStream getInputStream() throws IOException { - return new ByteArrayInputStream(_value.getBytes()); + return new ByteArrayInputStream(value.getBytes()); } } diff --git a/system/spring/src/main/java/org/wamblee/system/spring/component/HibernateComponent.java b/system/spring/src/main/java/org/wamblee/system/spring/component/HibernateComponent.java index c52c87c3..3f172094 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/component/HibernateComponent.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/component/HibernateComponent.java @@ -57,7 +57,7 @@ public class HibernateComponent extends SpringComponent { private static final String HIBERNATE_SPRING_CONFIG = "spring/org.wamblee.system.spring.component.hibernate.xml"; - private final RequiredInterface CONFIG = new DefaultRequiredInterface( + private final RequiredInterface config = new DefaultRequiredInterface( "config", ORMappingConfig.class); /** @@ -72,16 +72,16 @@ public class HibernateComponent extends SpringComponent { Properties props = new Properties(); addProperties(HIBERNATE_PROPS_KEY, props); - addRequiredInterface(CONFIG); + addRequiredInterface(config); } @Override protected Scope doStart(Scope aExternalScope) { - ORMappingConfig config = aExternalScope.getInterfaceImplementation( - CONFIG.getProvider(), ORMappingConfig.class); - setProperty(HIBERNATE_SCHEMAUPDATE_PROP, "" + config.isSchemaUpdate()); + ORMappingConfig orMappingConfig = aExternalScope.getInterfaceImplementation( + config.getProvider(), ORMappingConfig.class); + setProperty(HIBERNATE_SCHEMAUPDATE_PROP, "" + orMappingConfig.isSchemaUpdate()); - DatabaseType db = config.getType(); + DatabaseType db = orMappingConfig.getType(); String dialect = db.handleCases(new DatabaseType.Switch() { @Override public String handleMySqlInnoDb() { diff --git a/system/spring/src/test/java/org/wamblee/system/spring/HelloService.java b/system/spring/src/test/java/org/wamblee/system/spring/HelloService.java index 8feead05..c3e623ce 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/HelloService.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/HelloService.java @@ -28,7 +28,7 @@ public class HelloService { * */ public HelloService(String aMsg) { - SpringComponentTest.EVENT_TRACKER.eventOccurred(aMsg); + SpringComponentTest.getEventTracker().eventOccurred(aMsg); msg = aMsg; } diff --git a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java index e4029206..2e0bf5c0 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java @@ -52,10 +52,14 @@ public class SpringComponentTest extends TestCase { private static final String PROPERTY_FILE = "test.org.wamblee.system.spring.properties"; - public static EventTracker EVENT_TRACKER; + private static EventTracker EVENT_TRACKER; private Scope externalScope; + public static EventTracker getEventTracker() { + return EVENT_TRACKER; + } + @Override protected void setUp() throws Exception { super.setUp(); diff --git a/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java b/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java index 37a1cb3c..ca74ec5c 100644 --- a/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java +++ b/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java @@ -45,7 +45,7 @@ public class JndiSessionCustomizer implements SessionCustomizer { * * */ - public void customize(Session session) throws Exception { + public void customize(Session aSession) throws Exception { JNDIConnector connector = null; Context context = null; @@ -53,7 +53,7 @@ public class JndiSessionCustomizer implements SessionCustomizer { context = new InitialContext(); if (null != context) { - connector = (JNDIConnector) session.getLogin().getConnector(); // possible + connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible // CCE // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP // Note: if both jta and non-jta elements exist this will only @@ -66,11 +66,11 @@ public class JndiSessionCustomizer implements SessionCustomizer { // Or, if you are specifying both JTA and non-JTA in your // persistence.xml then set both connectors to be safe - JNDIConnector writeConnector = (JNDIConnector) session + JNDIConnector writeConnector = (JNDIConnector) aSession .getLogin().getConnector(); writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) session) + JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession) .getReadConnectionPool().getLogin()).getConnector(); readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); diff --git a/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContext.java b/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContext.java index 8fd84946..4db8a112 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContext.java +++ b/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContext.java @@ -30,17 +30,17 @@ public class StubInitialContext extends InitialContext { } @Override - public void bind(String name, Object obj) throws NamingException { - bindings.put(name, obj); + public void bind(String aName, Object aObj) throws NamingException { + bindings.put(aName, aObj); } @Override - public Object lookup(String name) throws NamingException { - return bindings.get(name); + public Object lookup(String aName) throws NamingException { + return bindings.get(aName); } @Override - public Object lookup(Name name) throws NamingException { - return super.lookup(name.toString()); + public Object lookup(Name aName) throws NamingException { + return super.lookup(aName.toString()); } } diff --git a/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java b/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java index c2869ea3..8a9409d0 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java @@ -38,11 +38,11 @@ import javax.naming.spi.InitialContextFactory; */ public class StubInitialContextFactory implements InitialContextFactory { - private static Context context; + private static Context CONTEXT; private static void initialize() { try { - context = new StubInitialContext(); + CONTEXT = new StubInitialContext(); } catch (NamingException e) { // can't happen. throw new RuntimeException(e); } @@ -58,7 +58,7 @@ public class StubInitialContextFactory implements InitialContextFactory { // sets up the InitialContextFactoryForTest as default factory. System.setProperty(Context.INITIAL_CONTEXT_FACTORY, StubInitialContextFactory.class.getName()); - if (context == null) { + if (CONTEXT == null) { initialize(); } } @@ -68,11 +68,11 @@ public class StubInitialContextFactory implements InitialContextFactory { */ public static void unregister() { System.setProperty(Context.INITIAL_CONTEXT_FACTORY, ""); - context = null; + CONTEXT = null; } - public Context getInitialContext(Hashtable environment) + public Context getInitialContext(Hashtable aEnvironment) throws NamingException { - return context; + return CONTEXT; } } diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/AbstractDatabase.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/AbstractDatabase.java index 5a084e06..0fc871f1 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/AbstractDatabase.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/AbstractDatabase.java @@ -51,8 +51,13 @@ public abstract class AbstractDatabase implements Database { // constructed object at the connection pool. PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory( connectionFactory, connectionPool, null, null, false, true); + ingoredVariable(poolableConnectionFactory); itsDataSource = new PoolingDataSource(connectionPool); } + + private static void ingoredVariable(PoolableConnectionFactory aFactory) { + // Empty + } // / BELOW THIS LINE IS NOT OF INTEREST TO SUBCLASSES. diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseBuilder.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseBuilder.java index f086c6d1..d8807c38 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseBuilder.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseBuilder.java @@ -62,7 +62,8 @@ public class DatabaseBuilder { */ private static final String DB_CAPABILITIES_PROP = "TEST_DB_CAPABILITIES"; - private static ServiceLoader LOADER = null; + private static ServiceLoader LOADER = + ServiceLoader.load(DatabaseProvider.class); private DatabaseBuilder() { // Empty. @@ -97,10 +98,9 @@ public class DatabaseBuilder { aCapabilities = new String[] { DatabaseProvider.CAPABILITY_IN_MEMORY }; } } - LOGGER.info("Using capabilities: " + aCapabilities); + LOGGER.info("Using capabilities: " + Arrays.asList(aCapabilities)); } synchronized (DatabaseBuilder.class) { - initLoader(); for (DatabaseProvider db : LOADER) { if (db.supportsCapabilities(aCapabilities)) { return db.create(); @@ -118,7 +118,6 @@ public class DatabaseBuilder { * @return List of databases. */ public static List getSupportedDatabases() { - initLoader(); List descriptions = new ArrayList(); for (DatabaseProvider db : LOADER) { descriptions.add(db.getDescription()); @@ -126,10 +125,4 @@ public class DatabaseBuilder { return descriptions; } - private static void initLoader() { - if (LOADER == null) { - LOADER = ServiceLoader.load(DatabaseProvider.class); - } - } - } diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseDescription.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseDescription.java index d476a8a3..8427c1d8 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseDescription.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseDescription.java @@ -48,13 +48,13 @@ public class DatabaseDescription { } private String printCapabilities() { - String res = ""; + StringBuffer res = new StringBuffer(); for (int i = 0; i < itsCapabilities.length; i++) { - res += "" + itsCapabilities[i]; + res.append(itsCapabilities[i]); if (i < itsCapabilities.length - 1) { - res += ", "; + res.append(", "); } } - return res; + return res.toString(); } } diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java index 5fdaa25a..45e96499 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java @@ -37,10 +37,10 @@ public class DatabaseStarter { * where the database class name must be the name of a concrete subclass of * {@link Database}. * - * @param args + * @param aArgs */ - public static void main(String[] args) throws Exception { - String clazz = args[0]; + public static void main(String[] aArgs) throws Exception { + String clazz = aArgs[0]; try { new DatabaseStarter(Class.forName(clazz)).start(); } catch (Exception e) { diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java index bc622749..5f26bd8e 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.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.support.persistence; import java.sql.Connection; @@ -146,15 +146,20 @@ public class DatabaseUtils { LOG.fine("Getting database table names to clean (schema: '" + SCHEMA_PATTERN + "'"); - ResultSet tables = dataSource.getConnection().getMetaData().getTables( - null, SCHEMA_PATTERN, "%", new String[] { "TABLE" }); - while (tables.next()) { - String table = tables.getString("TABLE_NAME"); - if (aSelection.accept(table)) { - result.add(table); + Connection connection = dataSource.getConnection(); + try { + ResultSet tables = connection.getMetaData().getTables(null, + SCHEMA_PATTERN, "%", new String[] { "TABLE" }); + while (tables.next()) { + String table = tables.getString("TABLE_NAME"); + if (aSelection.accept(table)) { + result.add(table); + } } + return (String[]) result.toArray(new String[0]); + } finally { + connection.close(); } - return (String[]) result.toArray(new String[0]); } public void emptyTables() throws Exception { @@ -363,7 +368,7 @@ public class DatabaseUtils { if (aObject instanceof Integer) { aStatement.setInt(aIndex, ((Integer) aObject).intValue()); } else if (aObject instanceof Long) { - aStatement.setLong(aIndex, ((Integer) aObject).longValue()); + aStatement.setLong(aIndex, ((Long) aObject).longValue()); } else if (aObject instanceof String) { aStatement.setString(aIndex, (String) aObject); } else { diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DerbyDatabase.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DerbyDatabase.java index 40e52afa..33bd4f44 100755 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DerbyDatabase.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DerbyDatabase.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.support.persistence; import java.io.File; @@ -243,8 +243,8 @@ public class DerbyDatabase extends AbstractDatabase { private void shutdownDerby() { try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); - throw new RuntimeException("Derby did not shutdown, " - + " should always throw exception at shutdown"); + throw new RuntimeException( + "Derby did not shutdown, should always throw exception at shutdown"); } catch (Exception e) { LOGGER.info("Derby has been shut down."); } diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/JpaBuilder.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/JpaBuilder.java index 4e824093..4d1921f5 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/JpaBuilder.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/JpaBuilder.java @@ -52,13 +52,13 @@ public class JpaBuilder { /** * Executes the unit of work. A transaction has been started. * - * @param em + * @param aEm * Entity manager. * @return Result of the execute method. If you don't want to return * anything use Void for the return type and return * null from the implementation. */ - T execute(EntityManager em); + T execute(EntityManager aEm) throws Exception; } private PersistenceUnitDescription persistenceUnit; @@ -94,7 +94,7 @@ public class JpaBuilder { } factory = createFactory(); execute(new JpaUnitOfWork() { - public Void execute(EntityManager em) { + public Void execute(EntityManager aEm) { // Empty, just to trigger database schema creation. return null; } diff --git a/test/enterprise/src/test/java/org/wamblee/support/persistence/DatabaseUtilsTestBase.java b/test/enterprise/src/test/java/org/wamblee/support/persistence/DatabaseUtilsTestBase.java index 8ca1a156..9012dbd5 100644 --- a/test/enterprise/src/test/java/org/wamblee/support/persistence/DatabaseUtilsTestBase.java +++ b/test/enterprise/src/test/java/org/wamblee/support/persistence/DatabaseUtilsTestBase.java @@ -78,9 +78,9 @@ public class DatabaseUtilsTestBase { // Put some data in the database. builder.execute(new JpaUnitOfWork() { - public Void execute(EntityManager em) { + public Void execute(EntityManager aEm) { MyEntity entity = new MyEntity("a", "b"); - em.persist(entity); + aEm.persist(entity); return null; } }); diff --git a/test/enterprise/src/test/java/org/wamblee/support/persistence/MyEntityExampleTestBase.java b/test/enterprise/src/test/java/org/wamblee/support/persistence/MyEntityExampleTestBase.java index 8bf094b3..7cb81a92 100644 --- a/test/enterprise/src/test/java/org/wamblee/support/persistence/MyEntityExampleTestBase.java +++ b/test/enterprise/src/test/java/org/wamblee/support/persistence/MyEntityExampleTestBase.java @@ -85,9 +85,9 @@ public class MyEntityExampleTestBase { // as and execute the // unit of work. builder.execute(new JpaUnitOfWork() { - public Void execute(EntityManager em) { + public Void execute(EntityManager aEm) { MyEntity entity = new MyEntity("a", "b"); - em.persist(entity); + aEm.persist(entity); return null; } }); diff --git a/test/enterprise/src/test/java/org/wamblee/support/persistence/MyTables.java b/test/enterprise/src/test/java/org/wamblee/support/persistence/MyTables.java index 9b5c9825..e0a337fe 100644 --- a/test/enterprise/src/test/java/org/wamblee/support/persistence/MyTables.java +++ b/test/enterprise/src/test/java/org/wamblee/support/persistence/MyTables.java @@ -34,8 +34,8 @@ public class MyTables implements ITableFilterSimple { // Empty. } - public boolean accept(String tableName) throws DataSetException { - return tableName.startsWith("XYZ_"); + public boolean accept(String aTableName) throws DataSetException { + return aTableName.startsWith("XYZ_"); } } diff --git a/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java b/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java index cc2dbd35..bc4a23a0 100644 --- a/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java +++ b/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java @@ -45,7 +45,7 @@ public class JndiSessionCustomizer implements SessionCustomizer { * * */ - public void customize(Session session) throws Exception { + public void customize(Session aSession) throws Exception { JNDIConnector connector = null; Context context = null; @@ -53,7 +53,7 @@ public class JndiSessionCustomizer implements SessionCustomizer { context = new InitialContext(); if (null != context) { - connector = (JNDIConnector) session.getLogin().getConnector(); // possible + connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible // CCE // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP // Note: if both jta and non-jta elements exist this will only @@ -66,11 +66,11 @@ public class JndiSessionCustomizer implements SessionCustomizer { // Or, if you are specifying both JTA and non-JTA in your // persistence.xml then set both connectors to be safe - JNDIConnector writeConnector = (JNDIConnector) session + JNDIConnector writeConnector = (JNDIConnector) aSession .getLogin().getConnector(); writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) session) + JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession) .getReadConnectionPool().getLogin()).getConnector(); readConnector.setLookupType(JNDIConnector.STRING_LOOKUP);