blob: f0167b569edfbd4761f821fe505396dd5e46870f [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
16import java.util.logging.Logger;
17import junit.framework.Assert;
18import net.named_data.jndn.Face;
19import net.named_data.jndn.Name;
Andrew Brown07466442015-02-24 09:07:02 -080020import net.named_data.jndn.security.KeyChain;
Andrew Brown63bed362015-02-18 11:28:50 -080021
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 */
28public class IntegrationSuite {
29
30 private static final Logger logger = Logger.getLogger(IntegrationSuite.class.getName());
31
Andrew Brown07466442015-02-24 09:07:02 -080032 /**
33 * Test NFD methods
34 *
35 * @param args
36 * @throws Exception
37 */
Andrew Brown63bed362015-02-18 11:28:50 -080038 public static void main(String[] args) throws Exception {
andrewsbrown458524b2015-02-23 09:10:13 -080039 Face face = new Face("localhost");
Andrew Brown07466442015-02-24 09:07:02 -080040 KeyChain keyChain = buildTestKeyChain();
41 face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
42
Andrew Brown63bed362015-02-18 11:28:50 -080043 Assert.assertTrue(NFD.pingLocal(face));
Andrew Brown07466442015-02-24 09:07:02 -080044
Andrew Brown63bed362015-02-18 11:28:50 -080045 // grab datasets
46 Assert.assertFalse(NFD.getFaceList(face).isEmpty());
47 Assert.assertFalse(NFD.getFibList(face).isEmpty());
48 Assert.assertFalse(NFD.getRouteList(face).isEmpty());
Andrew Brown07466442015-02-24 09:07:02 -080049
Andrew Brown63bed362015-02-18 11:28:50 -080050 // create a new route
Andrew Brown07466442015-02-24 09:07:02 -080051 Assert.assertTrue(NFD.register(face, "udp4://127.0.0.1:56363", new Name("/my/test/route"), 999));
52
Andrew Brown63bed362015-02-18 11:28:50 -080053 // remove the route
Andrew Brown07466442015-02-24 09:07:02 -080054 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 Brown63bed362015-02-18 11:28:50 -080073 }
74}