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