Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.core')
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java24
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java28
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ErrorReport.java6
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IDiagnostics.java23
4 files changed, 78 insertions, 3 deletions
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java
index 9f6dc3d46..8fd6869c9 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java
@@ -11,9 +11,12 @@
package org.eclipse.tm.internal.tcf.services.local;
import java.math.BigDecimal;
+import java.util.Map;
import org.eclipse.tm.internal.tcf.core.Token;
+import org.eclipse.tm.tcf.core.Command;
import org.eclipse.tm.tcf.protocol.IChannel;
+import org.eclipse.tm.tcf.protocol.IErrorReport;
import org.eclipse.tm.tcf.protocol.IToken;
import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.protocol.Protocol;
@@ -46,6 +49,12 @@ public class DiagnosticsService implements IDiagnostics {
Number n = (Number)args[0];
channel.sendResult(token, JSON.toJSONSequence(new Object[]{ n }));
}
+ else if (name.equals("echoERR")) {
+ if (args.length != 1) throw new Exception("Invalid number of arguments");
+ @SuppressWarnings("unchecked")
+ Map<String,Object> err = (Map<String,Object>)args[0];
+ channel.sendResult(token, JSON.toJSONSequence(new Object[]{ err, Command.toErrorString(err) }));
+ }
else if (name.equals("getTestList")) {
if (args.length != 0) throw new Exception("Invalid number of arguments");
channel.sendResult(token, JSON.toJSONSequence(new Object[]{ null, new String[0] }));
@@ -85,6 +94,21 @@ public class DiagnosticsService implements IDiagnostics {
return token;
}
+ public IToken echoERR(final Throwable err, final DoneEchoERR done) {
+ final IToken token = new Token();
+ Protocol.invokeLater(new Runnable() {
+ public void run() {
+ if (err instanceof IErrorReport) {
+ done.doneEchoERR(token, null, err, Command.toErrorString(((IErrorReport)err).getAttributes()));
+ }
+ else {
+ done.doneEchoERR(token, null, err, err.getMessage());
+ }
+ }
+ });
+ return token;
+ }
+
public IToken getTestList(final DoneGetTestList done) {
final IToken token = new Token();
Protocol.invokeLater(new Runnable() {
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java
index b2a0104fc..a5dbdaca2 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java
@@ -12,10 +12,12 @@ package org.eclipse.tm.internal.tcf.services.remote;
import java.math.BigDecimal;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import org.eclipse.tm.tcf.core.Command;
import org.eclipse.tm.tcf.protocol.IChannel;
+import org.eclipse.tm.tcf.protocol.IErrorReport;
import org.eclipse.tm.tcf.protocol.IToken;
import org.eclipse.tm.tcf.services.IDiagnostics;
@@ -108,6 +110,32 @@ public class DiagnosticsProxy implements IDiagnostics {
}.token;
}
+ public IToken echoERR(Throwable err, final DoneEchoERR done) {
+ Map<String,Object> map = null;
+ if (err instanceof IErrorReport) {
+ map = ((IErrorReport)err).getAttributes();
+ }
+ else {
+ map = new HashMap<String,Object>();
+ map.put(IErrorReport.ERROR_TIME, new Long(System.currentTimeMillis()));
+ map.put(IErrorReport.ERROR_CODE, new Integer(IErrorReport.TCF_ERROR_OTHER));
+ map.put(IErrorReport.ERROR_FORMAT, err.getMessage());
+ }
+ return new Command(channel, this, "echoERR", new Object[]{ map }) {
+ @Override
+ public void done(Exception error, Object[] args) {
+ Throwable err = null;
+ String str = null;
+ if (error == null) {
+ assert args.length == 2;
+ err = toError(args[0]);
+ str = (String)args[1];
+ }
+ done.doneEchoERR(token, error, err, str);
+ }
+ }.token;
+ }
+
public IToken getTestList(final DoneGetTestList done) {
return new Command(channel, this, "getTestList", null) {
@Override
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ErrorReport.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ErrorReport.java
index 5fcf099fe..d2054ad0e 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ErrorReport.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ErrorReport.java
@@ -15,13 +15,13 @@ import java.util.Map;
import org.eclipse.tm.tcf.protocol.IErrorReport;
-class ErrorReport extends Exception implements IErrorReport {
+public class ErrorReport extends Exception implements IErrorReport {
private static final long serialVersionUID = 3687543884858739977L;
private final Map<String,Object> attrs;
@SuppressWarnings("unchecked")
- ErrorReport(String msg, Map<String,Object> attrs) {
+ public ErrorReport(String msg, Map<String,Object> attrs) {
super(msg);
this.attrs = attrs;
Object caused_by = attrs.get(IErrorReport.ERROR_CAUSED_BY);
@@ -35,7 +35,7 @@ class ErrorReport extends Exception implements IErrorReport {
}
}
- ErrorReport(String msg, int code) {
+ public ErrorReport(String msg, int code) {
super(msg);
attrs = new HashMap<String,Object>();
attrs.put(ERROR_CODE, code);
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IDiagnostics.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IDiagnostics.java
index 98c5addb7..6ffa51237 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IDiagnostics.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IDiagnostics.java
@@ -72,6 +72,29 @@ public interface IDiagnostics extends IService {
}
/**
+ * 'echoERR' command result returns same error report that was given as command argument.
+ * The command is used to test remote agent ability to receive and transmit TCF error reports.
+ * @param error - an error object.
+ * @param done - command result call back object.
+ * @return - pending command handle.
+ */
+ IToken echoERR(Throwable error, DoneEchoERR done);
+
+ /**
+ * Call back interface for 'echoERR' command.
+ */
+ interface DoneEchoERR {
+ /**
+ * Called when 'echoERR' command is done.
+ * @param token - command handle.
+ * @param error - communication error report or null.
+ * @param error_obj - error object, should be equal to the command argument.
+ * @param error_msg - error object converted to a human readable string.
+ */
+ void doneEchoERR(IToken token, Throwable error, Throwable error_obj, String error_msg);
+ }
+
+ /**
* Get list of test names that are implemented by the service.
* Clients can request remote peer to run a test from the list.
* When started, a test performs a predefined set actions.

Back to the top