From e6cb0b4629c6c93e77b3ef56e568e277cdada54f Mon Sep 17 00:00:00 2001 From: Frederic Bregier Date: Thu, 18 Jul 2019 11:25:58 +0200 Subject: [PATCH] Add Junit to v3.1.0 --- .gitignore | 65 +- pom.xml | 14 +- src/main/.gitignore | 2 - .../java/org/waarp/snmp/utils/Version.java | 2 +- src/test/java/.gitkeep | 0 .../waarp/snmp/test/ExampleImplCounter32.java | 63 ++ .../waarp/snmp/test/ExampleImplGauge32.java | 101 +- .../waarp/snmp/test/WaarpImplPrivateMib.java | 309 ++++--- .../waarp/snmp/test/WaarpPrivateMonitor.java | 132 ++- .../snmp/test/WaarpSimpleSnmpClient.java | 338 +++---- .../snmp/test/WaarpSnmpClientAgentTest.java | 212 +++++ .../snmp/test/WaarpTestSnmpClientAgent.java | 142 --- .../snmp/test/WaarpTestVariableFactory.java | 126 +-- .../org/waarp/snmp/test/package-info.java | 21 +- src/test/resources/OPENR66-MIB | 867 ++++++++++++++++++ src/test/resources/SnmpConfiguration.xsd | 195 ++++ src/test/resources/snmpconfig.xml | 98 ++ 17 files changed, 2038 insertions(+), 649 deletions(-) delete mode 100644 src/main/.gitignore create mode 100644 src/test/java/.gitkeep create mode 100644 src/test/java/org/waarp/snmp/test/ExampleImplCounter32.java create mode 100644 src/test/java/org/waarp/snmp/test/WaarpSnmpClientAgentTest.java delete mode 100644 src/test/java/org/waarp/snmp/test/WaarpTestSnmpClientAgent.java create mode 100644 src/test/resources/OPENR66-MIB create mode 100644 src/test/resources/SnmpConfiguration.xsd create mode 100644 src/test/resources/snmpconfig.xml diff --git a/.gitignore b/.gitignore index ac10da6..bc42b32 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ local.properties .settings/ .loadpath .pmd -bin/ # External tool builders .externalToolBuilders/ @@ -33,9 +32,31 @@ bin/ ################# ## Java ################# +# Compiled class file *.class *.jardesc +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + ################# ## Visual Studio ################# @@ -133,5 +154,43 @@ Thumbs.db Desktop.ini runtime.properties -/dummyBootCounter.agent -/dummyConf.agent + +############### +## Intellij +############### +# User-specific stuff +.idea/ + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +.idea/modules.xml +.idea/*.iml +.idea/modules +*.iml +*.ipr + +# CMake +cmake-build-*/ + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +*.log + diff --git a/pom.xml b/pom.xml index 0f0c140..2210edb 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 WaarpSnmp - 3.0.7 + 3.1.0 WaarpSnmp Waarp SNMP support through SNMP4J http://waarp.github.com/WaarpSnmp @@ -51,7 +51,7 @@ Waarp WaarpCommon - 3.1.0 + 3.1.1 ch.qos.logback @@ -73,7 +73,13 @@ org.snmp4j snmp4j-agent - 2.6.4 + 2.6.3 + + + junit + junit + 4.12 + test @@ -102,7 +108,7 @@ 1.6 1.6 true - true + true diff --git a/src/main/.gitignore b/src/main/.gitignore deleted file mode 100644 index 83a82fe..0000000 --- a/src/main/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/dummyBootCounter.agent -/dummyConf.agent diff --git a/src/main/java/org/waarp/snmp/utils/Version.java b/src/main/java/org/waarp/snmp/utils/Version.java index 2e6d2ff..f097108 100644 --- a/src/main/java/org/waarp/snmp/utils/Version.java +++ b/src/main/java/org/waarp/snmp/utils/Version.java @@ -3,7 +3,7 @@ /** Provides the version information of Waarp SNMP */ public final class Version { /** The version identifier. */ - public static final String ID = "3.0.7"; + public static final String ID = "3.1.0"; /** Prints out the version identifier to stdout. */ public static void main(String[] args) { System.out.println(ID); } private Version() { super(); } diff --git a/src/test/java/.gitkeep b/src/test/java/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/test/java/org/waarp/snmp/test/ExampleImplCounter32.java b/src/test/java/org/waarp/snmp/test/ExampleImplCounter32.java new file mode 100644 index 0000000..93ffc2f --- /dev/null +++ b/src/test/java/org/waarp/snmp/test/ExampleImplCounter32.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * This file is part of Waarp Project (named also Waarp or GG). + * + * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author + * tags. See the COPYRIGHT.txt in the distribution for a full listing of + * individual contributors. + * + * All Waarp Project is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Waarp . If not, see . + ******************************************************************************/ +package org.waarp.snmp.test; + +import org.snmp4j.smi.OID; +import org.waarp.snmp.interf.WaarpCounter32; + +/** + * Example of WaarpGauge32 Usage + * + * @author Frederic Bregier + */ +@SuppressWarnings("serial") +public class ExampleImplCounter32 extends WaarpCounter32 { + public static final long STARTUP = 42; + + public OID oid; + + long _internalValue = STARTUP; + + /** + * + */ + public ExampleImplCounter32(OID oid) { + super(); + this.oid = oid; + } + + /** + * + */ + public ExampleImplCounter32(OID oid, long value) { + super(value); + this.oid = oid; + } + + protected void setInternalValue() { + _internalValue++; + setValue(_internalValue); + } + + protected void setInternalValue(long value) { + _internalValue = value; + setValue(_internalValue); + } +} diff --git a/src/test/java/org/waarp/snmp/test/ExampleImplGauge32.java b/src/test/java/org/waarp/snmp/test/ExampleImplGauge32.java index 97b5dfc..da2e9d3 100644 --- a/src/test/java/org/waarp/snmp/test/ExampleImplGauge32.java +++ b/src/test/java/org/waarp/snmp/test/ExampleImplGauge32.java @@ -1,22 +1,22 @@ -/** - * This file is part of Waarp Project. - * - * Copyright 2009, Frederic Bregier, and individual contributors by the @author - * tags. See the COPYRIGHT.txt in the distribution for a full listing of - * individual contributors. - * - * All Waarp Project is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * Waarp. If not, see . - */ +/******************************************************************************* + * This file is part of Waarp Project (named also Waarp or GG). + * + * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author + * tags. See the COPYRIGHT.txt in the distribution for a full listing of + * individual contributors. + * + * All Waarp Project is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Waarp . If not, see . + ******************************************************************************/ package org.waarp.snmp.test; import org.snmp4j.smi.OID; @@ -24,39 +24,40 @@ /** * Example of WaarpGauge32 Usage - * + * * @author Frederic Bregier - * */ @SuppressWarnings("serial") public class ExampleImplGauge32 extends WaarpGauge32 { - public OID oid; - - long _internalValue = 42; - - protected void setInternalValue() { - _internalValue++; - setValue(_internalValue); - } - - protected void setInternalValue(long value) { - _internalValue = value; - setValue(_internalValue); - } - - /** - * - */ - public ExampleImplGauge32(OID oid) { - super(); - this.oid = oid; - } - - /** - * - */ - public ExampleImplGauge32(OID oid, long value) { - super(value); - this.oid = oid; - } + public static final long STARTUP = 42; + + public OID oid; + + long _internalValue = STARTUP; + + /** + * + */ + public ExampleImplGauge32(OID oid) { + super(); + this.oid = oid; + } + + /** + * + */ + public ExampleImplGauge32(OID oid, long value) { + super(value); + this.oid = oid; + } + + protected void setInternalValue() { + _internalValue++; + setValue(_internalValue); + } + + protected void setInternalValue(long value) { + _internalValue = value; + setValue(_internalValue); + } } diff --git a/src/test/java/org/waarp/snmp/test/WaarpImplPrivateMib.java b/src/test/java/org/waarp/snmp/test/WaarpImplPrivateMib.java index bd3f032..adf2b4b 100644 --- a/src/test/java/org/waarp/snmp/test/WaarpImplPrivateMib.java +++ b/src/test/java/org/waarp/snmp/test/WaarpImplPrivateMib.java @@ -1,22 +1,22 @@ -/** - * This file is part of Waarp Project. - * - * Copyright 2009, Frederic Bregier, and individual contributors by the @author - * tags. See the COPYRIGHT.txt in the distribution for a full listing of - * individual contributors. - * - * All Waarp Project is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * Waarp. If not, see . - */ +/******************************************************************************* + * This file is part of Waarp Project (named also Waarp or GG). + * + * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author + * tags. See the COPYRIGHT.txt in the distribution for a full listing of + * individual contributors. + * + * All Waarp Project is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Waarp . If not, see . + ******************************************************************************/ package org.waarp.snmp.test; import org.snmp4j.agent.DuplicateRegistrationException; @@ -32,158 +32,163 @@ /** * Example of Implementation of WaarpPrivateMib - * + * * @author Frederic Bregier - * */ public class WaarpImplPrivateMib extends WaarpPrivateMib { - /** - * Internal Logger - */ - private static WaarpLogger logger = WaarpLoggerFactory - .getLogger(WaarpImplPrivateMib.class); + /** + * Internal Logger + */ + private static WaarpLogger logger = WaarpLoggerFactory + .getLogger(WaarpImplPrivateMib.class); - /** - * @param sysdesc - * @param port - * @param smiPrivateCodeFinal - * @param typeWaarpObject - * @param scontactName - * @param stextualName - * @param saddress - * @param iservice - */ - public WaarpImplPrivateMib(String sysdesc, int port, int smiPrivateCodeFinal, - int typeWaarpObject, String scontactName, String stextualName, - String saddress, int iservice) { - super(sysdesc, port, smiPrivateCodeFinal, typeWaarpObject, - scontactName, stextualName, saddress, iservice); - } + /** + * @param sysdesc + * @param port + * @param smiPrivateCodeFinal + * @param typeWaarpObject + * @param scontactName + * @param stextualName + * @param saddress + * @param iservice + */ + public WaarpImplPrivateMib(String sysdesc, int port, int smiPrivateCodeFinal, + int typeWaarpObject, String scontactName, + String stextualName, + String saddress, int iservice) { + super(sysdesc, port, smiPrivateCodeFinal, typeWaarpObject, + scontactName, stextualName, saddress, iservice); + } - public void updateServices(WaarpMOScalar scalar) { - // 3 groups to check - OID oid = scalar.getOid(); - if (oid.startsWith(rootOIDWaarpGlobal)) { - // UpTime - if (oid.equals(rootOIDWaarpGlobalUptime)) { - return; - } - ((WaarpPrivateMonitor) agent.getMonitor()).generalValuesUpdate(); - } else if (oid.startsWith(rootOIDWaarpDetailed)) { - ((WaarpPrivateMonitor) agent.getMonitor()).detailedValuesUpdate(); - } else if (oid.startsWith(rootOIDWaarpError)) { - ((WaarpPrivateMonitor) agent.getMonitor()).errorValuesUpdate(); - } + public void updateServices(WaarpMOScalar scalar) { + // 3 groups to check + OID oid = scalar.getOid(); + if (oid.startsWith(rootOIDWaarpGlobal)) { + // UpTime + if (oid.equals(rootOIDWaarpGlobalUptime)) { + return; + } + ((WaarpPrivateMonitor) agent.getMonitor()).generalValuesUpdate(); + } else if (oid.startsWith(rootOIDWaarpDetailed)) { + ((WaarpPrivateMonitor) agent.getMonitor()).detailedValuesUpdate(); + } else if (oid.startsWith(rootOIDWaarpError)) { + ((WaarpPrivateMonitor) agent.getMonitor()).errorValuesUpdate(); } + } - public void updateServices(MOScope range) { - // UpTime first - OID low = range.getLowerBound(); + public void updateServices(MOScope range) { + // UpTime first + OID low = range.getLowerBound(); - boolean okGeneral = true; - boolean okDetailed = true; - boolean okError = true; - if (low != null) { - logger.debug("low: {}:{} " + rootOIDWaarpGlobal + ":" + - rootOIDWaarpDetailed + ":" + rootOIDWaarpError, - low, range.isLowerIncluded()); - if (low.size() <= rootOIDWaarp.size() && - low.startsWith(rootOIDWaarp)) { - // test for global requests - okGeneral = okDetailed = okError = true; - } else { - // Test for sub requests - okGeneral &= low.startsWith(rootOIDWaarpGlobal); - okDetailed &= low.startsWith(rootOIDWaarpDetailed); - okError &= low.startsWith(rootOIDWaarpError); - } - } - logger.debug("General:" + okGeneral + " Detailed:" + okDetailed + - " Error:" + okError); - if (okGeneral) { - ((WaarpPrivateMonitor) agent.getMonitor()).generalValuesUpdate(); - } - if (okDetailed) { - ((WaarpPrivateMonitor) agent.getMonitor()).detailedValuesUpdate(); - } - if (okError) { - ((WaarpPrivateMonitor) agent.getMonitor()).errorValuesUpdate(); - } + boolean okGeneral = true; + boolean okDetailed = true; + boolean okError = true; + if (low != null) { + logger.debug("low: {}:{} " + rootOIDWaarpGlobal + ":" + + rootOIDWaarpDetailed + ":" + rootOIDWaarpError, + low, range.isLowerIncluded()); + if (low.size() <= rootOIDWaarp.size() && + low.startsWith(rootOIDWaarp)) { + // test for global requests + okGeneral = okDetailed = okError = true; + } else { + // Test for sub requests + okGeneral &= low.startsWith(rootOIDWaarpGlobal); + okDetailed &= low.startsWith(rootOIDWaarpDetailed); + okError &= low.startsWith(rootOIDWaarpError); + } } - - @Override - protected void agentRegisterWaarpMib() - throws DuplicateRegistrationException { - defaultAgentRegisterWaarpMib(); + logger.debug("General:" + okGeneral + " Detailed:" + okDetailed + + " Error:" + okError); + if (okGeneral) { + ((WaarpPrivateMonitor) agent.getMonitor()).generalValuesUpdate(); + } + if (okDetailed) { + ((WaarpPrivateMonitor) agent.getMonitor()).detailedValuesUpdate(); + } + if (okError) { + ((WaarpPrivateMonitor) agent.getMonitor()).errorValuesUpdate(); } + } - /** - * Example of trap for All - * - * @param message - * @param message2 - * @param number - */ - public void notifyInfo(String message, String message2, int number) { - if (!TrapLevel.All.isLevelValid(agent.getTrapLevel())) - return; - logger.warn("Notify: " + NotificationElements.InfoTask + ":" + message + + @Override + protected void agentRegisterWaarpMib() + throws DuplicateRegistrationException { + defaultAgentRegisterWaarpMib(); + } + + /** + * Example of trap for All + * + * @param message + * @param message2 + * @param number + */ + public void notifyInfo(String message, String message2, int number) { + if (!TrapLevel.All.isLevelValid(agent.getTrapLevel())) { + return; + } + logger.warn("Notify: " + NotificationElements.InfoTask + ":" + message + ":" + number); - agent.getNotificationOriginator().notify( - new OctetString("public"), - NotificationElements.InfoTask.getOID(rootOIDWaarpNotif), - new VariableBinding[] { - new VariableBinding(NotificationElements.InfoTask - .getOID(rootOIDWaarpNotif, - NotificationTasks.stepStatusInfo + agent.getNotificationOriginator().notify( + new OctetString("public"), + NotificationElements.InfoTask.getOID(rootOIDWaarpNotif), + new VariableBinding[] { + new VariableBinding(NotificationElements.InfoTask + .getOID(rootOIDWaarpNotif, + NotificationTasks.stepStatusInfo .getOID()), new OctetString( - message)), - new VariableBinding( - NotificationElements.InfoTask - .getOID(rootOIDWaarpNotif, - NotificationTasks.filenameInfo - .getOID()), - new OctetString(message2)), - new VariableBinding(NotificationElements.InfoTask - .getOID(rootOIDWaarpNotif, - NotificationTasks.specialIdInfo + message)), + new VariableBinding( + NotificationElements.InfoTask + .getOID(rootOIDWaarpNotif, + NotificationTasks.filenameInfo + .getOID()), + new OctetString(message2)), + new VariableBinding(NotificationElements.InfoTask + .getOID(rootOIDWaarpNotif, + NotificationTasks.specialIdInfo .getOID()), new Counter64( - number)), - new VariableBinding(NotificationElements.InfoTask - .getOID(rootOIDWaarpNotif, - NotificationTasks.idRuleInfo.getOID()), + number)), + new VariableBinding(NotificationElements.InfoTask + .getOID(rootOIDWaarpNotif, + NotificationTasks.idRuleInfo + .getOID()), new OctetString(NotificationElements.InfoTask - .name())) }); - } + .name())) + }); + } - /** - * Example of trap for Error - * - * @param message - * @param message2 - * @param number - */ - public void notifyError(String message, String message2, int number) { - if (!TrapLevel.Alert.isLevelValid(agent.getTrapLevel())) - return; - logger.warn("Notify: " + NotificationElements.TrapError + ":" + + /** + * Example of trap for Error + * + * @param message + * @param message2 + * @param number + */ + public void notifyError(String message, String message2, int number) { + if (!TrapLevel.Alert.isLevelValid(agent.getTrapLevel())) { + return; + } + logger.warn("Notify: " + NotificationElements.TrapError + ":" + message + ":" + number); - agent.getNotificationOriginator().notify( - new OctetString("public"), - NotificationElements.TrapError.getOID(rootOIDWaarpNotif), - new VariableBinding[] { - new VariableBinding(NotificationElements.TrapError - .getOID(rootOIDWaarpNotif, 1), + agent.getNotificationOriginator().notify( + new OctetString("public"), + NotificationElements.TrapError.getOID(rootOIDWaarpNotif), + new VariableBinding[] { + new VariableBinding(NotificationElements.TrapError + .getOID(rootOIDWaarpNotif, 1), new OctetString(message)), - new VariableBinding(NotificationElements.TrapError - .getOID(rootOIDWaarpNotif, 1), + new VariableBinding(NotificationElements.TrapError + .getOID(rootOIDWaarpNotif, 1), new OctetString(message2)), - new VariableBinding(NotificationElements.TrapError - .getOID(rootOIDWaarpNotif, 1), + new VariableBinding(NotificationElements.TrapError + .getOID(rootOIDWaarpNotif, 1), new Counter64(number)), - new VariableBinding(NotificationElements.TrapError - .getOID(rootOIDWaarpNotif, 1), + new VariableBinding(NotificationElements.TrapError + .getOID(rootOIDWaarpNotif, 1), new OctetString(NotificationElements.TrapError - .name())) }); - } + .name())) + }); + } } diff --git a/src/test/java/org/waarp/snmp/test/WaarpPrivateMonitor.java b/src/test/java/org/waarp/snmp/test/WaarpPrivateMonitor.java index 1a08aca..34e13c7 100644 --- a/src/test/java/org/waarp/snmp/test/WaarpPrivateMonitor.java +++ b/src/test/java/org/waarp/snmp/test/WaarpPrivateMonitor.java @@ -1,22 +1,22 @@ -/** - * This file is part of Waarp Project. - * - * Copyright 2009, Frederic Bregier, and individual contributors by the @author - * tags. See the COPYRIGHT.txt in the distribution for a full listing of - * individual contributors. - * - * All Waarp Project is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * Waarp. If not, see . - */ +/******************************************************************************* + * This file is part of Waarp Project (named also Waarp or GG). + * + * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author + * tags. See the COPYRIGHT.txt in the distribution for a full listing of + * individual contributors. + * + * All Waarp Project is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Waarp . If not, see . + ******************************************************************************/ package org.waarp.snmp.test; import org.waarp.common.logging.WaarpLogger; @@ -26,71 +26,69 @@ /** * This implementation show how to support SNMP. - * + * * @author Frederic Bregier - * */ public class WaarpPrivateMonitor implements WaarpInterfaceMonitor { - /** - * Internal Logger - */ - private static WaarpLogger logger = WaarpLoggerFactory - .getLogger(WaarpPrivateMonitor.class); + /** + * Internal Logger + */ + private static WaarpLogger logger = WaarpLoggerFactory + .getLogger(WaarpPrivateMonitor.class); - public WaarpSnmpAgent agent; + public WaarpSnmpAgent agent; - /** - * @return the agent - */ - public WaarpSnmpAgent getAgent() { - return agent; - } + /** + * @return the agent + */ + public WaarpSnmpAgent getAgent() { + return agent; + } - /** - * @param agent - * the agent to set - */ - public void setAgent(WaarpSnmpAgent agent) { - this.agent = agent; - } + /** + * @param agent the agent to set + */ + public void setAgent(WaarpSnmpAgent agent) { + this.agent = agent; + } - public void initialize() { - // TODO Auto-generated method stub - logger.warn("Call"); - } + public void initialize() { + // TODO Auto-generated method stub + logger.warn("Call"); + } - public void releaseResources() { - // TODO Auto-generated method stub - logger.warn("Call"); + public void releaseResources() { + // TODO Auto-generated method stub + logger.warn("Call"); - } + } - /* - * function to test if the computations need to be redone - * - */ - public void generalValuesUpdate() { - synchronized (agent) { - // TODO Auto-generated method stub + /* + * function to test if the computations need to be redone + * + */ + public void generalValuesUpdate() { + synchronized (agent) { + // TODO Auto-generated method stub - logger.warn("Call"); - } + logger.warn("Call"); } + } - public void detailedValuesUpdate() { - synchronized (agent) { - // TODO Auto-generated method stub - logger.warn("Call"); + public void detailedValuesUpdate() { + synchronized (agent) { + // TODO Auto-generated method stub + logger.warn("Call"); - } } + } - public void errorValuesUpdate() { - synchronized (agent) { - // TODO Auto-generated method stub - logger.warn("Call"); + public void errorValuesUpdate() { + synchronized (agent) { + // TODO Auto-generated method stub + logger.warn("Call"); - } } + } } diff --git a/src/test/java/org/waarp/snmp/test/WaarpSimpleSnmpClient.java b/src/test/java/org/waarp/snmp/test/WaarpSimpleSnmpClient.java index 6179270..90db7fd 100644 --- a/src/test/java/org/waarp/snmp/test/WaarpSimpleSnmpClient.java +++ b/src/test/java/org/waarp/snmp/test/WaarpSimpleSnmpClient.java @@ -1,28 +1,24 @@ -/** - * This file is part of Waarp Project. - * - * Copyright 2009, Frederic Bregier, and individual contributors by the @author - * tags. See the COPYRIGHT.txt in the distribution for a full listing of - * individual contributors. - * - * All Waarp Project is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * Waarp. If not, see . - */ +/******************************************************************************* + * This file is part of Waarp Project (named also Waarp or GG). + * + * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author + * tags. See the COPYRIGHT.txt in the distribution for a full listing of + * individual contributors. + * + * All Waarp Project is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Waarp . If not, see . + ******************************************************************************/ package org.waarp.snmp.test; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import org.snmp4j.CommunityTarget; import org.snmp4j.PDU; import org.snmp4j.Snmp; @@ -42,163 +38,173 @@ import org.snmp4j.util.TableEvent; import org.snmp4j.util.TableUtils; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + /** * Simple SNMP Client (for testing purpose) - * + * * @author Frederic Bregier - * */ public class WaarpSimpleSnmpClient { - private String address; - - private int port; - - private Snmp snmp; - - /** - * @param clientAddress - * @param port - */ - public WaarpSimpleSnmpClient(String clientAddress, int port) { - this.address = clientAddress; - this.port = port; - try { - start(); - } catch (IOException e) { - System.err.println(e); - throw new RuntimeException(e); - } - } - - // Since snmp4j relies on asynch req/resp we need a listener - // for responses which should be closed - public void stop() throws IOException { - snmp.close(); - } - - /** - * Start the Snmp session. If you forget the listen() method you will not - * get any answers because the communication is asynchronous and the - * listen() method listens for answers. - * - * @throws IOException - **/ - private void start() throws IOException { - UdpAddress upaddress = new UdpAddress(port); - System.err.println("Listen: " + upaddress); - TransportMapping transport = new DefaultUdpTransportMapping(upaddress); - snmp = new Snmp(transport); - // Do not forget this line! - transport.listen(); - } + private String address; - /** - * Method which takes a single OID and returns the response from the agent - * as a String. - * - * @param oid - * @return String - * @throws IOException - **/ - public String getAsString(OID oid) throws IOException { - ResponseEvent event = get(new OID[] { - oid }); - return event.getResponse().get(0).getVariable().toString(); - } + private int port; - /** - * This method is capable of handling multiple OIDs linked with a listener - * - * @param oids - * @param listener - * - * @throws IOException - **/ - public void getAsString(OID oids, ResponseListener listener) { - try { - snmp.send(getPDU(new OID[] { - oids }), getTarget(), null, listener); - } catch (IOException e) { - throw new RuntimeException(e); - } - } + private Snmp snmp; - /** - * - * @param oids - * @return A PDU from oids - */ - private PDU getPDU(OID oids[]) { - PDU pdu = new PDU(); - for (OID oid : oids) { - pdu.add(new VariableBinding(oid)); - } - - pdu.setType(PDU.GET); - return pdu; + /** + * @param clientAddress + * @param port + */ + public WaarpSimpleSnmpClient(String clientAddress, int port) { + this.address = clientAddress; + this.port = port; + try { + start(); + } catch (IOException e) { + System.err.println(e); + throw new RuntimeException(e); } - - /** - * This method is capable of handling multiple OIDs - * - * @param oids - * @return ResponseEvent - * @throws IOException - **/ - public ResponseEvent get(OID oids[]) throws IOException { - ResponseEvent event = snmp.send(getPDU(oids), getTarget(), null); - if (event != null) { - return event; - } - throw new RuntimeException("GET timed out"); + } + + /** + * Start the Snmp session. If you forget the listen() method you will not get + * any answers because the communication + * is asynchronous and the listen() method listens for answers. + * + * @throws IOException + **/ + private void start() throws IOException { + UdpAddress upaddress = new UdpAddress(port); + System.err.println("Listen: " + upaddress); + TransportMapping transport = + new DefaultUdpTransportMapping(upaddress); + snmp = new Snmp(transport); + // Do not forget this line! + transport.listen(); + } + + public static String extractSingleString(ResponseEvent event) { + return event.getResponse().get(0).getVariable().toString(); + } + + // Since snmp4j relies on asynch req/resp we need a listener + // for responses which should be closed + public void stop() throws IOException { + snmp.close(); + } + + /** + * Method which takes a single OID and returns the response from the agent as + * a String. + * + * @param oid + * + * @return String + * + * @throws IOException + **/ + public String getAsString(OID oid) throws IOException { + ResponseEvent event = get(new OID[] { + oid + }); + return event.getResponse().get(0).getVariable().toString(); + } + + /** + * This method is capable of handling multiple OIDs + * + * @param oids + * + * @return ResponseEvent + * + * @throws IOException + **/ + public ResponseEvent get(OID oids[]) throws IOException { + ResponseEvent event = snmp.send(getPDU(oids), getTarget(), null); + if (event != null) { + return event; } - - /** - * This method returns a Target, which contains information about where the - * data should be fetched and how. - * - * @return - **/ - private Target getTarget() { - Address targetAddress = GenericAddress.parse(address); - CommunityTarget target = new CommunityTarget(); - target.setCommunity(new OctetString("public")); - target.setAddress(targetAddress); - target.setRetries(2); - target.setTimeout(1500); - target.setVersion(SnmpConstants.version2c); - return target; + throw new RuntimeException("GET timed out"); + } + + /** + * @param oids + * + * @return A PDU from oids + */ + private PDU getPDU(OID oids[]) { + PDU pdu = new PDU(); + for (OID oid : oids) { + pdu.add(new VariableBinding(oid)); } - /** - * Normally this would return domain objects or something else than this... - */ - public List> getTableAsStrings(OID[] oids) { - TableUtils tUtils = new TableUtils(snmp, new DefaultPDUFactory()); - - List events = tUtils - .getTable(getTarget(), oids, null, null); - - List> list = new ArrayList>(); - for (TableEvent event : events) { - if (event.isError()) { - System.err.println(event); - continue; - // throw new - // RuntimeException(event.getErrorMessage(),event.getException()); - } - List strList = new ArrayList(); - list.add(strList); - for (VariableBinding vb : event.getColumns()) { - strList.add(vb.getVariable().toString()); - } - } - return list; + pdu.setType(PDU.GET); + return pdu; + } + + /** + * This method returns a Target, which contains information about where the + * data should be fetched and how. + * + * @return + **/ + private Target getTarget() { + Address targetAddress = GenericAddress.parse(address); + CommunityTarget target = new CommunityTarget(); + target.setCommunity(new OctetString("public")); + target.setAddress(targetAddress); + target.setRetries(2); + target.setTimeout(1500); + target.setVersion(SnmpConstants.version2c); + return target; + } + + /** + * This method is capable of handling multiple OIDs linked with a listener + * + * @param oids + * @param listener + * + * @throws IOException + **/ + public void getAsString(OID oids, ResponseListener listener) { + try { + snmp.send(getPDU(new OID[] { + oids + }), getTarget(), null, listener); + } catch (IOException e) { + throw new RuntimeException(e); } - - public static String extractSingleString(ResponseEvent event) { - return event.getResponse().get(0).getVariable().toString(); + } + + /** + * Normally this would return domain objects or something else than this... + */ + public List> getTableAsStrings(OID[] oids) { + TableUtils tUtils = new TableUtils(snmp, new DefaultPDUFactory()); + + List events = tUtils + .getTable(getTarget(), oids, null, null); + + List> list = new ArrayList>(); + for (TableEvent event : events) { + if (event.isError()) { + System.err.println(event); + continue; + // throw new + // RuntimeException(event.getErrorMessage(),event.getException()); + } + List strList = new ArrayList(); + list.add(strList); + for (VariableBinding vb : event.getColumns()) { + strList.add(vb.getVariable().toString()); + } } + return list; + } } diff --git a/src/test/java/org/waarp/snmp/test/WaarpSnmpClientAgentTest.java b/src/test/java/org/waarp/snmp/test/WaarpSnmpClientAgentTest.java new file mode 100644 index 0000000..4768599 --- /dev/null +++ b/src/test/java/org/waarp/snmp/test/WaarpSnmpClientAgentTest.java @@ -0,0 +1,212 @@ +/******************************************************************************* + * This file is part of Waarp Project (named also Waarp or GG). + * + * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author + * tags. See the COPYRIGHT.txt in the distribution for a full listing of + * individual contributors. + * + * All Waarp Project is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Waarp . If not, see . + ******************************************************************************/ +package org.waarp.snmp.test; + +import org.junit.Test; +import org.snmp4j.event.ResponseEvent; +import org.snmp4j.event.ResponseListener; +import org.snmp4j.mp.SnmpConstants; +import org.snmp4j.security.AuthMD5; +import org.snmp4j.security.AuthSHA; +import org.snmp4j.security.PrivAES128; +import org.snmp4j.security.PrivAES192; +import org.snmp4j.security.PrivAES256; +import org.snmp4j.security.PrivDES; +import org.snmp4j.security.USM; +import org.snmp4j.security.UsmUser; +import org.snmp4j.smi.OctetString; +import org.waarp.common.logging.WaarpLogLevel; +import org.waarp.common.logging.WaarpLoggerFactory; +import org.waarp.common.logging.WaarpSlf4JLoggerFactory; +import org.waarp.snmp.WaarpMOFactory; +import org.waarp.snmp.WaarpSnmpAgent; +import org.waarp.snmp.utils.WaarpMOScalar; + +import java.io.File; +import java.io.IOException; + +import static org.junit.Assert.*; + +/** + * Test class for Agent and simple Client + * + * @author Frederic Bregier + */ +public class WaarpSnmpClientAgentTest { + static WaarpSnmpAgent agent; + + static WaarpSimpleSnmpClient client; + + static WaarpImplPrivateMib test; + + @Test + public void allTests() throws Exception { + WaarpLoggerFactory + .setDefaultFactory(new WaarpSlf4JLoggerFactory(WaarpLogLevel.DEBUG)); + ClassLoader classLoader = WaarpSnmpClientAgentTest.class.getClassLoader(); + File file = new File(classLoader.getResource("snmpconfig.xml").getFile()); + if (!file.exists()) { + System.err.println("Need SnmpConfig file"); + return; + } + setUp(file.getAbsolutePath()); + System.out.println("Test SysDescr"); + verifySysDescr(); + System.out.println("Test Table"); + verifyTableContents(); + Thread.sleep(1000); + sendNotification(); + Thread.sleep(3000); + long uptime = agent.getUptime(); + long systemUptime = agent.getUptimeSystemTime(); + assertTrue(uptime < systemUptime); + testAddUser(); + System.out.println("Stopping"); + tearDown(); + } + + public static void setUp(String file) throws Exception { + // Setup the client to use our newly started agent + client = new WaarpSimpleSnmpClient("udp:127.0.0.1/2001", 1162); + // Create a monitor + WaarpPrivateMonitor monitor = new WaarpPrivateMonitor(); + // Create a Mib + test = new WaarpImplPrivateMib("Waarp Test SNMP", 6666, 66666, 66, + "F. Bregier", "Waarp Test SNMP V1.0", + "Paris, France", 72); + // Set the default VariableFactory + WaarpMOFactory.setFactory(new WaarpTestVariableFactory()); + // Create the agent associated with the monitor and Mib + agent = new WaarpSnmpAgent(new File(file), monitor, test); + agent.start(); + } + + /** + * Simply verifies that we get the same sysDescr as we have registered in our + * agent + */ + public static void verifySysDescr() throws IOException { + assertEquals(test.textualSysDecr, + client.getAsString(SnmpConstants.sysDescr)); + } + + /** + * Verify that the table contents is ok. + */ + public static void verifyTableContents() { + for (WaarpMOScalar scalar : test.rowInfo.getRow()) { + try { + System.out.println("Read " + scalar.getID() + ":" + + client.getAsString(scalar.getID())); + } catch (IOException e) { + System.err.println(scalar.getID() + ":" + e.getMessage()); + continue; + } + } + } + + public static void sendNotification() { + test.notifyInfo("Une alerte", "un autre texte d'alerte", 1971); + test.notifyError("Une seconde alerte", "un second texte d'alerte", 20); + } + + public void testAddUser() { + USM usm = new USM(); + UsmUser user = new UsmUser(new OctetString("TEST"), AuthSHA.ID, new + OctetString("maplesyrup"), PrivDES.ID, new + OctetString("maplesyrup")); + usm.addUser(user.getSecurityName(), + usm.getLocalEngineID(), user); + user = new UsmUser(new + OctetString("SHA"), AuthSHA.ID, + new OctetString("SHAAuthPassword"), + null, null); + usm.addUser(user.getSecurityName(), + usm.getLocalEngineID(), user); + user = new UsmUser(new + OctetString("SHADES"), AuthSHA.ID, new + OctetString("SHADESAuthPassword"), PrivDES.ID, new + OctetString("SHADESPrivPassword")); + usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); + user = new UsmUser(new OctetString("MD5DES"), AuthMD5.ID, new + OctetString("MD5DESAuthPassword"), PrivDES.ID, new + OctetString("MD5DESPrivPassword")); + usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); + user = new UsmUser(new OctetString("SHAAES128"), AuthSHA.ID, new + OctetString("SHAAES128AuthPassword"), PrivAES128.ID, new + OctetString("SHAAES128PrivPassword")); + usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); + user = new UsmUser(new OctetString("SHAAES192"), AuthSHA.ID, new + OctetString("SHAAES192AuthPassword"), PrivAES192.ID, new + OctetString("SHAAES192PrivPassword")); + usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); + user = new UsmUser(new OctetString("SHAAES256"), AuthSHA.ID, new + OctetString("SHAAES256AuthPassword"), PrivAES256.ID, new + OctetString("SHAAES256PrivPassword")); + usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); + + user = new UsmUser(new OctetString("MD5AES128"), AuthMD5.ID, new + OctetString("MD5AES128AuthPassword"), PrivAES128.ID, new + OctetString("MD5AES128PrivPassword")); + usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); + user = new UsmUser(new OctetString("MD5AES192"), AuthMD5.ID, new + OctetString("MD5AES192AuthPassword"), PrivAES192.ID, new + OctetString("MD5AES192PrivPassword")); + usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); + user = new UsmUser(new OctetString("MD5AES256"), AuthMD5.ID, new + OctetString("MD5AES256AuthPassword"), PrivAES256.ID, new + OctetString("MD5AES256PrivPassword")); + usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); + + } + + public static void tearDown() throws Exception { + agent.stop(); + client.stop(); + } + + private static boolean assertEquals(String a, String b) { + if (!a.equals(b)) { + System.err.println("Not Equals! " + a + " and " + b); + fail("Should be equals"); + return false; + } + System.out.println("Equal: " + a); + return true; + } + + static class StringResponseListener implements ResponseListener { + + private String value = null; + + public void onResponse(ResponseEvent event) { + System.out.println(event.getResponse()); + if (event.getResponse() != null) { + value = WaarpSimpleSnmpClient.extractSingleString(event); + } + } + + public String getValue() { + System.out.println(value); + return value; + } + + } +} diff --git a/src/test/java/org/waarp/snmp/test/WaarpTestSnmpClientAgent.java b/src/test/java/org/waarp/snmp/test/WaarpTestSnmpClientAgent.java deleted file mode 100644 index 81ca0c2..0000000 --- a/src/test/java/org/waarp/snmp/test/WaarpTestSnmpClientAgent.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This file is part of Waarp Project. - * - * Copyright 2009, Frederic Bregier, and individual contributors by the @author - * tags. See the COPYRIGHT.txt in the distribution for a full listing of - * individual contributors. - * - * All Waarp Project is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * Waarp. If not, see . - */ -package org.waarp.snmp.test; - -import java.io.File; -import java.io.IOException; - -import org.snmp4j.event.ResponseEvent; -import org.snmp4j.event.ResponseListener; -import org.snmp4j.mp.SnmpConstants; -import org.waarp.common.logging.WaarpLogLevel; -import org.waarp.common.logging.WaarpLoggerFactory; -import org.waarp.common.logging.WaarpSlf4JLoggerFactory; -import org.waarp.snmp.WaarpMOFactory; -import org.waarp.snmp.WaarpSnmpAgent; -import org.waarp.snmp.utils.WaarpMOScalar; - -/** - * Test class for Agent and simple Client - * - * @author Frederic Bregier - * - */ -public class WaarpTestSnmpClientAgent { - static WaarpSnmpAgent agent; - - static WaarpSimpleSnmpClient client; - - static WaarpImplPrivateMib test; - - public static void main(String[] args) throws Exception { - WaarpLoggerFactory.setDefaultFactory(new WaarpSlf4JLoggerFactory(WaarpLogLevel.DEBUG)); - if (args.length == 0) { - System.err.println("Need SnmpConfig file"); - System.exit(1); - } - setUp(args[0]); - System.out.println("Test SysDescr"); - verifySysDescr(); - System.out.println("Test Table"); - verifyTableContents(); - Thread.sleep(10000); - sendNotification(); - Thread.sleep(30000); - System.out.println("Stopping"); - tearDown(); - } - - public static void setUp(String file) throws Exception { - // Setup the client to use our newly started agent - client = new WaarpSimpleSnmpClient("udp:127.0.0.1/2001", 1162); - // Create a monitor - WaarpPrivateMonitor monitor = new WaarpPrivateMonitor(); - // Create a Mib - test = new WaarpImplPrivateMib("Waarp Test SNMP", 6666, 66666, 66, - "F. Bregier", "Waarp Test SNMP V1.0", "Paris, France", 72); - // Set the default VariableFactory - WaarpMOFactory.setFactory(new WaarpTestVariableFactory()); - // Create the agent associated with the monitor and Mib - agent = new WaarpSnmpAgent(new File(file), monitor, test); - agent.start(); - } - - public static void tearDown() throws Exception { - agent.stop(); - client.stop(); - } - - private static boolean assertEquals(String a, String b) { - if (!a.equals(b)) { - System.err.println("Not Equals! " + a + " and " + b); - return false; - } - System.out.println("Equal: " + a); - return true; - } - - /** - * Simply verifies that we get the same sysDescr as we have registered in - * our agent - */ - public static void verifySysDescr() throws IOException { - assertEquals(test.textualSysDecr, - client.getAsString(SnmpConstants.sysDescr)); - } - - /** - * Verify that the table contents is ok. - */ - public static void verifyTableContents() { - for (WaarpMOScalar scalar : test.rowInfo.getRow()) { - try { - System.out.println("Read " + scalar.getID() + ":" + - client.getAsString(scalar.getID())); - } catch (IOException e) { - System.err.println(scalar.getID() + ":" + e.getMessage()); - continue; - } - } - } - - public static void sendNotification() { - test.notifyInfo("Une alerte", "un autre texte d'alerte", 1971); - test.notifyError("Une seconde alerte", "un second texte d'alerte", 20); - } - - static class StringResponseListener implements ResponseListener { - - private String value = null; - - public void onResponse(ResponseEvent event) { - System.out.println(event.getResponse()); - if (event.getResponse() != null) { - value = WaarpSimpleSnmpClient.extractSingleString(event); - } - } - - public String getValue() { - System.out.println(value); - return value; - } - - } - -} diff --git a/src/test/java/org/waarp/snmp/test/WaarpTestVariableFactory.java b/src/test/java/org/waarp/snmp/test/WaarpTestVariableFactory.java index c4db1f3..270ed4c 100644 --- a/src/test/java/org/waarp/snmp/test/WaarpTestVariableFactory.java +++ b/src/test/java/org/waarp/snmp/test/WaarpTestVariableFactory.java @@ -1,25 +1,24 @@ -/** - * This file is part of Waarp Project. - * - * Copyright 2009, Frederic Bregier, and individual contributors by the @author - * tags. See the COPYRIGHT.txt in the distribution for a full listing of - * individual contributors. - * - * All Waarp Project is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * Waarp. If not, see . - */ +/******************************************************************************* + * This file is part of Waarp Project (named also Waarp or GG). + * + * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author + * tags. See the COPYRIGHT.txt in the distribution for a full listing of + * individual contributors. + * + * All Waarp Project is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Waarp . If not, see . + ******************************************************************************/ package org.waarp.snmp.test; -import org.snmp4j.smi.Counter32; import org.snmp4j.smi.Counter64; import org.snmp4j.smi.Integer32; import org.snmp4j.smi.IpAddress; @@ -32,52 +31,57 @@ import org.snmp4j.smi.Variable; import org.waarp.snmp.interf.WaarpInterfaceVariableFactory; +import static junit.framework.TestCase.*; + /** * @author Frederic Bregier - * */ public class WaarpTestVariableFactory implements WaarpInterfaceVariableFactory { - public Variable getVariable(OID oid, int type, int mibLevel, int entry) { - Variable var; - switch (type) { - case SMIConstants.SYNTAX_INTEGER: - // case SMIConstants.SYNTAX_INTEGER32: - var = new Integer32(); - break; - case SMIConstants.SYNTAX_OCTET_STRING: - // case SMIConstants.SYNTAX_BITS: - var = new OctetString(); - break; - case SMIConstants.SYNTAX_NULL: - var = new Null(); - break; - case SMIConstants.SYNTAX_OBJECT_IDENTIFIER: - var = new OID(); - break; - case SMIConstants.SYNTAX_IPADDRESS: - var = new IpAddress(); - break; - case SMIConstants.SYNTAX_COUNTER32: - var = new Counter32(); - break; - case SMIConstants.SYNTAX_GAUGE32: - // case SMIConstants.SYNTAX_UNSIGNED_INTEGER32: - var = new ExampleImplGauge32(oid); - break; - case SMIConstants.SYNTAX_TIMETICKS: - var = new TimeTicks(); - break; - case SMIConstants.SYNTAX_OPAQUE: - var = new Opaque(); - break; - case SMIConstants.SYNTAX_COUNTER64: - var = new Counter64(); - break; - default: - throw new IllegalArgumentException("Unmanaged Type: " + type); - } - return var; + public Variable getVariable(OID oid, int type, int mibLevel, int entry) { + Variable var; + switch (type) { + case SMIConstants.SYNTAX_INTEGER: + // case SMIConstants.SYNTAX_INTEGER32: + var = new Integer32(); + break; + case SMIConstants.SYNTAX_OCTET_STRING: + // case SMIConstants.SYNTAX_BITS: + var = new OctetString(); + break; + case SMIConstants.SYNTAX_NULL: + var = new Null(); + break; + case SMIConstants.SYNTAX_OBJECT_IDENTIFIER: + var = new OID(); + break; + case SMIConstants.SYNTAX_IPADDRESS: + var = new IpAddress(); + break; + case SMIConstants.SYNTAX_COUNTER32: + var = new ExampleImplCounter32(oid); + assertTrue(((ExampleImplCounter32) var).getValue() > + ExampleImplCounter32.STARTUP); + break; + case SMIConstants.SYNTAX_GAUGE32: + // case SMIConstants.SYNTAX_UNSIGNED_INTEGER32: + var = new ExampleImplGauge32(oid); + assertTrue( + ((ExampleImplGauge32) var).getValue() > ExampleImplGauge32.STARTUP); + break; + case SMIConstants.SYNTAX_TIMETICKS: + var = new TimeTicks(); + break; + case SMIConstants.SYNTAX_OPAQUE: + var = new Opaque(); + break; + case SMIConstants.SYNTAX_COUNTER64: + var = new Counter64(); + break; + default: + throw new IllegalArgumentException("Unmanaged Type: " + type); } + return var; + } } diff --git a/src/test/java/org/waarp/snmp/test/package-info.java b/src/test/java/org/waarp/snmp/test/package-info.java index ce9690d..f0e7df0 100644 --- a/src/test/java/org/waarp/snmp/test/package-info.java +++ b/src/test/java/org/waarp/snmp/test/package-info.java @@ -1,6 +1,25 @@ +/******************************************************************************* + * This file is part of Waarp Project (named also Waarp or GG). + * + * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author + * tags. See the COPYRIGHT.txt in the distribution for a full listing of + * individual contributors. + * + * All Waarp Project is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Waarp . If not, see . + ******************************************************************************/ + /** * Test Classes to validate SNMP support - * */ package org.waarp.snmp.test; diff --git a/src/test/resources/OPENR66-MIB b/src/test/resources/OPENR66-MIB new file mode 100644 index 0000000..77aac40 --- /dev/null +++ b/src/test/resources/OPENR66-MIB @@ -0,0 +1,867 @@ +OPENR66-MIB DEFINITIONS ::= BEGIN + +IMPORTS + NOTIFICATION-GROUP, NOTIFICATION-TYPE, enterprises, OBJECT-TYPE, Counter32, Gauge32, Counter64, MODULE-IDENTITY, mib-2 + FROM SNMPv2-SMI + TimeStamp, TEXTUAL-CONVENTION + FROM SNMPv2-TC + SnmpAdminString + FROM SNMP-FRAMEWORK-MIB + system + FROM SNMPv2-MIB; + +openr66 MODULE-IDENTITY + LAST-UPDATED "201103050000Z" + ORGANIZATION "Waarp OpenR66" + CONTACT-INFO + " Frederic Bregier + + E-Mail: openr66@free.fr" + DESCRIPTION + "The MIB module describing OpenR66 Mib" + REVISION "201103050000Z" + DESCRIPTION + "This revision is the first setup of the OpenR66 MIB." +-- 1.3.6.1.4.1.66666.66.1.1 -- +::= { enterprises 66666 66 1 1 } + +-- root +waarp OBJECT IDENTIFIER ::= { enterprises 66666 } +r66 OBJECT IDENTIFIER ::= { waarp 66 } + +-- Textual conventions + +-- DistinguishedName is used to refer to objects in the +-- directory. + +DistinguishedName ::= TEXTUAL-CONVENTION + DISPLAY-HINT "255a" + STATUS current + DESCRIPTION + "A Distinguished Name represented in accordance with + RFC 2253, presented in the UTF-8 charset defined in + RFC 2279." + SYNTAX OCTET STRING (SIZE (0..255)) + +-- Uniform Resource Locators are stored in URLStrings. + +URLString ::= TEXTUAL-CONVENTION + DISPLAY-HINT "255a" + STATUS current + DESCRIPTION + "A Uniform Resource Locator represented in accordance + with RFCs 1738 and 2368, presented in the NVT ASCII + charset defined in RFC 854." + SYNTAX OCTET STRING (SIZE (0..255)) + + +-- The basic applEntry contains the different elements. + +applDefinitions OBJECT IDENTIFIER ::= { r66 1 } +applGlobalValues OBJECT IDENTIFIER ::= { r66 2 } +applDetailedValues OBJECT IDENTIFIER ::= { r66 3 } +applErrorValues OBJECT IDENTIFIER ::= { r66 4 } +waarptraps OBJECT IDENTIFIER ::= { r66 5 } + + +applName OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The name the network service application chooses to be + known by." + ::= {applDefinitions 1} + +applServerName OBJECT-TYPE + SYNTAX DistinguishedName + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The Server Name of this particular instance." + ::= {applDefinitions 2} + +applVersion OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The version of network service application software. + This field is usually defined by the vendor of the + network service application software." + ::= {applDefinitions 3} + +applDescription OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "A text description of the application. This information + is intended to identify and briefly describe the + application in a status display." + ::= {applDefinitions 4} + +applURL OBJECT-TYPE + SYNTAX URLString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "A URL pointing to a description of the application. + This information is intended to identify and describe + the application in a status display." + ::= {applDefinitions 5} + +assocApplicationProtocol OBJECT-TYPE + SYNTAX OBJECT IDENTIFIER + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "An identification of the protocol being used for the + application. For an OSI Application, this will be the + Application Context. For Internet applications, OID + values of the form {applTCPProtoID port} or {applUDPProtoID + port} are used for TCP-based and UDP-based protocols, + respectively. In either case 'port' corresponds to the + primary port number being used by the protocol. The + usual IANA procedures may be used to register ports for + new protocols." + ::= {applDefinitions 6} + + +applUptime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time the network service + application was last initialized. If the application was + last initialized prior to the last initialization of the + network management subsystem, then this object contains + a zero value." + ::= {applGlobalValues 1} + +applOperStatus OBJECT-TYPE + SYNTAX INTEGER { + up(1), + down(2), + halted(3), + congested(4), + restarting(5), + quiescing(6) + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Indicates the operational status of the network service + application. 'down' indicates that the network service is + not available. 'up' indicates that the network service + is operational and available. 'halted' indicates that the + service is operational but not available. 'congested' + indicates that the service is operational but no additional + inbound associations can be accommodated. 'restarting' + indicates that the service is currently unavailable but is + in the process of restarting and will be available soon. + 'quiescing' indicates that service is currently operational + but is in the process of shutting down. Additional inbound + associations may be rejected by applications in the + 'quiescing' state." + ::= {applGlobalValues 2} + +applLastChange OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time the network service + application entered its current operational state. If + the current state was entered prior to the last + initialization of the local network management subsystem, + then this object contains a zero value." + ::= {applGlobalValues 3} + +applInboundAssociations OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of current associations to the network service + application, where it is the responder. An inbound + association occurs when another application successfully + connects to this one." + ::= {applGlobalValues 4} + +applOutboundAssociations OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of current associations to the network service + application, where it is the initiator. An outbound + association occurs when this application successfully + connects to another one." + ::= {applGlobalValues 5} + +applAccumInboundAssociations OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of associations to the application entity + since application initialization, where it was the responder." + ::= {applGlobalValues 6} + +applAccumOutboundAssociations OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of associations to the application entity + since application initialization, where it was the initiator." + ::= {applGlobalValues 7} + +applLastInboundActivity OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time this application last + had an inbound association. If the last association + occurred prior to the last initialization of the network + subsystem, then this object contains a zero value." + ::= {applGlobalValues 8} + +applLastOutboundActivity OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time this application last + had an outbound association. If the last association + occurred prior to the last initialization of the network + subsystem, then this object contains a zero value." + ::= {applGlobalValues 9} + +applRejectedInboundAssociations OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of inbound associations the application + entity has rejected, since application initialization. + Rejected associations are not counted in the accumulated + association totals. Note that this only counts + associations the application entity has rejected itself; + it does not count rejections that occur at lower layers + of the network. Thus, this counter may not reflect the + true number of failed inbound associations." + ::= {applGlobalValues 10} + +applFailedOutboundAssociations OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number associations where the application entity + is initiator and association establishment has failed, + since application initialization. Failed associations are + not counted in the accumulated association totals." + ::= {applGlobalValues 11} + + -- Bandwidth +applInboundBandwidthKBS OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The Inbound bandwidth usage in KB/s." + ::= {applGlobalValues 12} + +applOutboundBandwidthKBS OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The Outbound bandwidth usage in KB/s." + ::= {applGlobalValues 13} + + -- Overall status including past, future and current transfers +nbInfoUnknown OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count with Info as Unknown." + ::= {applGlobalValues 14} + +nbInfoNotUpdated OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count with Info as NotUpdated." + ::= {applGlobalValues 15} + +nbInfoInterrupted OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count with Info as Interrupted." + ::= {applGlobalValues 16} + +nbInfoToSubmit OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count with Info as ToSubmit." + ::= {applGlobalValues 17} + +nbInfoError OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count with Info as Error." + ::= {applGlobalValues 18} + +nbInfoRunning OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count with Info as Running." + ::= {applGlobalValues 19} + +nbInfoDone OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count with Info as Done." + ::= {applGlobalValues 20} + + + -- Current situation of all transfers, running or not +nbStepAllTransfer OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count in total, running or not." + ::= {applGlobalValues 21} + +memoryTotal OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total Allocated Memory in KiloBytes." + ::= {applGlobalValues 22} + +memoryFree OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total Free Memory in KiloBytes." + ::= {applGlobalValues 23} + +memoryUsed OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total Used Memory in KiloBytes." + ::= {applGlobalValues 24} + +nbThreads OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total number of active threads." + ::= {applGlobalValues 25} + +nbNetworkConnection OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total number of active network connections." + ::= {applGlobalValues 26} + +-- detailed part + +nbStepNotask OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Step is as NoTask." + ::= {applDetailedValues 1} + +nbStepPretask OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Step is as PreTask." + ::= {applDetailedValues 2} + +nbStepTransfer OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Step is as Transfer." + ::= {applDetailedValues 3} + +nbStepPosttask OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Step is as PostTask." + ::= {applDetailedValues 4} + +nbStepAllDone OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Step is as AllDone." + ::= {applDetailedValues 5} + +nbStepError OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Step is as Error." + ::= {applDetailedValues 6} + + + -- First on Running Transfers only +nbAllRunningStep OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count of all transfers currently in running." + ::= {applDetailedValues 7} + +nbRunningStep OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count in Step Running." + ::= {applDetailedValues 8} + +nbInitOkStep OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count in Step InitOk." + ::= {applDetailedValues 9} + +nbPreProcessingOkStep OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count in Step PreProcessingOk." + ::= {applDetailedValues 10} + +nbTransferOkStep OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count in Step TransferOk." + ::= {applDetailedValues 11} + +nbPostProcessingOkStep OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count in Step PostProcessingOk." + ::= {applDetailedValues 12} + +nbCompleteOkStep OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count in Step CompleteOk." + ::= {applDetailedValues 13} + + + -- Error Status on all transfers +nbStatusConnectionImpossible OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is ConnectionImpossible." + ::= {applErrorValues 1} + +nbStatusServerOverloaded OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is ServerOverloaded." + ::= {applErrorValues 2} + +nbStatusBadAuthent OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is BadAuthent." + ::= {applErrorValues 3} + +nbStatusExternalOp OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is ExternalOp." + ::= {applErrorValues 4} + +nbStatusTransferError OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is TransferError." + ::= {applErrorValues 5} + +nbStatusMD5Error OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is MD5Error." + ::= {applErrorValues 6} + +nbStatusDisconnection OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is Disconnection." + ::= {applErrorValues 7} + +nbStatusFinalOp OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is FinalOp." + ::= {applErrorValues 8} + +nbStatusUnimplemented OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is Unimplemented." + ::= {applErrorValues 9} + +nbStatusInternal OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is Internal." + ::= {applErrorValues 10} + +nbStatusWarning OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is Warning." + ::= {applErrorValues 11} + +nbStatusQueryAlreadyFinished OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is QueryAlreadyFinished." + ::= {applErrorValues 12} + +nbStatusQueryStillRunning OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is QueryStillRunning." + ::= {applErrorValues 13} + +nbStatusNotKnownHost OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is NotKnownHost." + ::= {applErrorValues 14} + +nbStatusQueryRemotelyUnknown OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is QueryRemotelyUnknown." + ::= {applErrorValues 15} + +nbStatusCommandNotFound OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is CommandNotFound." + ::= {applErrorValues 16} + +nbStatusPassThroughMode OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is PassThroughMode." + ::= {applErrorValues 17} + +nbStatusRemoteShutdown OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is RemoteShutdown." + ::= {applErrorValues 18} + +nbStatusShutdown OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is Shutdown." + ::= {applErrorValues 19} + +nbStatusRemoteError OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is RemoteError." + ::= {applErrorValues 20} + +nbStatusStopped OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is Stopped." + ::= {applErrorValues 21} + +nbStatusCanceled OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is Canceled." + ::= {applErrorValues 22} + +nbStatusFileNotFound OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is FileNotFound." + ::= {applErrorValues 23} + +nbStatusUnknown OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Transfers count where Status is Unknown." + ::= {applErrorValues 24} + +-- test notification + +startOrShutdownObject OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Start Or Shutdown Extra Information." +::= { startOrShutdownWaarp 1 } + +startOrShutdownWaarp NOTIFICATION-TYPE + OBJECTS { startOrShutdownObject } + STATUS current + DESCRIPTION "Start or Shutdown SMIv2 notification" + ::= { waarpgroup 1 } + +errorObject OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Nature of Error." +::= { errorWaarp 1 } + +errorWaarp NOTIFICATION-TYPE + OBJECTS { errorObject } + STATUS current + DESCRIPTION "Error SMIv2 notification" + ::= { waarpgroup 2 } + +warningObject OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Nature of Warning." +::= { warningWaarp 1 } + +warningWaarp NOTIFICATION-TYPE + OBJECTS { warningObject } + STATUS current + DESCRIPTION "Warning SMIv2 notification" + ::= { waarpgroup 3 } + +overloadedObject OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Overloaded Server extra information." +::= { overloadedWaarp 1 } + +overloadedWaarp NOTIFICATION-TYPE + OBJECTS { overloadedObject } + STATUS current + DESCRIPTION "Overloaded SMIv2 notification" + ::= { waarpgroup 4 } + +globalStepInfo OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "GlobalStep rank." +::= { infoWaarp 1 } +stepInfo OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Step in GlobalStep." +::= { infoWaarp 2 } +rankFileInfo OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "File Rank." +::= { infoWaarp 3 } +stepStatusInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Status of Step." +::= { infoWaarp 4 } +filenameInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Current Filename." +::= { infoWaarp 5 } +originalNameInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Original Filename." +::= { infoWaarp 6 } +idRuleInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "ID of Rule." +::= { infoWaarp 7 } +modeTransInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Mode of Transfer." +::= { infoWaarp 8 } +retrieveModeInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Retrieve Mode." +::= { infoWaarp 9 } +startTransInfo OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Start Time of this transfer." +::= { infoWaarp 10 } +infoStatusInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Current Status." +::= { infoWaarp 11 } +requesterInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Requester Id for this transfer." +::= { infoWaarp 12 } +requestedInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Requested Id for this transfer." +::= { infoWaarp 13 } +specialIdInfo OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Unique Id for this Transfer." +::= { infoWaarp 14 } + +infoWaarp NOTIFICATION-TYPE + OBJECTS { globalStepInfo, stepInfo, rankFileInfo, stepStatusInfo, filenameInfo, + originalNameInfo, idRuleInfo, modeTransInfo, retrieveModeInfo, startTransInfo, + infoStatusInfo, requesterInfo, requestedInfo, specialIdInfo } + STATUS current + DESCRIPTION "Info SMIv2 notification" + ::= { waarpgroup 5 } + +waarpgroup NOTIFICATION-GROUP + NOTIFICATIONS { startOrShutdownWaarp,errorWaarp,warningWaarp,overloadedWaarp,infoWaarp } + STATUS current + DESCRIPTION "Group of Notification in Waarp" + ::= { waarptraps 1 } + +END diff --git a/src/test/resources/SnmpConfiguration.xsd b/src/test/resources/SnmpConfiguration.xsd new file mode 100644 index 0000000..abd7b14 --- /dev/null +++ b/src/test/resources/SnmpConfiguration.xsd @@ -0,0 +1,195 @@ + + + + + + + + True + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/snmpconfig.xml b/src/test/resources/snmpconfig.xml new file mode 100644 index 0000000..d08c1fc --- /dev/null +++ b/src/test/resources/snmpconfig.xml @@ -0,0 +1,98 @@ + + + udp:0.0.0.0/2001 + tcp:0.0.0.0/2002 + 4 + False + True + 4 + + + + notificationV2c + UdpIpv4 +
127.0.0.1/162
+ 200 + 1 + True +
+ + notificationV3 + UdpIpv4 +
127.0.0.1/162
+ 200 + 1 + False +
+
+ + + SHADES + SHA + SHADESAuthPassword + PDES + SHADESPrivPassword + + + TEST + SHA + maplesyrup + PDES + maplesyrup + + + SHA + SHA + SHAAuthPassword + + + MD5DES + MD5 + MD5DESAuthPassword + PDES + MD5DESPrivPassword + + + SHAAES128 + SHA + SHAAES128AuthPassword + PAES128 + SHAAES128PrivPassword + + + SHAAES192 + SHA + SHAAES192AuthPassword + PAES192 + SHAAES192PrivPassword + + + SHAAES256 + SHA + SHAAES256AuthPassword + PAES256 + SHAAES256PrivPassword + + + MD5AES128 + MD5 + MD5AES128AuthPassword + PAES128 + MD5AES128PrivPassword + + + MD5AES192 + MD5 + MD5AES192AuthPassword + PAES192 + MD5AES192PrivPassword + + + MD5AES256 + MD5 + MD5AES256AuthPassword + PAES256 + MD5AES256PrivPassword + + +
\ No newline at end of file