blob: d21c3e04ccb98c824c8219e4e77b03adfc31d149 [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
Andrew Brown211d2b62015-02-18 11:12:02 -080025 /**
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);
Andrew Brownc46c1602015-02-18 10:45:56 -080038
Andrew Brown211d2b62015-02-18 11:12:02 -080039 // encode
40 Blob encoded = response.wireEncode();
Andrew Brownc46c1602015-02-18 10:45:56 -080041
Andrew Brown211d2b62015-02-18 11:12:02 -080042 // decode
43 ControlResponse decoded = new ControlResponse();
44 decoded.wireDecode(encoded.buf());
Andrew Brownc46c1602015-02-18 10:45:56 -080045
Andrew Brown211d2b62015-02-18 11:12:02 -080046 // 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 }
Andrew Brownc46c1602015-02-18 10:45:56 -080052}