Revision 6778
Added by ben leinfelder about 13 years ago
test/edu/ucsb/nceas/metacat/replication/ReplicationTest.java | ||
---|---|---|
34 | 34 |
import junit.framework.TestSuite; |
35 | 35 |
import edu.ucsb.nceas.MCTestCase; |
36 | 36 |
import edu.ucsb.nceas.metacat.MetaCatServlet; |
37 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlInterface; |
|
37 | 38 |
import edu.ucsb.nceas.metacat.client.Metacat; |
38 | 39 |
import edu.ucsb.nceas.metacat.client.MetacatFactory; |
39 | 40 |
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException; |
... | ... | |
123 | 124 |
public void testReplicateData_AtoB() { |
124 | 125 |
try { |
125 | 126 |
// the id |
126 |
String docid = DocumentUtil.generateDocumentId("replicationTest", 1); |
|
127 |
String baseDocid = DocumentUtil.generateDocumentId("replicationTest", 0); |
|
128 |
String docid = baseDocid + "." + 1; |
|
127 | 129 |
|
128 | 130 |
// the test data |
129 | 131 |
String object = "test"; |
... | ... | |
141 | 143 |
String replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
142 | 144 |
|
143 | 145 |
assertEquals(object, replicatedObject); |
146 |
|
|
147 |
// update the object |
|
148 |
docid = baseDocid + "." + 2; |
|
149 |
object = "test2"; |
|
150 |
m.upload(docid, "testObject", IOUtils.toInputStream(object, MetaCatServlet.DEFAULT_ENCODING), object.getBytes(MetaCatServlet.DEFAULT_ENCODING).length); |
|
151 |
|
|
152 |
// wait for replication (forced) |
|
153 |
Thread.sleep(forceReplicationSleep); |
|
154 |
|
|
155 |
// check the target for the updated data |
|
156 |
is = targetMetacat.read(docid); |
|
157 |
replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
|
158 |
|
|
159 |
assertEquals(object, replicatedObject); |
|
160 |
|
|
161 |
// update the access control rules |
|
162 |
m.setAccess( |
|
163 |
docid, |
|
164 |
AccessControlInterface.PUBLIC, |
|
165 |
AccessControlInterface.READSTRING, |
|
166 |
AccessControlInterface.ALLOW, |
|
167 |
AccessControlInterface.ALLOWFIRST); |
|
168 |
|
|
169 |
// wait for replication (forced) |
|
170 |
Thread.sleep(forceReplicationSleep); |
|
171 |
|
|
172 |
// check the target for the same data, logout to act as public |
|
173 |
targetMetacat.logout(); |
|
174 |
is = targetMetacat.read(docid); |
|
175 |
replicatedObject = IOUtils.toString(is, MetaCatServlet.DEFAULT_ENCODING); |
|
176 |
|
|
177 |
assertEquals(object, replicatedObject); |
|
144 | 178 |
|
145 | 179 |
} catch (Exception e) { |
146 | 180 |
e.printStackTrace(); |
Also available in: Unified diff
test update and set access during replication from A->B
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5520