Update the SNMP Unit tests.
Delete the nbproject (will be available as a zip on https://www.opends.org/wiki/page/BuildingAndRunningOpenDSWithinNetbeans)
4 files deleted
6 files modified
| | |
| | | <jvmarg value="-Demma.coverage.out.merge=false" /> |
| | | <jvmarg value="-Dorg.opends.server.BuildRoot=${basedir}" /> |
| | | <jvmarg value="-Dorg.opends.server.RunningUnitTests=true" /> |
| | | <jvmarg value="-Dorg.opends.server.snmp.opendmk=${opendmk.lib.dir}"/> |
| | | <jvmarg value="-Dorg.opends.test.suppressOutput=${org.opends.test.suppressOutput}" /> |
| | | <jvmarg value="-Dorg.opends.test.pauseOnFailure=${org.opends.test.pauseOnFailure}" /> |
| | | <jvmarg value="-Dorg.opends.test.debug.target=${org.opends.test.debug.target}" /> |
| | |
| | | */ |
| | | public static final String TEST_ROOT_DN_STRING = "o=test"; |
| | | |
| | | /** |
| | | * The string representation of the OpenDMK jar file location |
| | | * that will be used as base to determine if snmp is included or not |
| | | */ |
| | | public static final String PROPERTY_OPENDMK_LOCATION = |
| | | "org.opends.server.snmp.opendmk"; |
| | | |
| | | /** |
| | | * The test text writer for the Debug Logger |
| | |
| | | File testBinDir = new File(testRoot, "bin"); |
| | | |
| | | // Snmp resource |
| | | String opendmkJarFileLocation = |
| | | System.getProperty(PROPERTY_OPENDMK_LOCATION); |
| | | |
| | | File opendmkJar = new File(opendmkJarFileLocation, "jdmkrt.jar"); |
| | | |
| | | File snmpResourceDir = new File(buildRoot + File.separator + "src" + |
| | | File.separator + "snmp" + File.separator + |
| | | "resource"); |
| | | |
| | | File snmpConfigDir = new File(snmpResourceDir, "config"); |
| | | |
| | | File testSnmpResourceDir = new File (testConfigDir + File.separator + |
| | | "snmp"); |
| | | |
| | |
| | | copyFile(new File(testResourceDir, "client-cert.p12"), |
| | | new File(testConfigDir, "client-cert.p12")); |
| | | |
| | | if (opendmkJar.exists()) { |
| | | appendFile(new File(snmpConfigDir, "config.snmp.ldif"), |
| | | new File(testConfigDir,"config.ldif")); |
| | | } |
| | | |
| | | for (File f : testBinDir.listFiles()) |
| | | { |
| | | try |
| | |
| | | out.close(); |
| | | } |
| | | |
| | | public static void appendFile(File src, File dst) throws IOException { |
| | | InputStream in = new FileInputStream(src); |
| | | OutputStream out = new FileOutputStream(dst, true); |
| | | |
| | | // Transfer bytes from in to out |
| | | byte[] buf = new byte[8192]; |
| | | int len; |
| | | while ((len = in.read(buf)) > 0) { |
| | | out.write(buf, 0, len); |
| | | } |
| | | in.close(); |
| | | out.close(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Get the LDAP port the test environment Directory Server instance is |
| | | * running on. |
| | |
| | | import com.sun.management.snmp.manager.SnmpPeer; |
| | | import com.sun.management.snmp.manager.SnmpSession; |
| | | import com.sun.management.snmp.manager.usm.SnmpUsmPeer; |
| | | import java.io.File; |
| | | import java.net.InetAddress; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | /** |
| | | * An abstract class that all SNMP unit test should extend. |
| | | */ |
| | | @Test(enabled=false, groups = {"precommit", "snmp"}, sequential = true) |
| | | @Test(enabled=true, groups = {"precommit", "snmp"}, sequential = true) |
| | | public abstract class SNMPConnectionManager extends DirectoryServerTestCase { |
| | | |
| | | /** |
| | |
| | | * @return an SNMP Connection handler |
| | | * @throws an Exception is something went wrong. |
| | | */ |
| | | public SNMPConnectionHandler getSNMPConnectionHandler() throws Exception { |
| | | protected SNMPConnectionHandler getSNMPConnectionHandler() throws Exception { |
| | | List<ConnectionHandler> handlers = |
| | | DirectoryServer.getConnectionHandlers(); |
| | | assertNotNull(handlers); |
| | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | new org.opends.server.types.Attribute( |
| | | "ds-cfg-enabled", "true"))); |
| | | |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | new org.opends.server.types.Attribute( |
| | |
| | | new org.opends.server.types.Attribute( |
| | | "ds-cfg-traps-destination", hosts))); |
| | | |
| | | String jarFileLocation = |
| | | System.getProperty("org.opends.server.snmp.opendmk"); |
| | | |
| | | mods.add(new Modification(ModificationType.ADD, |
| | | new org.opends.server.types.Attribute( |
| | | "ds-cfg-opendmk-jarfile", jarFileLocation + File.separator + |
| | | "jdmkrt.jar"))); |
| | | |
| | | ModifyOperationBasis op = new ModifyOperationBasis( |
| | | conn, |
| | | conn.nextOperationID(), |
| | |
| | | DN.decode("cn=SNMP Connection Handler,cn=Connection Handlers,cn=config"), |
| | | mods); |
| | | op.run(); |
| | | |
| | | mods.clear(); |
| | | |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | new org.opends.server.types.Attribute( |
| | | "ds-cfg-enabled", "true"))); |
| | | |
| | | op = new ModifyOperationBasis( |
| | | conn, |
| | | conn.nextOperationID(), |
| | | conn.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.decode("cn=SNMP Connection Handler,cn=Connection Handlers,cn=config"), |
| | | mods); |
| | | |
| | | op.run(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * A simple test for : - JMX connection establishment withou using SSL - |
| | | * JMX get and set - configuration change |
| | | */ |
| | | @Test(enabled=false, groups = {"precommit", "snmp"}, sequential = true) |
| | | @Test(enabled=true, groups = {"precommit", "snmp"}, sequential = true) |
| | | public class SNMPSyncManagerV2AccessTest extends SNMPConnectionManager { |
| | | |
| | | @BeforeClass |
| | |
| | | {"dsSlaveHits"}}; |
| | | } |
| | | |
| | | @Test(enabled=false,dataProvider = "listAttributes") |
| | | @Test(enabled=true,dataProvider = "listAttributes") |
| | | public void checkAttribute(String attributeName) { |
| | | |
| | | // get the SNMP peer agent |
| | |
| | | {"", false}}; |
| | | } |
| | | |
| | | @Test(enabled = false,dataProvider = "listCommunities") |
| | | @Test(enabled = true,dataProvider = "listCommunities") |
| | | public void checkCommunity(String community, boolean expectedResult) { |
| | | |
| | | try { |
| | |
| | | * <p>As a reminder, if you wish to query the SNMP agent example provided |
| | | * as part of Java DMK, use port 8085. |
| | | */ |
| | | @Test(enabled=false, groups = {"precommit", "snmp"}, sequential = true) |
| | | @Test(enabled=true, groups = {"precommit", "snmp"}, sequential = true) |
| | | public class SNMPTrapManagerTest extends SNMPConnectionManager { |
| | | |
| | | @BeforeClass |
| | |
| | | super.setUp(); |
| | | } |
| | | |
| | | @Test(enabled = false) |
| | | @Test(enabled = true) |
| | | public void checkTraps() { |
| | | try { |
| | | |