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

File RootViewTest.java

 

Code metrics

0
24
7
1
124
60
7
0.29
3.43
7
1

Classes

Class Line # Actions
RootViewTest 31 24 0% 7 0
1.0100%
 

Contributing tests

This file is covered by 7 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.Test;
24   
25    /**
26    * Test case for webdav root view.
27    *
28    * @version $Id: 1f0a4de6703bacd1bd03501f7bee0c0d5347a6d8 $
29    * @since 1.8RC2
30    */
 
31    public class RootViewTest extends AbstractWebDAVTest
32    {
33    /**
34    * Test PROPFIND request on webdav root.
35    */
 
36  1 toggle @Test
37    public void testPropFind() throws Exception
38    {
39  1 propFind(ROOT, 1, DavServletResponse.SC_MULTI_STATUS);
40    }
41   
42    /**
43    * Test creating a collection resource (directory) under webdav root.
44    */
 
45  1 toggle @Test
46    public void testCreateCollection() throws Exception
47    {
48  1 mkCol(ROOT + "/collection", DavServletResponse.SC_METHOD_NOT_ALLOWED);
49    }
50   
51    /**
52    * Test creating an ordinary resource (file) under webdav root.
53    */
 
54  1 toggle @Test
55    public void testCreateFile() throws Exception
56    {
57  1 put(ROOT + "/test.txt", "Content", DavServletResponse.SC_METHOD_NOT_ALLOWED);
58    }
59   
60    /**
61    * Test creating, moving and deleting a temporary collection resource under webdav root.
62    */
 
63  1 toggle @Test
64    public void testTempCollectionOperations() throws Exception
65    {
66  1 String tempCollectionUrl = ROOT + "/.temp";
67    // Create.
68  1 mkCol(tempCollectionUrl, DavServletResponse.SC_CREATED);
69    // Invalid rename (move).
70  1 move(tempCollectionUrl, "/xwiki/webdav/temp2", DavServletResponse.SC_METHOD_NOT_ALLOWED);
71    // Valid rename (move): renaming temporary collections is not allowed at the moment.
72  1 move(tempCollectionUrl, "/xwiki/webdav/.temp2", DavServletResponse.SC_FORBIDDEN);
73    // Delete.
74  1 delete(tempCollectionUrl, DavServletResponse.SC_NO_CONTENT);
75    }
76   
77    /**
78    * Test creating, moving and deleting a temporary (file) resource under webdav root.
79    */
 
80  1 toggle @Test
81    public void testTempFileOperations() throws Exception
82    {
83  1 String tempFileUrl = ROOT + "/temp.txt~";
84  1 String destinationUrl = ROOT + "/.temp.txt";
85  1 String relativeDestinationUrl = "/xwiki/webdav/.temp.txt";
86    // Create.
87  1 put(tempFileUrl, "Content", DavServletResponse.SC_CREATED);
88    // Spool.
89  1 get(tempFileUrl, DavServletResponse.SC_OK);
90    // Invalid rename (move).
91  1 move(tempFileUrl, "/xwiki/webdav/temp.txt", DavServletResponse.SC_METHOD_NOT_ALLOWED);
92    // Valid rename (move).
93  1 move(tempFileUrl, relativeDestinationUrl, DavServletResponse.SC_CREATED);
94    // Spool.
95  1 get(destinationUrl, DavServletResponse.SC_OK);
96    // Delete.
97  1 delete(destinationUrl, DavServletResponse.SC_NO_CONTENT);
98    }
99   
100    /**
101    * Test renaming each of base views.
102    */
 
103  1 toggle @Test
104    public void testMoveBaseViews() throws Exception
105    {
106  1 String invalidDestination = "/xwiki/webdav/target";
107  1 String validDestination = "/xwiki/webdav/.temp";
108  1 for (String baseView : BASE_VIEWS) {
109  5 move(baseView, invalidDestination, DavServletResponse.SC_METHOD_NOT_ALLOWED);
110  5 move(baseView, validDestination, DavServletResponse.SC_METHOD_NOT_ALLOWED);
111    }
112    }
113   
114    /**
115    * Test deleting each of base views.
116    */
 
117  1 toggle @Test
118    public void testDeleteBaseViews() throws Exception
119    {
120  1 for (String baseView : BASE_VIEWS) {
121  5 delete(baseView, DavServletResponse.SC_FORBIDDEN);
122    }
123    }
124    }