andrewsbrown | e8e8e85 | 2015-03-09 13:48:31 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 14 | package com.intel.jndn.management; |
| 15 | |
| 16 | import com.intel.jndn.management.types.LocalControlHeader; |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 17 | import com.intel.jndn.utils.SimpleClient; |
andrewsbrown | e8e8e85 | 2015-03-09 13:48:31 -0700 | [diff] [blame] | 18 | import java.util.logging.Logger; |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 19 | import junit.framework.Assert; |
andrewsbrown | e8e8e85 | 2015-03-09 13:48:31 -0700 | [diff] [blame] | 20 | import net.named_data.jndn.Data; |
| 21 | import net.named_data.jndn.Face; |
| 22 | import net.named_data.jndn.Name; |
| 23 | import net.named_data.jndn.encoding.EncodingException; |
| 24 | import net.named_data.jndn.security.KeyChain; |
| 25 | import static org.junit.Assert.assertTrue; |
| 26 | |
| 27 | /** |
| 28 | * Test functionality for LocalControlHeader |
| 29 | * |
| 30 | * @author Andrew Brown <andrew.brown@intel.com> |
| 31 | */ |
| 32 | public 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()); |
andrewsbrown | 579a9f1 | 2015-03-09 18:27:13 -0700 | [diff] [blame] | 47 | |
andrewsbrown | e8e8e85 | 2015-03-09 13:48:31 -0700 | [diff] [blame] | 48 | // enable incoming face ID header |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 49 | NFD.enableLocalControlHeader(forwarder, LocalControlHeader.INCOMING_FACE_ID); |
andrewsbrown | e8e8e85 | 2015-03-09 13:48:31 -0700 | [diff] [blame] | 50 | |
| 51 | // use and verify |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 52 | Data data = SimpleClient.getDefault().getSync(forwarder, new Name("/localhost/nfd")); |
andrewsbrown | e8e8e85 | 2015-03-09 13:48:31 -0700 | [diff] [blame] | 53 | long faceId = data.getIncomingFaceId(); |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 54 | Assert.assertTrue(faceId != -1); // this verifies that the headers are working correctly |
andrewsbrown | e8e8e85 | 2015-03-09 13:48:31 -0700 | [diff] [blame] | 55 | logger.info("Face ID for this client on the forwarder: " + faceId); |
| 56 | } |
| 57 | } |