|
33 | 33 | import org.mockito.Mock;
|
34 | 34 | import static org.mockito.Mockito.when;
|
35 | 35 | import org.mockito.MockitoAnnotations;
|
| 36 | +import org.modeshape.common.FixFor; |
36 | 37 | import org.modeshape.common.util.IoUtil;
|
37 | 38 | import org.modeshape.jcr.api.RepositoryFactory;
|
38 | 39 | import org.modeshape.web.jcr.ModeShapeJcrDeployer;
|
@@ -135,7 +136,7 @@ public void shouldNotCommitNullTransaction() throws Exception {
|
135 | 136 |
|
136 | 137 | private void compareChildrenWithSession( String[] children,
|
137 | 138 | String path ) throws Exception {
|
138 |
| - List<String> sessChildren = new LinkedList<String>(); |
| 139 | + List<String> sessChildren = new LinkedList<>(); |
139 | 140 | Node node = (Node)session.getItem(path);
|
140 | 141 | for (NodeIterator iter = node.getNodes(); iter.hasNext(); ) {
|
141 | 142 | sessChildren.add(iter.nextNode().getName());
|
@@ -253,4 +254,39 @@ public void shouldSimulateAddingFileThroughWebdav() throws Exception {
|
253 | 254 | assertThat(ob, is(notNullValue()));
|
254 | 255 | }
|
255 | 256 |
|
| 257 | + @Test |
| 258 | + @FixFor( "MODE-2589" ) |
| 259 | + public void shouldSimulateAddingAndCopyingZeroLengthFileThroughWebdav() throws Exception { |
| 260 | + final String testString = ""; |
| 261 | + final String sourceUri = TEST_ROOT_PATH + "/TestFile.rtf"; |
| 262 | + final String destinationUri = TEST_ROOT_PATH + "/CopyOfTestFile.rtf"; |
| 263 | + |
| 264 | + when(request.getPathInfo()).thenReturn(""); |
| 265 | + store.getStoredObject(tx, ""); |
| 266 | + |
| 267 | + when(request.getPathInfo()).thenReturn(sourceUri); |
| 268 | + store.getStoredObject(tx, sourceUri); |
| 269 | + |
| 270 | + when(request.getPathInfo()).thenReturn("/"); // will ask for parent during resolution ... |
| 271 | + store.createResource(tx, sourceUri); |
| 272 | + |
| 273 | + when(request.getPathInfo()).thenReturn(sourceUri); |
| 274 | + long length = store.setResourceContent(tx, sourceUri, new ByteArrayInputStream(testString.getBytes()), "text/plain", |
| 275 | + "UTF-8"); |
| 276 | + |
| 277 | + assertThat((int)length, is(testString.getBytes().length)); |
| 278 | + |
| 279 | + StoredObject ob = store.getStoredObject(tx, sourceUri); |
| 280 | + assertThat(ob, is(notNullValue())); |
| 281 | + |
| 282 | + when(request.getPathInfo()).thenReturn("/"); // will ask for parent during resolution ... |
| 283 | + store.createResource(tx, destinationUri); |
| 284 | + |
| 285 | + when(request.getPathInfo()).thenReturn(destinationUri); |
| 286 | + length = store.setResourceContent(tx, destinationUri, store.getResourceContent(tx, sourceUri), "text/plain", "UTF-8"); |
| 287 | + |
| 288 | + assertThat((int)length, is(testString.getBytes().length)); |
| 289 | + ob = store.getStoredObject(tx, destinationUri); |
| 290 | + assertThat(ob, is(notNullValue())); |
| 291 | + } |
256 | 292 | }
|
0 commit comments