Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARQ-1975 Adds arquillian resource provider for servlet context #92

Closed
wants to merge 3 commits into from
Closed

Conversation

lordofthejars
Copy link
Member

No description provided.

…vlet protocol.

Adds ServletContext as Arquillian Resource so it can be used in the tests. In case of in-container tests, ServletContxt used is the one provided by the Servlet protocol.
In case of client test, it only works in case of embedded containers and they are the responsible of provide the instance by producing the instance
@lordofthejars
Copy link
Member Author

Wait since I need to refactor what you mention in this comment.

@lordofthejars
Copy link
Member Author

@aslakknutsen notice that ServletContext is set in ThreadLocal inside execute method (https://github.com/arquillian/arquillian-core/blob/master/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/runner/ServletTestRunner.java#L92) so ManagerStarting would it contain a null or a real value? Not sure, maybe the best event would be before enrichment?

@aslakknutsen
Copy link
Member

It should be set by the time ManagerStarting happens in container. This is roughly the order of execution:

  • Request ServletTestRunner
  • Run JUnit
  • Run Arquillian Core +

@@ -32,6 +34,7 @@
public void register(ExtensionBuilder builder)
{
builder.service(Protocol.class, org.jboss.arquillian.protocol.servlet.v_2_5.ServletProtocol.class)
.service(Protocol.class, org.jboss.arquillian.protocol.servlet.v_3.ServletProtocol.class);
.service(Protocol.class, org.jboss.arquillian.protocol.servlet.v_3.ServletProtocol.class)
.service(ResourceProvider.class, ServletContextResourceProvider.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you need to add a Validate.classExists("javax.servlet.ServletContext") around the ServletContextResourceProvider service registration to avoid requiring the servlet-api classes to be available on client classpath.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix that btw..:)

@aslakknutsen
Copy link
Member

Thank you! Pushed upstream d1e9964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants