[
https://issues.jboss.org/browse/ARQ-2189?page=com.atlassian.jira.plugin.s...
]
Björn Kautler updated ARQ-2189:
-------------------------------
Description:
We just upgraded our Arquillian version to 1.4.0.Final and now the JUnit rules do not work
properly.
We have a {{LoginRule}} like
{code}
public class LoginRule implements TestRule
{
@EJB
private SecurityManagement securityManagement;
private String username;
private String password;
public LoginRule(String username, String password)
{
this.username = username;
this.password = password;
}
@Override
public Statement apply(Statement base, Description description)
{
return new Statement()
{
public void evaluate() throws Throwable
{
login();
base.evaluate();
}
};
}
...
}
{code}
If we use it in a test like
{code}
@Rule
public LoginRule login = new LoginRule("user", "pass");
@Test
public void test()
{
// do something with login
}
{code}
Unfortunately this does not work anymore, as {{securityManagement}} was not injected and
so the {{login}} method in the rule fails which would have used it.
With a subclass with default parameter like
{code}
public class CertainLoginRule extends LoginRule
{
public CertainLoginRule()
{
super("user", "pass");
}
}
{code}
and the usage
{code}
@Rule
public CertainLoginRule login = new CertainLoginRule();
@Test
public void test()
{
// do something with login
}
{code}
it works properly.
We tested different variations with subclass, without, constructors with parameters,
without and so on.
The significant part seems to be the parameters to the constructor. If there are none
injection works as expected, if there some, injection is not done. :-(
was:
We just upgraded our Arquillian version to 1.4.0.Final and now the JUnit rules do not work
properly.
We have a {{LoginRule}} like
{code}
public class LoginRule implements TestRule
{
@EJB
private SecurityManagement securityManagement;
private String username;
private String password;
public LoginRule(String username, String password)
{
this.username = username;
this.password = password;
}
@Override
public Statement apply(Statement base, Description description)
{
return new Statement()
{
public void evaluate() throws Throwable
{
login();
base.evaluate();
}
};
}
...
}
If we use it in a test like
{code}
@Rule
public LoginRule login = new LoginRule("user", "pass");
@Test
public void test()
{
// do something with login
}
{code}
Unfortunately this does not work anymore, as {{securityManagement}} was not injected and
so the {{login}} method in the rule fails which would have used it.
With a subclass with default parameter like
{code}
public class CertainLoginRule extends LoginRule
{
public CertainLoginRule()
{
super("user", "pass");
}
}
{code}
and the usage
{code}
@Rule
public CertainLoginRule login = new CertainLoginRule();
@Test
public void test()
{
// do something with login
}
{code}
it works properly.
We tested different variations with subclass, without, constructors with parameters,
without and so on.
The significant part seems to be the parameters to the constructor. If there are none
injection works as expected, if there some, injection is not done. :-(
Injection into JUnit rule does not work properly
------------------------------------------------
Key: ARQ-2189
URL:
https://issues.jboss.org/browse/ARQ-2189
Project: Arquillian
Issue Type: Bug
Affects Versions: 1.4.0.Final
Reporter: Björn Kautler
We just upgraded our Arquillian version to 1.4.0.Final and now the JUnit rules do not
work properly.
We have a {{LoginRule}} like
{code}
public class LoginRule implements TestRule
{
@EJB
private SecurityManagement securityManagement;
private String username;
private String password;
public LoginRule(String username, String password)
{
this.username = username;
this.password = password;
}
@Override
public Statement apply(Statement base, Description description)
{
return new Statement()
{
public void evaluate() throws Throwable
{
login();
base.evaluate();
}
};
}
...
}
{code}
If we use it in a test like
{code}
@Rule
public LoginRule login = new LoginRule("user", "pass");
@Test
public void test()
{
// do something with login
}
{code}
Unfortunately this does not work anymore, as {{securityManagement}} was not injected and
so the {{login}} method in the rule fails which would have used it.
With a subclass with default parameter like
{code}
public class CertainLoginRule extends LoginRule
{
public CertainLoginRule()
{
super("user", "pass");
}
}
{code}
and the usage
{code}
@Rule
public CertainLoginRule login = new CertainLoginRule();
@Test
public void test()
{
// do something with login
}
{code}
it works properly.
We tested different variations with subclass, without, constructors with parameters,
without and so on.
The significant part seems to be the parameters to the constructor. If there are none
injection works as expected, if there some, injection is not done. :-(
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)