Changeset 3598
- Timestamp:
- 09/20/13 13:51:10 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/nb-configuration.xml
r3452 r3598 23 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/mockDaoDispatcher.xml</config-file> 26 <config-file>src/main/resources/spring-config/daoDispatcher.xml</config-file> 25 <config-file>src/main/resources/spring-config/resourceDao.xml</config-file> 27 26 </config-files> 28 27 <config-file-groups/> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/ResourceDao.java
r3593 r3598 36 36 public Number getInternalID(UUID externalId); 37 37 38 39 /** 40 * 41 * @param uri 42 * @return internal identifier of the resource with uri, or null if there is no resource with this uri 43 */ 44 public Number getInternalIDFromURI(String uri); 45 38 46 /** 39 47 * -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java
r3596 r3598 133 133 public Number[] addCachedForVersion(Number versionID, CachedRepresentationInfo cachedInfo, Blob cachedBlob) { 134 134 Number[] result = new Number[2]; 135 String cachedExternalIDstring = cachedInfo.getRef(); 136 UUID cachedUUID = (cachedExternalIDstring != null) ? UUID.fromString(cachedExternalIDstring) : null; 137 result[1] = cachedRepresentationDao.getInternalID(cachedUUID); 135 result[1] = cachedRepresentationDao.getInternalIDFromURI(cachedInfo.getRef()); 138 136 if (result[1] == null) { 139 137 result[1] = cachedRepresentationDao.addCachedRepresentation(cachedInfo, cachedBlob); … … 144 142 } 145 143 144 146 145 @Override 147 146 public Number[] addSiblingVersionForSource(Number sourceID, Version version) throws SQLException { 148 147 Number[] result = new Number[2]; 149 String versionURI = version.getURI(); 150 UUID versionUUID = (versionURI != null) ? UUID.fromString(versionDao.stringURItoExternalID(versionURI)) : null; 151 result[1] = versionDao.getInternalID(versionUUID); 148 result[1] = versionDao.getInternalIDFromURI(version.getURI()); 152 149 if (result[1] == null) { 153 150 result[1] = versionDao.addVersion(version); … … 157 154 } 158 155 156 // TODo: mapping uri to external ID 159 157 @Override 160 158 public Map<String, String> addSourcesForAnnotation(Number annotationID, List<SourceInfo> sources) throws SQLException { 161 159 Map<String, String> result = new HashMap<String, String>(); 162 for (SourceInfo sourceInfo : sources) { 163 if (sourceExists(sourceInfo)) { 164 int affectedRows = annotationDao.addAnnotationSource(annotationID, sourceDao.getInternalID(UUID.fromString(sourceInfo.getRef()))); 160 Number sourceIDRunner; 161 for (SourceInfo sourceInfo : sources) { 162 sourceIDRunner = sourceDao.getInternalIDFromURI(sourceInfo.getRef()); 163 if (sourceIDRunner != null) { 164 int affectedRows = annotationDao.addAnnotationSource(annotationID, sourceIDRunner); 165 165 } else { 166 166 Source newSource = createFreshSource(sourceInfo); … … 168 168 Number sourceID = sourceDao.addSource(newSource); 169 169 Number[] intermediateResult = addSiblingVersionForSource(sourceID, newVersion); 170 result.put(sourceInfo.getRef(), sourceDao.getExternalID(sourceID).toString()); 170 String sourceTemporaryID = sourceDao.stringURItoExternalID(sourceInfo.getRef()); 171 result.put(sourceTemporaryID, sourceDao.getExternalID(sourceID).toString()); 171 172 int affectedRows = annotationDao.addAnnotationSource(annotationID, sourceID); 172 173 } … … 175 176 } 176 177 177 // TODO add more criteria of being an existing sources178 private boolean sourceExists(SourceInfo sourceInfo) {179 boolean result = (sourceDao.getInternalID(UUID.fromString(sourceInfo.getRef())) != null);180 return result;181 }182 178 183 179 @Override -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java
r3596 r3598 24 24 import java.util.List; 25 25 import java.util.UUID; 26 import javax.sql.DataSource; 26 27 import javax.xml.datatype.DatatypeConfigurationException; 27 28 import javax.xml.datatype.XMLGregorianCalendar; … … 89 90 protected String _serviceURI; 90 91 91 92 92 93 93 94 /////////////////// Class field SETTERS ///////////// … … 112 113 } 113 114 115 ///////////////////////////////////////////// 114 116 @Override 115 117 public UUID getExternalID(Number internalId) { … … 120 122 } 121 123 124 ////////////////////////////////////////////// 125 @Override 126 public Number getInternalIDFromURI(String uri) { 127 String externalID = stringURItoExternalID(uri); 128 return getInternalID(UUID.fromString(externalID)); 129 } 130 122 131 ///////////////////////////////////////////////////// 123 132 protected XMLGregorianCalendar retrieveTimeStamp(Number internalID) { -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/resources/spring-config/dbIntegrityService.xml
r3477 r3598 25 25 "> 26 26 <bean class="eu.dasish.annotation.backend.dao.impl.DBIntegrityServiceImlp"> 27 <!-- <constructor-arg ref="dataSource"/> -->28 27 </bean> 29 28 </beans> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceTest.java
r3596 r3598 79 79 @Autowired 80 80 private AnnotationDao annotationDao; 81 @Autowired82 private NotebookDao notebookDao;81 82 83 83 TestInstances testInstances = new TestInstances(); 84 84 … … 288 288 String type = "text"; 289 289 String tool = "latex"; 290 String externalID = UUID.randomUUID().toString(); 290 291 final CachedRepresentationInfo newCachedInfo = new CachedRepresentationInfo(); 291 292 newCachedInfo.setMimeType(mime); 292 293 newCachedInfo.setType(type); 293 294 newCachedInfo.setTool(tool); 295 newCachedInfo.setRef(TestBackendConstants._TEST_SERVLET_URI + externalID); 294 296 295 297 String blobString = "aaa"; … … 300 302 mockery.checking(new Expectations() { 301 303 { 302 oneOf(cachedRepresentationDao).getInternalID(null); 304 305 oneOf(cachedRepresentationDao).getInternalIDFromURI(newCachedInfo.getRef()); 303 306 will(returnValue(null)); 304 307 … … 322 325 * Test of addSiblingVersionForSource method, of class DBIntegrityServiceImlp. 323 326 */ 327 // TODO: teset with non-null esrive URI 324 328 @Test 325 329 public void testAddSiblingVersionForSource() throws Exception { … … 328 332 // test adding completely new version 329 333 final Version mockVersion = new Version(); // should be # 8 330 final UUID mockUUID = UUID.randomUUID();331 mockVersion.setURI( mockUUID.toString()); // _serviceURI is assumed to be null for this test, therefore URI coincides with the externalID of the version334 String externalID = UUID.randomUUID().toString(); 335 mockVersion.setURI(TestBackendConstants._TEST_SERVLET_URI + externalID); 332 336 mockVersion.setVersion("version 8"); 333 337 334 338 mockery.checking(new Expectations() { 335 339 { 336 oneOf(versionDao).stringURItoExternalID(mockUUID.toString()); 337 will(returnValue(mockUUID.toString())); 338 339 oneOf(versionDao).getInternalID(mockUUID); 340 oneOf(versionDao).getInternalIDFromURI(mockVersion.getURI()); 340 341 will(returnValue(null)); 341 342 … … 358 359 359 360 final Version mockVersionTwo = new Version(); // should be # 3 360 final UUID mockUUIDTwo = UUID.fromString(TestBackendConstants._TEST_VERSION_3_EXT_ID); 361 mockVersionTwo.setURI(mockUUIDTwo.toString()); // _serviceURI is assumed to be null for this test,therefore URI coincides with the externalID of the version 361 mockVersionTwo.setURI(TestBackendConstants._TEST_SERVLET_URI + TestBackendConstants._TEST_VERSION_3_EXT_ID); 362 362 mockVersionTwo.setVersion("version 3"); 363 363 364 364 mockery.checking(new Expectations() { 365 365 { 366 oneOf(versionDao).stringURItoExternalID(mockUUIDTwo.toString()); 367 will(returnValue(mockUUIDTwo.toString())); 368 369 oneOf(versionDao).getInternalID(mockUUIDTwo); 366 oneOf(versionDao).getInternalIDFromURI(mockVersionTwo.getURI()); 370 367 will(returnValue(3)); 371 368 … … 390 387 SourceInfo testSourceOne = new SourceInfo(); 391 388 testSourceOne.setLink(TestBackendConstants._TEST_SOURCE_1_LINK); 392 testSourceOne.setRef(TestBackendConstants._TEST_S OURCE_1_EXT_ID);389 testSourceOne.setRef(TestBackendConstants._TEST_SERVLET_URI + TestBackendConstants._TEST_SOURCE_1_EXT_ID); 393 390 testSourceOne.setVersion(TestBackendConstants._TEST_VERSION_1_EXT_ID); 394 List<SourceInfo> mockSourceListOne = new ArrayList<SourceInfo>();391 final List<SourceInfo> mockSourceListOne = new ArrayList<SourceInfo>(); 395 392 mockSourceListOne.add(testSourceOne); 396 393 397 394 mockery.checking(new Expectations() { 398 395 { 399 // in sourceExists 400 oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class))); 396 oneOf(sourceDao).getInternalIDFromURI(mockSourceListOne.get(0).getRef()); 401 397 will(returnValue(1)); 402 398 403 // in addSourceForAnnotationItself404 oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class)));405 will(returnValue(1));406 407 399 oneOf(annotationDao).addAnnotationSource(1, 1); 408 400 will(returnValue(1)); … … 415 407 // test 2: adding a new source 416 408 SourceInfo testSourceTwo = new SourceInfo(); 417 testSourceTwo.setRef(UUID.randomUUID().toString()); 409 final String tempSourceID = UUID.randomUUID().toString(); 410 testSourceTwo.setRef(TestBackendConstants._TEST_SERVLET_URI + tempSourceID); 418 411 testSourceTwo.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK); 419 412 testSourceTwo.setVersion("version 1.0"); 420 List<SourceInfo> mockSourceListTwo = new ArrayList<SourceInfo>();413 final List<SourceInfo> mockSourceListTwo = new ArrayList<SourceInfo>(); 421 414 mockSourceListTwo.add(testSourceTwo); 422 415 … … 425 418 mockery.checking(new Expectations() { 426 419 { 427 // in sourceExists 428 oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class))); 420 oneOf(sourceDao).getInternalIDFromURI(mockSourceListTwo.get(0).getRef()); 429 421 will(returnValue(null)); 422 430 423 431 424 oneOf(sourceDao).addSource(with(aNonNull(Source.class))); … … 433 426 434 427 //////////// mockery in the call addSiblingVersionForSource ////////////// 428 oneOf(versionDao).getInternalIDFromURI(null); 429 will(returnValue(null)); 435 430 436 oneOf(versionDao).getInternalID(null);437 will(returnValue(null));438 439 431 oneOf(versionDao).addVersion(with(aNonNull(Version.class))); 440 432 will(returnValue(8)); // next free number … … 445 437 ////////////////////////////////////// 446 438 439 oneOf(sourceDao).stringURItoExternalID(mockSourceListTwo.get(0).getRef()); 440 will(returnValue(tempSourceID)); 441 447 442 oneOf(sourceDao).getExternalID(6); 448 443 will(returnValue(mockNewSourceUUID)); … … 456 451 Map<String, String> resultTwo = dbIntegrityService.addSourcesForAnnotation(1, mockSourceListTwo); 457 452 assertEquals(1, resultTwo.size()); 458 assertEquals( resultTwo.get(testSourceTwo.getRef()), mockNewSourceUUID.toString());453 assertEquals(mockNewSourceUUID.toString(), resultTwo.get(tempSourceID)); 459 454 460 455 } … … 476 471 477 472 // expectations for addSourcesForannotation 478 // first check if the source exists 479 oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class))); 473 oneOf(sourceDao).getInternalIDFromURI(with(aNonNull(String.class))); 480 474 will(returnValue(1)); 481 475 482 oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class)));483 will(returnValue(1));484 485 476 oneOf(annotationDao).addAnnotationSource(6, 1); 486 477 will(returnValue(1)); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java
r3594 r3598 182 182 assertEquals(null, annotaionIdNull); 183 183 } 184 185 /** 186 * Test of getInternalIDFromURI method, 187 * public Number getInternalIDFromURI(UUID externalID); 188 */ 189 @Test 190 public void testGetInternalIDFRomURI() { 191 System.out.println("test getInternalIDFromURI"); 192 jdbcAnnotationDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI); 193 String uri = TestBackendConstants._TEST_SERVLET_URI + TestBackendConstants._TEST_ANNOT_2_EXT; 194 Number result = jdbcAnnotationDao.getInternalIDFromURI(uri); 195 assertEquals(2, result.intValue()); 196 } 184 197 185 198 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDaoTest.java
r3596 r3598 20 20 import eu.dasish.annotation.backend.TestBackendConstants; 21 21 import eu.dasish.annotation.schema.CachedRepresentationInfo; 22 import java.io.InputStream;23 22 import java.io.UnsupportedEncodingException; 24 23 import java.sql.Blob; … … 27 26 import javax.sql.rowset.serial.SerialBlob; 28 27 import javax.sql.rowset.serial.SerialException; 29 import org.hsqldb.jdbc.JDBCBlobClient;30 28 import org.junit.Test; 31 29 import static org.junit.Assert.*; … … 39 37 * @author olhsha 40 38 */ 41 42 39 @RunWith(SpringJUnit4ClassRunner.class) 43 40 @ContextConfiguration({"/spring-test-config/dataSource.xml", "/spring-config/cachedRepresentationDao.xml"}) 44 public class JdbcCachedRepresentationDaoTest extends JdbcResourceDaoTest {45 41 public class JdbcCachedRepresentationDaoTest extends JdbcResourceDaoTest { 42 46 43 @Autowired 47 JdbcCachedRepresentationDao jdbcCachedRepresentationDao; 48 49 44 JdbcCachedRepresentationDao jdbcCachedRepresentationDao; 45 50 46 public JdbcCachedRepresentationDaoTest() { 51 47 } 52 53 54 48 55 49 /** 56 50 * Test of getExternalId method, of class JdbcCachedRepresentationDao. 57 51 * public UUID getExternalId(Number internalID); 58 52 * 59 53 */ 60 @Test 54 @Test 61 55 public void testGetExternalId() { 62 56 System.out.println("getExternalId"); … … 66 60 assertEquals(expResult, result); 67 61 } 68 69 62 70 63 /** 71 64 * Test of getInternalId method, of class JdbcCachedRepresentationDao. 72 * public 65 * public Number getInternalId(UUID externalID); 73 66 */ 74 67 @Test 75 68 public void testGetInternalId() { 76 System.out.println(" getInternalId");69 System.out.println("test getInternalID"); 77 70 UUID externalID = UUID.fromString(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_); 78 71 Number result = jdbcCachedRepresentationDao.getInternalID(externalID); 79 72 assertEquals(1, result.intValue()); 80 73 } 81 74 75 82 76 /** 83 * Test of get CachedRepresentationInfo method, of class JdbcCachedRepresentationDao.84 * public CachedRepresentationInfo getCachedRepresentationInfo(Number internalID);77 * Test of getInternalIDFromURI method, 78 * public Number getInternalIDFromURI(UUID externalID); 85 79 */ 86 @Test 80 @Test 81 public void testGetInternalIDFRomURI() { 82 System.out.println("test getInternalIDFromURI"); 83 jdbcCachedRepresentationDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI); 84 String uri = TestBackendConstants._TEST_SERVLET_URI + TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_; 85 Number result = jdbcCachedRepresentationDao.getInternalIDFromURI(uri); 86 assertEquals(1, result.intValue()); 87 } 88 89 /** 90 * Test of getCachedRepresentationInfo method, of class 91 * JdbcCachedRepresentationDao. public CachedRepresentationInfo 92 * getCachedRepresentationInfo(Number internalID); 93 */ 94 @Test 87 95 public void testGetCachedRepresentationInfo() { 88 96 System.out.println("getCachedRepresentationInfo"); 89 97 90 98 jdbcCachedRepresentationDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI); 91 CachedRepresentationInfo result = jdbcCachedRepresentationDao.getCachedRepresentationInfo(1); 92 assertEquals(TestBackendConstants._TEST_SERVLET_URI +TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_, result.getRef());99 CachedRepresentationInfo result = jdbcCachedRepresentationDao.getCachedRepresentationInfo(1); 100 assertEquals(TestBackendConstants._TEST_SERVLET_URI + TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_, result.getRef()); 93 101 assertEquals(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_MIME_TYPE_, result.getMimeType()); 94 102 assertEquals(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_TOOL_, result.getTool()); 95 103 assertEquals(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_TYPE_, result.getType()); 96 assertEquals(TestBackendConstants._TEST_SERVLET_URI +TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_, result.getRef());104 assertEquals(TestBackendConstants._TEST_SERVLET_URI + TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_, result.getRef()); 97 105 } 98 106 99 107 /** 100 * Test of getCachedRepresentationBlob method, of class JdbcCachedRepresentationDao. 101 * public CachedRepresentationInfo getCachedRepresentationInfo(Number internalID); 108 * Test of getCachedRepresentationBlob method, of class 109 * JdbcCachedRepresentationDao. public CachedRepresentationInfo 110 * getCachedRepresentationInfo(Number internalID); 102 111 */ 103 @Test 104 public void testGetCachedRepresentationBlob() throws SQLException, UnsupportedEncodingException {112 @Test 113 public void testGetCachedRepresentationBlob() throws SQLException, UnsupportedEncodingException { 105 114 System.out.println("getCachedRepresentationBlob "); 106 115 Blob result = jdbcCachedRepresentationDao.getCachedRepresentationBlob(1); … … 110 119 assertEquals(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_BLOB_BYTE_2, resultBytes[1]); 111 120 } 112 113 121 114 122 /** 115 * Test of deleteCachedRepresentationInfo method, of class JdbcCachedRepresentationDao. 116 * public int deleteCachedRepresentationInfo(Number internalID); 123 * Test of deleteCachedRepresentationInfo method, of class 124 * JdbcCachedRepresentationDao. public int 125 * deleteCachedRepresentationInfo(Number internalID); 117 126 */ 118 @Test 127 @Test 119 128 public void testDeleteCachedRepresentationInfo() { 120 129 System.out.println("deleteCachedRepresentationInfo"); … … 122 131 int result = jdbcCachedRepresentationDao.deleteCachedRepresentation(internalID); 123 132 assertEquals(1, result); 124 133 125 134 int resultTwo = jdbcCachedRepresentationDao.deleteCachedRepresentation(internalID); 126 135 assertEquals(0, resultTwo); 127 136 128 137 Number internalIDDoNotDelete = 5; 129 int resultThree = jdbcCachedRepresentationDao.deleteCachedRepresentation(internalIDDoNotDelete);138 int resultThree = jdbcCachedRepresentationDao.deleteCachedRepresentation(internalIDDoNotDelete); 130 139 assertEquals(0, resultThree); 131 140 } 132 141 133 142 /** 134 * Test of addCachedRepresentationInfo method, of class JdbcCachedRepresentationDao. 135 * public CachedRepresentationInfo addCachedRepresentationInfo(CachedRepresentationInfo cached); 143 * Test of addCachedRepresentationInfo method, of class 144 * JdbcCachedRepresentationDao. public CachedRepresentationInfo 145 * addCachedRepresentationInfo(CachedRepresentationInfo cached); 136 146 */ 137 @Test 138 public void testAddCachedRepresentation() throws SerialException, SQLException {147 @Test 148 public void testAddCachedRepresentation() throws SerialException, SQLException { 139 149 System.out.println("addCachedRepresentation"); 140 150 141 151 CachedRepresentationInfo cachedInfo = new CachedRepresentationInfo(); 142 152 cachedInfo.setMimeType("text/plain"); … … 144 154 cachedInfo.setType("text"); 145 155 cachedInfo.setRef(null); 146 147 String 148 byte[] blobBytes = blobString.getBytes(); 156 157 String blobString = "111"; 158 byte[] blobBytes = blobString.getBytes(); 149 159 final Blob cachedBlob = new SerialBlob(blobBytes); 150 160 151 161 Number result = jdbcCachedRepresentationDao.addCachedRepresentation(cachedInfo, cachedBlob); 152 162 // checking … … 157 167 assertEquals("text", addedCachedInfo.getType()); 158 168 assertFalse(addedCachedInfo.getRef() == null); // new non-null external identifier should be assigned 159 169 160 170 Blob addedBlob = jdbcCachedRepresentationDao.getCachedRepresentationBlob(result); 161 171 int lengthBlob = 3; 162 172 String addedBlobString = new String(addedBlob.getBytes(1, lengthBlob)); 163 173 assertEquals(blobString, addedBlobString); 164 174 165 175 } 166 176 167 177 168 178 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDaoTest.java
r3594 r3598 18 18 package eu.dasish.annotation.backend.dao.impl; 19 19 20 import eu.dasish.annotation.backend.TestBackendConstants; 20 21 import java.io.File; 21 22 import java.io.FileNotFoundException; … … 23 24 import java.net.URL; 24 25 import java.util.Scanner; 26 import java.util.UUID; 25 27 import org.junit.After; 26 28 import org.junit.Before; 29 import org.junit.Test; 27 30 import org.springframework.beans.factory.annotation.Autowired; 28 31 import org.springframework.dao.DataAccessException; 29 32 import org.springframework.jdbc.core.JdbcTemplate; 33 import static org.junit.Assert.*; 34 import org.junit.runner.RunWith; 35 import org.springframework.test.context.ContextConfiguration; 36 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 30 37 /** 31 38 * 32 39 * @author olhsha 33 40 */ 34 41 @RunWith(SpringJUnit4ClassRunner.class) 42 @ContextConfiguration({"/spring-test-config/dataSource.xml"}) 35 43 public class JdbcResourceDaoTest { 36 44 … … 40 48 private String getNormalisedSql() throws FileNotFoundException, URISyntaxException { 41 49 // remove the unsupported sql for the test 42 final URL sqlUrl = Jdbc NotebookDaoTest.class.getResource("/sql/DashishAnnotatorCreate.sql");50 final URL sqlUrl = JdbcResourceDaoTest.class.getResource("/sql/DashishAnnotatorCreate.sql"); 43 51 String sqlString = new Scanner(new File(sqlUrl.toURI()), "UTF8").useDelimiter("\\Z").next(); 44 52 for (String unknownToken : new String[]{ … … 80 88 } 81 89 82 90 /** 91 * Test of stringURItoExternalID method 92 * public String stringURItoExternalID(String uri); 93 */ 94 @Test 95 public void testStringURItoExternalID() { 96 JdbcResourceDao jdbcResourceDao = new JdbcResourceDao(); 97 System.out.println("test stringURItoExternalID"); 98 jdbcResourceDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI); 99 String randomUUID = UUID.randomUUID().toString(); 100 String uri = TestBackendConstants._TEST_SERVLET_URI + randomUUID; 101 String externalID = jdbcResourceDao.stringURItoExternalID(uri); 102 assertEquals(randomUUID, externalID); 103 } 104 105 /** 106 * Test of externalIDtoURI method 107 * public String externalIDtoURI(String externalID); 108 */ 109 @Test 110 public void testExternalIDtoURI() { 111 System.out.println("test stringURItoExternalID"); 112 JdbcResourceDao jdbcResourceDao = new JdbcResourceDao(); 113 jdbcResourceDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI); 114 String randomUUID = UUID.randomUUID().toString(); 115 String uri = TestBackendConstants._TEST_SERVLET_URI + randomUUID; 116 String uriResult = jdbcResourceDao.externalIDtoURI(randomUUID); 117 assertEquals(uri, uriResult); 118 } 83 119 84 120 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDaoTest.java
r3593 r3598 65 65 assertEquals(expResult, result); 66 66 } 67 68 /** 69 * Test of getInternalIDFromURI method, 70 * public Number getInternalIDFromURI(UUID externalID); 71 */ 72 @Test 73 public void testGetInternalIDFRomURI() { 74 System.out.println("test getInternalIDFromURI"); 75 jdbcSourceDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI); 76 String uri = TestBackendConstants._TEST_SERVLET_URI + TestBackendConstants._TEST_SOURCE_1_EXT_ID; 77 Number result = jdbcSourceDao.getInternalIDFromURI(uri); 78 assertEquals(1, result.intValue()); 79 } 80 67 81 68 82 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDaoTest.java
r3463 r3598 64 64 assertEquals(expResult, result); 65 65 } 66 67 /** 68 * Test of getInternalIDFromURI method, 69 * public Number getInternalIDFromURI(UUID externalID); 70 */ 71 @Test 72 public void testGetInternalIDFRomURI() { 73 System.out.println("test getInternalIDFromURI"); 74 jdbcVersionDao.setServiceURI(TestBackendConstants._TEST_SERVLET_URI); 75 String uri = TestBackendConstants._TEST_SERVLET_URI + TestBackendConstants._TEST_VERSION_1_EXT_ID; 76 Number result = jdbcVersionDao.getInternalIDFromURI(uri); 77 assertEquals(1, result.intValue()); 78 } 79 80 66 81 67 82 /**
Note: See TracChangeset
for help on using the changeset viewer.