Changeset 6674
- Timestamp:
- Jan 8, 2015, 1:31:28 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.4-stable/src/test/TestAnyToAny.java
r6100 r6674 71 71 test_exists(sampleId, "third", false); 72 72 73 // Test relinking to a new item in a single transaction 74 int sampleId2 = test_relink(id); 75 73 76 // Standard test: Delete 74 77 if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); … … 82 85 83 86 TestSample.test_delete(sampleId); 87 TestSample.test_delete(sampleId2); 84 88 TestFile.test_delete(fileId1); 85 89 TestFile.test_delete(fileId2); … … 121 125 } 122 126 127 static int test_relink(int id) 128 { 129 if (id == 0) return 0; 130 int sampleId = 0; 131 DbControl dc = null; 132 try 133 { 134 dc = TestUtil.getDbControl(); 135 Sample s = Sample.getNew(dc); 136 dc.saveItem(s); 137 138 AnyToAny a = AnyToAny.getById(dc, id); 139 a.setTo(s); 140 a.setDescription("Relinked "+new Date()); 141 dc.commit(); 142 143 sampleId = s.getId(); 144 dc = TestUtil.getDbControl(); 145 dc.reattachItem(a, false); 146 write_item(0, a); 147 if (a.getToId() != sampleId) 148 { 149 throw new BaseException("Relink failed: " + a.getToId() + " != " + sampleId); 150 } 151 write("--Relink any-to-any OK"); 152 } 153 catch (Throwable ex) 154 { 155 write("--Relink any-to-any FAILED"); 156 ex.printStackTrace(); 157 ok = false; 158 } 159 finally 160 { 161 if (dc != null) dc.close(); 162 } 163 return sampleId; 164 } 165 123 166 static void test_load(int id) 124 167 { … … 185 228 { 186 229 if (!TestUtil.getSilent()) System.out.println(i+":\t"+a.getId()+"\t"+a.getName()+"\t"+ 187 a.getDescription()+"\t"+a.getFrom ()+"\t"+a.getTo());230 a.getDescription()+"\t"+a.getFromType()+"["+a.getFromId()+"]\t"+a.getToType()+"["+a.getToId()+"]"); 188 231 } 189 232 static void write(String message)
Note: See TracChangeset
for help on using the changeset viewer.