From issues at jboss.org Sun May 13 04:01:00 2018 From: issues at jboss.org (=?UTF-8?Q?Matthias_B=C3=BCnger_=28JIRA=29?=) Date: Sun, 13 May 2018 04:01:00 -0400 (EDT) Subject: [arquillian-issues] [JBoss JIRA] (ARQ-2182) @ApplyScriptBefore on test method is executed before methods annotated with @Before In-Reply-To: References: Message-ID: [ https://issues.jboss.org/browse/ARQ-2182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Matthias B?nger updated ARQ-2182: --------------------------------- Issue Type: Bug (was: Feature Request) > @ApplyScriptBefore on test method is executed before methods annotated with @Before > ----------------------------------------------------------------------------------- > > Key: ARQ-2182 > URL: https://issues.jboss.org/browse/ARQ-2182 > Project: Arquillian > Issue Type: Bug > Components: Extension - Persistence > Affects Versions: persistence_1.0.0.Alpha7 > Environment: JBoss Wildfly > Oracle 11 > Arquillian 1.4.0.FINAL > Persistence_Extension 1.0.0.Alpha7 > Reporter: Matthias B?nger > Assignee: Bartosz Majsak > > I want to use an setUp-method annotated with {{@Before}} to apply a script with general preparations, executed before each method of my test class. In this script ("prepare_test.sql") I empty a table and insert some records. For this I used the {{@ApplyScriptBefore}}. > In one of my test cases I want to insert more records and apply another script ("moreusers", which only has some insert statements). > See this class > {code:title=DataSourceTest.java|borderStyle=solid} > @RunWith(Arquillian.class) > public class DataSourceTest { > @Before > @ApplyScriptBefore({ "prepare_test.sql" }) > public void setUp() { > System.out.println("SetUp"); > } > @ApplyScriptBefore({ "moreusers.sql" }) > @Test > public void GetAllEmps() { > // The "prepare_test.sql" and the "moreusers.sql" should have been applied > } > > @Test > public void OtherTest() { > // Only the "prepare_test.sql" should have been applied > } > } > {code} > {code:sql|title=prepare_test.sql|borderStyle=solid} > delete from bish.EMP; > -- 14 Default-Employes > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7839','KING','PRESIDENT',null,to_date('17.11.81','DD.MM.RR'),'5000',null,'10'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7698','BLAKE','MANAGER','7839',to_date('01.05.81','DD.MM.RR'),'2850',null,'30'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7782','CLARK','MANAGER','7839',to_date('09.06.81','DD.MM.RR'),'2450',null,'10'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7566','JONES','MANAGER','7839',to_date('02.04.81','DD.MM.RR'),'2975',null,'20'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7788','SCOTT','ANALYST','7566',to_date('09.12.82','DD.MM.RR'),'3000',null,'20'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7902','FORD','ANALYST','7566',to_date('03.12.81','DD.MM.RR'),'3000',null,'20'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7369','SMITH','CLERK','7902',to_date('17.12.80','DD.MM.RR'),'800',null,'20'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7499','ALLEN','SALESMAN','7698',to_date('20.02.81','DD.MM.RR'),'1600','300','30'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7521','WARD','SALESMAN','7698',to_date('22.02.81','DD.MM.RR'),'1250','500','30'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7654','MARTIN','SALESMAN','7698',to_date('28.09.81','DD.MM.RR'),'1250','1400','30'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7844','TURNER','SALESMAN','7698',to_date('08.09.81','DD.MM.RR'),'1500','0','30'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7876','ADAMS','CLERK','7788',to_date('12.01.83','DD.MM.RR'),'1100',null,'20'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7900','JAMES','CLERK','7698',to_date('03.12.81','DD.MM.RR'),'950',null,'30'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('7934','MILLER','CLERK','7782',to_date('23.01.82','DD.MM.RR'),'1300',null,'10'); > -- Standard noch 2 dazu, macht 16 > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('9999','Test','Eins','7782',to_date('23.01.82','DD.MM.RR'),'1300',null,'10'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('9998','Test','Zwei','7782',to_date('23.01.82','DD.MM.RR'),'1300',null,'10'); > commit; > {code} > {code:sql|title=moreusers.sql|borderStyle=solid} > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('9997','Test','Drei','7782',to_date('23.01.82','DD.MM.RR'),'1300',null,'10'); > Insert into bish.EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values ('9996','Test','Vier','7782',to_date('23.01.82','DD.MM.RR'),'1300',null,'10'); > commit; > {code} > I think you get the situation. I won't focus the "{{OtherTest()}}" method no more in the description. > When I now execute the {{GetAllEmps()}} I get constraint problems (parent key not found for coloum mgr), because the script "{{moreusers.sql}}" is executed before the "{{prepare_tests.sql}}". > If I delete the {{setUpMethod}} and annotate the testmethod {{GetAllEmps()}} with both scripts > {code:borderStyle=solid} > @ApplyScriptBefore({ "prepare_test.sql", "moreusers.sql" }) > {code} > then the test passes, because the execution order ist correct and both scripts are applied. But I don't want to annotate every test method with the default script which should run before every test, but only annotate those methods which need further scripts/data. > So I would expect that the method annotated with {{@Before}} and its other annotations are executed before a "normal" test method and its annotations are executed. The docs say so, but the descriped scenario above shows that this is not reality. -- This message was sent by Atlassian JIRA (v7.5.0#75005) From issues at jboss.org Tue May 29 09:18:00 2018 From: issues at jboss.org (=?UTF-8?Q?Bj=C3=B6rn_Kautler_=28JIRA=29?=) Date: Tue, 29 May 2018 09:18:00 -0400 (EDT) Subject: [arquillian-issues] [JBoss JIRA] (ARQ-2034) Test enrichment and JUnit @Rule do not harmonize In-Reply-To: References: Message-ID: [ https://issues.jboss.org/browse/ARQ-2034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13583524#comment-13583524 ] Bj?rn Kautler commented on ARQ-2034: ------------------------------------ [~mjobanek] as those two commits were not merged, but {{e633190}} instead, does that solve both points, or just the first one? > Test enrichment and JUnit @Rule do not harmonize > ------------------------------------------------ > > Key: ARQ-2034 > URL: https://issues.jboss.org/browse/ARQ-2034 > Project: Arquillian > Issue Type: Bug > Components: Base Implementation > Affects Versions: 1.1.11.Final > Environment: junit 4.11 > arquillian-junit-container 1.1.11.Final > wildfly-arquillian-container-remote 8.1.0.Final > Reporter: Bj?rn Kautler > Assignee: Matous Jobanek > Fix For: 1.1.12.Final > > > We are starting with Arquillian tests on a remote WildFly instance. > I tried to write a JUnit {{@Rule}}, that can be used to make a login call for all test methods automatically, but I was not yet able to make it work, as I need an injected {{@Ejb}} instance for this. > I tried to add {{@EJB private InterfaceLoginManagement interfaceLoginManagement;}} to the {{TestRule}} implementation, but it stays {{null}}. I've read at ARQ-1954 that this should probably work, but unfortunately it is not, at least not with the remote container runner. {{org.jboss.arquillian.junit.extension.JUnitCoreExtension}} that should register {{org.jboss.arquillian.junit.extension.UpdateTestResultBeforeAfter}} and {{org.jboss.arquillian.junit.RulesEnricher}} is not even loaded on the container side. Maybe the {{META-INF/services/}} file is missing? > Then I tried to simply give the injected instance to the rule from the test class like > {code} > @EJB private InterfaceLoginManagement interfaceLoginManagement; > @Rule private LoginRule loginRule = new LoginRule(interfaceLoginManagement); > {code} > or even > {code} > @EJB private InterfaceLoginManagement interfaceLoginManagement; > @Rule public LoginRule getLoginRule() { > return new LoginRule(() -> { > return interfaceLoginManagement; > }); > } > {code} > with the {{LoginRule}} receiving a {{Supplier}} and call it as late as possible, i. e. in the rules {{apply()}} method. But even this is still too early as the EJB is still {{null}} and the test enrichers are only run between the {{@Rule}} applying and {{@Before}} methods. > So I'd like to suggest two things: > # Fix the implementation of ARQ-1954 if it should work on container side which I assume it should > # Make the test enrichments earlier in the lifecycle, i. e. before the {{@Rule}} s are being applied, or rather even before the {{@Rule}} methods are called, so that you at least can use the injected instances in the {{@Rule}} annotated methods to forward them to a rule. This is necessary even if top 1 is taken care of, because you might want to use a 3rd Party rule the code of which you cannot change. -- This message was sent by Atlassian JIRA (v7.5.0#75005)