Skip to content

Commit c93cbff

Browse files
author
eugenp
committed
integration testing work
1 parent 36b89aa commit c93cbff

8 files changed

Lines changed: 40 additions & 18 deletions

‎eclipse/INTEGRATION-ALL.launch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<listEntry value="1"/>
88
</listAttribute>
99
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
10-
<mapEntry key="persistenceTarget" value="hsqldb"/>
10+
<mapEntry key="persistenceTarget" value="test"/>
1111
<mapEntry key="target" value="dev"/>
1212
</mapAttribute>
1313
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>

‎eclipse/INTEGRATION-SINGLE.launch‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
33
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4-
<listEntry value="/rest/src/test/java/org/rest/sec/persistence/service/RoleServiceSearchPersistenceIntegrationTest.java"/>
4+
<listEntry value="/rest/src/test/java/org/rest/sec/web/privilege/PrivilegeLogicRESTIntegrationTest.java"/>
55
</listAttribute>
66
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
77
<listEntry value="1"/>
88
</listAttribute>
99
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
10-
<mapEntry key="persistenceTarget" value="hsqldb"/>
10+
<mapEntry key="persistenceTarget" value="test"/>
1111
<mapEntry key="target" value="dev"/>
1212
</mapAttribute>
1313
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
1414
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
15-
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
15+
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value="whenAResourceIsCreated_then201IsReceived"/>
1616
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
1717
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
18-
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.rest.sec.persistence.service.RoleServiceSearchPersistenceIntegrationTest"/>
18+
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.rest.sec.web.privilege.PrivilegeLogicRESTIntegrationTest"/>
1919
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="rest"/>
2020
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
2121
</launchConfiguration>

‎src/main/resources/persistence-mysql.properties‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jdbc.url=jdbc:mysql://localhost:3306/rest_01
55

66
# hibernate.X
77
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
8-
hibernate.show_sql=true
9-
hibernate.hbm2ddl.auto=create-drop
8+
hibernate.show_sql=false
9+
hibernate.hbm2ddl.auto=validate
1010

1111
# persistence.X
1212
jpa.generateDdl=true

‎src/test/java/org/rest/persistence/AbstractPersistenceServiceIntegrationTest.java‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,11 @@
1212
import org.hamcrest.Matchers;
1313
import org.junit.Ignore;
1414
import org.junit.Test;
15-
import org.junit.runner.RunWith;
1615
import org.rest.common.IEntity;
1716
import org.rest.persistence.service.IService;
18-
import org.rest.spring.context.ContextTestConfig;
19-
import org.rest.spring.persistence.jpa.PersistenceJPAConfig;
20-
import org.rest.spring.testing.TestingTestConfig;
2117
import org.springframework.dao.DataAccessException;
22-
import org.springframework.test.context.ContextConfiguration;
23-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
24-
import org.springframework.test.context.support.AnnotationConfigContextLoader;
18+
import org.springframework.test.annotation.Rollback;
2519

