git-svn-id: https://stereo.googlecode.com/svn/trunk@440 c67ee986-0855-0410-825f-15918...
[stereo.git] / DACPlib / test / util / response / ServerInfoTest.java
blobe670dc51ac770a7a913ea3bfc673d5ba2b468aa2
1 package util.response;
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;
14 import api.Reader;
15 import api.Writer;
16 import dacp.DACPReader;
17 import dacp.DACPWriter;
19 public class ServerInfoTest {
21 private ServerInfo input;
22 private ServerInfo output;
24 @Before
25 public void setUp() throws Exception {
27 input = new ServerInfo("Test Server", 15);
29 ByteArrayOutputStream out = new ByteArrayOutputStream();
30 Writer w = new DACPWriter(out);
31 w.appendNode(input);
33 ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
34 Reader r = new DACPReader(in, in.available());
36 output = ServerInfo.read(r.nextComposite(r.iterator().next()));
39 @Test
40 public void testServerInfo() {
41 for (Constants c: input.getAllTags()) {
42 switch (c.type) {
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]);
49 break;
50 default:
51 assertEquals(input.get(c), output.get(c));