Andrew Brown | 63bed36 | 2015-02-18 11:28:50 -0800 | [diff] [blame] | 1 | /* |
| 2 | * File name: IntegrationSuite.java |
| 3 | * |
| 4 | * Purpose: Tests to run with a local NFD as part of integration testing; will |
| 5 | * not run in the maven test phase, must be run manually. |
| 6 | * |
| 7 | * © Copyright Intel Corporation. All rights reserved. |
| 8 | * Intel Corporation, 2200 Mission College Boulevard, |
| 9 | * Santa Clara, CA 95052-8119, USA |
| 10 | */ |
| 11 | package com.intel.jndn.management; |
| 12 | |
| 13 | import java.util.logging.Logger; |
| 14 | import junit.framework.Assert; |
| 15 | import net.named_data.jndn.Face; |
| 16 | import net.named_data.jndn.Name; |
Andrew Brown | 0746644 | 2015-02-24 09:07:02 -0800 | [diff] [blame^] | 17 | import net.named_data.jndn.security.KeyChain; |
Andrew Brown | 63bed36 | 2015-02-18 11:28:50 -0800 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Tests to run with a local NFD as part of integration testing; will not run in |
| 21 | * the maven test phase, must be run manually. |
| 22 | * |
| 23 | * @author Andrew Brown <andrew.brown@intel.com> |
| 24 | */ |
| 25 | public class IntegrationSuite { |
| 26 | |
| 27 | private static final Logger logger = Logger.getLogger(IntegrationSuite.class.getName()); |
| 28 | |
Andrew Brown | 0746644 | 2015-02-24 09:07:02 -0800 | [diff] [blame^] | 29 | /** |
| 30 | * Test NFD methods |
| 31 | * |
| 32 | * @param args |
| 33 | * @throws Exception |
| 34 | */ |
Andrew Brown | 63bed36 | 2015-02-18 11:28:50 -0800 | [diff] [blame] | 35 | public static void main(String[] args) throws Exception { |
andrewsbrown | 458524b | 2015-02-23 09:10:13 -0800 | [diff] [blame] | 36 | Face face = new Face("localhost"); |
Andrew Brown | 0746644 | 2015-02-24 09:07:02 -0800 | [diff] [blame^] | 37 | KeyChain keyChain = buildTestKeyChain(); |
| 38 | face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName()); |
| 39 | |
Andrew Brown | 63bed36 | 2015-02-18 11:28:50 -0800 | [diff] [blame] | 40 | Assert.assertTrue(NFD.pingLocal(face)); |
Andrew Brown | 0746644 | 2015-02-24 09:07:02 -0800 | [diff] [blame^] | 41 | |
Andrew Brown | 63bed36 | 2015-02-18 11:28:50 -0800 | [diff] [blame] | 42 | // grab datasets |
| 43 | Assert.assertFalse(NFD.getFaceList(face).isEmpty()); |
| 44 | Assert.assertFalse(NFD.getFibList(face).isEmpty()); |
| 45 | Assert.assertFalse(NFD.getRouteList(face).isEmpty()); |
Andrew Brown | 0746644 | 2015-02-24 09:07:02 -0800 | [diff] [blame^] | 46 | |
Andrew Brown | 63bed36 | 2015-02-18 11:28:50 -0800 | [diff] [blame] | 47 | // create a new route |
Andrew Brown | 0746644 | 2015-02-24 09:07:02 -0800 | [diff] [blame^] | 48 | Assert.assertTrue(NFD.register(face, "udp4://127.0.0.1:56363", new Name("/my/test/route"), 999)); |
| 49 | |
Andrew Brown | 63bed36 | 2015-02-18 11:28:50 -0800 | [diff] [blame] | 50 | // remove the route |
Andrew Brown | 0746644 | 2015-02-24 09:07:02 -0800 | [diff] [blame^] | 51 | Assert.assertTrue(NFD.unregister(face, new Name("/my/test/route"), "udp4://127.0.0.1:56363")); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Setup the KeyChain with a default identity; TODO move this to |
| 56 | * MemoryIdentityStorage once it can handle getting/setting defaults |
| 57 | * |
| 58 | * @return |
| 59 | * @throws net.named_data.jndn.security.SecurityException |
| 60 | */ |
| 61 | public static KeyChain buildTestKeyChain() throws net.named_data.jndn.security.SecurityException { |
| 62 | KeyChain keyChain = new KeyChain(); |
| 63 | try { |
| 64 | keyChain.getDefaultCertificateName(); |
| 65 | } catch (net.named_data.jndn.security.SecurityException e) { |
| 66 | keyChain.createIdentity(new Name("/test/identity")); |
| 67 | keyChain.getIdentityManager().setDefaultIdentity(new Name("/test/identity")); |
| 68 | } |
| 69 | return keyChain; |
Andrew Brown | 63bed36 | 2015-02-18 11:28:50 -0800 | [diff] [blame] | 70 | } |
| 71 | } |