use of org.codehaus.jettison.json.JSONArray in project ORCID-Source by ORCID.
the class SalesForceAdapter method extractObjectListFromRecords.
private List<JSONObject> extractObjectListFromRecords(JSONObject object) throws JSONException {
List<JSONObject> objects = new ArrayList<>();
JSONArray records = object.getJSONArray("records");
for (int i = 0; i < records.length(); i++) {
objects.add(records.getJSONObject(i));
}
return objects;
}
use of org.codehaus.jettison.json.JSONArray in project wildfly by wildfly.
the class InboundBridgeTestCase method testRollbackWithTwoParticipants.
@Test
public void testRollbackWithTwoParticipants() throws Exception {
txSupport.startTx();
enlistLoggingRestATParticipant();
enlistInboundBridgeResource();
txSupport.rollbackTx();
JSONArray participantResourceInvocations = getLoggingRestATParticipantInvocations();
JSONArray xaResourceInvocations = getInboundBridgeResourceInvocations();
Assert.assertEquals(1, participantResourceInvocations.length());
Assert.assertEquals("LoggingRestATResource.terminateParticipant(" + TxStatusMediaType.TX_ROLLEDBACK + ")", participantResourceInvocations.get(0));
Assert.assertEquals(3, xaResourceInvocations.length());
Assert.assertEquals("LoggingXAResource.start", xaResourceInvocations.get(0));
Assert.assertEquals("LoggingXAResource.end", xaResourceInvocations.get(1));
Assert.assertEquals("LoggingXAResource.rollback", xaResourceInvocations.get(2));
}
use of org.codehaus.jettison.json.JSONArray in project wildfly by wildfly.
the class InboundBridgeTestCase method testRollback.
@Test
public void testRollback() throws Exception {
txSupport.startTx();
enlistInboundBridgeResource();
txSupport.rollbackTx();
JSONArray jsonArray = getInboundBridgeResourceInvocations();
Assert.assertEquals(3, jsonArray.length());
Assert.assertEquals("LoggingXAResource.start", jsonArray.get(0));
Assert.assertEquals("LoggingXAResource.end", jsonArray.get(1));
Assert.assertEquals("LoggingXAResource.rollback", jsonArray.get(2));
}
use of org.codehaus.jettison.json.JSONArray in project wildfly by wildfly.
the class InboundBridgeTestCase method testCommit.
@Test
public void testCommit() throws Exception {
txSupport.startTx();
enlistInboundBridgeResource();
txSupport.commitTx();
final JSONArray jsonArray = getInboundBridgeResourceInvocations();
Assert.assertEquals(4, jsonArray.length());
Assert.assertEquals("LoggingXAResource.start", jsonArray.get(0));
Assert.assertEquals("LoggingXAResource.end", jsonArray.get(1));
Assert.assertEquals("LoggingXAResource.prepare", jsonArray.get(2));
Assert.assertEquals("LoggingXAResource.commit", jsonArray.get(3));
}
use of org.codehaus.jettison.json.JSONArray in project apex-core by apache.
the class StramUtils method getStackTrace.
public static JSONObject getStackTrace() {
Map<Thread, StackTraceElement[]> stackTraces = Thread.getAllStackTraces();
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
for (Map.Entry<Thread, StackTraceElement[]> elements : stackTraces.entrySet()) {
JSONObject jsonThread = new JSONObject();
Thread thread = elements.getKey();
try {
jsonThread.put("name", thread.getName());
jsonThread.put("state", thread.getState());
jsonThread.put("id", thread.getId());
JSONArray stackTraceElements = new JSONArray();
for (StackTraceElement stackTraceElement : elements.getValue()) {
stackTraceElements.put(stackTraceElement.toString());
}
jsonThread.put("stackTraceElements", stackTraceElements);
jsonArray.put(jsonThread);
} catch (Exception ex) {
LOG.warn("Getting stack trace for the thread " + thread.getName() + " failed.");
continue;
}
}
try {
jsonObject.put("threads", jsonArray);
} catch (JSONException e) {
throw new RuntimeException(e);
}
return jsonObject;
}
Aggregations