I am trying to inject Atmosphere components and factories using the javax.inject.Inject annotation in a test.
In my code I have defined an instance variable as below:
@Inject
private BroadcasterFactory broadcasterFactory;
My build.gradle declares the following dependencies:
compile 'org.jboss.resteasy:jaxrs-api:3.0.11.Final'
compile 'org.jboss.resteasy:resteasy-jackson-provider:3.0.11.Final'
compile 'org.jboss.resteasy:resteasy-multipart-provider:3.0.11.Final'
compile 'net.sf.dozer:dozer:5.5.1'
compile 'com.netiq:websockify:1.6-proactive'
compile 'org.atmosphere:atmosphere-runtime:2.3.2'
compile 'javax.inject:javax.inject:1'
runtime 'org.eclipse.jetty.websocket:websocket-server:9.2.10.v20150310'
runtime 'org.eclipse.jetty:jetty-webapp:9.2.10.v20150310'
runtime 'javax.servlet:javax.servlet-api:3.0.1'
testCompile 'org.jboss.resteasy:tjws:3.0.11.Final'
testCompile 'org.mockito:mockito-core:1.10.19'
When I run my application test in debug I can see that the instance variable broadcasterFactory is null.
My configuration for Atmosphere in web.xml is the following:
<servlet>
<servlet-name>atmosphere</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.cpr.sessionSupport</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.websocket.messageContentType</param-name>
<param-value>application/json</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.websocket.bufferSize</param-name>
<!-- Maximum value allowed by Jetty -->
<!-- See class org.eclipse.jetty.websocket.api.WebSocketPolicy.setInputBufferSize -->
<param-value>32768</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.websocket.maxTextMessageSize</param-name>
<param-value>102400</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.asyncSupport</param-name>
<param-value>org.atmosphere.container.Jetty9AsyncSupportWithWebSocket</param-value>
</init-param>
<init-param>
<!-- http://ift.tt/1GOYlnb -->
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>
What do I miss? Any idea that could help to understand what is the issue is welcome.
Aucun commentaire:
Enregistrer un commentaire