Revision 6790
Added by ben leinfelder over 12 years ago
ReplicationTest.java | ||
---|---|---|
26 | 26 |
package edu.ucsb.nceas.metacat.replication; |
27 | 27 |
|
28 | 28 |
import java.io.InputStream; |
29 |
import java.io.Reader; |
|
29 | 30 |
import java.io.StringReader; |
30 | 31 |
import java.net.URL; |
31 | 32 |
|
... | ... | |
185 | 186 |
// wait for replication (forced) |
186 | 187 |
Thread.sleep(forceReplicationSleep); |
187 | 188 |
|
188 |
// check that it is missing |
|
189 |
replicatedObject = null; |
|
189 |
// TODO: check that it is missing |
|
190 |
// update should fail since it is "archived" |
|
191 |
docid = baseDocid + "." + 3; |
|
192 |
object = "test3"; |
|
190 | 193 |
try { |
191 |
is = targetMetacat.read(docid); |
|
192 |
replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
|
193 |
} catch (DocumentNotFoundException dnfe) { |
|
194 |
// expect this |
|
194 |
targetMetacat.upload(docid, "testObject", IOUtils.toInputStream(object, MetaCatServlet.DEFAULT_ENCODING), object.getBytes(MetaCatServlet.DEFAULT_ENCODING).length); |
|
195 |
} catch (Exception e) { |
|
196 |
// should fail |
|
195 | 197 |
assertTrue(true); |
196 |
} |
|
197 |
assertNull(replicatedObject); |
|
198 |
return; |
|
199 |
} |
|
200 |
// if we get here, he have failed |
|
201 |
fail("Should not have been able to update archived data"); |
|
198 | 202 |
|
199 | 203 |
|
200 | 204 |
} catch (Exception e) { |
... | ... | |
293 | 297 |
// wait for replication (forced) |
294 | 298 |
Thread.sleep(forceReplicationSleep); |
295 | 299 |
|
296 |
// check that it is missing |
|
297 |
replicatedObject = null; |
|
298 |
try { |
|
299 |
is = targetMetacat.read(docid); |
|
300 |
replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
|
301 |
} catch (DocumentNotFoundException dnfe) { |
|
302 |
// expect this |
|
303 |
assertTrue(true); |
|
304 |
} |
|
305 |
assertNull(replicatedObject); |
|
300 |
// query for the docid -- should not be returned since it is archived |
|
301 |
String queryString = getTestEmlQuery(docid, EML2_1_0); |
|
302 |
Reader xmlQuery = new StringReader(queryString); |
|
303 |
Reader resultReader = targetMetacat.query(xmlQuery); |
|
304 |
String results = IOUtils.toString(resultReader); |
|
305 |
assertFalse(results.contains(docid)); |
|
306 | 306 |
|
307 | 307 |
} catch (Exception e) { |
308 | 308 |
e.printStackTrace(); |
Also available in: Unified diff
query for deleted metadata when testing that replication communicated the deletion. to check data, we try to update the data object on the target node (which should fail)