| 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.communication; |
| 22 |
|
|
| 23 |
|
import junit.framework.TestCase; |
| 24 |
|
import net.sf.arestc.configuration.ClientConfigurationFactory; |
| 25 |
|
|
| 26 |
|
import org.apache.commons.configuration.ConfigurationException; |
| 27 |
|
import org.apache.commons.httpclient.HttpClient; |
| 28 |
|
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; |
| 29 |
|
import org.apache.log4j.Logger; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
@author |
| 36 |
|
|
|
|
|
| 77.8% |
Uncovered Elements: 4 (18) |
Complexity: 5 |
Complexity Density: 0.33 |
|
| 37 |
|
public class ConfigurationFactoryTest extends TestCase { |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
private static final Logger LOGGER = Logger.getLogger(ConfigurationFactoryTest.class |
| 41 |
|
.getName()); |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
private HttpClient client; |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
@see |
| 50 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 51 |
1
|
@Override... |
| 52 |
|
protected void setUp() throws Exception { |
| 53 |
1
|
super.setUp(); |
| 54 |
1
|
client = new HttpClient(new MultiThreadedHttpConnectionManager()); |
| 55 |
|
|
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
@see |
| 62 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 63 |
1
|
@Override... |
| 64 |
|
protected void tearDown() throws Exception { |
| 65 |
1
|
client = null; |
| 66 |
1
|
super.tearDown(); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@link |
| 73 |
|
|
| 74 |
|
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 3 |
Complexity Density: 0.27 |
1
PASS
|
|
| 75 |
1
|
public void testConfigureHttpClientString() {... |
| 76 |
|
|
| 77 |
1
|
try { |
| 78 |
1
|
ClientConfigurationFactory.getInstance().configure(client, null); |
| 79 |
1
|
assertFalse(null == client); |
| 80 |
|
} catch (final ConfigurationException e) { |
| 81 |
0
|
LOGGER.error(e); |
| 82 |
0
|
fail("configuration failed to lunch the default when passed null for file name"); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
|
| 86 |
1
|
final String path = this.getClass().getClassLoader() |
| 87 |
|
.getResource("httpconfiguration.xml").getPath(); |
| 88 |
1
|
try { |
| 89 |
1
|
ClientConfigurationFactory.getInstance().configure(client, path); |
| 90 |
1
|
assertFalse(null == client); |
| 91 |
|
} catch (final ConfigurationException e) { |
| 92 |
0
|
LOGGER.error(e); |
| 93 |
0
|
fail("configuration failed find the config file with absolute path"); |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
} |