| 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 java.io.ByteArrayInputStream; |
| 24 |
|
import java.io.ByteArrayOutputStream; |
| 25 |
|
import java.io.IOException; |
| 26 |
|
import java.io.InputStream; |
| 27 |
|
import java.io.ObjectInputStream; |
| 28 |
|
import java.io.ObjectOutputStream; |
| 29 |
|
|
| 30 |
|
import junit.framework.TestCase; |
| 31 |
|
import net.sf.arestc.configuration.CommunicationFactory; |
| 32 |
|
|
| 33 |
|
import org.apache.log4j.Logger; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
@author |
| 40 |
|
|
|
|
|
| 86.7% |
Uncovered Elements: 4 (30) |
Complexity: 7 |
Complexity Density: 0.28 |
|
| 41 |
|
public class CommunicationFactoryTest extends TestCase { |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
private static final Logger LOGGER = Logger |
| 45 |
|
.getLogger(CommunicationFactoryTest.class |
| 46 |
|
.getName()); |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
@see |
| 52 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 53 |
3
|
@Override... |
| 54 |
|
protected void setUp() throws Exception { |
| 55 |
3
|
super.setUp(); |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
@see |
| 62 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 63 |
3
|
@Override... |
| 64 |
|
protected void tearDown() throws Exception { |
| 65 |
3
|
CommunicationFactory.getInstance().shutdown(); |
| 66 |
3
|
super.tearDown(); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@link |
| 73 |
|
|
| 74 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
| 75 |
1
|
public void testIsConfigured() {... |
| 76 |
1
|
assertNotNull(CommunicationFactory.getInstance().isConfigured()); |
| 77 |
|
|
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
@link |
| 84 |
|
|
| 85 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
| 86 |
1
|
public void testIsMultiThreaded() {... |
| 87 |
1
|
assertNotNull(CommunicationFactory.getInstance().isMultiThreaded()); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
|
|
|
| 80% |
Uncovered Elements: 4 (20) |
Complexity: 3 |
Complexity Density: 0.15 |
1
PASS
|
|
| 93 |
1
|
public void testSerialisation() {... |
| 94 |
|
|
| 95 |
1
|
final ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| 96 |
1
|
ObjectOutputStream oos; |
| 97 |
1
|
try { |
| 98 |
1
|
oos = new ObjectOutputStream(out); |
| 99 |
|
|
| 100 |
1
|
oos.writeObject(CommunicationFactory.getInstance()); |
| 101 |
1
|
oos.close(); |
| 102 |
|
|
| 103 |
|
|
| 104 |
1
|
byte[] pickled = null; |
| 105 |
1
|
pickled = out.toByteArray(); |
| 106 |
1
|
InputStream in = null; |
| 107 |
1
|
in = new ByteArrayInputStream(pickled); |
| 108 |
1
|
ObjectInputStream ois = null; |
| 109 |
1
|
ois = new ObjectInputStream(in); |
| 110 |
1
|
Object o = null; |
| 111 |
1
|
o = ois.readObject(); |
| 112 |
1
|
final CommunicationFactory copy = (CommunicationFactory) o; |
| 113 |
|
|
| 114 |
|
|
| 115 |
1
|
assertEquals(CommunicationFactory.getInstance().isMultiThreaded(), |
| 116 |
|
copy.isMultiThreaded()); |
| 117 |
|
|
| 118 |
|
} catch (final IOException e) { |
| 119 |
0
|
LOGGER.error(e); |
| 120 |
0
|
fail("IOException"); |
| 121 |
|
} catch (final ClassNotFoundException e) { |
| 122 |
0
|
LOGGER.error(e); |
| 123 |
0
|
fail("ClassNotFoundException"); |
| 124 |
|
} |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
} |