Changeset 3450
- Timestamp:
- 08/20/13 15:54:35 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/nb-configuration.xml
r3221 r3450 20 20 <config-files> 21 21 <config-file>src/main/resources/spring-config/sourceDao.xml</config-file> 22 <config-file>src/main/resources/spring-config/ VersionDao.xml</config-file>23 <config-file>src/main/resources/spring-config/ CachedRepresentationDao.xml</config-file>22 <config-file>src/main/resources/spring-config/versionDao.xml</config-file> 23 <config-file>src/main/resources/spring-config/cachedRepresentationDao.xml</config-file> 24 24 <config-file>src/test/resources/spring-test-config/mockVersionDao.xml</config-file> 25 <config-file>src/test/resources/spring-test-config/mock CachedRepresenationDao.xml</config-file>25 <config-file>src/test/resources/spring-test-config/mockDaoDispatcher.xml</config-file> 26 26 </config-files> 27 27 <config-file-groups/> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/MockObjectsFactory.java
r3408 r3450 24 24 import eu.dasish.annotation.backend.dao.UserDao; 25 25 import eu.dasish.annotation.backend.dao.VersionDao; 26 import eu.dasish.annotation.backend.rest.DaoDispatcher; 26 27 import org.jmock.Mockery; 27 28 … … 63 64 return context.mock(VersionDao.class); 64 65 } 66 67 public DaoDispatcher newDaoDispatcher() { 68 return context.mock(DaoDispatcher.class); 69 } 65 70 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java
r3413 r3450 232 232 assertEquals(6, newAnnotationID); 233 233 234 // checking 234 235 Annotation addedAnnotation= jdbcAnnotationDao.getAnnotationWithoutSources(6); 235 236 assertFalse(null == addedAnnotation.getURI()); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDaoTest.java
r3413 r3450 123 123 124 124 Number result = jdbcCachedRepresentationDao.addCachedRepresentationInfo(cached); 125 // checking 125 126 CachedRepresentationInfo addedCached = jdbcCachedRepresentationDao.getCachedRepresentationInfo(result); 126 127 assertEquals(8, result.intValue()); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDaoTest.java
r3413 r3450 133 133 Number result = jdbcSourceDao.addSource(freshSource); 134 134 assertEquals(6, result); 135 // detailed checking 135 136 Source addedSource = jdbcSourceDao.getSource(result); 136 137 assertEquals(link, addedSource.getLink()); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDaoTest.java
r3413 r3450 109 109 Number result = jdbcVersionDao.addVersion(freshVersion); 110 110 assertEquals(8, result); 111 // detailed checking 111 112 Version addedVersion = jdbcVersionDao.getVersion(result); 112 113 assertFalse(null == addedVersion.getVersion()); // extend once "version" information is fixed, and becomes different from externalID -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r3408 r3450 21 21 import eu.dasish.annotation.backend.TestBackendConstants; 22 22 import eu.dasish.annotation.backend.TestInstances; 23 import eu.dasish.annotation.backend.dao.AnnotationDao;24 import eu.dasish.annotation.backend.dao.NotebookDao;25 import eu.dasish.annotation.backend.dao.SourceDao;26 import eu.dasish.annotation.backend.dao.UserDao;27 23 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier; 28 24 import eu.dasish.annotation.backend.identifiers.UserIdentifier; 29 25 import eu.dasish.annotation.schema.Annotation; 30 import eu.dasish.annotation.schema.ResourceREF;31 26 import java.sql.SQLException; 32 27 import javax.xml.bind.JAXBElement; … … 41 36 import java.lang.InstantiationException; 42 37 import javax.servlet.ServletException; 43 import org.junit.Ignore;44 38 import org.springframework.mock.web.MockHttpServletRequest; 45 39 /** … … 49 43 50 44 @RunWith(value = SpringJUnit4ClassRunner.class) 51 @ContextConfiguration(locations = {"/spring-test-config/dataSource.xml", "/spring-test-config/mockAnnotationDao.xml", 52 "/spring-test-config/mockSourceDao.xml", 53 "/spring-test-config/mockUserDao.xml", "/spring-test-config/mockNotebookDao.xml", "/spring-test-config/mockery.xml"}) 45 @ContextConfiguration(locations = {"/spring-test-config/dataSource.xml", "/spring-test-config/mockDaoDispatcher.xml", 46 "/spring-test-config/mockery.xml", }) 54 47 public class AnnotationResourceTest { 55 48 … … 57 50 private Mockery mockery; 58 51 @Autowired 59 private AnnotationDao annotationDao; 60 @Autowired 61 private UserDao userDao; 62 @Autowired 63 private NotebookDao notebookDao; 64 @Autowired 65 private SourceDao sourceDao; 66 52 private DaoDispatcher daoDispatcher; 67 53 @Autowired 68 54 private AnnotationResource annotationResource; … … 76 62 */ 77 63 @Test 78 @Ignore79 64 public void testGetAnnotation() throws SQLException { 80 65 System.out.println("getAnnotation"); … … 82 67 final int annotationID = 2; 83 68 final Annotation expectedAnnotation = (new TestInstances()).getAnnotationOne(); 84 // the result of the mocking chain is the same as the expected annotation. 85 // mockery.checking(new Expectations() { 86 // { 87 // oneOf(annotationDao).getInternalID(new AnnotationIdentifier(annotationIdentifier)); 88 // will(returnValue(annotationID)); 89 // 90 // oneOf(annotationDao).getAnnotation(annotationID); 91 // will(returnValue(expectedAnnotation)); 92 // } 93 // }); 69 70 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(new AnnotationIdentifier(annotationIdentifier)); 71 //final Annotation annotation = daoDispatcher.getAnnotation(annotationID); 72 mockery.checking(new Expectations() { 73 { 74 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(AnnotationIdentifier.class))); 75 will(returnValue(annotationID)); 76 77 oneOf(daoDispatcher).getAnnotation(annotationID); 78 will(returnValue(expectedAnnotation)); 79 } 80 }); 94 81 95 82 JAXBElement<Annotation> result = annotationResource.getAnnotation(annotationIdentifier); … … 103 90 public void testDeleteAnnotation() throws SQLException { 104 91 System.out.println("deleteAnnotation"); 105 92 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(new AnnotationIdentifier(annotationIdentifier)); 93 //int[] resultDelete = daoDispatcher.deleteAnnotation(annotationID); 106 94 107 95 mockery.checking(new Expectations() { 108 96 { 109 oneOf( annotationDao).getInternalID(new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_5_EXT));97 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(AnnotationIdentifier.class))); 110 98 will(returnValue(5)); 111 99 112 oneOf( annotationDao).deleteAnnotation(5);100 oneOf(daoDispatcher).deleteAnnotation(5); 113 101 will(returnValue(1)); 114 102 } … … 117 105 String result = annotationResource.deleteAnnotation(TestBackendConstants._TEST_ANNOT_5_EXT); 118 106 assertEquals("1", result); 119 120 // now, try to delete the same annotation one more time121 // if it has been already deleted then the method under testing should return 0122 mockery.checking(new Expectations() {123 {124 oneOf(annotationDao).getInternalID(new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_5_EXT));125 will(returnValue(5));126 127 oneOf(annotationDao).deleteAnnotation(5);128 will(returnValue(0));129 }130 });131 132 result = annotationResource.deleteAnnotation(TestBackendConstants._TEST_ANNOT_5_EXT);133 assertEquals("0", result);134 107 } 135 108 … … 138 111 */ 139 112 @Test 140 @Ignore141 113 public void testCreateAnnotation() throws SQLException, InstantiationException, IllegalAccessException, ServletException { 142 114 System.out.println("test createAnnotation"); 143 115 final Annotation annotationToAdd = new GenericType<Annotation>(){}.getRawClass().newInstance(); 144 116 145 final Annotation addedAnnotation = annotationToAdd; 146 final AnnotationIdentifier annotationIdentifier = new GenericType<AnnotationIdentifier>(){}.getRawClass().newInstance(); 147 addedAnnotation.setURI(annotationIdentifier.toString()); 148 ResourceREF ownerRef = new ResourceREF(); 149 ownerRef.setRef(String.valueOf(5)); 150 addedAnnotation.setOwner(ownerRef); 151 152 final UserIdentifier owner = new UserIdentifier(TestBackendConstants._TEST_USER_5_EXT_ID); 117 // Number userID = null; 118 // if (remoteUser != null) { 119 // userID = daoDispatcher.getUserInternalIdentifier(new UserIdentifier(remoteUser)); 120 // } 121 // Number newAnnotationID = daoDispatcher.addUsersAnnotation(annotation, userID); 122 // Annotation newAnnotation = daoDispatcher.getAnnotation(newAnnotationID); 153 123 154 // mockery.checking(new Expectations() { 155 // { 156 // oneOf(userDao).getInternalID(owner); 157 // will(returnValue(5)); 158 // 159 // oneOf(annotationDao).addAnnotation(annotationToAdd, 5); 160 // will(returnValue(addedAnnotation)); 161 // 162 // oneOf(permissionsDao).addAnnotationPrincipalPermission(annotationIdentifier, owner, Permission.OWNER); 163 // will(returnValue(1)); 164 // } 165 // }); 124 mockery.checking(new Expectations() { 125 { 126 oneOf(daoDispatcher).getUserInternalIdentifier(with(aNonNull(UserIdentifier.class))); 127 will(returnValue(5)); 128 129 oneOf(daoDispatcher).addUsersAnnotation(annotationToAdd, 5); 130 will(returnValue(1)); 131 } 132 }); 166 133 167 134 … … 173 140 JAXBElement<Annotation> result = annotationResource.createAnnotation(annotationToAdd); 174 141 assertEquals(String.valueOf(5), result.getValue().getOwner().getRef()); 175 assertEquals(annotationIdentifier.toString(), result.getValue().getURI()); 176 142 assertFalse(null == result.getValue().getURI()); 177 143 178 144 }
Note: See TracChangeset
for help on using the changeset viewer.