4 import static org
.junit
.Assert
.assertEquals
;
6 import interfaces
.Constants
;
8 import java
.io
.ByteArrayInputStream
;
9 import java
.io
.ByteArrayOutputStream
;
11 import org
.junit
.Before
;
12 import org
.junit
.Test
;
16 import dacp
.DACPReader
;
17 import dacp
.DACPWriter
;
19 public class ServerInfoTest
{
21 private ServerInfo input
;
22 private ServerInfo output
;
25 public void setUp() throws Exception
{
27 input
= new ServerInfo("Test Server", 15);
29 ByteArrayOutputStream out
= new ByteArrayOutputStream();
30 Writer w
= new DACPWriter(out
);
33 ByteArrayInputStream in
= new ByteArrayInputStream(out
.toByteArray());
34 Reader r
= new DACPReader(in
, in
.available());
36 output
= ServerInfo
.read(r
.nextComposite(r
.iterator().next()));
40 public void testServerInfo() {
41 for (Constants c
: input
.getAllTags()) {
43 case Constants
.VERSION
:
44 byte[] a
= (byte[])input
.get(c
);
45 byte[] b
= (byte[])output
.get(c
);
46 for (int i
= 0; i
< 4; i
++) {
47 assertEquals(a
[i
], b
[i
]);
51 assertEquals(input
.get(c
), output
.get(c
));