1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.webdav.test

File TempFileTest.java

 

Code metrics

0
15
4
1
87
39
4
0.27
3.75
4
1

Classes

Class Line # Actions
TempFileTest 32 15 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.webdav.test;
21   
22    import org.apache.jackrabbit.webdav.DavServletResponse;
23    import org.junit.After;
24    import org.junit.Test;
25   
26    /**
27    * Test case for nested temporary files in webdav interface.
28    *
29    * @version $Id: d097ee7eba1e050076b1d4259a3edc239314397e $
30    * @since 1.8RC2
31    */
 
32    public class TempFileTest extends AbstractWebDAVTest
33    {
34    /**
35    * Temporary working directory for all tests.
36    */
37    public static final String TEMP_ROOT = ROOT + "/.temp";
38   
 
39  2 toggle @Override
40    public void setUp() throws Exception
41    {
42  2 super.setUp();
43  2 mkCol(TEMP_ROOT, DavServletResponse.SC_CREATED);
44    }
45   
46    /**
47    * Test creating, moving and deleting a (temporary) collection resource under another temporary collection.
48    */
 
49  1 toggle @Test
50    public void testTempCollectionOperations() throws Exception
51    {
52  1 String tempCollectionUrl = TEMP_ROOT + "/temp";
53    // Create.
54  1 mkCol(tempCollectionUrl, DavServletResponse.SC_CREATED);
55    // Rename (move): Not allowed.
56  1 move(tempCollectionUrl, "/xwiki/webdav/.temp/temp2", DavServletResponse.SC_FORBIDDEN);
57    // Delete.
58  1 delete(tempCollectionUrl, DavServletResponse.SC_NO_CONTENT);
59    }
60   
61    /**
62    * Test creating, spooling, moving and deleting (temporary) files under a temporary collection.
63    */
 
64  1 toggle @Test
65    public void testTempFileOperations() throws Exception
66    {
67  1 String tempFileUrl = TEMP_ROOT + "/temp.txt";
68  1 String destinationUrl = TEMP_ROOT + "/temp2.txt";
69  1 String relativeDestinationUrl = "/xwiki/webdav/.temp/temp2.txt";
70    // Create.
71  1 put(tempFileUrl, "Content", DavServletResponse.SC_CREATED);
72    // Spool.
73  1 get(tempFileUrl, DavServletResponse.SC_OK);
74    // Rename (move).
75  1 move(tempFileUrl, relativeDestinationUrl, DavServletResponse.SC_CREATED);
76    // Spool.
77  1 get(destinationUrl, DavServletResponse.SC_OK);
78    // Delete.
79  1 delete(destinationUrl, DavServletResponse.SC_NO_CONTENT);
80    }
81   
 
82  2 toggle @After
83    public void tearDown() throws Exception
84    {
85  2 delete(TEMP_ROOT, DavServletResponse.SC_NO_CONTENT);
86    }
87    }