blob: 5d026e067a2d1754b451e401ad3ddce737ce1ca3 [file] [log] [blame]
Andrew Brownc46c1602015-02-18 10:45:56 -08001/*
2 * File name: ControlResponseTest.java
3 *
4 * Purpose: Test encoding/decoding of ControlResponses.
5 *
6 * © Copyright Intel Corporation. All rights reserved.
7 * Intel Corporation, 2200 Mission College Boulevard,
8 * Santa Clara, CA 95052-8119, USA
9 */
10package com.intel.jndn.management;
11
12import com.intel.jndn.management.types.ControlResponse;
13import junit.framework.Assert;
14import net.named_data.jndn.ControlParameters;
15import net.named_data.jndn.util.Blob;
16import org.junit.Test;
17
18/**
19 * Test encoding/decoding of ControlResponses.
20 *
21 * @author Andrew Brown <andrew.brown@intel.com>
22 */
23public class ControlResponseTest {
24
25 /**
26 * Test encoding/decoding
27 *
28 * @throws java.lang.Exception
29 */
30 @Test
31 public void testEncodeDecode() throws Exception {
32 ControlParameters parameters = new ControlParameters();
33 parameters.setFaceId(3);
34 ControlResponse response = new ControlResponse();
35 response.setStatusCode(404);
36 response.setStatusText("Not Found");
37 response.getBody().add(parameters);
38
39 // encode
40 Blob encoded = response.wireEncode();
41
42 // decode
43 ControlResponse decoded = new ControlResponse();
44 decoded.wireDecode(encoded.buf());
45
46 // test
47 Assert.assertEquals(response.getStatusCode(), decoded.getStatusCode());
48 Assert.assertEquals(response.getStatusText(), decoded.getStatusText());
49 Assert.assertEquals(response.getBody().size(), decoded.getBody().size());
50 Assert.assertEquals(response.getBody().get(0).getFaceId(), decoded.getBody().get(0).getFaceId());
51 }
52}