|
SnmpTrapAgentTest |
|
1 package com.mccrory.scott.spumoni.test;
2
3 ////////////////////////////////////////////////////////////////////////////////
4 // Copyright (C) 2002 Scott McCrory
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ////////////////////////////////////////////////////////////////////////////////
20
21 import junit.framework.TestCase;
22
23 import com.mccrory.scott.spumoni.SnmpTrapAgent;
24
25 /**
26 * <P>JUnit test case for the SnmpTrapAgent class.</P>
27 *
28 * @author <a href="mailto:smccrory@users.sourceforge.net">Scott McCrory</a>.
29 * @version CVS $Id: SnmpTrapAgentTest.java,v 1.2 2002/08/04 22:04:53 smccrory Exp $
30 */
31 public class SnmpTrapAgentTest extends TestCase {
32
33 /** A class-wide storage container for the command-line arguments **/
34 private static String[] myargs;
35
36 /**
37 * SnmpTrapAgentTest constructor
38 * @param name java.lang.String
39 */
40 public SnmpTrapAgentTest(String name) {
41 super(name);
42 }
43
44 /**
45 * Runs the JUnit test from the command line.
46 * @param args java.lang.String[]
47 */
48 public static void main(String[] args) {
49
50 myargs = args;
51 junit.textui.TestRunner.run(SnmpTrapAgentTest.class);
52
53 }
54
55 /**
56 * Makes sure we can create the SnmpTrapAgent object and send V1 and V2 traps.
57 * Note that it does not guarantee that they were formatted correctly or
58 * successfully received by a trap daemon (trapd).
59 * Creation date: (1/12/2002 7:22:47 PM)
60 */
61 public void testSnmpTrapAgent() {
62
63 try {
64
65 SnmpTrapAgent sa = new SnmpTrapAgent("localhost", 162, "1.3.6.1.2.1.1232.1.1");
66 assertNotNull(sa);
67
68 sa.sendV1Trap("V1 Trap");
69 sa.sendV2Trap("V2 Trap");
70
71 sa.close();
72
73 }
74 catch (Exception e) {
75 e.printStackTrace();
76 fail("Should not encounter " + e.getMessage());
77 }
78
79 }
80 }
|
SnmpTrapAgentTest |
|