blob: 5f32711f3e9821aa5b522eb480fe8f2e18f7901d [file] [log] [blame]
Andrew Brown63bed362015-02-18 11:28:50 -08001/*
andrewsbrown7e6b9e82015-03-03 16:11:11 -08002 * 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 Brown63bed362015-02-18 11:28:50 -080013 */
14package com.intel.jndn.management;
15
andrewsbrown43b96302015-03-17 21:51:43 +010016import com.intel.jndn.management.types.RibEntry;
Andrew Brown63bed362015-02-18 11:28:50 -080017import java.util.logging.Logger;
18import junit.framework.Assert;
19import net.named_data.jndn.Face;
20import net.named_data.jndn.Name;
Andrew Brown07466442015-02-24 09:07:02 -080021import net.named_data.jndn.security.KeyChain;
Andrew Brown63bed362015-02-18 11:28:50 -080022
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 */
29public class IntegrationSuite {
30
31 private static final Logger logger = Logger.getLogger(IntegrationSuite.class.getName());
32
Andrew Brown07466442015-02-24 09:07:02 -080033 /**
34 * Test NFD methods
35 *
36 * @param args
37 * @throws Exception
38 */
Andrew Brown63bed362015-02-18 11:28:50 -080039 public static void main(String[] args) throws Exception {
andrewsbrown458524b2015-02-23 09:10:13 -080040 Face face = new Face("localhost");
Andrew Brown07466442015-02-24 09:07:02 -080041 KeyChain keyChain = buildTestKeyChain();
42 face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
43
Andrew Brown63bed362015-02-18 11:28:50 -080044 Assert.assertTrue(NFD.pingLocal(face));
Andrew Brown07466442015-02-24 09:07:02 -080045
Andrew Brown63bed362015-02-18 11:28:50 -080046 // grab datasets
47 Assert.assertFalse(NFD.getFaceList(face).isEmpty());
48 Assert.assertFalse(NFD.getFibList(face).isEmpty());
49 Assert.assertFalse(NFD.getRouteList(face).isEmpty());
Andrew Brown07466442015-02-24 09:07:02 -080050
Andrew Brown63bed362015-02-18 11:28:50 -080051 // create a new route
andrewsbrown43b96302015-03-17 21:51:43 +010052 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 Brown61bfc592015-03-17 14:11:36 -070057 logger.info("Found route: " + route.getName().toUri());
andrewsbrown43b96302015-03-17 21:51:43 +010058 if(route.getName().equals(new Name("/my/test/route"))){
59 found = true;
60 }
61 }
62 Assert.assertTrue(found);
Andrew Brown07466442015-02-24 09:07:02 -080063
Andrew Brown63bed362015-02-18 11:28:50 -080064 // remove the route
andrewsbrown43b96302015-03-17 21:51:43 +010065 NFD.unregister(face, new Name("/my/test/route"), "udp4://127.0.0.1:56363");
Andrew Brown07466442015-02-24 09:07:02 -080066 }
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 Brown63bed362015-02-18 11:28:50 -080084 }
85}