perfsonar-dev - r2142 - in trunk/functional-testing: common/echo sqlma sqlma/common
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: r2142 - in trunk/functional-testing: common/echo sqlma sqlma/common
- Date: Mon, 26 Feb 2007 06:02:59 -0500
Author: michalis
Date: 2007-02-26 06:02:58 -0500 (Mon, 26 Feb 2007)
New Revision: 2142
Modified:
trunk/functional-testing/common/echo/EchoRequests.java
trunk/functional-testing/sqlma/Test_Values.sql
trunk/functional-testing/sqlma/common/SQLClient.java
trunk/functional-testing/sqlma/common/test.java
trunk/functional-testing/sqlma/common/xmlDBClient.java
Log:
New functionalities added to the xml and db client.
Modified: trunk/functional-testing/common/echo/EchoRequests.java
===================================================================
--- trunk/functional-testing/common/echo/EchoRequests.java 2007-02-26
10:42:56 UTC (rev 2141)
+++ trunk/functional-testing/common/echo/EchoRequests.java 2007-02-26
11:02:58 UTC (rev 2142)
@@ -74,6 +74,33 @@
}
/**
+ * @return
+ */
+ private Element createParameters(){
+
+ return new Element("parameters",nmwg);
+ }
+
+ /**
+ * @param name
+ * @param nameValue
+ * @param value
+ * @param valueValue
+ * @return
+ */
+ private Element createParameter(String name, String nameValue, String
value, String valueValue){
+
+ Element parameter = new Element("parameter",nmwg);
+ if(name!=null){
+ parameter.setAttribute(name, nameValue);
+ }
+ if(value!=null){
+ parameter.setAttribute(value, valueValue);
+ }
+ return parameter;
+ }
+
+ /**
* Method that creates the metadata element
*
* @param id
Modified: trunk/functional-testing/sqlma/Test_Values.sql
===================================================================
--- trunk/functional-testing/sqlma/Test_Values.sql 2007-02-26 10:42:56
UTC (rev 2141)
+++ trunk/functional-testing/sqlma/Test_Values.sql 2007-02-26 11:02:58
UTC (rev 2142)
@@ -4,9 +4,7 @@
#Author Michalis Michael, Cynet
# insert statements for testing domain_link table
-1970-01-14 07:51:58
-1970-01-14 08:52:40
INSERT
INTO domain_link (id, status_oper, time)
Modified: trunk/functional-testing/sqlma/common/SQLClient.java
===================================================================
--- trunk/functional-testing/sqlma/common/SQLClient.java 2007-02-26
10:42:56 UTC (rev 2141)
+++ trunk/functional-testing/sqlma/common/SQLClient.java 2007-02-26
11:02:58 UTC (rev 2142)
@@ -27,6 +27,19 @@
*/
private Connection con;
+ private final static String[] deleteTableValues = {
+ "delete from domain_link", "delete from
interdomain_link" };
+
+ private final static String[] inserts = {
+ "INSERT INTO domain_link (id, status_oper, time)
VALUES ('DFN-link-1234', 'up', '1970-01-14 07:55:00')",
+ "INSERT INTO domain_link (id, status_oper, time)
VALUES ('DFN-link-1234', 'up', '2007-01-25 12:00:00')",
+ "INSERT INTO domain_link (id, status_oper, time)
VALUES ('DFN-Surfnet-Link-5678', 'down', '1970-01-14 08:30:00')",
+ "INSERT INTO domain_link (id, status_oper, time)
VALUES ('DFN-Surfnet-Link-5678', 'down', '2007-01-25 13:00:00')",
+ "INSERT INTO domain_link (id, status_oper, time)
VALUES ('PSNC-DFN-MUE-Link-1001', 'up', '1970-01-14 08:00:00')",
+ "INSERT INTO domain_link (id, status_oper, time)
VALUES ('PSNC-DFN-MUE-Link-1001', 'up', '2007-01-25 11:00:00')",
+ "INSERT INTO interdomain_link (id, status_oper, time)
VALUES ('PSNC-2-DFN-MUE-Link-1002', 'down', '1970-01-14 08:15:00')",
+ "INSERT INTO interdomain_link (id, status_oper, time)
VALUES ('PSNC-2-DFN-MUE-Link-1002', 'down', '2007-01-25 10:00:00')" };
+
//
-----------------------------------------------------------------------
// constructors
@@ -273,6 +286,43 @@
}
/**
+ * Method used for deleting all values from domain and interdomain
link
+ * tables
+ *
+ * @throws SQLException
+ */
+ public void deleteTableValues() throws SQLException {
+ if (!con.isClosed()) {
+ Statement stm = con.createStatement();
+
+ for (int i = 0; i < deleteTableValues.length; i++) {
+ stm.execute(deleteTableValues[i]);
+ }
+ } else {
+ System.out.println("Connection Failed");
+ }
+
+ }
+
+ /**
+ * Method for inserting predefined values in the domain and
interdomain link
+ * tables
+ *
+ * @throws SQLException
+ */
+ public void populateTables() throws SQLException {
+ if (!con.isClosed()) {
+ Statement stm = con.createStatement();
+
+ for (int i = 0; i < inserts.length; i++) {
+ stm.execute(inserts[i]);
+ }
+ } else {
+ System.out.println("Connection Failed");
+ }
+ }
+
+ /**
* Method for closing down the connection to the database.
*
* @return True if the connection is closed
Modified: trunk/functional-testing/sqlma/common/test.java
===================================================================
--- trunk/functional-testing/sqlma/common/test.java 2007-02-26 10:42:56
UTC (rev 2141)
+++ trunk/functional-testing/sqlma/common/test.java 2007-02-26 11:02:58
UTC (rev 2142)
@@ -30,7 +30,7 @@
"perfsonar_ma", "testpass");
java.sql.Date d = new java.sql.Date(1144500);
-
+
System.out.println(d.toString());
System.out.println(d.getTime());
System.out.println(d.toString());
@@ -50,12 +50,11 @@
/*
* ResultSet rset = stm.executeQuery(query); while
(rset.next()) {
*
- * System.out.println(rset.getString(1));
- * } // query="select * from domain_link where
time>'"+time+"' and
- * id='DFN-link-1235'"; query = "select id,
status_oper,
- * status_admin, unix_timestamp(time) from
domain_link where
- * id='DFN-link-1234' and time=(select max(time) from
domain_link
- * where id='DFN-link-1234')"; // query ="select
+ * System.out.println(rset.getString(1)); } //
query="select * from
+ * domain_link where time>'"+time+"' and
id='DFN-link-1235'"; query =
+ * "select id, status_oper, status_admin,
unix_timestamp(time) from
+ * domain_link where id='DFN-link-1234' and
time=(select max(time)
+ * from domain_link where id='DFN-link-1234')"; //
query ="select
* MAX(unix_timestamp(time)) from domain_link where
* id='DFN-link-1234'"; //query ="select id,
status_oper,
* status_admin, unix_timestamp(time) as time from
domain_link where
@@ -70,29 +69,59 @@
* System.out.println(rset.getString(5)+"
"+rset.getString(6)); }
*/
Statement stm = con.createStatement();
- String query = "select id, status_oper, status_admin,
unix_timestamp(time) from domain_link where unix_timestamp(time)>=1144318523
and unix_timestamp(time)<=1147960133";
- //ResultSet rset = stm.executeQuery(query);
- //System.out.println(rset.getString(1));
- SQLClient client = new SQLClient(
-
"jdbc:mysql://192.168.10.86:3306/perfsonar_ma",
- "perfsonar_ma", "testpass");
+ // String query = "select id, status_oper,
status_admin,
+ // unix_timestamp(time) from domain_link where
+ // unix_timestamp(time)>=1144318523 and
+ // unix_timestamp(time)<=1147960133";
+ String[] deleteTableValues = { "delete from
domain_link",
+ "delete from interdomain_link" };
+ // stm.addBatch(setTestValues);
+ for (int i = 0; i < deleteTableValues.length; i++) {
+ stm.execute(deleteTableValues[i]);
+ }
+ // boolean command = stm.execute(deleteValues);
+ // System.out.println("Command executed:" + command);
+ // setTestValues = "delete from interdomain_link";
+ // stm.addBatch(setTestValues);
+ // boolean command =
+ // stm.executeBatch();
+ // command = stm.execute(setTestValues);
+ // ResultSet set = stm.getResultSet();
+ // System.out.println("Command executed:" + command);
+ String[] inserts = {
+ "INSERT INTO domain_link (id,
status_oper, time) VALUES ('DFN-link-1234', 'up', '1970-01-14 07:55:00')",
+ "INSERT INTO domain_link (id,
status_oper, time) VALUES ('DFN-link-1234', 'up', '2007-01-25 12:00:00')",
+ "INSERT INTO domain_link (id,
status_oper, time) VALUES ('DFN-Surfnet-Link-5678', 'down', '1970-01-14
08:30:00')",
+ "INSERT INTO domain_link (id,
status_oper, time) VALUES ('DFN-Surfnet-Link-5678', 'down', '2007-01-25
13:00:00')",
+ "INSERT INTO domain_link (id,
status_oper, time) VALUES ('PSNC-DFN-MUE-Link-1001', 'up', '1970-01-14
08:00:00')",
+ "INSERT INTO domain_link (id,
status_oper, time) VALUES ('PSNC-DFN-MUE-Link-1001', 'up', '2007-01-25
11:00:00')",
+ "INSERT INTO interdomain_link (id,
status_oper, time) VALUES ('PSNC-2-DFN-MUE-Link-1002', 'down', '1970-01-14
08:15:00')",
+ "INSERT INTO interdomain_link (id,
status_oper, time) VALUES ('PSNC-2-DFN-MUE-Link-1002', 'down', '2007-01-25
10:00:00')" };
+ for (int i = 0; i < inserts.length; i++) {
+ stm.execute(inserts[i]);
+ }
+ // stm.execute(inserts[0]);
+ // ResultSet rset = stm.executeQuery(query);
+ // System.out.println(rset.getString(1));
+ /*
+ * SQLClient client = new SQLClient(
+ * "jdbc:mysql://192.168.10.86:3306/perfsonar_ma",
"perfsonar_ma",
+ * "testpass");
+ */
- //Hashtable resultTable =
client.executeTimeRangeQuery(1144318523,
- // 1147960133, "", "domain_link");
-
- Hashtable resultTable = client.executeNowQuery("",
"interdomain_link");
-
- if (!resultTable.isEmpty()) {
- Enumeration en=resultTable.elements();
- while(en.hasMoreElements()){
- String[] results = (String[])
en.nextElement();
- System.out.println("Results:");
- System.out.println(results[0] + " " +
results[1] + " "
- + results[2] + " " +
results[3]);
- }
- } else {
- System.out.println("Result list is empty!");
- }
+ // Hashtable resultTable =
client.executeTimeRangeQuery(1144318523,
+ // 1147960133, "", "domain_link");
+ /*
+ * Hashtable resultTable = client.executeNowQuery("",
+ * "interdomain_link");
+ *
+ * if (!resultTable.isEmpty()) { Enumeration
+ * en=resultTable.elements();
while(en.hasMoreElements()){ String[]
+ * results = (String[]) en.nextElement();
+ * System.out.println("Results:");
System.out.println(results[0] + " " +
+ * results[1] + " " + results[2] + " " + results[3]);
} } else {
+ * System.out.println("Result list is empty!"); }
+ */
} catch (Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
Modified: trunk/functional-testing/sqlma/common/xmlDBClient.java
===================================================================
--- trunk/functional-testing/sqlma/common/xmlDBClient.java 2007-02-26
10:42:56 UTC (rev 2141)
+++ trunk/functional-testing/sqlma/common/xmlDBClient.java 2007-02-26
11:02:58 UTC (rev 2142)
@@ -1,5 +1,7 @@
package sqlma.common;
+import java.io.File;
+
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
@@ -7,6 +9,7 @@
import org.xmldb.api.base.ResourceIterator;
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
+import org.xmldb.api.modules.XMLResource;
import org.xmldb.api.modules.XPathQueryService;
/**
@@ -21,7 +24,7 @@
/**
* The collection and database to be used in the class
*/
- private Collection collection;
+ private static Collection collection;
private Database database;
@@ -61,7 +64,7 @@
}
}
-
+
//
--------------------------------------------------------------------
// public methods
@@ -123,6 +126,30 @@
}
/**
+ * Method for clearing values in the eXist database
+ *
+ * @param valuesFile
+ * The file that is qoing to be used for initializing the
values
+ * @throws XMLDBException
+ */
+ public boolean clearValues(String valuesFile) throws XMLDBException {
+ File f = new File(valuesFile);
+ XMLResource document = (XMLResource)
collection.createResource(
+ "sql-database_TEST.xml", "XMLResource");
+ if (!f.canRead()) {
+ System.out.println("cannot read file ");
+ return false;
+ }
+ document.setContent(f);
+ System.out.print("Restoring values in document " +
document.getId()
+ + "...");
+ Collection child =
collection.getChildCollection("sqlmqconfig");
+ collection.storeResource(document);
+ System.out.println("ok.");
+ return true;
+ }
+
+ /**
* This method closes the connection with the database
*
* @throws XMLDBException
@@ -142,7 +169,7 @@
xmlDBClient client = null;
try {
client = new xmlDBClient(
-
"192.168.10.86:8080/exist/xmlrpc/sqlmaconfig",
+
"192.168.10.86:21/exist/xmlrpc/db/sqlmaconfig",
"sqlmaservice", "testpass");
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
@@ -160,7 +187,8 @@
try {
System.out
.println(client
-
.executeQuery("//nmwg:metadata/nmwg:subject/nmtl2:link/nmtl2:name=\"DFN-GARR-Link-001\""));
+
.executeQuery("//nmwg:metadata/nmwg:subject/nmtl2:link/nmtl2:name=\"DFN-link-1234\""));
+ client.clearValues("C:/sql-database_TEST.xml");
} catch (XMLDBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- r2142 - in trunk/functional-testing: common/echo sqlma sqlma/common, svnlog, 02/26/2007
Archive powered by MHonArc 2.6.16.