From 2e2410712c7a0cbc20122f05c728e4f07dd1fdda Mon Sep 17 00:00:00 2001
From: fguigues <fguigues@localhost>
Date: Thu, 20 Mar 2008 17:34:28 +0000
Subject: [PATCH] Update the SNMP Unit tests. Delete the nbproject (will be available as a zip on https://www.opends.org/wiki/page/BuildingAndRunningOpenDSWithinNetbeans)
---
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java | 37 +++++++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index 822809f..10ad394 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -135,7 +135,13 @@
* cases that depend on this specific value of "o=test".
*/
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
@@ -254,13 +260,20 @@
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");
-
+
if (Boolean.getBoolean(PROPERTY_COPY_CLASSES_TO_TEST_PKG)) {
copyDirectory(serverClassesDir, testClassesDir);
copyDirectory(unitClassesDir, testClassesDir);
@@ -287,6 +300,11 @@
new File(testConfigDir, "server-cert.p12"));
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())
{
@@ -814,6 +832,21 @@
in.close();
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
--
Gitblit v1.10.0