perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r6352 - in trunk/perfsonar-base/apt: . annotated annotated/net annotated/net/geant annotated/net/geant/perfsonar dummyservice/net/geant/perfsonar/dummyservice/xpath src/main/java/net/geant/perfsonar/annotations src/main/java/net/geant/perfsonar/annotations/ls src/main/java/net/geant/perfsonar/annotations/request src/main/java/net/geant/perfsonar/annotations/selftest src/main/java/net/geant/perfsonar/annotations/xpath src/test/java/net/geant/perfsonar/annotations src/test/java/net/geant/perfsonar/annotations/selftest src/test/java/net/geant/perfsonar/annotations/selftest/compiler
Subject: perfsonar development work
List archive
[pS-dev] [GEANT/SA2/ps-java-services] r6352 - in trunk/perfsonar-base/apt: . annotated annotated/net annotated/net/geant annotated/net/geant/perfsonar dummyservice/net/geant/perfsonar/dummyservice/xpath src/main/java/net/geant/perfsonar/annotations src/main/java/net/geant/perfsonar/annotations/ls src/main/java/net/geant/perfsonar/annotations/request src/main/java/net/geant/perfsonar/annotations/selftest src/main/java/net/geant/perfsonar/annotations/xpath src/test/java/net/geant/perfsonar/annotations src/test/java/net/geant/perfsonar/annotations/selftest src/test/java/net/geant/perfsonar/annotations/selftest/compiler
Chronological Thread
- From:
- To:
- Subject: [pS-dev] [GEANT/SA2/ps-java-services] r6352 - in trunk/perfsonar-base/apt: . annotated annotated/net annotated/net/geant annotated/net/geant/perfsonar dummyservice/net/geant/perfsonar/dummyservice/xpath src/main/java/net/geant/perfsonar/annotations src/main/java/net/geant/perfsonar/annotations/ls src/main/java/net/geant/perfsonar/annotations/request src/main/java/net/geant/perfsonar/annotations/selftest src/main/java/net/geant/perfsonar/annotations/xpath src/test/java/net/geant/perfsonar/annotations src/test/java/net/geant/perfsonar/annotations/selftest src/test/java/net/geant/perfsonar/annotations/selftest/compiler
- Date: Mon, 6 May 2013 14:09:23 +0100 (BST)
- Authentication-results: sfpop-ironport02.merit.edu; dkim=neutral (message not signed) header.i=none
Author: psnc.pietrzak
Date: 2013-05-06 14:09:23 +0100 (Mon, 06 May 2013)
New Revision: 6352
Added:
trunk/perfsonar-base/apt/annotated/net/
trunk/perfsonar-base/apt/annotated/net/geant/
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/Handlers.java
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/LookupServiceRegister.java
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/SelfTestsConfiguration.java
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/XPaths.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/Identifier.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/XPaths.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/EnvelopedXPath.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/IdentifierValidator.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathValidator.java
Removed:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathCollector.java
Modified:
trunk/perfsonar-base/apt/dummyservice/net/geant/perfsonar/dummyservice/xpath/InvalidXPaths.java
trunk/perfsonar-base/apt/dummyservice/net/geant/perfsonar/dummyservice/xpath/NMWGMessage.java
trunk/perfsonar-base/apt/pom.xml
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/XPath.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/ls/TemplateEngine.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/request/TemplateEngine.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/selftest/SelfTestProcessor.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/selftest/TemplateEngine.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/TemplateEngine.java
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathProcessor.java
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/XPathProcessorTest.java
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/SelfTestProcessorTest.java
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/BinaryClassLoader.java
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/DiagnosticImpl.java
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/Diagnostics.java
Log:
Improved debugging. Added Identifier and XPaths annotations.
Added: trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/Handlers.java
===================================================================
--- trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/Handlers.java
(rev 0)
+++ trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/Handlers.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,15 @@
+package net.geant.perfsonar;
+
+import static net.geant.perfsonar.Configuration.*;
+import javax.annotation.Generated;
+
+@Generated("net.geant.perfsonar.annotations.request.TemplateEngine")
+public class Handlers {
+
+ public Handlers() {
+ try {
+
configure(when("SetupDataRequest").then(net.geant.perfsonar.dummyservice.ServiceController.class).execute(any(java.lang.String.class)));
+
configure(when("MetadataKeyRequest").then(net.geant.perfsonar.dummyservice.ServiceController.class).listAvailableRouters());
+ } catch (Exception ex) { }
+ }
+}
Added:
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/LookupServiceRegister.java
===================================================================
---
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/LookupServiceRegister.java
(rev 0)
+++
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/LookupServiceRegister.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,15 @@
+package net.geant.perfsonar;
+
+import static net.geant.perfsonar.ls.LSRegistrationTask.*;
+import static net.geant.perfsonar.Configuration.*;
+import javax.annotation.Generated;
+
+@Generated("net.geant.perfsonar.annotations.ls.TemplateEngine")
+public class LookupServiceRegister {
+
+ public LookupServiceRegister() {
+ try {
+
configure(registerToLookupService(net.geant.perfsonar.dummyservice.ServiceController.class).listAvailableRouters());
+ } catch (Exception ex) { }
+ }
+}
Added:
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/SelfTestsConfiguration.java
===================================================================
---
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/SelfTestsConfiguration.java
(rev 0)
+++
trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/SelfTestsConfiguration.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,22 @@
+package net.geant.perfsonar;
+
+import static net.geant.perfsonar.selftest.SelfTestRunner.addSelfTest;
+import static net.geant.perfsonar.selftest.SelfTestRunner.any;
+import static net.geant.perfsonar.selftest.SelfTestRunner.configureForType;
+import static net.geant.perfsonar.selftest.SelfTestRunner.selfTestData;
+import javax.annotation.Generated;
+
+@Generated("net.geant.perfsonar.annotations.selftest.TemplateEngine")
+public class SelfTestsConfiguration {
+ public SelfTestsConfiguration() {
+ try {
+ addSelfTest("add string ${index}", "Added ${arg}.",
net.geant.perfsonar.dummyservice.selftest.ValidSelfTests.class).add(any(java.lang.String.class));
+ configureForType(java.lang.String.class,
selfTestData(net.geant.perfsonar.dummyservice.selftest.ValidSelfTests.class).getStringValues());
+ addSelfTest("checked exception", "Exception was not thrown.",
net.geant.perfsonar.dummyservice.selftest.ValidSelfTests.class).throwCheckedException();
+ addSelfTest("independent", "Self tests are independent from each
other.",
net.geant.perfsonar.dummyservice.selftest.ValidSelfTests.class).independent();
+ addSelfTest("constant", "Added constant.",
net.geant.perfsonar.dummyservice.selftest.ValidSelfTests.class).addConstant();
+ addSelfTest("add integer ${index}", "Added ${arg} at ${index}.",
net.geant.perfsonar.dummyservice.selftest.ValidSelfTests.class).add(any(java.lang.Integer.class));
+ configureForType(java.lang.Integer.class,
selfTestData(net.geant.perfsonar.dummyservice.selftest.ValidSelfTests.class).getIntegers());
+ } catch (Exception ex) { }
+ }
+}
Added: trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/XPaths.java
===================================================================
--- trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/XPaths.java
(rev 0)
+++ trunk/perfsonar-base/apt/annotated/net/geant/perfsonar/XPaths.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,16 @@
+package net.geant.perfsonar;
+
+import static net.geant.perfsonar.messaging.XPathDeserializer.any;
+import static net.geant.perfsonar.messaging.XPathDeserializer.declarePrefix;
+import static net.geant.perfsonar.messaging.XPathDeserializer.identifier;
+import static net.geant.perfsonar.messaging.XPathDeserializer.whenXPath;
+import javax.annotation.Generated;
+
+@Generated("net.geant.perfsonar.annotations.xpath.TemplateEngine")
+public class XPaths {
+
+ public XPaths() {
+ try {
+ } catch (Exception ex) { }
+ }
+}
Modified:
trunk/perfsonar-base/apt/dummyservice/net/geant/perfsonar/dummyservice/xpath/InvalidXPaths.java
===================================================================
---
trunk/perfsonar-base/apt/dummyservice/net/geant/perfsonar/dummyservice/xpath/InvalidXPaths.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/dummyservice/net/geant/perfsonar/dummyservice/xpath/InvalidXPaths.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -1,10 +1,23 @@
package net.geant.perfsonar.dummyservice.selftest;
+import static net.geant.perfsonar.messaging.XPathDeserializer.any;
+import static net.geant.perfsonar.messaging.XPathDeserializer.whenXPath;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
+import javax.xml.xpath.XPathException;
+
+import org.junit.Test;
+import org.xml.sax.InputSource;
+
import net.geant.perfsonar.annotations.Namespace;
import net.geant.perfsonar.annotations.XPath;
import net.geant.perfsonar.annotations.selftest.*;
+import net.geant.perfsonar.messaging.DeserializationException;
public abstract class InvalidXPaths {
private String id;
@@ -22,15 +35,4 @@
namespaces=@Namespace(prefix="nmwg",
uri="http://ggf.org/ns/nmwg/base/2.0/"))
private static void publicNonStaticAreAllowed(String arg) {
}
-
- @XPath(xpath="nmwg:message/@id",
-
namespaces=@Namespace(prefix="nmwg",
uri="http://ggf.org/ns/nmwg/base/2.0/"))
- public void invalidArgumentType(Integer value) {
- }
-
- @XPath(xpath="nmwg:message/@id",
-
namespaces=@Namespace(prefix="nmwg",
uri="http://ggf.org/ns/nmwg/base/2.0/"))
- public String voidMethodIsAllowed(String value) {
- return null;
- }
}
Modified:
trunk/perfsonar-base/apt/dummyservice/net/geant/perfsonar/dummyservice/xpath/NMWGMessage.java
===================================================================
---
trunk/perfsonar-base/apt/dummyservice/net/geant/perfsonar/dummyservice/xpath/NMWGMessage.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/dummyservice/net/geant/perfsonar/dummyservice/xpath/NMWGMessage.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -1,6 +1,8 @@
package net.geant.perfsonar.dummyservice.xpath;
+import net.geant.perfsonar.annotations.Identifier;
import net.geant.perfsonar.annotations.XPath;
+import net.geant.perfsonar.annotations.XPaths;
import net.geant.perfsonar.annotations.Namespace;
public class NMWGMessage {
@@ -9,16 +11,20 @@
private static final String NMWG_URI =
"http://ggf.org/ns/nmwg/base/2.0/";
- @XPath(xpath="nmwg:message/@id",
namespaces=@Namespace(prefix="nmwg",
uri=NMWG_URI))
+ @XPaths({
+ @XPath(xpath="nmwg:message/nmwg:metadata/@metadataIdRef"),
+ @XPath(xpath="nmwg:message/@id",
namespaces=@Namespace(prefix="nmwg",
uri=NMWG_URI))
+ })
public void setId(String id) {
this.id = id;
}
- @XPath(xpath="nmwg:message/@type",
namespaces=@Namespace(prefix="nmwg",
uri=NMWG_URI))
+ @XPath(xpath="nmwg:message/@type")
public void setType(String type) {
this.type = type;
}
+ @Identifier
public String getId() {
return id;
}
Modified: trunk/perfsonar-base/apt/pom.xml
===================================================================
--- trunk/perfsonar-base/apt/pom.xml 2013-05-06 13:08:11 UTC (rev 6351)
+++ trunk/perfsonar-base/apt/pom.xml 2013-05-06 13:09:23 UTC (rev 6352)
@@ -14,7 +14,7 @@
<name>perfSONAR base 3 APT</name>
<description>The psBase3 Annotation Processing Tool</description>
<packaging>jar</packaging>
-
+
<scm>
<connection>scm:svn:http://svn.geant.net/GEANT/SA2/ps-java-services/trunk/perfsonar-base/apt/</connection>
<developerConnection>scm:svn:svn+ssh:///GEANT/SA2/ps-java-services/trunk/perfsonar-base/apt/</developerConnection>
@@ -50,19 +50,19 @@
</dependency>
<dependency>
<groupId>net.geant.perfsonar.base</groupId>
- <artifactId>base</artifactId>
+ <artifactId>messaging</artifactId>
<version>3.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.geant.perfsonar.base</groupId>
- <artifactId>ls</artifactId>
+ <artifactId>base</artifactId>
<version>3.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.geant.perfsonar.base</groupId>
- <artifactId>messaging</artifactId>
+ <artifactId>ls</artifactId>
<version>3.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Added:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/Identifier.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/Identifier.java
(rev 0)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/Identifier.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,12 @@
+package net.geant.perfsonar.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.SOURCE)
+public @interface Identifier {
+
+}
Modified:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/XPath.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/XPath.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/XPath.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -3,5 +3,5 @@
public @interface XPath {
String xpath();
- Namespace[] namespaces();
+ Namespace[] namespaces() default {};
}
Added:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/XPaths.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/XPaths.java
(rev 0)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/XPaths.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,18 @@
+package net.geant.perfsonar.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Aggregates multiple xpaths for the given method.
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ *
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.SOURCE)
+public @interface XPaths {
+ XPath[] value();
+}
Modified:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/ls/TemplateEngine.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/ls/TemplateEngine.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/ls/TemplateEngine.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -24,7 +24,7 @@
write("@Generated(\"" + getClass().getName() + "\")\n");
write("public class LookupServiceRegister {\n");
write("\n");
- write(" static {\n");
+ write(" public LookupServiceRegister() {\n");
write(" try {\n");
writeHandlerInvocation(handler);
write(" } catch (Exception ex) { }\n");
Modified:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/request/TemplateEngine.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/request/TemplateEngine.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/request/TemplateEngine.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -24,7 +24,7 @@
write("@Generated(\"" + getClass().getName() + "\")\n");
write("public class Handlers {\n");
write("\n");
- write(" static {\n");
+ write(" public Handlers() {\n");
write(" try {\n");
writeHandlerInvocations(handlers);
write(" } catch (Exception ex) { }\n");
Modified:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/selftest/SelfTestProcessor.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/selftest/SelfTestProcessor.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/selftest/SelfTestProcessor.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -64,7 +64,7 @@
private Writer openWriter(Set<? extends Element> elements) throws
IOException {
final Filer filer = processingEnv.getFiler();
- final FileObject out =
filer.createSourceFile("net.geant.perfsonar.SelfTestRunnerImpl",
+ final FileObject out =
filer.createSourceFile("net.geant.perfsonar.SelfTestsConfiguration",
elements.toArray(new Element[0]));
return out.openWriter();
}
Modified:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/selftest/TemplateEngine.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/selftest/TemplateEngine.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/selftest/TemplateEngine.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -19,125 +19,37 @@
this.writer = writer;
write("package net.geant.perfsonar;\n\n");
- write("import java.io.IOException;\n");
- write("import java.text.MessageFormat;\n");
- write("import java.util.List;\n");
+ write("import static
net.geant.perfsonar.selftest.SelfTestRunner.addSelfTest;\n");
+ write("import static
net.geant.perfsonar.selftest.SelfTestRunner.any;\n");
+ write("import static
net.geant.perfsonar.selftest.SelfTestRunner.configureForType;\n");
+ write("import static
net.geant.perfsonar.selftest.SelfTestRunner.selfTestData;\n");
write("import javax.annotation.Generated;\n");
write("\n");
- write("import net.geant.perfsonar.base.Scheduler;\n");
- write("import net.geant.perfsonar.selftest.*;\n");
- write("\n");
write("@Generated(\"" + getClass().getName() + "\")\n");
- write("public class SelfTestRunnerImpl implements
SelfTestRunner {\n");
- write("\n");
- write(" public void runSuite(final Scheduler scheduler,
final SelfTestLogger listener) {\n");
+ write("public class SelfTestsConfiguration {\n");
+ write(" public SelfTestsConfiguration() {\n");
+ write(" try {\n");
writeTestsInvocations(selftestsDG, selfTestData);
+ write(" } catch (Exception ex) { }\n");
write(" }\n");
write("}\n");
}
private void writeTestsInvocations(List<List<ExecutableElement>>
selftestsDG,
Map<TypeMirror, ExecutableElement> selfTestData)
throws IOException {
-
- int i = 0;
+
for (List<ExecutableElement> methods : selftestsDG)
for (ExecutableElement method : methods) {
- if (method.getParameters().size() == 1) {
- write(" int i" + i + " =
0;\n");
- write(" for (");
-
write(method.getParameters().get(0).asType().toString());
- write(" data" + i + " : ");
- write("new " +
method.getEnclosingElement() + "().");
-
write(selfTestData.get(method.getParameters().get(0).asType()).getSimpleName()
+ "()) {\n");
- }
+ write(" addSelfTest(\"" +
method.getAnnotation(SelfTest.class).name() + "\", \"" +
method.getAnnotation(SelfTest.class).successMessage() + "\", " +
method.getEnclosingElement() + ".class)." + method.getSimpleName() + "(");
- executeMethod(i, method);
-
if (method.getParameters().size() == 1) {
- write(" ");
- write("}\n");
- i++;
- }
+ TypeMirror type =
method.getParameters().get(0).asType();
+ write("any(" + type.toString() +
".class));\n");
+ write(" configureForType("
+ type.toString() + ".class, selfTestData(" + method.getEnclosingElement() +
".class)." + selfTestData.get(type).getSimpleName() + "());\n");
+ } else
+ write(");\n");
}
}
-
- private void executeMethod(int i, ExecutableElement method)
- throws IOException {
-
- if (method.getParameters().size() == 1)
- write(" scheduler.runInParallel(new
ParameterizedSelfTestTask<" +
method.getParameters().get(0).asType().toString() + ">(data" + i + ", i" + i
+ ") {\n");
- else
- write(" scheduler.runInParallel(new Runnable()
{\n");
-
- write(" public void run() {\n");
- write(" try {\n");
-
- write(" ");
- if (method.getParameters().size() == 1)
- write(" ");
-
- write("new " + method.getEnclosingElement() + "()");
- write("." + method.getSimpleName() + "(");
- if (method.getParameters().size() == 0)
- write(");\n");
- else {
- write("getData());\n");
- }
-
- write(" ");
- if (method.getParameters().size() == 1)
- write(" ");
-
- write("listener.success(");
-
write(parseMessage(method.getAnnotation(SelfTest.class).name(), i) + ", ");
-
write(parseMessage(method.getAnnotation(SelfTest.class).successMessage(), i)
+ ");\n");
- write(" ");
-
- if (method.getParameters().size() == 1)
- write(" ");
- write("} catch (Throwable t) {\n");
- write(" ");
- if (method.getParameters().size() == 1)
- write(" ");
- write("listener.failure(" +
parseMessage(method.getAnnotation(SelfTest.class).name(), i) + ",
t.getMessage());\n");
- write(" ");
- if (method.getParameters().size() == 1)
- write(" ");
- write("}\n");
- write(" }\n");
- write(" });\n");
- if (method.getParameters().size() == 1) {
- write(" i" + i + "++;\n");
- }
- }
-
- private String parseMessage(String message, int i) {
- int index = 0;
- boolean wasIndex = false;
- boolean wasArg = false;
-
- if (!message.contains("${index}") &&
!message.contains("${arg}"))
- return "\"" + message + "\"";
-
- if (message.contains("${index}")) {
- message = message.replace("${index}", "{0}");
- index++;
- wasIndex = true;
- }
- if (message.contains("${arg}")) {
- message = message.replace("${arg}", "{" + index +
"}");
- wasArg = true;
- }
-
- message = "MessageFormat.format(\"" + message + "\"";
- if (wasIndex)
- message += ", getIndex()";
- if (wasArg)
- message += ", getData()";
- message += ")";
-
- return message;
- }
}
Added:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/EnvelopedXPath.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/EnvelopedXPath.java
(rev 0)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/EnvelopedXPath.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,42 @@
+package net.geant.perfsonar.annotations.xpath;
+
+import net.geant.perfsonar.annotations.XPath;
+
+public class EnvelopedXPath {
+
+ private XPath annotation;
+
+ protected EnvelopedXPath(XPath annotation) {
+ this.annotation = annotation;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((annotation == null) ? 0 :
annotation.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;
+ EnvelopedXPath other = (EnvelopedXPath) obj;
+ if (annotation == null) {
+ if (other.annotation != null)
+ return false;
+ } else if
(!annotation.xpath().equals(other.annotation.xpath()))
+ return false;
+ return true;
+ }
+
+ public XPath getAnnotation() {
+ return annotation;
+ }
+}
Added:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/IdentifierValidator.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/IdentifierValidator.java
(rev 0)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/IdentifierValidator.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,83 @@
+package net.geant.perfsonar.annotations.xpath;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+
+import net.geant.perfsonar.annotations.selftest.AbstractClassChecker;
+import net.geant.perfsonar.annotations.selftest.BaseMethodElementVisitor;
+import net.geant.perfsonar.annotations.selftest.SelfTestProcessorListener;
+
+/**
+ * Checks whether methods annotated with Identifier are valid.
+ *
+ * <p>Valid methods are:
+ * <ul>
+ * <li>with exactly zero arguments</li>
+ * <li>public</li>
+ * <li>non static</li>
+ * <li>cannot be abstract</li>
+ * <li>cannot be final</li>
+ * <li>the enclosing class cannot be abstract</li>
+ * </ul></p>
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ *
+ */
+public class IdentifierValidator extends
BaseMethodElementVisitor<List<ExecutableElement>, SelfTestProcessorListener> {
+
+ final AbstractClassChecker checker = new AbstractClassChecker();
+ final List<TypeElement> abstractClasses = new
ArrayList<TypeElement>();
+
+ private final List<ExecutableElement> ids = new
ArrayList<ExecutableElement>();
+
+ protected IdentifierValidator(List<ExecutableElement> ids) {
+ this.ids.addAll(ids);
+ }
+
+ @Override
+ public List<ExecutableElement> visitExecutable(ExecutableElement
elem, SelfTestProcessorListener listener) {
+ if(isDeclarationViolated(elem, listener))
+ return ids;
+
+ ids.add(elem);
+
+ return ids;
+ }
+
+ protected boolean isDeclarationViolated(ExecutableElement elem,
+ SelfTestProcessorListener listener) {
+ int errorsCount = 0;
+
+ if (super.isDeclarationViolated(elem, listener))
+ errorsCount++;
+
+ if (elem.getModifiers().contains(Modifier.FINAL)) {
+ listener.error("The method cannot be final.", elem);
+ errorsCount++;
+ }
+
+ if (elem.getModifiers().contains(Modifier.STATIC)) {
+ listener.error("The method cannot be static.", elem);
+ errorsCount++;
+ }
+
+ if (elem.isVarArgs() || (elem.getParameters().size() > 0)) {
+ listener.error("The method must have zero
parameters.", elem);
+ errorsCount++;
+ }
+
+ if (checker.isEnclosingClassAbstract(elem)) {
+ if
(!abstractClasses.contains(checker.getEnclosingType(elem))) {
+
abstractClasses.add(checker.getEnclosingType(elem));
+ listener.error("The class cannot be
abstract.", checker.getEnclosingType(elem));
+ errorsCount++;
+ }
+ }
+
+ return (errorsCount > 0);
+ }
+}
Modified:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/TemplateEngine.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/TemplateEngine.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/TemplateEngine.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -2,11 +2,12 @@
import java.io.IOException;
import java.io.Writer;
+import java.lang.annotation.IncompleteAnnotationException;
+import java.util.List;
import java.util.Map;
import javax.lang.model.element.ExecutableElement;
-import net.geant.perfsonar.annotations.XPath;
import net.geant.perfsonar.annotations.Namespace;
public class TemplateEngine {
@@ -16,47 +17,64 @@
writer.write(text);
}
- public void writeXPaths(Writer writer, Map<String, ExecutableElement>
xpaths) throws IOException {
+ public void writeXPaths(Writer writer, Map<EnvelopedXPath,
ExecutableElement> xpaths, List<ExecutableElement> ids) throws IOException {
this.writer = writer;
write("package net.geant.perfsonar;\n\n");
write("import static
net.geant.perfsonar.messaging.XPathDeserializer.any;\n");
write("import static
net.geant.perfsonar.messaging.XPathDeserializer.declarePrefix;\n");
+ write("import static
net.geant.perfsonar.messaging.XPathDeserializer.identifier;\n");
write("import static
net.geant.perfsonar.messaging.XPathDeserializer.whenXPath;\n");
write("import javax.annotation.Generated;\n");
write("\n");
write("@Generated(\"" + getClass().getName() + "\")\n");
write("public class XPaths {\n");
write("\n");
- write(" static {\n");
+ write(" public XPaths() {\n");
write(" try {\n");
+ writeIdentiferInvocations(ids);
writeXPathInvocations(xpaths);
write(" } catch (Exception ex) { }\n");
write(" }\n");
write("}\n");
}
- private void writeXPathInvocations(Map<String, ExecutableElement>
xpaths) throws IOException {
- for (String xpath : xpaths.keySet()) {
+ private void writeIdentiferInvocations(List<ExecutableElement> ids)
throws IOException {
+ for (ExecutableElement method : ids) {
+ write("identifier(");
+
write(method.getEnclosingElement().asType().toString());
+ write(".class).");
+ write(method.getSimpleName().toString());
+ write("();\n");
+ }
+
+ }
+
+ private void writeXPathInvocations(Map<EnvelopedXPath,
ExecutableElement> xpaths) throws IOException {
+ for (EnvelopedXPath xpath : xpaths.keySet()) {
final ExecutableElement method = xpaths.get(xpath);
- for (Namespace namespace :
method.getAnnotation(XPath.class).namespaces()) {
- write(" ");
- write("declarePrefix(\"");
- write(namespace.prefix());
- write("\", \"");
- write(namespace.uri());
- write("\");\n");
+ try {
+ for (Namespace namespace :
xpath.getAnnotation().namespaces()) {
+ write(" ");
+ write("declarePrefix(\"");
+ write(namespace.prefix());
+ write("\", \"");
+ write(namespace.uri());
+ write("\");\n");
+ }
+ } catch (IncompleteAnnotationException ex) {
+ //do nothing when namespaces attribute is not
defined in XPath annotation
}
write(" ");
write("whenXPath(\"");
- write(xpath);
+ write(xpath.getAnnotation().xpath());
write("\").then(");
write(method.getEnclosingElement().asType().toString());
write(".class).");
write(method.getSimpleName().toString());
- write("(any(String.class));\n");
+ write("(any(" +
method.getParameters().get(0).asType().toString() + ".class));\n");
}
}
}
Deleted:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathCollector.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathCollector.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathCollector.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -1,63 +0,0 @@
-package net.geant.perfsonar.annotations.xpath;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.type.TypeKind;
-
-import net.geant.perfsonar.annotations.XPath;
-import net.geant.perfsonar.annotations.selftest.BaseMethodElementVisitor;
-import net.geant.perfsonar.annotations.selftest.SelfTestProcessorListener;
-
-public class XPathCollector extends BaseMethodElementVisitor<Map<String,
ExecutableElement>, SelfTestProcessorListener> {
-
- private final Map<String, ExecutableElement> xpaths
- = new Hashtable<String, ExecutableElement>();
-
- protected XPathCollector(Map<String, ExecutableElement> xpaths) {
-
- this.xpaths.putAll(xpaths);
- }
-
- @Override
- public Map<String, ExecutableElement>
visitExecutable(ExecutableElement elem, SelfTestProcessorListener listener) {
- if(isDeclarationViolated(elem, listener))
- return xpaths;
-
- xpaths.put(elem.getAnnotation(XPath.class).xpath(), elem);
-
- return xpaths;
- }
-
- protected boolean isDeclarationViolated(ExecutableElement elem,
- SelfTestProcessorListener listener) {
- int errorsCount = 0;
-
- if (super.isDeclarationViolated(elem, listener))
- errorsCount++;
-
- if (elem.getReturnType().getKind() != TypeKind.VOID) {
- listener.error("Type of the method must be void.",
elem);
- errorsCount++;
- }
-
- if (elem.getModifiers().contains(Modifier.FINAL)) {
- listener.error("The method cannot be final.", elem);
- errorsCount++;
- }
-
- if (elem.isVarArgs() || (elem.getParameters().size() > 1)) {
- listener.error("The method cannot have more than one
parameter.", elem);
- errorsCount++;
- }
-
- if ((elem.getParameters().size() < 1) ||
(!elem.getParameters().get(0).asType().toString().equals("java.lang.String")))
{
- listener.error("The method must have exactly one
parameter of type java.lang.String", elem);
- errorsCount++;
- }
-
- return (errorsCount > 0);
- }
-}
Modified:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathProcessor.java
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathProcessor.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathProcessor.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -2,7 +2,9 @@
import java.io.IOException;
import java.io.Writer;
+import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -17,28 +19,30 @@
import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
+import net.geant.perfsonar.annotations.Identifier;
import net.geant.perfsonar.annotations.XPath;
-import net.geant.perfsonar.annotations.selftest.AbstractClassChecker;
+import net.geant.perfsonar.annotations.XPaths;
import net.geant.perfsonar.annotations.selftest.SelfTestProcessorListener;
import
net.geant.perfsonar.annotations.selftest.SelfTestProcessorListenerImpl;
-@SupportedAnnotationTypes("net.geant.perfsonar.annotations.XPath")
+/**
+ * Processes methods annotated with XPath annotation.
+ *
+ * <p>Valid methods are:
+ * <ul>
+ * <li>with exactly one argument</li>
+ * <li>public</li>
+ * <li>non static</li>
+ * <li>cannot be abstract</li>
+ * <li>cannot be final</li>
+ * <li>the enclosing class cannot be abstract</li>
+ * </ul></p>
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+@SupportedAnnotationTypes({"net.geant.perfsonar.annotations.XPath",
"net.geant.perfsonar.annotations.XPaths",
"net.geant.perfsonar.annotations.Identifier"})
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class XPathProcessor extends AbstractProcessor {
- private Map<String, ExecutableElement> filter(Map<String,
ExecutableElement> xpaths, SelfTestProcessorListener reporter) {
- final Map<String, ExecutableElement> result = new
Hashtable<String, ExecutableElement>();
- final AbstractClassChecker checker = new
AbstractClassChecker();
- for (String name : xpaths.keySet()) {
- final ExecutableElement method = xpaths.get(name);
- if (!checker.isEnclosingClassAbstract(method))
- result.put(name, method);
- else
- reporter.error("The class cannot be
abstract.", checker.getEnclosingType(method));
- }
-
- return result;
- }
-
@Override
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
@@ -47,16 +51,29 @@
return false;
final SelfTestProcessorListener reporter = new
SelfTestProcessorListenerImpl(processingEnv.getMessager());
- final Map<String, ExecutableElement> xpaths = new
Hashtable<String, ExecutableElement>();
+ final Map<EnvelopedXPath, ExecutableElement> xpaths = new
Hashtable<EnvelopedXPath, ExecutableElement>();
+ final List<ExecutableElement> ids = new
ArrayList<ExecutableElement>();
+ final XPathValidator xpathValidator = new XPathValidator();
+ final IdentifierValidator idValidator = new
IdentifierValidator(ids);
- for (Element method : getXPaths(roundEnv)) {
- xpaths.putAll(method.accept(new
XPathCollector(xpaths), reporter));
+ xpathValidator.setAggregator();
+ for (Element method :
getMethodsAnnotatedWithXPaths(roundEnv)) {
+ xpaths.putAll(method.accept(xpathValidator,
reporter));
}
+ xpathValidator.unsetAggregator();
+ for (Element method : getMethodsAnnotatedWithXPath(roundEnv))
{
+ xpaths.putAll(method.accept(xpathValidator,
reporter));
+ }
+
+ for (Element method :
getMethodsAnnotatedWithIdentifier(roundEnv)) {
+ ids.addAll(method.accept(idValidator, reporter));
+ }
+
Writer writer = null;
try {
- writer = openWriter(getXPaths(roundEnv));
- new TemplateEngine().writeXPaths(writer,
filter(xpaths, reporter));
+ writer =
openWriter(getMethodsAnnotatedWithXPath(roundEnv));
+ new TemplateEngine().writeXPaths(writer, xpaths, ids);
} catch (IOException ex) {
reporter.error(ex.toString());
} finally {
@@ -77,7 +94,15 @@
return out.openWriter();
}
- private Set<? extends Element> getXPaths(RoundEnvironment roundEnv) {
+ private Set<? extends Element>
getMethodsAnnotatedWithXPath(RoundEnvironment roundEnv) {
return roundEnv.getElementsAnnotatedWith(XPath.class);
}
+
+ private Set<? extends Element>
getMethodsAnnotatedWithXPaths(RoundEnvironment roundEnv) {
+ return roundEnv.getElementsAnnotatedWith(XPaths.class);
+ }
+
+ private Set<? extends Element>
getMethodsAnnotatedWithIdentifier(RoundEnvironment roundEnv) {
+ return roundEnv.getElementsAnnotatedWith(Identifier.class);
+ }
}
Copied:
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathValidator.java
(from rev 6179,
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathCollector.java)
===================================================================
---
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathValidator.java
(rev 0)
+++
trunk/perfsonar-base/apt/src/main/java/net/geant/perfsonar/annotations/xpath/XPathValidator.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -0,0 +1,97 @@
+package net.geant.perfsonar.annotations.xpath;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+
+import net.geant.perfsonar.annotations.XPath;
+import net.geant.perfsonar.annotations.XPaths;
+import net.geant.perfsonar.annotations.selftest.AbstractClassChecker;
+import net.geant.perfsonar.annotations.selftest.BaseMethodElementVisitor;
+import net.geant.perfsonar.annotations.selftest.SelfTestProcessorListener;
+
+/**
+ * Checks whether methods annotated with XPath are valid.
+ *
+ * <p>Valid methods are:
+ * <ul>
+ * <li>with exactly one argument</li>
+ * <li>public</li>
+ * <li>non static</li>
+ * <li>cannot be abstract</li>
+ * <li>cannot be final</li>
+ * <li>the enclosing class cannot be abstract</li>
+ * </ul></p>
+ *
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ *
+ */
+public class XPathValidator extends
BaseMethodElementVisitor<Map<EnvelopedXPath, ExecutableElement>,
SelfTestProcessorListener> {
+
+ final AbstractClassChecker checker = new AbstractClassChecker();
+ final List<TypeElement> abstractClasses = new
ArrayList<TypeElement>();
+
+ private final Map<EnvelopedXPath, ExecutableElement> xpaths
+ = new Hashtable<EnvelopedXPath, ExecutableElement>();
+ private boolean aggregator;
+
+ public void setAggregator() {
+ aggregator = true;
+ }
+
+ public void unsetAggregator() {
+ aggregator = false;
+ }
+
+ @Override
+ public Map<EnvelopedXPath, ExecutableElement>
visitExecutable(ExecutableElement elem, SelfTestProcessorListener listener) {
+ if(isDeclarationViolated(elem, listener))
+ return xpaths;
+
+ if (!aggregator)
+ xpaths.put(new
EnvelopedXPath(elem.getAnnotation(XPath.class)), elem);
+ else
+ for (XPath xpath :
elem.getAnnotation(XPaths.class).value())
+ xpaths.put(new EnvelopedXPath(xpath), elem);
+
+ return xpaths;
+ }
+
+ protected boolean isDeclarationViolated(ExecutableElement elem,
+ SelfTestProcessorListener listener) {
+ int errorsCount = 0;
+
+ if (super.isDeclarationViolated(elem, listener))
+ errorsCount++;
+
+ if (elem.getModifiers().contains(Modifier.FINAL)) {
+ listener.error("The method cannot be final.", elem);
+ errorsCount++;
+ }
+
+ if (elem.getModifiers().contains(Modifier.STATIC)) {
+ listener.error("The method cannot be static.", elem);
+ errorsCount++;
+ }
+
+ if (elem.isVarArgs() || (elem.getParameters().size() > 1)) {
+ listener.error("The method cannot have more than one
parameter.", elem);
+ errorsCount++;
+ }
+
+ if (checker.isEnclosingClassAbstract(elem)) {
+ if
(!abstractClasses.contains(checker.getEnclosingType(elem))) {
+
abstractClasses.add(checker.getEnclosingType(elem));
+ listener.error("The class cannot be
abstract.", checker.getEnclosingType(elem));
+ errorsCount++;
+ }
+ }
+
+ return (errorsCount > 0);
+ }
+}
Modified:
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/XPathProcessorTest.java
===================================================================
---
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/XPathProcessorTest.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/XPathProcessorTest.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -71,13 +71,12 @@
public void shouldNotCompileInvalidXPaths() {
assertEquals(
new Diagnostics()
- .addAbstractMethodViolationAtLine(14)
- .addNumberOfParametersViolationAtLine(18)
- .addStaticMethodViolationAtLine(23)
- .addRangeViolationAtLine(23)
- .addSetterArgumentTypeViolationAtLine(28)
- .addSetterReturnTypeViolationAtLine(33),
-
+ .addAbstractClassViolationAtLine(22)
+ .addAbstractMethodViolationAtLine(27)
+ .addNumberOfParametersViolationAtLine(31)
+ .addStaticMethodViolationAtLine(36)
+ .addStaticMethodViolationAtLine(36)
+ .addRangeViolationAtLine(36),
compiler.compile("/net/geant/perfsonar/dummyservice/xpath/InvalidXPaths.java"));
}
@@ -101,6 +100,7 @@
assertEquals("request1",
msg.getClass().getMethod("getId").invoke(msg));
assertEquals("EchoRequest",
msg.getClass().getMethod("getType").invoke(msg));
assertEquals("http://schemas.perfsonar.net/tools/admin/echo/2.0",
echo.getClass().getMethod("getEventType").invoke(echo));
+ assertEquals(nmwgClass.getMethod("getId"),
XPathDeserializer.findIdentifier(nmwgClass));
}
@SuppressWarnings("unchecked")
Modified:
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/SelfTestProcessorTest.java
===================================================================
---
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/SelfTestProcessorTest.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/SelfTestProcessorTest.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -8,6 +8,7 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ExecutionException;
import net.geant.perfsonar.annotations.selftest.compiler.BinaryClassLoader;
import net.geant.perfsonar.annotations.selftest.compiler.CompilerHelper;
@@ -39,6 +40,13 @@
@Override
public void stopAll() {
}
+
+ @Override
+ public void waitToFinish(Runnable... tasks)
+ throws InterruptedException,
ExecutionException {
+ // TODO Auto-generated method stub
+
+ }
};
final SelfTestLoggerHelper logger = new SelfTestLoggerHelper();
Modified:
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/BinaryClassLoader.java
===================================================================
---
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/BinaryClassLoader.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/BinaryClassLoader.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -18,7 +18,8 @@
}
public SelfTestRunner newSelfTestRunner() throws
InstantiationException, IllegalAccessException, ClassNotFoundException {
- return (SelfTestRunner)
loadClass("net.geant.perfsonar.SelfTestRunnerImpl").newInstance();
+
loadClass("net.geant.perfsonar.SelfTestsConfiguration").newInstance();
+ return new SelfTestRunner();
}
public Class<?> findClass(String name) throws ClassNotFoundException {
Modified:
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/DiagnosticImpl.java
===================================================================
---
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/DiagnosticImpl.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/DiagnosticImpl.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -32,7 +32,14 @@
}
private String getMessage(Diagnostic<?> d) {
- return
d.getMessage(Locale.getDefault()).substring(d.getMessage(Locale.getDefault()).lastIndexOf(":")
+ 1).trim();
+ String msg = d.getMessage(Locale.getDefault());
+ int idx = msg.indexOf(":");
+ msg = msg.substring(idx + 1).trim();
+
+ if (idx != -1)
+ return msg.substring(msg.indexOf(":") + 1).trim();
+
+ return msg;
}
@Override
Modified:
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/Diagnostics.java
===================================================================
---
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/Diagnostics.java
2013-05-06 13:08:11 UTC (rev 6351)
+++
trunk/perfsonar-base/apt/src/test/java/net/geant/perfsonar/annotations/selftest/compiler/Diagnostics.java
2013-05-06 13:09:23 UTC (rev 6352)
@@ -68,11 +68,11 @@
return add(lineNumber, "The return type of the method must be
of type java.util.List<E>");
}
- public Diagnostics addSetterReturnTypeViolationAtLine(int lineNumber)
{
- return add(lineNumber, "Type of the method must be void.");
- }
+// public Diagnostics addSetterReturnTypeViolationAtLine(int lineNumber)
{
+// return add(lineNumber, "Type of the method must be void.");
+// }
public Diagnostics addSetterArgumentTypeViolationAtLine(int
lineNumber) {
- return add(lineNumber, "The method must have exactly one
parameter of type java.lang.String");
+ return add(lineNumber, "The method must have exactly one
parameter.");
}
}
- [pS-dev] [GEANT/SA2/ps-java-services] r6352 - in trunk/perfsonar-base/apt: . annotated annotated/net annotated/net/geant annotated/net/geant/perfsonar dummyservice/net/geant/perfsonar/dummyservice/xpath src/main/java/net/geant/perfsonar/annotations src/main/java/net/geant/perfsonar/annotations/ls src/main/java/net/geant/perfsonar/annotations/request src/main/java/net/geant/perfsonar/annotations/selftest src/main/java/net/geant/perfsonar/annotations/xpath src/test/java/net/geant/perfsonar/annotations src/test/java/net/geant/perfsonar/annotations/selftest src/test/java/net/geant/perfsonar/annotations/selftest/compiler, svn-noreply, 05/06/2013
Archive powered by MHonArc 2.6.16.