Author: alexsmirnov
Date: 2010-06-16 20:29:54 -0400 (Wed, 16 Jun 2010)
New Revision: 17633
Modified:
root/core/branches/jsr-330/impl/pom.xml
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/DefaultModule.java
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/InitializationListener.java
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
Log:
fix tests
Modified: root/core/branches/jsr-330/impl/pom.xml
===================================================================
--- root/core/branches/jsr-330/impl/pom.xml 2010-06-17 00:23:45 UTC (rev 17632)
+++ root/core/branches/jsr-330/impl/pom.xml 2010-06-17 00:29:54 UTC (rev 17633)
@@ -47,7 +47,6 @@
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>jsr330-impl</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.cssparser</groupId>
Modified:
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/DefaultModule.java
===================================================================
---
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-06-17
00:23:45 UTC (rev 17632)
+++
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-06-17
00:29:54 UTC (rev 17633)
@@ -2,19 +2,19 @@
import org.ajax4jsf.cache.Cache;
import org.ajax4jsf.renderkit.AJAXDataSerializer;
-import org.richfaces.jsr330.BindingModule;
+import org.richfaces.jsr330.Module;
import org.richfaces.jsr330.InjectorConfig;
import org.richfaces.resource.DefaultResourceCodec;
import org.richfaces.resource.ResourceCodec;
import org.richfaces.skin.SkinFactory;
import org.richfaces.skin.SkinFactoryImpl;
-public class DefaultModule implements BindingModule {
+public class DefaultModule implements Module {
public void configure(InjectorConfig injector) {
- injector.register(SkinFactory.class).to(SkinFactoryImpl.class);
- injector.register(AJAXDataSerializer.class).to(AJAXDataSerializer.class);
- injector.register(ResourceCodec.class).toService(DefaultResourceCodec.class);
+ injector.register(SkinFactory.class).to(SkinFactoryImpl.class).asSingleton();
+
injector.register(AJAXDataSerializer.class).to(AJAXDataSerializer.class).asSingleton();
+
injector.register(ResourceCodec.class).toService(DefaultResourceCodec.class).asSingleton();
injector.register(Cache.class).toProviderInstance(new CacheProvider());
}
Modified:
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/InitializationListener.java
===================================================================
---
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/InitializationListener.java 2010-06-17
00:23:45 UTC (rev 17632)
+++
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/InitializationListener.java 2010-06-17
00:29:54 UTC (rev 17633)
@@ -31,7 +31,7 @@
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
-import org.richfaces.jsr330.BindingModule;
+import org.richfaces.jsr330.Module;
import org.richfaces.jsr330.DependencyException;
import org.richfaces.jsr330.InjectorImpl;
import org.richfaces.jsr330.ServiceException;
@@ -58,11 +58,11 @@
protected DependencyInjector createInjector() {
InjectorImpl injector = new InjectorImpl();
- ArrayList<BindingModule> modules = new ArrayList<BindingModule>();
+ ArrayList<Module> modules = new ArrayList<Module>();
modules.add(new DefaultModule());
try {
- modules.addAll(ServiceLoader.loadServices(BindingModule.class));
- injector.init(modules.toArray(new BindingModule[]{}));
+ modules.addAll(ServiceLoader.loadServices(Module.class));
+ injector.init(modules.toArray(new Module[]{}));
} catch (ServiceException e) {
throw new FacesException(e);
} catch (DependencyException e) {
Modified:
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
===================================================================
---
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2010-06-17
00:23:45 UTC (rev 17632)
+++
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2010-06-17
00:29:54 UTC (rev 17633)
@@ -41,7 +41,7 @@
import org.easymock.EasyMock;
import org.jboss.test.faces.AbstractFacesTest;
import org.richfaces.application.ServiceTracker;
-import org.richfaces.jsr330.BindingModule;
+import org.richfaces.jsr330.Module;
import org.richfaces.jsr330.InjectorConfig;
import org.richfaces.jsr330.InjectorImpl;
import org.richfaces.util.Util;
@@ -143,7 +143,7 @@
EasyMock.eq(null),
EasyMock.eq("4_0_alpha"))).andReturn("/rfRes/Resource2/4_0_alpha");
EasyMock.replay(resourceCodec);
InjectorImpl injector = new InjectorImpl();
- injector.init(new BindingModule(){
+ injector.init(new Module(){
public void configure(InjectorConfig injector) {
injector.register(ResourceCodec.class).toInstance(resourceCodec);
Modified:
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
===================================================================
---
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java 2010-06-17
00:23:45 UTC (rev 17632)
+++
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java 2010-06-17
00:29:54 UTC (rev 17633)
@@ -41,7 +41,7 @@
import org.jboss.test.faces.AbstractFacesTest;
import org.jboss.test.faces.htmlunit.LocalWebClient;
import org.richfaces.application.ServiceTracker;
-import org.richfaces.jsr330.BindingModule;
+import org.richfaces.jsr330.Module;
import org.richfaces.jsr330.InjectorConfig;
import org.richfaces.jsr330.InjectorImpl;
import org.richfaces.util.Util;
@@ -223,6 +223,7 @@
setupFacesRequest();
final ResourceCodec mockedCodec = EasyMock.createNiceMock(ResourceCodec.class);
+ final org.ajax4jsf.cache.Cache mockCache =
EasyMock.createNiceMock(org.ajax4jsf.cache.Cache.class);
EasyMock.expect(mockedCodec.decodeResourceName(EasyMock.<FacesContext>notNull(),
EasyMock.eq("StateHolderResource"))).andReturn("org.richfaces.resource.StateHolderResourceImpl");
@@ -232,12 +233,13 @@
EasyMock.eq("StateHolderResource"))).andReturn(null);
EasyMock.expect(mockedCodec.getResourceKey(EasyMock.<FacesContext>notNull(),
EasyMock.eq("StateHolderResource"))).andReturn("StateHolderResource.jsf?db=1");
- EasyMock.replay(mockedCodec);
+ EasyMock.replay(mockedCodec,mockCache);
InjectorImpl injector = new InjectorImpl();
- injector.init(new BindingModule(){
+ injector.init(new Module(){
public void configure(InjectorConfig injector) {
injector.register(ResourceCodec.class).toInstance(mockedCodec);
+ injector.register(org.ajax4jsf.cache.Cache.class).toInstance(mockCache);
}
});
Modified:
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
===================================================================
---
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-17
00:23:45 UTC (rev 17632)
+++
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-17
00:29:54 UTC (rev 17633)
@@ -48,7 +48,7 @@
private final Scope<T> singltonScope = new Scope<T>() {
- private boolean instantiated = false;
+ private volatile boolean instantiated = false;
private volatile T value;
@@ -72,13 +72,14 @@
FacesContext facesContext = FacesContext.getCurrentInstance();
if (null != facesContext) {
Map<String, Object> map = getMap(facesContext);
- value = (T) map.get(target.toString());
+ String key = target.toString();
+ value = (T) map.get(key);
if(null == value){
rwLock.readLock().unlock();
rwLock.writeLock().lock();
try {
value = getProvider().get();
- map.put(target.toString(), value);
+ map.put(key, value);
} finally {
rwLock.readLock().lock();
rwLock.writeLock().unlock();
Show replies by date