Changeset 1631 for branches/3.0-Beta2/components
- Timestamp:
- 06/12/07 20:55:53 (16 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0-Beta2/components/server/test/ome/tools/utests/RepositoryTaskTest.java
r1597 r1631 28 28 public class RepositoryTaskTest extends TestCase { 29 29 30 RepositoryTask task = null;31 private OmeroContext ctx;32 private SimpleJdbcTemplate template;33 private static int setupCount = 0;34 35 @Configuration(beforeTestMethod=true)36 protected void setUp() throws Exception {37 setupCount++;38 39 /**40 * run this once only, set to 1 to create files and add rows to41 * the eventlog table42 */43 44 if (setupCount == 1) {45 addTestFiles();46 //addTestRows();47 }48 task = new RepositoryTask();49 }50 @Configuration(afterTestMethod=true)51 protected void tearDown() throws Exception {52 task = null;53 }54 55 @Test56 public void testGetFileIds() throws Exception {57 List<Long> ids = task.getFileIds();58 assertTrue(ids.size() == 2);59 }60 61 @Test62 public void testGetPixelIds() throws Exception {63 List<Long> ids = task.getPixelIds();64 assertTrue(ids.size() == 596);65 }66 67 @Test68 public void testGetThumbnailIds() throws Exception {69 List<Long> ids = task.getThumbnailIds();70 assertTrue(ids.size() == 617);71 }72 73 /**74 * private utility method to create files for deleting75 *76 */77 private void addTestFiles() {78 // create empty files for tests79 File origFile1, origFile2, pixelFile1, pixelFile2, thumbnailFile1;80 81 origFile1 = new File("/OMERO/Files/63");82 origFile2 = new File("/OMERO/Files/100");83 pixelFile1 = new File("/OMERO/Pixels/Dir-002/2613");84 pixelFile2 = new File("/OMERO/Pixels/Dir-004/4189");85 thumbnailFile1 = new File("/OMERO/Thumbnails/Dir-003/3331");86 87 try {88 if (!origFile1.exists()) {89 origFile1.createNewFile();90 }91 if (!origFile2.exists()) {92 origFile2.createNewFile();93 }94 95 if (!pixelFile1.exists()) {96 pixelFile1.createNewFile();97 }98 if (!pixelFile2.exists()) {99 pixelFile2.createNewFile();100 }101 102 if (!thumbnailFile1.exists()) {103 thumbnailFile1.createNewFile();104 }105 106 } catch (IOException ioex) {107 ioex.printStackTrace();108 }109 }110 111 private void addTestRows() {112 ctx = OmeroContext.getManagedServerContext();113 template = (SimpleJdbcTemplate) ctx.getBean("simpleJdbcTemplate");114 115 String[] inserts = {116 "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99000,63,'DELETE','ome.model.core.OriginalFile',-1,999)",117 "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99001,100,'DELETE','ome.model.core.OriginalFile',-1,999)",118 "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99002,2613,'DELETE','ome.model.core.Pixels',-1,999)",119 "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99003,4189,'DELETE','ome.model.core.Pixels',-1,999)",120 "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99004,3331,'DELETE','ome.model.display.Thumbnail',-1,999)",121 };122 123 for (int i=0; i<inserts.length; i++) {124 template.getJdbcOperations().execute(inserts[i]);125 }126 }30 // RepositoryTask task = null; 31 // private OmeroContext ctx; 32 // private SimpleJdbcTemplate template; 33 // private static int setupCount = 0; 34 // 35 // @Configuration(beforeTestMethod=true) 36 // protected void setUp() throws Exception { 37 // setupCount++; 38 // 39 // /** 40 // * run this once only, set to 1 to create files and add rows to 41 // * the eventlog table 42 // */ 43 // 44 // if (setupCount == 1) { 45 // addTestFiles(); 46 // //addTestRows(); 47 // } 48 // task = new RepositoryTask(); 49 // } 50 // @Configuration(afterTestMethod=true) 51 // protected void tearDown() throws Exception { 52 // task = null; 53 // } 54 // 55 // @Test 56 // public void testGetFileIds() throws Exception { 57 // List<Long> ids = task.getFileIds(); 58 // assertTrue(ids.size() == 2); 59 //} 60 // 61 // @Test 62 // public void testGetPixelIds() throws Exception { 63 // List<Long> ids = task.getPixelIds(); 64 // assertTrue(ids.size() == 596); 65 // } 66 // 67 // @Test 68 // public void testGetThumbnailIds() throws Exception { 69 // List<Long> ids = task.getThumbnailIds(); 70 // assertTrue(ids.size() == 617); 71 // } 72 // 73 // /** 74 // * private utility method to create files for deleting 75 // * 76 // */ 77 // private void addTestFiles() { 78 // // create empty files for tests 79 // File origFile1, origFile2, pixelFile1, pixelFile2, thumbnailFile1; 80 // 81 // origFile1 = new File("/OMERO/Files/63"); 82 // origFile2 = new File("/OMERO/Files/100"); 83 // pixelFile1 = new File("/OMERO/Pixels/Dir-002/2613"); 84 // pixelFile2 = new File("/OMERO/Pixels/Dir-004/4189"); 85 // thumbnailFile1 = new File("/OMERO/Thumbnails/Dir-003/3331"); 86 // 87 // try { 88 // if (!origFile1.exists()) { 89 // origFile1.createNewFile(); 90 // } 91 // if (!origFile2.exists()) { 92 // origFile2.createNewFile(); 93 // } 94 // 95 // if (!pixelFile1.exists()) { 96 // pixelFile1.createNewFile(); 97 // } 98 // if (!pixelFile2.exists()) { 99 // pixelFile2.createNewFile(); 100 // } 101 // 102 // if (!thumbnailFile1.exists()) { 103 // thumbnailFile1.createNewFile(); 104 // } 105 // 106 // } catch (IOException ioex) { 107 // ioex.printStackTrace(); 108 // } 109 // } 110 // 111 // private void addTestRows() { 112 // ctx = OmeroContext.getManagedServerContext(); 113 // template = (SimpleJdbcTemplate) ctx.getBean("simpleJdbcTemplate"); 114 // 115 // String[] inserts = { 116 // "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99000,63,'DELETE','ome.model.core.OriginalFile',-1,999)", 117 // "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99001,100,'DELETE','ome.model.core.OriginalFile',-1,999)", 118 // "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99002,2613,'DELETE','ome.model.core.Pixels',-1,999)", 119 // "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99003,4189,'DELETE','ome.model.core.Pixels',-1,999)", 120 // "insert into eventlog (id, entityid, action, entitytype, permissions, event) values (99004,3331,'DELETE','ome.model.display.Thumbnail',-1,999)", 121 // }; 122 // 123 // for (int i=0; i<inserts.length; i++) { 124 // template.getJdbcOperations().execute(inserts[i]); 125 // } 126 // } 127 127 }
