blob: 7686616d5b70bfe1a26cffbc891331d8fd1fd899 [file] [log] [blame]
andrewsbrowne8e8e852015-03-09 13:48:31 -07001/*
2 * jndn-management
3 * Copyright (c) 2015, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU Lesser General Public License,
7 * version 3, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12 * more details.
13 */
14package com.intel.jndn.management;
15
16import com.intel.jndn.management.types.LocalControlHeader;
andrewsbrown43b96302015-03-17 21:51:43 +010017import com.intel.jndn.utils.SimpleClient;
andrewsbrowne8e8e852015-03-09 13:48:31 -070018import java.util.logging.Logger;
andrewsbrown43b96302015-03-17 21:51:43 +010019import junit.framework.Assert;
andrewsbrowne8e8e852015-03-09 13:48:31 -070020import net.named_data.jndn.Data;
21import net.named_data.jndn.Face;
22import net.named_data.jndn.Name;
23import net.named_data.jndn.encoding.EncodingException;
24import net.named_data.jndn.security.KeyChain;
25import static org.junit.Assert.assertTrue;
26
27/**
28 * Test functionality for LocalControlHeader
29 *
30 * @author Andrew Brown <andrew.brown@intel.com>
31 */
32public class LocalControlHeaderTest {
33
34 private static final Logger logger = Logger.getLogger(IntegrationSuite.class.getName());
35
36 /**
37 * Integration test to run on actual system
38 *
39 * @param args
40 * @throws EncodingException
41 */
42 public static void main(String[] args) throws Exception {
43 // setup forwarder face
44 Face forwarder = new Face("localhost");
45 KeyChain keyChain = IntegrationSuite.buildTestKeyChain();
46 forwarder.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
andrewsbrown579a9f12015-03-09 18:27:13 -070047
andrewsbrowne8e8e852015-03-09 13:48:31 -070048 // enable incoming face ID header
andrewsbrown43b96302015-03-17 21:51:43 +010049 NFD.enableLocalControlHeader(forwarder, LocalControlHeader.INCOMING_FACE_ID);
andrewsbrowne8e8e852015-03-09 13:48:31 -070050
51 // use and verify
andrewsbrown43b96302015-03-17 21:51:43 +010052 Data data = SimpleClient.getDefault().getSync(forwarder, new Name("/localhost/nfd"));
andrewsbrowne8e8e852015-03-09 13:48:31 -070053 long faceId = data.getIncomingFaceId();
andrewsbrown43b96302015-03-17 21:51:43 +010054 Assert.assertTrue(faceId != -1); // this verifies that the headers are working correctly
andrewsbrowne8e8e852015-03-09 13:48:31 -070055 logger.info("Face ID for this client on the forwarder: " + faceId);
56 }
57}