26-
@RunWith( SpringJUnit4ClassRunner.class )
27-
@ContextConfiguration( classes = { TestingTestConfig.class, PersistenceJPAConfig.class, ContextTestConfig.class },loader = AnnotationConfigContextLoader.class )
2820
public abstract class AbstractPersistenceServiceIntegrationTest< T extends IEntity >{
2921

3022
// tests
@@ -103,6 +95,7 @@ public void whenEntityWithIdIsCreated_thenDataAccessException(){
10395
getService().create( entityWithId );
10496
}
10597
@Test
98+
@Rollback
10699
public void whenEntityIsCreated_thenNoExceptions(){
107100
persistNewEntity();
108101
}

‎src/test/java/org/rest/sec/persistence/service/PrincipalServicePersistenceIntegrationTest.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44

55
import org.junit.Before;
66
import org.junit.Test;
7+
import org.junit.runner.RunWith;
78
import org.rest.persistence.AbstractPersistenceServiceIntegrationTest;
89
import org.rest.sec.model.Principal;
910
import org.rest.sec.model.Role;
11+
import org.rest.spring.context.ContextTestConfig;
12+
import org.rest.spring.persistence.jpa.PersistenceJPAConfig;
13+
import org.rest.spring.testing.TestingTestConfig;
1014
import org.springframework.beans.factory.annotation.Autowired;
1115
import org.springframework.dao.DataAccessException;
16+
import org.springframework.test.context.ContextConfiguration;
17+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
18+
import org.springframework.test.context.support.AnnotationConfigContextLoader;
1219

1320
import com.google.common.collect.Sets;
1421

22+
@RunWith( SpringJUnit4ClassRunner.class )
23+
@ContextConfiguration( classes = { TestingTestConfig.class, PersistenceJPAConfig.class, ContextTestConfig.class },loader = AnnotationConfigContextLoader.class )
1524
public class PrincipalServicePersistenceIntegrationTest extends AbstractPersistenceServiceIntegrationTest< Principal >{
1625

1726
@Autowired private IPrivilegeService privilegeService;

‎src/test/java/org/rest/sec/persistence/service/PrivilegeServicePersistenceIntegrationTest.java‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44

55
import org.junit.Before;
66
import org.junit.Test;
7+
import org.junit.runner.RunWith;
78
import org.rest.persistence.AbstractPersistenceServiceIntegrationTest;
89
import org.rest.sec.model.Privilege;
10+
import org.rest.spring.context.ContextTestConfig;
11+
import org.rest.spring.persistence.jpa.PersistenceJPAConfig;
12+
import org.rest.spring.testing.TestingTestConfig;
913
import org.springframework.beans.factory.annotation.Autowired;
1014
import org.springframework.dao.DataAccessException;
15+
import org.springframework.test.context.ContextConfiguration;
16+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
17+
import org.springframework.test.context.support.AnnotationConfigContextLoader;
1118

19+
@RunWith( SpringJUnit4ClassRunner.class )
20+
@ContextConfiguration( classes = { TestingTestConfig.class, PersistenceJPAConfig.class, ContextTestConfig.class },loader = AnnotationConfigContextLoader.class )
1221
public class PrivilegeServicePersistenceIntegrationTest extends AbstractPersistenceServiceIntegrationTest< Privilege >{
1322

1423
@Autowired private IPrivilegeService privilegeService;
@@ -22,9 +31,9 @@ public class PrivilegeServicePersistenceIntegrationTest extends AbstractPersiste
2231
*/
2332
@Before
2433
public final void before(){
25-
principalService.deleteAll();
34+
/*principalService.deleteAll();
2635
roleService.deleteAll();
27-
privilegeService.deleteAll();
36+
privilegeService.deleteAll();*/
2837
}
2938

3039
// create

‎src/test/java/org/rest/sec/persistence/service/RoleServicePersistenceIntegrationTest.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@
66

77
import org.junit.Before;
88
import org.junit.Test;
9+
import org.junit.runner.RunWith;
910
import org.rest.persistence.AbstractPersistenceServiceIntegrationTest;
1011
import org.rest.sec.model.Privilege;
1112
import org.rest.sec.model.Role;
13+
import org.rest.spring.context.ContextTestConfig;
14+
import org.rest.spring.persistence.jpa.PersistenceJPAConfig;
15+
import org.rest.spring.testing.TestingTestConfig;
1216
import org.springframework.beans.factory.annotation.Autowired;
1317
import org.springframework.dao.DataAccessException;
18+
import org.springframework.test.context.ContextConfiguration;
19+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
20+
import org.springframework.test.context.support.AnnotationConfigContextLoader;
1421

1522
import com.google.common.collect.Sets;
1623

24+
@RunWith( SpringJUnit4ClassRunner.class )
25+
@ContextConfiguration( classes = { TestingTestConfig.class, PersistenceJPAConfig.class, ContextTestConfig.class },loader = AnnotationConfigContextLoader.class )
1726
public class RoleServicePersistenceIntegrationTest extends AbstractPersistenceServiceIntegrationTest< Role >{
1827

1928
@Autowired private IPrivilegeService privilegeService;

‎src/test/java/org/rest/sec/persistence/service/RoleServiceSearchPersistenceIntegrationTest.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
import org.springframework.test.context.ContextConfiguration;
2121
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
2222
import org.springframework.test.context.support.AnnotationConfigContextLoader;
23+
import org.springframework.test.context.transaction.TransactionConfiguration;
2324

2425
import com.google.common.collect.Sets;
2526

2627
@RunWith( SpringJUnit4ClassRunner.class )
2728
@ContextConfiguration( classes = { TestingTestConfig.class, PersistenceJPAConfig.class, ContextTestConfig.class },loader = AnnotationConfigContextLoader.class )
2829
@SuppressWarnings( "unchecked" )
30+
@TransactionConfiguration( defaultRollback = true )
2931
public class RoleServiceSearchPersistenceIntegrationTest{
3032

3133
@Autowired private IPrivilegeService privilegeService;

0 commit comments

Comments
 (0)