blob: 05d59b05610b6152d92138c42d5ad4fbdcd7acf7 [file] [log] [blame]
Andrew Brown63bed362015-02-18 11:28:50 -08001/*
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 */
11package com.intel.jndn.management;
12
13import java.util.logging.Logger;
14import junit.framework.Assert;
15import net.named_data.jndn.Face;
16import net.named_data.jndn.Name;
Andrew Brown07466442015-02-24 09:07:02 -080017import net.named_data.jndn.security.KeyChain;
Andrew Brown63bed362015-02-18 11:28:50 -080018
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 */
25public class IntegrationSuite {
26
27 private static final Logger logger = Logger.getLogger(IntegrationSuite.class.getName());
28
Andrew Brown07466442015-02-24 09:07:02 -080029 /**
30 * Test NFD methods
31 *
32 * @param args
33 * @throws Exception
34 */
Andrew Brown63bed362015-02-18 11:28:50 -080035 public static void main(String[] args) throws Exception {
andrewsbrown458524b2015-02-23 09:10:13 -080036 Face face = new Face("localhost");
Andrew Brown07466442015-02-24 09:07:02 -080037 KeyChain keyChain = buildTestKeyChain();
38 face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
39
Andrew Brown63bed362015-02-18 11:28:50 -080040 Assert.assertTrue(NFD.pingLocal(face));
Andrew Brown07466442015-02-24 09:07:02 -080041
Andrew Brown63bed362015-02-18 11:28:50 -080042 // grab datasets
43 Assert.assertFalse(NFD.getFaceList(face).isEmpty());
44 Assert.assertFalse(NFD.getFibList(face).isEmpty());
45 Assert.assertFalse(NFD.getRouteList(face).isEmpty());
Andrew Brown07466442015-02-24 09:07:02 -080046
Andrew Brown63bed362015-02-18 11:28:50 -080047 // create a new route
Andrew Brown07466442015-02-24 09:07:02 -080048 Assert.assertTrue(NFD.register(face, "udp4://127.0.0.1:56363", new Name("/my/test/route"), 999));
49
Andrew Brown63bed362015-02-18 11:28:50 -080050 // remove the route
Andrew Brown07466442015-02-24 09:07:02 -080051 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 Brown63bed362015-02-18 11:28:50 -080070 }
71}