1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.web

File SkinActionTest.java

 

Code metrics

0
28
9
1
120
77
16
0.57
3.11
9
1.78

Classes

Class Line # Actions
SkinActionTest 31 28 0% 16 7
0.810810881.1%
 

Contributing tests

This file is covered by 8 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 com.xpn.xwiki.web;
21   
22    import java.io.IOException;
23   
24    import org.jmock.cglib.MockObjectTestCase;
25   
26    /**
27    * Unit tests for the {@link com.xpn.xwiki.web.SkinAction} class.
28    *
29    * @version $Id: 604e7fcfa574b32edac7e35310d7d27b62300875 $
30    */
 
31    public class SkinActionTest extends MockObjectTestCase
32    {
33    private SkinAction action;
34   
 
35  8 toggle @Override
36    protected void setUp()
37    {
38  8 this.action = new SkinAction();
39    }
40   
 
41  1 toggle public void testIsTextJavascriptJavaScriptMimetype()
42    {
43  1 assertTrue(this.action.isJavascriptMimeType("text/javascript"));
44    }
45   
 
46  1 toggle public void testIsApplicationJavascriptJavaScriptMimetype()
47    {
48  1 assertTrue(this.action.isJavascriptMimeType("application/javascript"));
49    }
50   
 
51  1 toggle public void testIsApplicationXJavascriptJavaScriptMimetype()
52    {
53  1 assertTrue(this.action.isJavascriptMimeType("application/x-javascript"));
54    }
55   
 
56  1 toggle public void testIsTextEcmascriptJavaScriptMimetype()
57    {
58  1 assertTrue(this.action.isJavascriptMimeType("text/ecmascript"));
59    }
60   
 
61  1 toggle public void testIsApplicationEcmascriptJavaScriptMimetype()
62    {
63  1 assertTrue(this.action.isJavascriptMimeType("application/ecmascript"));
64    }
65   
 
66  1 toggle public void testNPEJavascriptMimetype()
67    {
68  1 assertFalse(this.action.isJavascriptMimeType(null));
69    }
70   
 
71  1 toggle public void testIncorrectSkinFile()
72    {
73  1 try {
74  1 this.action.getSkinFilePath("../../resources/js/xwiki/xwiki.js", "colibri");
75  0 assertTrue("should fail", false);
76    } catch (IOException e) {
77    // good
78    }
79  1 try {
80  1 this.action.getSkinFilePath("../../../", "colibri");
81  0 assertTrue("should fail", false);
82    } catch (IOException e) {
83    // good
84    }
85  1 try {
86  1 this.action.getSkinFilePath("resources/js/xwiki/xwiki.js", "..");
87  0 assertTrue("should fail", false);
88    } catch (IOException e) {
89    // good
90    }
91  1 try {
92  1 this.action.getSkinFilePath("../resources/js/xwiki/xwiki.js", ".");
93  0 assertTrue("should fail", false);
94    } catch (IOException e) {
95    // good
96    }
97    }
98   
 
99  1 toggle public void testIncorrectResourceFile()
100    {
101  1 try {
102  1 this.action.getResourceFilePath("../../skins/js/xwiki/xwiki.js");
103  0 assertTrue("should fail", false);
104    } catch (IOException e) {
105    // good
106    }
107  1 try {
108  1 this.action.getResourceFilePath("../../../");
109  0 assertTrue("should fail", false);
110    } catch (IOException e) {
111    // good
112    }
113  1 try {
114  1 this.action.getResourceFilePath("../../redirect");
115  0 assertTrue("should fail", false);
116    } catch (IOException e) {
117    // good
118    }
119    }
120    }