| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.environment; |
| 21 |
|
|
| 22 |
|
import java.io.File; |
| 23 |
|
|
| 24 |
|
import org.junit.Assert; |
| 25 |
|
import org.junit.Test; |
| 26 |
|
import org.slf4j.helpers.NOPLogger; |
| 27 |
|
import org.xwiki.component.manager.ComponentManager; |
| 28 |
|
import org.xwiki.component.util.ReflectionUtils; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@link |
| 32 |
|
|
| 33 |
|
@version |
| 34 |
|
@since |
| 35 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 3 |
Complexity Density: 0.16 |
|
| 36 |
|
public class SystemTest |
| 37 |
|
{ |
| 38 |
|
private static final File TMPDIR = new File(java.lang.System.getProperty("java.io.tmpdir"), "xwiki-temp"); |
| 39 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 40 |
1 |
@Test... |
| 41 |
|
public void testInitializeWithNoParameter() throws Exception |
| 42 |
|
{ |
| 43 |
1 |
ComponentManager componentManager = System.initialize(); |
| 44 |
1 |
Assert.assertNotNull(componentManager); |
| 45 |
|
|
| 46 |
1 |
Environment environment = componentManager.getInstance(Environment.class); |
| 47 |
|
|
| 48 |
|
|
| 49 |
1 |
ReflectionUtils.setFieldValue(environment, "logger", NOPLogger.NOP_LOGGER); |
| 50 |
|
|
| 51 |
|
|
| 52 |
1 |
Assert.assertEquals(TMPDIR, environment.getTemporaryDirectory()); |
| 53 |
|
|
| 54 |
|
|
| 55 |
1 |
Assert.assertEquals(new File(java.lang.System.getProperty("java.io.tmpdir")), |
| 56 |
|
environment.getPermanentDirectory()); |
| 57 |
|
} |
| 58 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
| 59 |
1 |
@Test... |
| 60 |
|
public void testInitializeWithAllDirectoriesSet() throws Exception |
| 61 |
|
{ |
| 62 |
1 |
File permanentDirectory = new File("/permanent"); |
| 63 |
1 |
File temporaryDirectory = new File("/temporary"); |
| 64 |
1 |
File resourceDirectory = new File("/resource"); |
| 65 |
|
|
| 66 |
1 |
ComponentManager componentManager = |
| 67 |
|
System.initialize(permanentDirectory, resourceDirectory, temporaryDirectory); |
| 68 |
1 |
Assert.assertNotNull(componentManager); |
| 69 |
|
|
| 70 |
1 |
Environment environment = componentManager.getInstance(Environment.class); |
| 71 |
|
|
| 72 |
|
|
| 73 |
1 |
Assert.assertEquals(temporaryDirectory, environment.getTemporaryDirectory()); |
| 74 |
|
|
| 75 |
|
|
| 76 |
1 |
Assert.assertEquals(permanentDirectory, environment.getPermanentDirectory()); |
| 77 |
|
} |
| 78 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 79 |
1 |
@Test... |
| 80 |
|
public void testDispose() throws Exception |
| 81 |
|
{ |
| 82 |
1 |
ComponentManager componentManager = System.initialize(); |
| 83 |
|
|
| 84 |
1 |
TestComponent testComponent = componentManager.getInstance(TestRole.class); |
| 85 |
|
|
| 86 |
1 |
Assert.assertFalse(testComponent.isDisposed()); |
| 87 |
|
|
| 88 |
1 |
System.dispose(componentManager); |
| 89 |
|
|
| 90 |
1 |
Assert.assertTrue(testComponent.isDisposed()); |
| 91 |
|
} |
| 92 |
|
} |