| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 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 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
@author |
| 38 |
|
|
|
|
|
| 87.5% |
Uncovered Elements: 4 (32) |
Complexity: 6 |
Complexity Density: 0.21 |
|
| 39 |
|
public class ServicesConfigurationFactoryTest extends TestCase { |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
private static final Logger LOGGER = Logger.getLogger(ServicesConfigurationFactoryTest.class |
| 43 |
|
.getName()); |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
private ServicesConfigurationFactory conf; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
@see |
| 52 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 53 |
2
|
@Override... |
| 54 |
|
protected void setUp() throws Exception { |
| 55 |
2
|
super.setUp(); |
| 56 |
2
|
conf = ServicesConfigurationFactory._instance; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
@see |
| 63 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 64 |
2
|
@Override... |
| 65 |
|
protected void tearDown() throws Exception { |
| 66 |
2
|
conf = null; |
| 67 |
2
|
super.tearDown(); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
@link |
| 74 |
|
|
| 75 |
|
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
1
PASS
|
|
| 76 |
1
|
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 |
|
|
| 99 |
|
|
| 100 |
|
@link |
| 101 |
|
|
| 102 |
|
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
1
PASS
|
|
| 103 |
1
|
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 |
|
} |