Moved MPRIS to a new project
[stereo.git] / DAAPLib / test / util / response / CtrlIntTest.java
blob93e3cde58ad64f816140ad4b9a1847c9804b2756
1 package util.response;
3 import static org.junit.Assert.assertEquals;
5 import java.io.ByteArrayInputStream;
6 import java.io.ByteArrayOutputStream;
7 import java.util.Iterator;
9 import org.junit.Before;
10 import org.junit.Test;
12 import api.Reader;
13 import api.Writer;
14 import dacp.DACPReader;
15 import dacp.DACPWriter;
17 public class CtrlIntTest {
19 public CtrlInt input;
20 public CtrlInt output;
22 @Before
23 public void setUp() throws Exception {
25 input = new CtrlInt(1);
27 ByteArrayOutputStream out = new ByteArrayOutputStream();
28 Writer w = new DACPWriter(out);
29 w.appendNode(input);
31 ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
32 Reader r = new DACPReader(in, in.available());
34 output = CtrlInt.read(r.nextComposite(r.iterator().next()));
37 @Test
38 public void testIds() {
39 Iterator<Integer> a = input.ids().iterator();
40 Iterator<Integer> b = output.ids().iterator();
41 while (a.hasNext() && b.hasNext()) {
42 assertEquals(a.next(), b.next());
44 assertEquals(a.hasNext(), b.hasNext());