Revision daf9013d
Added by Katja Luther over 12 years ago
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmEntityDaoBaseTest.java | ||
---|---|---|
18 | 18 |
import java.util.List; |
19 | 19 |
import java.util.UUID; |
20 | 20 |
|
21 |
import junit.framework.Assert; |
|
22 |
|
|
21 | 23 |
import org.junit.Before; |
22 | 24 |
import org.junit.Test; |
23 | 25 |
import org.springframework.security.authentication.AuthenticationManager; |
... | ... | |
29 | 31 |
import org.unitils.dbunit.annotation.ExpectedDataSet; |
30 | 32 |
import org.unitils.spring.annotation.SpringBeanByType; |
31 | 33 |
|
34 |
import eu.etaxonomy.cdm.database.EvaluationFailedException; |
|
32 | 35 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
33 | 36 |
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl; |
34 | 37 |
import eu.etaxonomy.cdm.model.common.User; |
... | ... | |
146 | 149 |
*/ |
147 | 150 |
@Test |
148 | 151 |
@DataSet("CdmEntityDaoBaseTest.xml") |
149 |
@ExpectedDataSet |
|
150 |
public void testSaveWithAuthentication() throws Exception { |
|
152 |
public void testSaveWithAuthenticationFailedPermissionEvaluation() throws Exception { |
|
151 | 153 |
User user = userDao.findByUuid(UUID.fromString("dbac0f20-07f2-11de-8c30-0800200c9a66")); |
152 | 154 |
assert user != null : "User cannot be null"; |
153 | 155 |
setAuthentication(user); |
156 |
List<User> userList = userDao.list(100, 0); |
|
157 |
|
|
158 |
try{ |
|
159 |
cdmEntityDaoBase.save(cdmBase); |
|
160 |
Assert.fail(); |
|
161 |
}catch(EvaluationFailedException e){ |
|
162 |
|
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
@Test |
|
167 |
@DataSet("CdmEntityDaoBaseTest.xml") |
|
168 |
|
|
169 |
public void testSaveWithAuthentication() throws Exception { |
|
170 |
User user = userDao.findByUuid(UUID.fromString("c026b289-1a36-4afc-8673-92ffe8ed05b6")); |
|
171 |
assert user != null : "User cannot be null"; |
|
172 |
setAuthentication(user); |
|
154 | 173 |
cdmEntityDaoBase.save(cdmBase); |
155 | 174 |
} |
156 |
|
|
157 | 175 |
/** |
158 | 176 |
* Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#update(eu.etaxonomy.cdm.model.common.CdmBase)}. |
159 | 177 |
*/ |
Also available in: Unified diff