Revision 6788
Added by ben leinfelder almost 13 years ago
test/edu/ucsb/nceas/metacat/replication/ReplicationTest.java | ||
---|---|---|
36 | 36 |
import edu.ucsb.nceas.MCTestCase; |
37 | 37 |
import edu.ucsb.nceas.metacat.MetaCatServlet; |
38 | 38 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlInterface; |
39 |
import edu.ucsb.nceas.metacat.client.DocumentNotFoundException; |
|
39 | 40 |
import edu.ucsb.nceas.metacat.client.Metacat; |
40 | 41 |
import edu.ucsb.nceas.metacat.client.MetacatFactory; |
41 | 42 |
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException; |
... | ... | |
176 | 177 |
replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
177 | 178 |
|
178 | 179 |
assertEquals(object, replicatedObject); |
180 |
|
|
181 |
// delete the object |
|
182 |
m.delete(docid); |
|
183 |
|
|
184 |
// wait for replication (forced) |
|
185 |
Thread.sleep(forceReplicationSleep); |
|
186 |
|
|
187 |
// check that it is missing |
|
188 |
replicatedObject = null; |
|
189 |
try { |
|
190 |
is = targetMetacat.read(docid); |
|
191 |
replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
|
192 |
} catch (DocumentNotFoundException dnfe) { |
|
193 |
// expect this |
|
194 |
assertTrue(true); |
|
195 |
} |
|
196 |
assertNull(replicatedObject); |
|
197 |
|
|
179 | 198 |
|
180 | 199 |
} catch (Exception e) { |
181 | 200 |
e.printStackTrace(); |
... | ... | |
266 | 285 |
replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
267 | 286 |
|
268 | 287 |
assertEquals(emlContent, replicatedObject); |
269 |
|
|
270 |
} catch (Exception e) { |
|
271 |
e.printStackTrace(); |
|
272 |
fail(e.getMessage()); |
|
273 |
} |
|
274 |
} |
|
275 |
|
|
276 |
public void testReplicateData_BtoA() { |
|
277 |
try { |
|
278 |
// the id |
|
279 |
String docid = DocumentUtil.generateDocumentId("replicationTest", 1); |
|
280 | 288 |
|
281 |
// the test data
|
|
282 |
String object = "test";
|
|
289 |
// delete the object
|
|
290 |
m.delete(docid);
|
|
283 | 291 |
|
284 |
// insert data locally |
|
285 |
targetMetacat.login(username, password); |
|
286 |
targetMetacat.upload(docid, "testObject", IOUtils.toInputStream(object, MetaCatServlet.DEFAULT_ENCODING), object.getBytes(MetaCatServlet.DEFAULT_ENCODING).length); |
|
287 |
|
|
288 | 292 |
// wait for replication (forced) |
289 | 293 |
Thread.sleep(forceReplicationSleep); |
290 | 294 |
|
291 |
// check the target for the same data |
|
292 |
m.login(username, password); |
|
293 |
InputStream is = m.read(docid); |
|
294 |
String replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
|
295 |
|
|
296 |
assertEquals(object, replicatedObject); |
|
295 |
// check that it is missing |
|
296 |
replicatedObject = null; |
|
297 |
try { |
|
298 |
is = targetMetacat.read(docid); |
|
299 |
replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
|
300 |
} catch (DocumentNotFoundException dnfe) { |
|
301 |
// expect this |
|
302 |
assertTrue(true); |
|
303 |
} |
|
304 |
assertNull(replicatedObject); |
|
297 | 305 |
|
298 | 306 |
} catch (Exception e) { |
299 | 307 |
e.printStackTrace(); |
Also available in: Unified diff
delete data and eml on the home Metacat and check that the change propagates to the target