use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project java-chassis by ServiceComb.
the class TestParamSerializer method testSerialize.
@Test
public void testSerialize() {
boolean status = true;
Assert.assertNotNull(paramSerializer);
String[] stringArray = new String[1];
stringArray[0] = "abc";
ProtobufGenerator obj = null;
try {
obj = new ProtobufGenerator(Mockito.mock(IOContext.class), 2, Mockito.mock(ObjectCodec.class), Mockito.mock(OutputStream.class));
} catch (IOException exce) {
}
Assert.assertNotNull(obj);
new MockUp<ProtobufGenerator>() {
@Mock
public void writeStartObject() throws IOException {
}
ProtobufSchema protobufSchema = new ProtobufSchema(null, null);
@Mock
public ProtobufSchema getSchema() {
return protobufSchema;
}
};
ProtobufMessage protobufMessage = new ProtobufMessage(null, null);
new MockUp<ProtobufSchema>() {
@Mock
public ProtobufMessage getRootType() {
return protobufMessage;
}
};
List<ProtobufField> listProtobufField = new ArrayList<ProtobufField>();
listProtobufField.add(Mockito.mock(ProtobufField.class));
new MockUp<ProtobufMessage>() {
@Mock
public Iterable<ProtobufField> fields() {
return listProtobufField;
}
};
new MockUp<JsonGenerator>() {
@Mock
public void writeObjectField(String fieldName, Object pojo) throws IOException {
}
};
new MockUp<ProtobufGenerator>() {
@Mock
public void writeEndObject() throws IOException {
}
};
try {
paramSerializer.serialize(stringArray, obj, Mockito.mock(SerializerProvider.class));
} catch (JsonProcessingException e) {
status = false;
} catch (IOException e) {
status = false;
}
Assert.assertTrue(status);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project azure-sdk-for-java by Azure.
the class VirtualMachineImpl method capture.
@Override
public String capture(String containerName, String vhdPrefix, boolean overwriteVhd) {
VirtualMachineCaptureParametersInner parameters = new VirtualMachineCaptureParametersInner();
parameters.withDestinationContainerName(containerName);
parameters.withOverwriteVhds(overwriteVhd);
parameters.withVhdPrefix(vhdPrefix);
VirtualMachineCaptureResultInner captureResult = this.manager().inner().virtualMachines().capture(this.resourceGroupName(), this.name(), parameters);
if (captureResult == null) {
return null;
}
ObjectMapper mapper = new ObjectMapper();
//Object to JSON string
try {
return mapper.writeValueAsString(captureResult.output());
} catch (JsonProcessingException e) {
throw Exceptions.propagate(e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project ORCID-Source by ORCID.
the class S3MessageProcessor method update_1_2_API.
private void update_1_2_API(String orcid) {
if (is12IndexingEnabled) {
try {
OrcidMessage profile = orcid12ApiClient.fetchPublicProfile(orcid);
// Update API 1.2
if (profile != null) {
s3Updater.updateS3(orcid, profile);
recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
}
} catch (LockedRecordException | DeprecatedRecordException e) {
try {
if (e instanceof LockedRecordException) {
LOG.error("Record " + orcid + " is locked");
exceptionHandler.handle12LockedRecordException(orcid, ((LockedRecordException) e).getOrcidMessage());
} else {
LOG.error("Record " + orcid + " is deprecated");
exceptionHandler.handle12DeprecatedRecordException(orcid, ((DeprecatedRecordException) e).getOrcidDeprecated());
}
recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
} catch (JsonProcessingException | AmazonClientException | JAXBException e1) {
LOG.error("Unable to handle LockedRecordException for record " + orcid, e1);
recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
}
} catch (Exception e) {
// something else went wrong fetching record from ORCID and
// threw a
// runtime exception
LOG.error("Unable to fetch record " + orcid + " for 1.2 API");
LOG.error(e.getMessage(), e);
recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project oxAuth by GluuFederation.
the class ServletLoggingFilter method getRequestDescription.
protected String getRequestDescription(RequestWrapper requestWrapper) {
HttpRequest httpRequest = new HttpRequest();
httpRequest.setSenderIP(requestWrapper.getLocalAddr());
httpRequest.setMethod(requestWrapper.getMethod());
httpRequest.setPath(requestWrapper.getRequestURI());
httpRequest.setParams(requestWrapper.isFormPost() ? null : requestWrapper.getParameters());
httpRequest.setHeaders(requestWrapper.getHeaders());
httpRequest.setBody(requestWrapper.getContent());
try {
return OBJECT_MAPPER.writeValueAsString(httpRequest);
} catch (JsonProcessingException e) {
log.warn("Cannot serialize Request to JSON", e);
return null;
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project asterixdb by apache.
the class RestApiServlet method doHandle.
private void doHandle(IServletResponse response, String query, SessionOutput sessionOutput, ResultDelivery resultDelivery) throws JsonProcessingException {
try {
response.setStatus(HttpResponseStatus.OK);
IHyracksClientConnection hcc = (IHyracksClientConnection) ctx.get(HYRACKS_CONNECTION_ATTR);
IHyracksDataset hds = (IHyracksDataset) ctx.get(HYRACKS_DATASET_ATTR);
if (hds == null) {
synchronized (ctx) {
hds = (IHyracksDataset) ctx.get(HYRACKS_DATASET_ATTR);
if (hds == null) {
hds = new HyracksDataset(hcc, appCtx.getCompilerProperties().getFrameSize(), ResultReader.NUM_READERS);
ctx.put(HYRACKS_DATASET_ATTR, hds);
}
}
}
IParser parser = parserFactory.createParser(query);
List<Statement> aqlStatements = parser.parse();
validate(aqlStatements);
MetadataManager.INSTANCE.init();
IStatementExecutor translator = statementExecutorFactory.create(appCtx, aqlStatements, sessionOutput, compilationProvider, componentProvider);
translator.compileAndExecute(hcc, hds, resultDelivery, null, new IStatementExecutor.Stats());
} catch (AsterixException | TokenMgrError | org.apache.asterix.aqlplus.parser.TokenMgrError pe) {
response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, pe.getMessage(), pe);
String errorMessage = ResultUtil.buildParseExceptionMessage(pe, query);
ObjectNode errorResp = ResultUtil.getErrorResponse(2, errorMessage, "", ResultUtil.extractFullStackTrace(pe));
sessionOutput.out().write(new ObjectMapper().writeValueAsString(errorResp));
} catch (Exception e) {
GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, e.getMessage(), e);
response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
ResultUtil.apiErrorHandler(sessionOutput.out(), e);
}
}
Aggregations