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