perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6148 - in trunk/psBase3/perfsonar-base: . src/main/java/net/geant/perfsonar src/main/java/net/geant/perfsonar/nmwg/response src/main/java/net/geant/perfsonar/response src/main/java/net/geant/perfsonar/xpath src/test/java/net/geant/perfsonar src/test/java/net/geant/perfsonar/helpers src/test/java/net/geant/perfsonar/messaging src/test/java/net/geant/perfsonar/messaging/xpath src/test/java/net/geant/perfsonar/mp/sshtelnet src/test/java/net/geant/perfsonar/xpath src/test/resources
Subject: perfsonar development work
List archive
[pS-dev] [GEANT/SA2/ps-java-services] r6148 - in trunk/psBase3/perfsonar-base: . src/main/java/net/geant/perfsonar src/main/java/net/geant/perfsonar/nmwg/response src/main/java/net/geant/perfsonar/response src/main/java/net/geant/perfsonar/xpath src/test/java/net/geant/perfsonar src/test/java/net/geant/perfsonar/helpers src/test/java/net/geant/perfsonar/messaging src/test/java/net/geant/perfsonar/messaging/xpath src/test/java/net/geant/perfsonar/mp/sshtelnet src/test/java/net/geant/perfsonar/xpath src/test/resources
Chronological Thread
- From:
- To:
- Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6148 - in trunk/psBase3/perfsonar-base: . src/main/java/net/geant/perfsonar src/main/java/net/geant/perfsonar/nmwg/response src/main/java/net/geant/perfsonar/response src/main/java/net/geant/perfsonar/xpath src/test/java/net/geant/perfsonar src/test/java/net/geant/perfsonar/helpers src/test/java/net/geant/perfsonar/messaging src/test/java/net/geant/perfsonar/messaging/xpath src/test/java/net/geant/perfsonar/mp/sshtelnet src/test/java/net/geant/perfsonar/xpath src/test/resources
- Date: Mon, 18 Feb 2013 20:07:41 +0000 (GMT)
- Authentication-results: sfpop-ironport07.merit.edu; dkim=neutral (message not signed) header.i=none
Author: psnc.pietrzak
Date: 2013-02-18 20:07:41 +0000 (Mon, 18 Feb 2013)
New Revision: 6148
Added:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/messaging/
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/EchoResponse.java
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/SelfTestResponse.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/messaging/
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/messaging/xpath/
Removed:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/EchoResponse.java
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/SelfTestResponse.java
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/TemplateEngine.java
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/Helper.java
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/ReferenceInterceptor.java
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/XPathConfiguration.java
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/XPathDeserializer.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/MockLSService.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/NMWG.groovy
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/SelfTestResult.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/messaging/xpath/XPathDeserializerTest.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/Command.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/Router.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/xpath/XPathDeserializerTest.java
trunk/psBase3/perfsonar-base/src/test/resources/configuration.xml
Modified:
trunk/psBase3/perfsonar-base/pom.xml
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/HandlerConfiguration.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/PerfSONARTest.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/SSHTelnetMPWebServiceTest.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/PerfSONARClient.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/PerfSONARServiceClient.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/Response.java
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/SSHTelnetMPService.java
Log:
Extracted messaging functionality.
Modified: trunk/psBase3/perfsonar-base/pom.xml
===================================================================
--- trunk/psBase3/perfsonar-base/pom.xml 2013-02-18 19:56:18 UTC (rev
6147)
+++ trunk/psBase3/perfsonar-base/pom.xml 2013-02-18 20:07:41 UTC (rev
6148)
@@ -14,7 +14,7 @@
<packaging>bundle</packaging>
<name>Framework for perfSONAR services</name>
-
+
<developers>
<developer>
<id>blazej.pietrzak</id>
@@ -49,21 +49,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <version>1.8.2</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.7</version>
- </dependency>
- <dependency>
<groupId>net.geant.perfsonar</groupId>
- <artifactId>perfsonar-base-annotations</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <artifactId>perfsonar-messaging</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
@@ -71,11 +59,12 @@
<version>2.2.2</version>
</dependency>
<dependency>
- <groupId>jlibs</groupId>
- <artifactId>jlibs-xmldog</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <groupId>net.geant.perfsonar</groupId>
+ <artifactId>perfsonar-messaging</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
@@ -119,19 +108,16 @@
</configuration>
</plugin>
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
-
<compilerId>groovy-eclipse-compiler</compilerId>
- <!-- set verbose to be true if you
want lots of uninteresting messages -->
- <!-- <verbose>true</verbose> -->
- </configuration>
- <dependencies>
- <dependency>
-
<groupId>org.codehaus.groovy</groupId>
-
<artifactId>groovy-eclipse-compiler</artifactId>
- <version>2.7.0-01</version>
- </dependency>
- </dependencies>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-tests-artifact</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
Modified:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/HandlerConfiguration.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/HandlerConfiguration.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/HandlerConfiguration.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -2,7 +2,7 @@
import java.lang.reflect.Method;
-import net.geant.perfsonar.xpath.Helper;
+import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
@@ -10,12 +10,13 @@
private String type;
- protected HandlerConfiguration(String type) {
+ public HandlerConfiguration(String type) {
this.type = type;
}
+ @SuppressWarnings("unchecked")
public <T> T then(Class<T> controller) throws InstantiationException,
IllegalAccessException {
- return Helper.createMock(controller, this);
+ return (T) Enhancer.create(controller, this);
}
public Object intercept(Object obj, Method method, Object[] args,
Deleted:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/EchoResponse.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/EchoResponse.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/EchoResponse.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,11 +0,0 @@
-package net.geant.perfsonar.nmwg.response;
-
-import java.io.IOException;
-import java.io.Writer;
-
-public class EchoResponse {
- public static void writeEcho(Writer writer, String requestId) throws
IOException {
- TemplateEngine.put("requestId", requestId);
- TemplateEngine.evaluate(writer, EchoResponse.class,
"EchoResponse.template");
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/SelfTestResponse.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/SelfTestResponse.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/SelfTestResponse.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,52 +0,0 @@
-package net.geant.perfsonar.nmwg.response;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import net.geant.perfsonar.ServiceType;
-import net.geant.perfsonar.selftest.SelfTestLogger;
-
-public class SelfTestResponse implements SelfTestLogger {
- private static Logger logger =
LoggerFactory.getLogger(SelfTestResponse.class);
-
- private Writer writer;
-
- public SelfTestResponse(ServiceType serviceType, String serviceName)
throws Exception {
- TemplateEngine.put("serviceType", serviceType);
- TemplateEngine.put("serviceName", serviceName);
- }
-
- public void begin(Writer writer, String requestId) throws IOException
{
- this.writer = writer;
- TemplateEngine.put("requestId", requestId);
- TemplateEngine.evaluate(writer, SelfTestResponse.class,
"SelfTest_header.template");
- }
-
- public void end() throws IOException {
- TemplateEngine.evaluate(writer, SelfTestResponse.class,
"SelfTest_footer.template");
- writer = null;
- }
-
- public void success(String name, String successMessage) {
- TemplateEngine.put("name", name);
- TemplateEngine.put("message", successMessage);
- try {
- TemplateEngine.evaluate(writer,
SelfTestResponse.class, "SelfTest_success.template");
- } catch (IOException e) {
- logger.error("Could not fill in the template with
self test results.", e);
- }
- }
-
- public void failure(String name, String message) {
- TemplateEngine.put("name", name);
- TemplateEngine.put("message", message);
- try {
- TemplateEngine.evaluate(writer,
SelfTestResponse.class, "SelfTest_failure.template");
- } catch (IOException e) {
- logger.error("Could not fill in the template with
self test results.", e);
- }
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/TemplateEngine.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/TemplateEngine.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/nmwg/response/TemplateEngine.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,75 +0,0 @@
-package net.geant.perfsonar.nmwg.response;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-
-/**
- * Provides facade to the underlying template engine. This implementation
uses
- * Velocity engine.
- *
- * @author <a
href="mailto:">Blazej
Pietrzak</a>
- *
- */
-/**
- * @author <a
href="">Blazej
Pietrzak</a>
- *
- */
-public class TemplateEngine {
- private final static VelocityEngine templateEngine = new
VelocityEngine();
- private final static VelocityContext context = new VelocityContext();
-
- static {
- try {
- templateEngine.init();
- } catch (Exception ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- }
-
- private static InputStream getTemplate(Class<?> homeDir, String name)
- throws IOException {
- final InputStream in =
homeDir.getClassLoader().getResourceAsStream(
- getFullPath(homeDir, name));
-
- if (in == null)
- throw new IOException("Template " + name + " cannot
be found.");
- return in;
- }
-
- private static String getFullPath(Class<?> homeDir, String name) {
- String result = homeDir.getPackage().getName();
- for (; result.indexOf(".") != -1; result = result.replace(".",
- File.separator))
- ;
- return result + File.separator + name;
- }
-
- /**
- * Writes to the stream provided by writer argument, the template
found in
- * the directory where the given class is stored using the template
provided
- * by name.
- *
- */
- public static void evaluate(Writer writer, Class<?> homeDir, String
name)
- throws IOException {
- // TODO change to not deprecated
- templateEngine.evaluate(context, writer, "successMessage",
- getTemplate(homeDir, name));
- }
-
-
- /**
- * Put data to the context. Data can be used in templates with a
macro ${identifier}
- * where identifier is the name put in the context.
- * More on template engine can be found at Apache Velocity website.
- */
- public static void put(String name, Object value) {
- context.put(name, value);
- }
-}
Added:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/EchoResponse.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/EchoResponse.java
(rev 0)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/EchoResponse.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -0,0 +1,18 @@
+package net.geant.perfsonar.response;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import net.geant.perfsonar.templates.TemplateEngine;
+
+/**
+ * Writes Echo response to the stream.
+ *
+ * @author <a
href="">Blazej
Pietrzak</a>
+ */
+public class EchoResponse {
+ public static void writeEcho(Writer writer, String requestId) throws
IOException {
+ TemplateEngine.put("requestId", requestId);
+ TemplateEngine.evaluate(writer, EchoResponse.class,
"EchoResponse.template");
+ }
+}
Added:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/SelfTestResponse.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/SelfTestResponse.java
(rev 0)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/response/SelfTestResponse.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -0,0 +1,58 @@
+package net.geant.perfsonar.response;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.geant.perfsonar.ServiceType;
+import net.geant.perfsonar.templates.TemplateEngine;
+import net.geant.perfsonar.selftest.SelfTestLogger;
+
+/**
+ * Builder for creating Self test responses to the writer streams.
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+public class SelfTestResponse implements SelfTestLogger {
+ private static Logger logger =
LoggerFactory.getLogger(SelfTestResponse.class);
+
+ private Writer writer;
+
+ public SelfTestResponse(ServiceType serviceType, String serviceName)
throws Exception {
+ TemplateEngine.put("serviceType", serviceType);
+ TemplateEngine.put("serviceName", serviceName);
+ }
+
+ public void begin(Writer writer, String requestId) throws IOException
{
+ this.writer = writer;
+ TemplateEngine.put("requestId", requestId);
+ TemplateEngine.evaluate(writer, SelfTestResponse.class,
"SelfTest_header.template");
+ }
+
+ public void end() throws IOException {
+ TemplateEngine.evaluate(writer, SelfTestResponse.class,
"SelfTest_footer.template");
+ writer = null;
+ }
+
+ public void success(String name, String successMessage) {
+ TemplateEngine.put("name", name);
+ TemplateEngine.put("message", successMessage);
+ try {
+ TemplateEngine.evaluate(writer,
SelfTestResponse.class, "SelfTest_success.template");
+ } catch (IOException e) {
+ logger.error("Could not fill in the template with
self test results.", e);
+ }
+ }
+
+ public void failure(String name, String message) {
+ TemplateEngine.put("name", name);
+ TemplateEngine.put("message", message);
+ try {
+ TemplateEngine.evaluate(writer,
SelfTestResponse.class, "SelfTest_failure.template");
+ } catch (IOException e) {
+ logger.error("Could not fill in the template with
self test results.", e);
+ }
+ }
+}
Deleted:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/Helper.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/Helper.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/Helper.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,20 +0,0 @@
-package net.geant.perfsonar.xpath;
-
-import net.sf.cglib.proxy.Callback;
-import net.sf.cglib.proxy.Enhancer;
-
-public class Helper {
-
- public static <T> T createMock(Class<T> controller, Callback
callback) {
- final Enhancer e = new Enhancer();
- e.setSuperclass(controller);
- e.setCallback(callback);
- @SuppressWarnings("unchecked")
- T result = (T) e.create();
- return result;
- }
-
- public static boolean isConfigurationInstance(Object object) {
- return
object.getClass().getName().contains("EnhancerByCGLIB");
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/ReferenceInterceptor.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/ReferenceInterceptor.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/ReferenceInterceptor.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,23 +0,0 @@
-package net.geant.perfsonar.xpath;
-
-import java.lang.reflect.Method;
-
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-public class ReferenceInterceptor implements MethodInterceptor {
-
- public Object intercept(Object obj, Method method, Object[] args,
- MethodProxy proxy) throws Throwable {
-
- if (method.getName().equals("toString") ||
method.getName().equals("hashCode") || method.getName().equals("finalize")) {
- return proxy.invokeSuper(obj, args);
- }
-
- if (args.length != 0)
- throw new IllegalArgumentException(method + "
identifier method must have zero arguments.");
-
- XPathDeserializer.putIdentifier(method.getDeclaringClass(),
method);
- return null;
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/XPathConfiguration.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/XPathConfiguration.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/XPathConfiguration.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,47 +0,0 @@
-package net.geant.perfsonar.xpath;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-public class XPathConfiguration implements MethodInterceptor {
-
- private String xpath;
- private Object object;
-
- private static final List<String> restrictedMethodNames =
Arrays.asList("toString", "hashCode", "finalize");
-
- public XPathConfiguration(String xpath) {
- this.xpath = xpath;
- }
-
- public <T> T then(Class<T> controller) throws InstantiationException,
IllegalAccessException {
- return Helper.createMock(controller, this);
- }
-
- public <T> T then(Class<T> clazz, T object) throws
InstantiationException, IllegalAccessException {
- this.object = object;
- return Helper.createMock(clazz, this);
- }
-
- public Object intercept(Object obj, Method method, Object[] args,
- MethodProxy proxy) throws Throwable {
-
- if (restrictedMethodNames.contains(method.getName())) {
- return proxy.invokeSuper(obj, args);
- }
-
- if (args.length != 1)
- throw new IllegalArgumentException("Setter method
must have exactly one argument of type String.");
-
- if (this.object != null)
- XPathDeserializer.putXPath(xpath, object, method);
- else
- XPathDeserializer.putXPath(xpath, method);
-
- return null;
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/XPathDeserializer.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/XPathDeserializer.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/main/java/net/geant/perfsonar/xpath/XPathDeserializer.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,232 +0,0 @@
-package net.geant.perfsonar.xpath;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.xpath.XPathException;
-
-import jlibs.xml.DefaultNamespaceContext;
-import jlibs.xml.sax.dog.NodeItem;
-import jlibs.xml.sax.dog.XMLDog;
-import jlibs.xml.sax.dog.XPathResults;
-import jlibs.xml.sax.dog.expr.Expression;
-
-import org.jaxen.saxpath.SAXPathException;
-import org.xml.sax.InputSource;
-
-/**
- * Deserializes data from XML stream.
- *
- * This class provides API for configuring XPath expressions that trigger
- * method invocation with values of the expression evaluation.
- * Please note that it uses streaming XPaths, so only a subset of
expressions can
- * be used. Those that require creation of DOM tree are not allowed.
- *
- * There are two approaches to configure deserializer: via API or via
annotations.
- * By invoking:
- * <code>declarePrefix("nmwg", uri)</code>
- * one informs the deserializer about prefixes for various namespaces.
- * By invoking:
- *
<code>whenXPath("/nmwg:message/@id").then(NMWGMessage.class).setId(any(String.class))</code>
- * deserializer will fire setId method from instance of NMWGMesssage class
and provide
- * as an argument the result of XPath expression provided in whenXPath
method.
- * During configuration no real method is executed.
- * The following configuration is developer friendly. It statically checks
whether
- * the method exists and in case of refactoring it will be reconfigured
automatically.
- *
- * By invoking:
- * <code>whenXPath(
- *
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/@metadataIdRef")
- * .then(Command.class).setCurrentRouter(
- * getReference(Router.class,
identifier(Router.class).getId()));</code>
- *
- * deserializer will invoke setCurrentRouter method and will provide a real
instance (not string)
- * of Router class identified by getId method in defined in Router class.
- *
- * Configuring deserializer via annotations requires psbase3-apt tool to be
present on the classpath during compilation.
- * By invoking:
- *
<code>@XPath(xpath="nmwg:message/nmwg:metadata[@id='meta']/nmwg:eventType/text()",
- *
namespaces=@Namespace(prefix="nmwg",
uri=NMWG_URI)) public void setEventType(String type)</code>
- *
- * setEventType method will be invoked when the xpath will be evaluated.
- *
- * @author <a
href="mailto:">Blazej
Pietrzak</a>
- *
- */
-public class XPathDeserializer {
-
- private final static DefaultNamespaceContext context = new
DefaultNamespaceContext();
- private Map<Class<?>, List<Object>> instances = new
Hashtable<Class<?>, List<Object>>();
-
- private static Map<Method, Object> objects = new Hashtable<Method,
Object>();
- private static Map<String, Method> xpaths = new Hashtable<String,
Method>();
- private static Map<Class<?>, Method> identifiers = new
Hashtable<Class<?>, Method>();
-
- public static void declarePrefix(String prefix, String uri) {
- context.declarePrefix(prefix, uri);
- }
-
- public static XPathConfiguration whenXPath(String xpath) {
- return new XPathConfiguration(xpath);
- }
-
- public static <T> T getReference(Class<T> type, String id) throws
InstantiationException, IllegalAccessException {
- return type.newInstance();
- }
-
- public static <T> T identifier(Class<T> type) {
- return Helper.createMock(type, new ReferenceInterceptor());
- }
-
- public static <T> T any(Class<T> type) {
- return null;
- }
-
- public static void putXPath(String xpath, Object object, Method
method) {
- objects.put(method, object);
- xpaths.put(xpath, method);
- }
-
- public static void putXPath(String xpath, Method method) {
- xpaths.put(xpath, method);
- }
-
- public static void clearConfiguration() {
- xpaths.clear();
- }
-
- private static Set<String> getXPaths() {
- return xpaths.keySet();
- }
-
- private static Method getXPathMethod(String xpath) {
- return xpaths.get(xpath);
- }
-
- public XPathDeserializer() {
- }
-
- /**
- * Deserializes objects from xml stream using streaming XPath
expressions.
- */
- public List<?> deserialize(InputSource reader) throws
SAXPathException, XPathException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException, InstantiationException {
- final XMLDog dog = new XMLDog(context);
- final List<Expression> expressions = new
ArrayList<Expression>();
- for (String xpath : XPathDeserializer.getXPaths()) {
- expressions.add(dog.addXPath(xpath));
- }
-
- final XPathResults results = dog.sniff(reader);
-
- for (Expression expr : sort(expressions)) {
- @SuppressWarnings("unchecked")
- final Collection<NodeItem> temp =
(Collection<NodeItem>) results.getResult(expr);
- if (temp.size() <= 0) continue;
- final Method method =
XPathDeserializer.getXPathMethod(expr.getXPath());
-
- for (NodeItem item : temp) {
- if
(method.getParameterTypes()[0].equals(String.class)) {
- method.invoke(getInstance(method),
item.value);
- } else {
- final Object reference =
getReference(item.value, identifiers.get(method.getParameterTypes()[0]));
- if (reference == null) continue;
- method.invoke(getInstance(method),
reference);
- }
-
- increment(method);
- }
- }
-
- final List<Object> result = new ArrayList<Object>();
- for (List<Object> temp : instances.values())
- result.addAll(temp);
- return result;
-
- }
-
- @SuppressWarnings("unchecked")
- public <T> List<T> getObjects(Class<T> type, List<Object> objects) {
- final List<T> result = new ArrayList<T>();
- for (Object obj : objects) {
- if (obj.getClass().equals(type)) {
- result.add((T) obj);
- }
- }
- return result;
- }
-
- private List<Expression> sort(List<Expression> expressions) {
- final List<Expression> result = new ArrayList<Expression>();
- final Iterator<Expression> iter = expressions.iterator();
-
- if (expressions.size() <= 0)
- return result;
-
- for (Expression expr = iter.next(); iter.hasNext(); expr =
iter.next()) {
- Method method =
XPathDeserializer.getXPathMethod(expr.getXPath());
- if (method == null)
- throw new RuntimeException("Cannot find
method for xpath " + expr.getXPath());
- if
(method.getParameterTypes()[0].equals(String.class)) {
- result.add(expr);
- iter.remove();
- }
- }
-
- result.addAll(expressions);
-
- return result;
- }
-
- private Object getReference(String value, Method identifierMethod)
throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
- if (instances.get(identifierMethod.getDeclaringClass()) ==
null)
- return null;
-
- for (Object instance :
instances.get(identifierMethod.getDeclaringClass())) {
- if (identifierMethod.invoke(instance).equals(value))
- return instance;
- }
- return null;
- }
-
- private void increment(Method method) {
- if (counts.get(method) == null)
- counts.put(method, 0);
-
- counts.put(method, counts.get(method) + 1);
- }
-
- private Map<Method, Integer> counts = new Hashtable<Method,
Integer>();
-
- private int getCount(Method method) {
- if (counts.get(method) == null)
- counts.put(method, 0);
-
- return counts.get(method);
- }
-
- private Object getInstance(Method method) throws
InstantiationException, IllegalAccessException {
- if (Modifier.isStatic(method.getModifiers()))
- return null;
- if (objects.get(method) != null)
- return objects.get(method);
- if (instances.get(method.getDeclaringClass()) == null) {
- instances.put(method.getDeclaringClass(), new
ArrayList<Object>());
- }
- if (instances.get(method.getDeclaringClass()).size() <
getCount(method) + 1)
-
instances.get(method.getDeclaringClass()).add(method.getDeclaringClass().newInstance());
-
- return
instances.get(method.getDeclaringClass()).get(getCount(method));
- }
-
- protected static void putIdentifier(Class<?> declaringClass, Method
method) {
- XPathDeserializer.identifiers.put(declaringClass, method);
- }
-}
Modified:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/PerfSONARTest.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/PerfSONARTest.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/PerfSONARTest.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,17 +1,18 @@
package net.geant.perfsonar;
-import static net.geant.perfsonar.helpers.SelfTestResult.failure;
-import static net.geant.perfsonar.helpers.SelfTestResult.success;
+import static net.geant.perfsonar.templates.SelfTestResult.failure;
+import static net.geant.perfsonar.templates.SelfTestResult.success;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.io.Reader;
-import net.geant.perfsonar.helpers.NMWG;
+import net.geant.perfsonar.templates.NMWG;
import net.geant.perfsonar.helpers.PerfSONARClient;
-import net.geant.perfsonar.helpers.SelfTestResult;
+import net.geant.perfsonar.helpers.Response;
import net.geant.perfsonar.mp.sshtelnet.Command;
import net.geant.perfsonar.mp.sshtelnet.SSHTelnetMPService;
+import net.geant.perfsonar.templates.SelfTestResult;
import org.junit.Before;
import org.junit.Test;
@@ -33,17 +34,17 @@
@Test
public void checkEcho() throws SAXException {
- assertEquals(NMWG.toEchoResponse(REQUEST_ID),
client.echo(REQUEST_ID));
+ assertEquals(new Response(NMWG.toEchoResponse(REQUEST_ID)),
client.echo(REQUEST_ID));
}
@Test
public void checkSelfTest() throws SAXException {
assertEquals(
- NMWG.toSelfTestResponse(
+ new Response(NMWG.toSelfTestResponse(
REQUEST_ID,
new SelfTestResult[] {
success("test1", "Test passed."),
-
failure("test2", "Test failed."), }),
+
failure("test2", "Test failed."), })),
client.selfTest(REQUEST_ID));
}
Modified:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/SSHTelnetMPWebServiceTest.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/SSHTelnetMPWebServiceTest.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/SSHTelnetMPWebServiceTest.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,15 +1,14 @@
package net.geant.perfsonar;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import java.io.IOException;
import javax.xml.ws.Endpoint;
-import net.geant.perfsonar.helpers.MockLSService;
-import net.geant.perfsonar.helpers.NMWG;
+import net.geant.perfsonar.templates.NMWG;
import net.geant.perfsonar.helpers.PerfSONARServiceClient;
+import net.geant.perfsonar.helpers.Response;
import net.geant.perfsonar.mp.sshtelnet.SSHTelnetMPService;
import org.junit.After;
@@ -18,19 +17,14 @@
import org.xml.sax.SAXException;
public class SSHTelnetMPWebServiceTest {
- private static final int TWO_SECONDS = 2000;
private static final String REQUEST_ID = "request1";
private static final String SERVICE_URL =
"http://localhost:9000/perfsonar-java-sshtelnet-mp";
- private static final String LS_URL =
"http://localhost:9000/perfsonar-ls";
- private MockLSService ls = new MockLSService();
-
private SSHTelnetMPService service = new SSHTelnetMPService();
private Endpoint endpoint;
@Before
- public void givenLSandSSHTelnetMPWebService() throws
InterruptedException, IOException {
- ls.publish(LS_URL);
+ public void givenSSHTelnetMPWebService() throws InterruptedException,
IOException {
endpoint = Endpoint.publish(SERVICE_URL, service);
}
@@ -38,22 +32,13 @@
public void stopServices() {
endpoint.stop();
service.stop();
- ls.stop();
endpoint = null;
- ls = null;
service = null;
}
@Test
- public void shouldRegisterToLookupService() throws Exception {
- Thread.sleep(TWO_SECONDS * 3 + 500);
- assertTrue(ls.getKeepAliveCount() > 0);
- assertEquals(1, ls.getRegisterCount());
- }
-
- @Test
public void shouldSayEcho() throws SAXException, InterruptedException
{
final PerfSONARServiceClient client = new
PerfSONARServiceClient(SERVICE_URL);
- assertEquals(NMWG.toEchoResponse(REQUEST_ID),
client.echo(REQUEST_ID));
+ assertEquals(new Response(NMWG.toEchoResponse(REQUEST_ID)),
client.echo(REQUEST_ID));
}
}
Deleted:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/MockLSService.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/MockLSService.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/MockLSService.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,55 +0,0 @@
-package net.geant.perfsonar.helpers;
-
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.Provider;
-import javax.xml.ws.WebServiceProvider;
-
-import net.geant.perfsonar.NMWGMessage;
-import net.geant.perfsonar.xpath.XPathDeserializer;
-
-import org.xml.sax.InputSource;
-
-@WebServiceProvider
-public class MockLSService implements Provider<StreamSource> {
- private int lsKeepAliveCount = 0;
- private int lsRegisterCount = 0;
- private Endpoint endpoint;
-
- @SuppressWarnings("unchecked")
- public StreamSource invoke(StreamSource input) {
- final XPathDeserializer deserializer = new
XPathDeserializer();
- NMWGMessage msg;
- try {
- msg = deserializer.getObjects(NMWGMessage.class,
(List<Object>) deserializer.deserialize(new
InputSource(input.getInputStream()))).get(0);
- if (msg.getType().equals("LSKeepaliveRequest"))
- lsKeepAliveCount++;
- else if (msg.getType().equals("LSRegisterRequest"))
- lsRegisterCount++;
- return new
StreamSource(NMWG.toLSResponse(msg.getId()));
- } catch (Exception ex) {
- fail(ex.toString());
- }
- return null;
- }
-
- public int getKeepAliveCount() {
- return lsKeepAliveCount;
- }
-
- public int getRegisterCount() {
- return lsRegisterCount;
- }
-
- public void publish(String url) {
- endpoint = Endpoint.publish(url, this);
- }
-
- public void stop() {
- endpoint.stop();
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/NMWG.groovy
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/NMWG.groovy
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/NMWG.groovy
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,216 +0,0 @@
-package net.geant.perfsonar.helpers
-
-import net.geant.perfsonar.mp.sshtelnet.Command;
-import net.geant.perfsonar.mp.sshtelnet.Router;
-
-
-import java.io.InputStream;
-import java.io.Reader;
-
-import groovy.xml.MarkupBuilder
-
-class NMWG {
- private static Reader createRequest(id, eventType, version) {
- def writer = new StringWriter()
- MarkupBuilder xml = new MarkupBuilder(writer)
- xml.mkp.xmlDeclaration(version:"1.0", encoding:"UTF-8")
-
xml.'nmwg:message'('xmlns:nmwg':'http://ggf.org/ns/nmwg/base/2.0/', id:id,
type:"EchoRequest") {
- 'nmwg:metadata'(id:"meta") {
- 'nmwg:eventType'
"http://schemas.perfsonar.net/tools/admin/${eventType}/${version}"
- }
- 'nmwg:data'(id:"data", metadataIdRef:"meta")
- }
-
- writer.write("\n");
- new StringReader(writer.toString())
- }
-
- static Reader toEchoRequest(String id) {
- createRequest(id, "echo", "2.0")
- }
-
- static Reader toSelfTestRequest(String id) {
- createRequest(id, "selftest", "1.0")
- }
-
- static Reader toMetadataKeyRequest(String id) {
- def writer = new StringWriter()
- MarkupBuilder xml = new MarkupBuilder(writer)
-
xml.'nmwg:message'('xmlns:nmwg':'http://ggf.org/ns/nmwg/base/2.0/', id:id,
type:"MetadataKeyRequest") {
- 'nmwg:metadata'(id:"meta") {
- 'nmwg:subject'(id:"server") {
- 'nmwg:parameters'(id:"params") {
-
'nmwg:parameter'(name:"param", "SES")
- }
- }
- }
- 'nmwg:data'(id:"data", metadataIdRef:"meta")
- }
-
- new StringReader(writer.toString())
- }
-
- static Reader toSetupDataRequest(String id, Command... commands) {
- def idx = 0;
- final def writer = new StringWriter()
- final MarkupBuilder xml = new MarkupBuilder(writer)
- xml.mkp.xmlDeclaration(version:"1.0", encoding:"UTF-8")
-
xml.'nmwg:message'('xmlns:nmwg':'http://ggf.org/ns/nmwg/base/2.0/',
'xmlns:nmwgtopo':'http://ggf.org/ns/nmwg/topology/2.0/', id:id,
type:"SetupDataRequest") {
- commands.each { command ->
- 'nmwg:metadata'(id:"meta${idx}") {
- 'nmwg:subject'(id:"subject${idx}") {
-
'nmwgtopo:endPoint'(type:"hostname", command.routerName)
- }
- 'nmwg:parameters'(id:"params${idx}") {
-
'nmwg:parameter'(name:"command", value:command.name)
-
'nmwg:parameter'(name:"description", value:command.description)
-
'nmwg:parameter'(name:"syntax", value:command.syntax)
- }
- 'nmwg:eventType' command.eventType
- }
- 'nmwg:data'(id:"data${idx}",
metadataIdRef:"meta${idx}")
- }
- }
- new StringReader(writer.toString())
- }
-
- static Response toSelfTestResponse(requestId, SelfTestResult...
tests) {
- createResponse(requestId) {
- 'nmwg:metadata'(id:"meta") {
- 'nmwg:eventType'
"http://schemas.perfsonar.net/tools/admin/selftest/1.0"
- }
- 'nmwg:data'(id:"data", metadataIdRef:"meta") {
- tests.each { test ->
- 'nmwg:metadata'(id:"${test.name}") {
- 'nmwg:eventType'
"http://schemas.perfsonar.net/tools/admin/selftest/MP/SSHTELNET/${test.name}/${test.status}/1.0"
- }
- 'nmwg:data'(id:"data_${test.name}",
metadataIdRef:"${test.name}") {
- 'nmwg:datum' test.message
- }
- }
- }
- }
- }
-
- static Response toEchoResponse(requestId) {
- createResponse(requestId) {
- 'nmwg:metadata'(id:"result-code") {
- 'nmwg:eventType' "echo/success"
- }
- 'nmwg:data'(id:"result-code-description",
metadataIdRef:"result-code") {
-
'nmwgr:datum'('xmlns:nmwgr':"http://ggf.org/ns/nmwg/result/2.0/",
- "This is the success echo response
from the service.")
- }
- }
- }
-
- private static Response createResponse(requestId, body) {
- final def writer = new StringWriter()
- final MarkupBuilder xml = new MarkupBuilder(writer)
- xml.mkp.xmlDeclaration(version:"1.0", encoding:"UTF-8")
-
xml.'nmwg:message'('xmlns:nmwg':"http://ggf.org/ns/nmwg/base/2.0/",
- id:"Resp_${requestId}", messageIdRef:"${requestId}",
type:"EchoResponse", body)
-
- new Response(new StringReader(writer.toString()))
- }
-
- public static Response toMetadataKeyResponse(String requestId,
Router... routers) {
- def idx = 0;
- final def writer = new StringWriter()
- final MarkupBuilder xml = new MarkupBuilder(writer)
- xml.mkp.xmlDeclaration(version:"1.0", encoding:"UTF-8")
-
xml.'nmwg:message'('xmlns:nmwg':"http://ggf.org/ns/nmwg/base/2.0/",
- id:"${requestId}_resp", messageIdRef:"${requestId}",
type:"MetadataKeyResponse") {
-
- routers.each { router ->
- 'nmwg:metadata'(id:"metadata${idx}") {
- 'nmwg:subject'(id:"subject${idx}",
router.name)
-
'nmwg:parameters'(id:"metaParams${idx}") {
- 'nmwg:parameter'(name:"url",
value:router.address.hostAddress)
- }
- }
- idx++
- }
-
- idx = 0
- routers.each { router ->
- 'nmwg:metadata'(id:"resultCodeMeta_${idx}") {
-
'nmwg:subject'(id:"resultCodeSubj_${idx}", metadataIdRef:"metadata${idx}")
-
'nmwg:eventType'("success.mp.sshtelnet")
- }
- 'nmwg:data'(id:"resultCodeMeta_${idx}",
metadataIdRef:"resultCodeMeta_${idx}") {
-
'nmwgr:datum'('xmlns:nmwgr':"http://ggf.org/ns/nmwg/result/2.0/",
"Successfully executed MetaDataKeyRequest")
- }
- idx++
- }
-
- idx = 0
- routers.each { router ->
- 'nmwg:data'(id:"data${idx}",
metadataIdRef:"metadata${idx}") {
- router.commands.each { command ->
-
'nmwgr:datum'('xmlns:nmwgr':"http://ggf.org/ns/nmwg/result/2.0/") {
-
'nmwg:parameters'(id:"params${idx}") {
-
'nmwg:parameter'(name:"command", value:command.name)
-
'nmwg:parameter'(name:"description", value:command.description)
- if
(command.syntax == null)
-
'nmwg:parameter'(name:"syntax")
- else
-
'nmwg:parameter'(name:"syntax", value:command.syntax)
- }
-
'nmwg:eventType'(command.eventType)
- }
- }
- }
- idx++
- }
- }
-
- new Response(new StringReader(writer.toString()))
- }
-
- public static Response toSetupDataResponse(String requestId,
Command... commands) {
- def idx = 0;
- final def writer = new StringWriter()
- final MarkupBuilder xml = new MarkupBuilder(writer)
- xml.mkp.xmlDeclaration(version:"1.0", encoding:"UTF-8")
-
xml.'nmwg:message'('xmlns:nmwg':"http://ggf.org/ns/nmwg/base/2.0/",
id:"${requestId}_resp", messageIdRef:"${requestId}",
type:"SetupDataResponse") {
- commands.each { command ->
- 'nmwg:metadata'(id:"meta${idx}") {
- 'nmwg:subject'(id:"subject${idx}") {
-
'nmwgtopo:endPoint'('xmlns:nmwgtopo':"http://ggf.org/ns/nmwg/topology/2.0/",
type:"hostname", command.routerName)
- }
- 'nmwg:parameters'(id:"params${idx}")
- 'nmwg:eventType'(command.eventType)
- }
-
- 'nmwg:data'(id:"data${idx}",
metadataIdRef:"meta${idx}") {
- 'nmwg:datum'(command.result)
- }
-
'nmwg:metadata'(id:"resultCodeMeta_meta${idx}") {
-
'nmwg:subject'(id:"resultCodeSubj_meta${idx}", metadataIdRef:"meta${idx}")
- 'nmwg:eventType'("success.mp.sshtelnet")
- }
- 'nmwg:data'(id:"resultCodeData_meta${idx}",
metadataIdRef:"resultCodeMeta_meta${idx}") {
-
'nmwgr:datum'('xmlns:nmwgr':"http://ggf.org/ns/nmwg/result/2.0/",
"Successfully executed request")
- }
-
- idx++
- }
- }
- new Response(new StringReader(writer.toString()))
- }
-
- public static Reader toLSResponse(String id) {
- def writer = new StringWriter()
- MarkupBuilder xml = new MarkupBuilder(writer)
-
xml.'nmwg:message'('xmlns:nmwg':'http://ggf.org/ns/nmwg/base/2.0/',
id:"${id}_resp", messageIdRef:id, type:"LSRegisterResponse") {
- 'nmwg:metadata'(id:"meta") {
- 'nmwg:eventType' "success"
- 'nmwg:key' "${id}"
- }
- 'nmwg:data'(id:"data", metadataIdRef:"meta")
- }
-
- new StringReader(writer.toString())
- }
-}
Modified:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/PerfSONARClient.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/PerfSONARClient.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/PerfSONARClient.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -6,6 +6,7 @@
import net.geant.perfsonar.PerfSONAR;
import net.geant.perfsonar.mp.sshtelnet.Command;
+import net.geant.perfsonar.templates.NMWG;
import org.xml.sax.SAXException;
Modified:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/PerfSONARServiceClient.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/PerfSONARServiceClient.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/PerfSONARServiceClient.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -9,6 +9,8 @@
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
+import net.geant.perfsonar.templates.NMWG;
+
import org.xml.sax.SAXException;
Modified:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/Response.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/Response.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/Response.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -14,7 +14,7 @@
this.input = new InputStreamReader(input);
}
- protected Response(Reader input) {
+ public Response(Reader input) {
this.input = input;
}
Deleted:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/SelfTestResult.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/SelfTestResult.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/helpers/SelfTestResult.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,21 +0,0 @@
-package net.geant.perfsonar.helpers;
-
-public class SelfTestResult {
- protected String name;
- protected String message;
- protected String status;
-
- private SelfTestResult(String name, String message, String status) {
- this.name = name;
- this.message = message;
- this.status = status;
- }
-
- public static SelfTestResult failure(String name, String message) {
- return new SelfTestResult(name, message, "failure");
- }
-
- public static SelfTestResult success(String name, String message) {
- return new SelfTestResult(name, message, "success");
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/messaging/xpath/XPathDeserializerTest.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/xpath/XPathDeserializerTest.java
2013-01-09 22:53:48 UTC (rev 6088)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/messaging/xpath/XPathDeserializerTest.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,94 +0,0 @@
-package net.geant.perfsonar.xpath;
-
-import static net.geant.perfsonar.xpath.XPathDeserializer.any;
-import static net.geant.perfsonar.xpath.XPathDeserializer.declarePrefix;
-import static net.geant.perfsonar.xpath.XPathDeserializer.getReference;
-import static net.geant.perfsonar.xpath.XPathDeserializer.identifier;
-import static net.geant.perfsonar.xpath.XPathDeserializer.whenXPath;
-import static org.junit.Assert.assertEquals;
-
-import java.io.Reader;
-import java.net.InetAddress;
-import java.util.Arrays;
-
-import net.geant.perfsonar.helpers.NMWG;
-import net.geant.perfsonar.mp.sshtelnet.Command;
-import net.geant.perfsonar.mp.sshtelnet.Router;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class XPathDeserializerTest {
- private static final String REQUEST_ID = "1";
-
- private Router[] routers;
- private Reader reader;
- private XPathDeserializer deserializer;
-
- @Before
- public void givenMessageAndDeserializationConfigured() throws
Exception {
-
- routers = new Router[] {
- new Router("metadata0", "test1",
-
InetAddress.getAllByName("192.168.1.1")[0],
- Command.PING_IPV6),
- new Router("metadata1", "test2",
-
InetAddress.getAllByName("192.168.1.2")[0],
- Command.SHOW_ENVIRONMENT) };
-
- reader = NMWG.toMetadataKeyResponse(REQUEST_ID,
routers).getReader();
-
- declarePrefix("nmwg", "http://ggf.org/ns/nmwg/base/2.0/");
- declarePrefix("nmwgr", "http://ggf.org/ns/nmwg/result/2.0/");
-
-
whenXPath("nmwg:message/nmwg:metadata[starts-with(@id,'metadata')]/@id")
- .then(Router.class).setId(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:metadata/nmwg:subject[starts-with(@id, 'subject')]/text()")
-
.then(Router.class).setName(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:metadata[starts-with(nmwg:subject/@id,
'subject')]/nmwg:parameters/nmwg:parameter[@name='url']/@value")
-
.then(Router.class).setAddress(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/@metadataIdRef")
- .then(Command.class).setCurrentRouter(
- getReference(Router.class,
identifier(Router.class).getId()));
-
- whenXPath(
-
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/nmwgr:datum/nmwg:parameters/nmwg:parameter[@name='command']/@value")
-
.then(Command.class).setName(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/nmwgr:datum/nmwg:parameters/nmwg:parameter[@name='description']/@value")
-
.then(Command.class).setDescription(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/nmwgr:datum/nmwg:parameters/nmwg:parameter[@name='syntax']/@value")
-
.then(Command.class).setSyntax(any(String.class));
-
- deserializer = new XPathDeserializer();
- }
-
- @After
- public void clearConfiguration() {
- XPathDeserializer.clearConfiguration();
- }
-
- @Test @Ignore
- public void shouldReturnRouters() throws Exception {
-
- assertEquals(Arrays.asList(
- Command.PING_IPV6,
- Command.SHOW_ENVIRONMENT,
- new Router("metadata0", "test1", InetAddress
-
.getAllByName("192.168.1.1")[0]),
- new Router("metadata1", "test2", InetAddress
-
.getAllByName("192.168.1.2")[0])),
- deserializer.deserialize(reader));
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/Command.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/Command.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/Command.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,163 +0,0 @@
-package net.geant.perfsonar.mp.sshtelnet;
-
-import java.io.IOException;
-
-public class Command {
-
- public static final Command PING = new Command("ping", "ping an [ip
address]", "[ip address]", "IP_PING");
-
- public static Command SHOW_ENVIRONMENT = new Command("show
environment", "show chassis environment", "",
"http://schemas.perfsonar.net/tools/sshtelnet/STATUS_SHOW_ENVIRONMENT/1.0");
-
- public static final Command TRACE_IPV4 = new Command("trace", "trace
the IPv4 path to [ip address]", "[ip address]",
"http://schemas.perfsonar.net/tools/sshtelnet/IP_TRACEROUTE/1.0");
-
- public static final Command TRACE_IPV6 = new Command("trace ipv6",
"trace the ipv6 path to [IPv6 address]", "[IPv6 address]",
"http://schemas.perfsonar.net/tools/sshtelnet/IPv6_TRACEROUTE/1.0");
-
- public static final Command SHOW_INTERFACES_FILTERS = new
Command("show interfaces filters", "display ip access lists", "",
"http://schemas.perfsonar.net/tools/sshtelnet/IP_ACCESS_LIST/1.0");
-
- //public static final Command SHOW_IPV6_INTERFACES_FILTERS = new
Command("show interfaces filters", "display IPv6 access lists");
-
- public static final Command SHOW_IPV6_INTERFACES = new Command("show
interfaces", "display the interfaces which are configured for IPv6",
"[interface] extensive",
"http://schemas.perfsonar.net/tools/sshtelnet/IPv6_INTERFACES/1.0");
-
- public static final Command PING_IPV6 = new Command("ping inet6",
"ping an [IPv6 address]", "[IPv6 address]",
"http://schemas.perfsonar.net/tools/sshtelnet/IPv6_PING/1.0");
-
- public static final Command TRACEROUTER_IPV6 = new
Command("traceroute inet6", "trace the ipv6 path to [ipv6 address]", "[IPv6
address]",
"http://schemas.perfsonar.net/tools/sshtelnet/IPv6_TRACEROUTE/1.0");
-
- private static Router currentRouter;
-
- private String routerName;
-
- private String name;
- private String description;
- private String syntax;
-
- private Router router;
-
- private String eventType;
-
- private Command(String name, String description, String syntax,
String eventType) {
- this(currentRouter, name, description, syntax, eventType);
- }
-
- private Command(Router router, String name, String description,
String syntax, String eventType) {
- this.router = router;
- this.name = name;
- this.description = description;
- this.syntax = syntax;
- this.eventType = eventType;
- }
-
- public Command() {
- this(currentRouter, null, null, null, null);
- }
-
- public String getEventType() {
- return eventType;
- }
-
- public void setEventType(String eventType) {
- this.eventType = eventType;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getSyntax() {
- return syntax;
- }
-
- public void execute() throws IOException {
- //router.execute(this);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((description == null) ? 0 :
description.hashCode());
- result = prime * result + ((name == null) ? 0 :
name.hashCode());
- result = prime * result + ((syntax == null) ? 0 :
syntax.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Command other = (Command) obj;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- if (syntax == null) {
- if (other.syntax != null)
- return false;
- } else if (!syntax.equals(other.syntax))
- return false;
- return true;
- }
-
- public void setCurrentRouter(Router router) {
- Command.currentRouter = router;
- this.router = router;
- }
-
- public void setRouter(Router router) {
- this.router = router;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public void setSyntax(String syntax) {
- this.syntax = syntax;
- }
-
- @Override
- public String toString() {
- return "Command [name=" + name + ", description=" +
description
- + ", syntax=" + syntax + ", router=" +
(router != null ? router.getName() : routerName) + "]";
- }
-
- public String getResult() {
- return "For address family: IPv4 Unicast@@@@@@For address
family: IPv6 Unicast@@@@@@For address family: VPNv4 Unicast@@@@@@For address
family: IPv4 Multicast@@@@@@For address family: IPv6 Multicast@@@@@@For
address family: NSAP Unicast@@@---END---";
- }
-
- public String getRouterName() {
- return routerName;
- }
-
- public void setRouterName(String routerName) {
- this.routerName = routerName;
- }
-
- public Command newInstance() {
- final Command result = new Command();
- result.setDescription(this.description);
- result.setEventType(this.eventType);
- result.setName(this.name);
- result.setRouterName(this.routerName);
- result.setSyntax(this.syntax);
- return result;
- }
-}
Deleted:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/Router.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/Router.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/Router.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,148 +0,0 @@
-package net.geant.perfsonar.mp.sshtelnet;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class Router {
-
- private static final int PORT_UNDEFINED = -1;
-
- public String name;
-
- public InetAddress address;
-
- public int port;
-
- private String id;
-
- private List<Command> commands = new ArrayList<Command>();
-
- public Router() {
-
- }
-
- public Router(String id, String name, InetAddress address, Command...
commands) {
- this(id, name, address, PORT_UNDEFINED, commands);
- }
-
- public Router(String id, String name, InetAddress address, int port,
Command... commands) {
- this.id = id;
- this.name = name;
- this.address = address;
- this.port = port;
- for (Command c : commands) {
- c.setRouter(this);
- addCommand(c);
- }
- }
-
- public String getName() {
- return name;
- }
-
- public InetAddress getAddress() {
- return address;
- }
-
- public int getPort() {
- return port;
- }
-
- public void addCommand(Command command) {
- commands.add(command);
- }
-
- public List<Command> getCommands() {
- return Collections.unmodifiableList(commands);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((address == null) ? 0 :
address.hashCode());
- result = prime * result
- + ((commands == null) ? 0 :
commands.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((name == null) ? 0 :
name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Router other = (Router) obj;
- if (address == null) {
- if (other.address != null)
- return false;
- } else if (!address.equals(other.address))
- return false;
- if (commands == null) {
- if (other.commands != null)
- return false;
- } else if (!commands.equals(other.commands))
- return false;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
-
-// public RouterConnection connect() throws IOException {
-// //return connectionManager.connect(url, port);
-// return null;
-// }
-
- @Override
- public String toString() {
- return "Router [name=" + name + ", address=" + address + ",
id=" + id
- + ", commands=" + commands + "]";
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setAddress(String address) throws UnknownHostException {
- this.address = InetAddress.getAllByName(address)[0];
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- public void startAddingCommands(String routerId) {
- // TODO Auto-generated method stub
-
- }
-
-// public void execute(Command command) throws IOException {
-// RouterConnection conn = null;
-// try {
-// conn = connect();
-// //command.result =
device.filter(conn.execute(device.toCommand(command)));
-// } finally {
-// if (conn != null)
-// conn.close();
-// }
-// }
-}
Modified:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/SSHTelnetMPService.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/SSHTelnetMPService.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/mp/sshtelnet/SSHTelnetMPService.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -2,31 +2,29 @@
import static net.geant.perfsonar.Configuration.configure;
import static net.geant.perfsonar.Configuration.when;
-import static net.geant.perfsonar.LSRegistrationTask.registerToLookupService;
-import static net.geant.perfsonar.xpath.XPathDeserializer.any;
-import static net.geant.perfsonar.xpath.XPathDeserializer.whenXPath;
+import static net.geant.perfsonar.messaging.XPathDeserializer.any;
+import static net.geant.perfsonar.messaging.XPathDeserializer.whenXPath;
import javax.xml.ws.WebServiceProvider;
-import net.geant.perfsonar.LSRegistrationTask;
import net.geant.perfsonar.PerfSONAR;
import net.geant.perfsonar.ServiceType;
@WebServiceProvider
public class SSHTelnetMPService extends PerfSONAR {
- private static final int HOUR = 60 * 60;
+// private static final int HOUR = 60 * 60;
+//
+// private static final int SECOND = 1;
- private static final int SECOND = 1;
+ //private final LSRegistrationTask lsRegistrationTask = new
LSRegistrationTask(logger, this);
+// private int lsInterval = HOUR;
- private final LSRegistrationTask lsRegistrationTask = new
LSRegistrationTask(logger, this);
- private int lsInterval = HOUR;
-
public SSHTelnetMPService() {
super();
- scheduler.runEvery(HOUR, lsRegistrationTask);
- scheduler.runEvery(SECOND, new
ConfigurationFileChecker(this));
+ /*scheduler.runEvery(HOUR, lsRegistrationTask);
+ scheduler.runEvery(SECOND, new
ConfigurationFileChecker(this));*/
}
@Override
@@ -47,8 +45,8 @@
configure(when("SetupDataRequest").then(ServiceController.class)
.execute(any(Command.class)));
-
configure(registerToLookupService(ServiceController.class)
- .listAvailableRoutersAndCommands());
+//
configure(registerToLookupService(ServiceController.class)
+// .listAvailableRoutersAndCommands());
whenXPath(
"nmwg:message/nmwg:metadata/nmwg:subject/nmwgtopo:endPoint/text()")
@@ -76,17 +74,17 @@
* Sets timeout in seconds between subsequent
registrations/keepalives to Lookup
* Service.
*/
- public synchronized void setLookupServiceInterval(String interval) {
- lsInterval = Integer.parseInt(interval);
- scheduler.stop(lsRegistrationTask);
- scheduler.runEvery(lsInterval, lsRegistrationTask);
- }
+// public synchronized void setLookupServiceInterval(String interval) {
+// lsInterval = Integer.parseInt(interval);
+// scheduler.stop(lsRegistrationTask);
+// scheduler.runEvery(lsInterval, lsRegistrationTask);
+// }
/**
* Returns timeout in seconds between subsequent
registrations/keepalives to Lookup
* Service.
*/
- public synchronized int getLookupServiceInterval() {
- return lsInterval;
- }
+// public synchronized int getLookupServiceInterval() {
+// return lsInterval;
+// }
}
Deleted:
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/xpath/XPathDeserializerTest.java
===================================================================
---
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/xpath/XPathDeserializerTest.java
2013-02-18 19:56:18 UTC (rev 6147)
+++
trunk/psBase3/perfsonar-base/src/test/java/net/geant/perfsonar/xpath/XPathDeserializerTest.java
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,103 +0,0 @@
-package net.geant.perfsonar.xpath;
-
-import static net.geant.perfsonar.xpath.XPathDeserializer.any;
-import static net.geant.perfsonar.xpath.XPathDeserializer.declarePrefix;
-import static net.geant.perfsonar.xpath.XPathDeserializer.getReference;
-import static net.geant.perfsonar.xpath.XPathDeserializer.identifier;
-import static net.geant.perfsonar.xpath.XPathDeserializer.whenXPath;
-import static org.junit.Assert.assertEquals;
-
-import java.io.Reader;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import net.geant.perfsonar.helpers.NMWG;
-import net.geant.perfsonar.mp.sshtelnet.Command;
-import net.geant.perfsonar.mp.sshtelnet.Router;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.xml.sax.InputSource;
-
-public class XPathDeserializerTest {
- private static final String REQUEST_ID = "1";
-
- private Router[] routers;
- private Reader reader;
- private XPathDeserializer deserializer;
-
- @Before
- public void givenMessageAndDeserializationConfigured() throws
Exception {
-
- routers = new Router[] {
- new Router("metadata0", "test1",
-
InetAddress.getAllByName("192.168.1.1")[0],
- Command.PING_IPV6),
- new Router("metadata1", "test2",
-
InetAddress.getAllByName("192.168.1.2")[0],
- Command.SHOW_ENVIRONMENT) };
-
- reader = NMWG.toMetadataKeyResponse(REQUEST_ID,
routers).getReader();
-
- declarePrefix("nmwg", "http://ggf.org/ns/nmwg/base/2.0/");
- declarePrefix("nmwgr", "http://ggf.org/ns/nmwg/result/2.0/");
-
-
whenXPath("nmwg:message/nmwg:metadata[starts-with(@id,'metadata')]/@id")
- .then(Router.class).setId(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:metadata/nmwg:subject[starts-with(@id, 'subject')]/text()")
-
.then(Router.class).setName(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:metadata[starts-with(nmwg:subject/@id,
'subject')]/nmwg:parameters/nmwg:parameter[@name='url']/@value")
-
.then(Router.class).setAddress(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/@metadataIdRef")
- .then(Command.class).setCurrentRouter(
- getReference(Router.class,
identifier(Router.class).getId()));
-
- whenXPath(
-
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/nmwgr:datum/nmwg:parameters/nmwg:parameter[@name='command']/@value")
-
.then(Command.class).setName(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/nmwgr:datum/nmwg:parameters/nmwg:parameter[@name='description']/@value")
-
.then(Command.class).setDescription(any(String.class));
-
- whenXPath(
-
"nmwg:message/nmwg:data[starts-with(@metadataIdRef,
'metadata')]/nmwgr:datum/nmwg:parameters/nmwg:parameter[@name='syntax']/@value")
-
.then(Command.class).setSyntax(any(String.class));
-
- deserializer = new XPathDeserializer();
- }
-
- @After
- public void clearConfiguration() {
- XPathDeserializer.clearConfiguration();
- }
-
- @Test
- public void shouldReturnRouters() throws Exception {
- final List<Object> actual = (List<Object>)
deserializer.deserialize(new InputSource(reader));
-
- assertEquals(Arrays.asList(Command.PING_IPV6,
Command.SHOW_ENVIRONMENT), getObjects(Command.class, actual));
- assertEquals(Arrays.asList(new Router("metadata0", "test1",
InetAddress.getAllByName("192.168.1.1")[0]),
- new Router("metadata1", "test2",
InetAddress.getAllByName("192.168.1.2")[0])), getObjects(Router.class,
actual));
- }
-
- @SuppressWarnings("unchecked")
- private <T> List<T> getObjects(Class<T> type, List<Object> objects) {
- final List<T> result = new ArrayList<T>();
- for (Object obj : objects) {
- if (obj.getClass().equals(type)) {
- result.add((T) obj);
- }
- }
- return result;
- }
-}
Deleted: trunk/psBase3/perfsonar-base/src/test/resources/configuration.xml
===================================================================
--- trunk/psBase3/perfsonar-base/src/test/resources/configuration.xml
2013-02-18 19:56:18 UTC (rev 6147)
+++ trunk/psBase3/perfsonar-base/src/test/resources/configuration.xml
2013-02-18 20:07:41 UTC (rev 6148)
@@ -1,132 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
-<configuration xmlns="http://service.perfsonar.org/ns/config/base/0.9/">
- <service name="sshtelnet-mp">
- <lookupInformation>
- <option name="accessPoint"
value="http://localhost:${tomcat.port}/${project.artifactId}/services/SSHTelnet"/>
- <option name="serviceName" value="Geant3 JAVA - SSHTelnet MP"/>
- <option name="serviceType" value="MP"/>
- </lookupInformation>
-
- <!-- Message Handlers - message types and service engines -->
-
- <messageHandler>
-
- <message type="EchoRequest"
-
handler="org.perfsonar.base2.service.messages.GenericMessageHandler">
- <option name="ServiceEngine"
-
value="org.perfsonar.service.measurementPoint.EchoServiceEngine" />
- <option name="authN" value="no" />
- </message>
-
- <message type="MetadataKeyRequest"
-
handler="org.perfsonar.base2.service.messages.GenericMessageHandler">
- <option name="ServiceEngine"
-
value="org.perfsonar.service.measurementPoint.ServiceCapabilitiesEngine" />
- <option name="authN" value="no" />
- </message>
-
- <message type="SetupDataRequest"
-
handler="org.perfsonar.base2.service.messages.GenericMessageHandler">
- <option name="ServiceEngine"
-
value="org.perfsonar.service.measurementPoint.SetupDataServiceEngine" />
- <option name="authN" value="no" />
- </message>
-
- </messageHandler>
-
- <!-- Additional auxiliary components -->
-
- <auxiliaryComponents>
- <component name="migrator"
className="org.perfsonar.base2.service.configuration.migration.MigratorComponent">
- <option name="config-directory" value="${old-config-directory}" />
- </component>
- <component name="XMLDB"
className="org.perfsonar.base2.service.storage.xml.XMLDBComponent">
- <option name="dataStorageClassName"
value="org.perfsonar.base2.service.storage.xml.exist.ExistHTTPDataStorage" />
- <option name="uri"
value="http://localhost:${tomcat.port}/exist/rest/db"/>
- <option name="username" value="sshtelnet"/>
- <option name="password" value="sshtelnet"/>
- </component>
-
- <component name="Configuration"
className="org.perfsonar.service.measurementPoint.Configuration">
- <option name="metadata-file"
value="${config.path}/sshtelnetmetadata.xml" />
- <option name="token-path" value="${token.path}" />
- </component>
-
- <!-- auth configuration -->
- <component name="auth"
className="org.perfsonar.base2.service.authn.component.wssec.WSSecAuthNComponent">
- <option name="as_endpoint"
value="http://homer.rediris.es:8080/geant2-java-as-1.2/services/SimpleService"/>
- <option name="comp_id" value="urn:compId"/>
- </component>
-
- <!-- Scheduler -->
- <component name="scheduling"
className="org.perfsonar.base2.service.scheduler.SchedulingComponent">
- <option name="schedulerClassName"
value="org.perfsonar.base2.service.scheduler.SimpleScheduler"/>
- <option name="interval" value="60"/>
-
- <actions>
- <action name="registration"
className="org.perfsonar.base2.service.registration.LSRegistrationAction">
- <option name="status" value="on" />
- <option name="interval" value="2" />
- <option name="registerDataSource"
value="org.perfsonar.base2.service.registration.MetadataExistDBRegisterDataSource"/>
- <option name="registerEventType"
value="http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/registration/summary/2.0"/>
- <option name="registrator"
value="org.perfsonar.base2.service.registration.GenericLSRegistrator"/>
- <option name="lsAddress-1"
value="http://localhost:9000/perfsonar-ls"/>
- </action>
-
- <!-- Checks whether a given metadata file has changed and updates
it in the database.
- If the given metadata file is not stored in the database it
is added. -->
- <action name="metadata-updater"
className="org.perfsonar.service.measurementPoint.MetadataUpdater">
- <!-- Should the user configured in the "Configuration" section
be created if it does not exist -->
- <option name="create-user" value="yes" />
-
- <!-- login and password for the user that has rights to create
user accounts. Obligatory only when "create-user" option is set to "yes" -->
- <option name="username" value="admin" />
- <option name="password" value="" />
- </action>
- </actions>
- </component>
- </auxiliaryComponents>
-
- <extension name="registerExtension-registerDataSource">
- <option name="exist-config" value="XMLDB" />
- </extension>
-
- <!--
....................................................................................
-->
-
- <!-- Protocol mappings, XML elements and their bingings -->
-
- <protocolMappings>
-
-
- <!-- default mapping -->
-
-
- <!-- general mappings -->
- <element name="{*}message"
- mapping="org.perfsonar.base2.xml.nmwg.Message"/>
- <element name="{*}metadata"
- mapping="org.perfsonar.base2.xml.nmwg.Metadata"/>
- <element name="{*}eventType"
- mapping="org.perfsonar.base2.xml.nmwg.EventType"/>
- <element name="{*}data"
- mapping="org.perfsonar.base2.xml.nmwg.Data"/>
- <element name="{*}subject"
- mapping="org.perfsonar.base2.xml.nmwg.Subject"/>
- <element name="{*}parameters"
- mapping="org.perfsonar.base2.xml.nmwg.Parameters"/>
- <element name="{*}parameter"
- mapping="org.perfsonar.base2.xml.nmwg.Parameter"/>
- <element name="*"
- mapping="org.perfsonar.base2.xml.Element"/>
- <element
name="{http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/1.0/}subject"
- mapping="org.perfsonar.base2.xml.TextElement"/>
-
-
- </protocolMappings>
-
-
- </service>
-
-
-</configuration>
- [pS-dev] [GEANT/SA2/ps-java-services] r6148 - in trunk/psBase3/perfsonar-base: . src/main/java/net/geant/perfsonar src/main/java/net/geant/perfsonar/nmwg/response src/main/java/net/geant/perfsonar/response src/main/java/net/geant/perfsonar/xpath src/test/java/net/geant/perfsonar src/test/java/net/geant/perfsonar/helpers src/test/java/net/geant/perfsonar/messaging src/test/java/net/geant/perfsonar/messaging/xpath src/test/java/net/geant/perfsonar/mp/sshtelnet src/test/java/net/geant/perfsonar/xpath src/test/resources, svn-noreply, 02/18/2013
Archive powered by MHonArc 2.6.16.