Clover Coverage Report - ARESTC 0.1.7-SNAPSHOT
Coverage timestamp: Fri Aug 27 2010 19:12:04 CEST
28   123   6   7
0   61   0.21   4
4     1.5  
1    
 
  ServicesConfigurationFactoryTest       Line # 39 28 0% 6 4 87.5% 0.875
 
  (2)
 
1    /*
2    *
3    * (C)opyright 2010, Nikolaos Georgosopoulos
4    *
5    * This file is part of ARESTC.
6   
7    ARESTC is free software: you can redistribute it and/or modify
8    it under the terms of the Lesser General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11   
12    ARESTC is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15    GNU General Public License for more details.
16   
17    You should have received a copy of the Lesser General Public License
18    along with ARESTC. If not, see <http://www.gnu.org/licenses/>.
19   
20    */
21    package net.sf.arestc.configuration;
22   
23    import java.util.Map;
24   
25    import junit.framework.TestCase;
26    import net.sf.arestc.core.services.HTTPMethods;
27    import net.sf.arestc.core.services.RESTService;
28    import net.sf.arestc.core.services.ServiceParameterTypes;
29   
30    import org.apache.commons.configuration.ConfigurationException;
31    import org.apache.log4j.Logger;
32   
33    // TODO: Auto-generated Javadoc
34    /**
35    * The Class ServicesConfigurationFactoryTest.
36    *
37    * @author georgosn
38    */
 
39    public class ServicesConfigurationFactoryTest extends TestCase {
40   
41    /** The Constant LOGGER. */
42    private static final Logger LOGGER = Logger.getLogger(ServicesConfigurationFactoryTest.class
43    .getName());
44   
45    /** The conf. */
46    private ServicesConfigurationFactory conf;
47   
48    /*
49    * (non-Javadoc)
50    *
51    * @see junit.framework.TestCase#setUp()
52    */
 
53  2 toggle @Override
54    protected void setUp() throws Exception {
55  2 super.setUp();
56  2 conf = ServicesConfigurationFactory._instance;
57    }
58   
59    /*
60    * (non-Javadoc)
61    *
62    * @see junit.framework.TestCase#tearDown()
63    */
 
64  2 toggle @Override
65    protected void tearDown() throws Exception {
66  2 conf = null;
67  2 super.tearDown();
68    }
69   
70    /**
71    * Test method for.
72    *
73    * {@link net.sf.arestc.configuration.ServicesConfigurationFactory#configure()}
74    * .
75    */
 
76  1 toggle public void testConfigure() {
77  1 try {
78  1 final Map<String, RESTService> services = conf.configure();
79  1 assertFalse(services.isEmpty());
80  1 assertTrue(services.containsKey("login"));
81  1 final RESTService loginService = services.get("login");
82  1 assertTrue(loginService.getName().equals("login"));
83  1 assertEquals("alfresco/service/api/login", loginService
84    .getContextPath().toString());
85  1 assertTrue(loginService.getMethod().equals(HTTPMethods.GET));
86  1 assertFalse(loginService.getParameters().isEmpty());
87  1 assertEquals(
88    2,
89    loginService.getParameters()
90    .get(ServiceParameterTypes.QUERY).size());
91    } catch (final ConfigurationException e) {
92  0 fail("configuration not possible, check if the services.xml is in the test class path");
93  0 LOGGER.error("Error occured in testConfigure:", e);
94    }
95    }
96   
97    /**
98    * Test method for.
99    *
100    * {@link net.sf.arestc.configuration.ServicesConfigurationFactory#configure(java.lang.String)}
101    * .
102    */
 
103  1 toggle public void testConfigureString() {
104  1 final String path = this.getClass().getClassLoader()
105    .getResource("services.xml").getPath();
106   
107  1 try {
108  1 final Map<String, RESTService> services = conf.configure(path);
109  1 assertFalse(services.isEmpty());
110  1 assertTrue(services.containsKey("login"));
111  1 final RESTService loginService = services.get("login");
112  1 assertTrue(loginService.getName().equals("login"));
113  1 assertEquals("alfresco/service/api/login", loginService
114    .getContextPath().toString());
115  1 assertTrue(loginService.getMethod().equals(HTTPMethods.GET));
116  1 assertFalse(loginService.getParameters().isEmpty());
117    } catch (final ConfigurationException e) {
118  0 fail("configuration not possible, check if the services.xml is in the test class path");
119  0 LOGGER.error("Error occured in testConfigure:", e);
120    }
121    }
122   
123    }