[JBoss JIRA] (ARQ-2183) Websphere container waits for entire timeout if application failed to deploy
by Gerhard Poul (JIRA)
[ https://issues.jboss.org/browse/ARQ-2183?page=com.atlassian.jira.plugin.s... ]
Gerhard Poul updated ARQ-2183:
------------------------------
Status: Resolved (was: Pull Request Sent)
Resolution: Done
> Websphere container waits for entire timeout if application failed to deploy
> ----------------------------------------------------------------------------
>
> Key: ARQ-2183
> URL: https://issues.jboss.org/browse/ARQ-2183
> Project: Arquillian
> Issue Type: Enhancement
> Components: WebSphere Containers
> Affects Versions: 1.0.0.CR1
> Environment: WLP, WebSphere Liberty Profile 8.5 Managed Container
> Reporter: Hank Ibell
> Assignee: Gerhard Poul
>
> h3. Issue Overview
> Currently, running the CDI TCK against Liberty takes about 3 hours and 20 minutes to complete. It looks like the container waits for the application MBean to reach the STARTED state and only gives up after the timeout elapses.
> The CDI TCK uses many broken applications to test that they do not deploy, so waiting the entire timeout for each test is not ideal. However, with the changes in this pull request, the CDI TCK now runs in approximately 50 minutes now.
> h3. Expected Behaviour
> Do not wait for timeout for application that failed to deploy.
> h3. Current Behaviour
> Container waits for a timeout to elapse before checking the logs to see if the application failed due to a deployment exception causing tests to take much longer to finish.
> h3. Steps To Reproduce
> 1. Deploy a CDI application that fails to start up due to a CDI deployment exception.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 8 months
[JBoss JIRA] (ARQ-2184) Improve application deployment exception checking
by Hank Ibell (JIRA)
[ https://issues.jboss.org/browse/ARQ-2184?page=com.atlassian.jira.plugin.s... ]
Hank Ibell updated ARQ-2184:
----------------------------
Status: Resolved (was: Pull Request Sent)
Resolution: Done
> Improve application deployment exception checking
> -------------------------------------------------
>
> Key: ARQ-2184
> URL: https://issues.jboss.org/browse/ARQ-2184
> Project: Arquillian
> Issue Type: Bug
> Components: WebSphere Containers
> Affects Versions: 1.0.0.CR1
> Environment: WLP, WebSphere Liberty Profile 8.5 Managed Container
> Reporter: Hank Ibell
> Assignee: Gerhard Poul
>
> h3. Issue Overview
> The container does not check if an application failed to start up due to subclasses of DeploymentException which the CDI specification allows:
> bq. An implementation is permitted to throw a subclass of DeploymentException for any deployment problem.
> Additionally, the container should throw an Arquillian DeploymentException if the application fails to startup for any reason.
> h3. Expected Behaviour
> WAS container should throw a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException or any subclass of it.
> h3. Current Behaviour
> WAS container only throws a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 8 months
[JBoss JIRA] (ARQ-2184) Improve application deployment exception checking
by Hank Ibell (JIRA)
[ https://issues.jboss.org/browse/ARQ-2184?page=com.atlassian.jira.plugin.s... ]
Hank Ibell updated ARQ-2184:
----------------------------
Description:
h3. Issue Overview
The container does not check if an application failed to start up due to subclasses of DeploymentException which the CDI specification allows:
bq. An implementation is permitted to throw a subclass of DeploymentException for any deployment problem.
Additionally, the container should throw an Arquillian DeploymentException if the application fails to startup for any reason.
h3. Expected Behaviour
WAS container should throw a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException or any subclass of it.
h3. Current Behaviour
WAS container only throws a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException.
was:
h3. Issue Overview
The container does not check if an application failed to start up due to subclasses of DeploymentException which the CDI specification allows:
bq. An implementation is permitted to throw a subclass of DeploymentException for any deployment problem.
Additionally, the container should throw an Arquillian DeploymentException if the application fails to startup for any reason.
h3. Expected Behaviour
1.WAS container should throw a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException or any subclass of it.
h3. Current Behaviour
WAS container only throws a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException.
> Improve application deployment exception checking
> -------------------------------------------------
>
> Key: ARQ-2184
> URL: https://issues.jboss.org/browse/ARQ-2184
> Project: Arquillian
> Issue Type: Bug
> Components: WebSphere Containers
> Affects Versions: 1.0.0.CR1
> Environment: WLP, WebSphere Liberty Profile 8.5 Managed Container
> Reporter: Hank Ibell
> Assignee: Gerhard Poul
>
> h3. Issue Overview
> The container does not check if an application failed to start up due to subclasses of DeploymentException which the CDI specification allows:
> bq. An implementation is permitted to throw a subclass of DeploymentException for any deployment problem.
> Additionally, the container should throw an Arquillian DeploymentException if the application fails to startup for any reason.
> h3. Expected Behaviour
> WAS container should throw a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException or any subclass of it.
> h3. Current Behaviour
> WAS container only throws a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 8 months
[JBoss JIRA] (ARQ-2184) Improve application deployment exception checking
by Hank Ibell (JIRA)
[ https://issues.jboss.org/browse/ARQ-2184?page=com.atlassian.jira.plugin.s... ]
Hank Ibell updated ARQ-2184:
----------------------------
Status: Pull Request Sent (was: Open)
Git Pull Request: https://github.com/OpenLiberty/liberty-arquillian/pull/5
> Improve application deployment exception checking
> -------------------------------------------------
>
> Key: ARQ-2184
> URL: https://issues.jboss.org/browse/ARQ-2184
> Project: Arquillian
> Issue Type: Bug
> Components: WebSphere Containers
> Affects Versions: 1.0.0.CR1
> Environment: WLP, WebSphere Liberty Profile 8.5 Managed Container
> Reporter: Hank Ibell
> Assignee: Gerhard Poul
>
> h3. Issue Overview
> The container does not check if an application failed to start up due to subclasses of DeploymentException which the CDI specification allows:
> bq. An implementation is permitted to throw a subclass of DeploymentException for any deployment problem.
> Additionally, the container should throw an Arquillian DeploymentException if the application fails to startup for any reason.
> h3. Expected Behaviour
> 1.WAS container should throw a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException or any subclass of it.
> h3. Current Behaviour
> WAS container only throws a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 8 months
[JBoss JIRA] (ARQ-2184) Improve application deployment exception checking
by Hank Ibell (JIRA)
Hank Ibell created ARQ-2184:
-------------------------------
Summary: Improve application deployment exception checking
Key: ARQ-2184
URL: https://issues.jboss.org/browse/ARQ-2184
Project: Arquillian
Issue Type: Bug
Components: WebSphere Containers
Affects Versions: 1.0.0.CR1
Environment: WLP, WebSphere Liberty Profile 8.5 Managed Container
Reporter: Hank Ibell
Assignee: Gerhard Poul
h3. Issue Overview
The container does not check if an application failed to start up due to subclasses of DeploymentException which the CDI specification allows:
bq. An implementation is permitted to throw a subclass of DeploymentException for any deployment problem.
Additionally, the container should throw an Arquillian DeploymentException if the application fails to startup for any reason.
h3. Expected Behaviour
1.WAS container should throw a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException or any subclass of it.
h3. Current Behaviour
WAS container only throws a CDI DeploymentException if the application fails to startup due to a CDI DeploymentException.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 8 months
[JBoss JIRA] (ARQ-2183) Websphere container waits for entire timeout if application failed to deploy
by Hank Ibell (JIRA)
[ https://issues.jboss.org/browse/ARQ-2183?page=com.atlassian.jira.plugin.s... ]
Hank Ibell updated ARQ-2183:
----------------------------
Status: Pull Request Sent (was: Open)
Git Pull Request: https://github.com/OpenLiberty/liberty-arquillian/pull/4
> Websphere container waits for entire timeout if application failed to deploy
> ----------------------------------------------------------------------------
>
> Key: ARQ-2183
> URL: https://issues.jboss.org/browse/ARQ-2183
> Project: Arquillian
> Issue Type: Enhancement
> Components: WebSphere Containers
> Affects Versions: 1.0.0.CR1
> Environment: WLP, WebSphere Liberty Profile 8.5 Managed Container
> Reporter: Hank Ibell
> Assignee: Gerhard Poul
>
> h3. Issue Overview
> Currently, running the CDI TCK against Liberty takes about 3 hours and 20 minutes to complete. It looks like the container waits for the application MBean to reach the STARTED state and only gives up after the timeout elapses.
> The CDI TCK uses many broken applications to test that they do not deploy, so waiting the entire timeout for each test is not ideal. However, with the changes in this pull request, the CDI TCK now runs in approximately 50 minutes now.
> h3. Expected Behaviour
> Do not wait for timeout for application that failed to deploy.
> h3. Current Behaviour
> Container waits for a timeout to elapse before checking the logs to see if the application failed due to a deployment exception causing tests to take much longer to finish.
> h3. Steps To Reproduce
> 1. Deploy a CDI application that fails to start up due to a CDI deployment exception.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 8 months
[JBoss JIRA] (ARQ-2183) Websphere container waits for entire timeout if application failed to deploy
by Hank Ibell (JIRA)
Hank Ibell created ARQ-2183:
-------------------------------
Summary: Websphere container waits for entire timeout if application failed to deploy
Key: ARQ-2183
URL: https://issues.jboss.org/browse/ARQ-2183
Project: Arquillian
Issue Type: Enhancement
Components: WebSphere Containers
Affects Versions: 1.0.0.CR1
Environment: WLP, WebSphere Liberty Profile 8.5 Managed Container
Reporter: Hank Ibell
Assignee: Gerhard Poul
h3. Issue Overview
Currently, running the CDI TCK against Liberty takes about 3 hours and 20 minutes to complete. It looks like the container waits for the application MBean to reach the STARTED state and only gives up after the timeout elapses.
The CDI TCK uses many broken applications to test that they do not deploy, so waiting the entire timeout for each test is not ideal. However, with the changes in this pull request, the CDI TCK now runs in approximately 50 minutes now.
h3. Expected Behaviour
Do not wait for timeout for application that failed to deploy.
h3. Current Behaviour
Container waits for a timeout to elapse before checking the logs to see if the application failed due to a deployment exception causing tests to take much longer to finish.
h3. Steps To Reproduce
1. Deploy a CDI application that fails to start up due to a CDI deployment exception.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
6 years, 8 months
[JBoss JIRA] (ARQ-2182) @ApplyScriptBefore on test method is executed before methods annotated with @Before
by Matthias Bünger (JIRA)
[ https://issues.jboss.org/browse/ARQ-2182?page=com.atlassian.jira.plugin.s... ]
Matthias Bünger updated ARQ-2182:
---------------------------------
Description:
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.
was:
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: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.
> @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: Feature Request
> 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)
6 years, 8 months
[JBoss JIRA] (ARQ-2182) @ApplyScriptBefore on test method is executed before methods annotated with @Before
by Matthias Bünger (JIRA)
[ https://issues.jboss.org/browse/ARQ-2182?page=com.atlassian.jira.plugin.s... ]
Matthias Bünger updated ARQ-2182:
---------------------------------
Description:
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: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.
was:
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: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: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.
> @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: Feature Request
> 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: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)
6 years, 8 months
[JBoss JIRA] (ARQ-2182) @ApplyScriptBefore on test method is executed before methods annotated with @Before
by Matthias Bünger (JIRA)
[ https://issues.jboss.org/browse/ARQ-2182?page=com.atlassian.jira.plugin.s... ]
Matthias Bünger updated ARQ-2182:
---------------------------------
Description:
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: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: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.
was:
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: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}
the "moreusers.sql"
{{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;}}
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
{{@ApplyScriptBefore({ "prepare_test.sql", "moreusers.sql" })}}
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.
> @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: Feature Request
> 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: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: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)
6 years, 8 months