protected void _reportInvalidBase64(Base64Variant paramBase64Variant, char paramChar, int paramInt, String paramString) throws JsonParseException { String str; if (paramChar <= ' ') str = "Illegal white space character (code 0x" + Integer.toHexString(paramChar) + ") as character #" + (paramInt + 1) + " of 4-char base64 unit: can only used between units"; while (true) { if (paramString != null) str = str + ": " + paramString; throw new JsonParseException(str, JsonLocation.NA); if (paramBase64Variant.usesPaddingChar(paramChar)) { str = "Unexpected padding character ('" + paramBase64Variant.getPaddingChar() + "') as character #" + (paramInt + 1) + " of 4-char base64 unit: padding only legal as 3rd or 4th character"; continue; } if ((!Character.isDefined(paramChar)) || (Character.isISOControl(paramChar))) { str = "Illegal character (code 0x" + Integer.toHexString(paramChar) + ") in base64 content"; continue; } str = "Illegal character '" + paramChar + "' (code 0x" + Integer.toHexString(paramChar) + ") in base64 content"; } }
@SuppressWarnings("unchecked") @Test(expected = EntityMarshallingException.class) public void testFromfileMapperThrowsJsonParseException() throws Exception { // setup File file = new File(filename); FileUtils.writeStringToFile(new File(filename), "stuff"); FileUtils.writeStringToFile(new File(metadataFilename), "{\"contentType\":\"text/plain\"}"); final ObjectMapper objectMapper = Mockito.mock(ObjectMapper.class); String message = "shit happens"; Mockito.when(objectMapper.readValue(Matchers.isA(File.class), Matchers.isA(Class.class))).thenThrow(new JsonParseException(message, new JsonLocation(new String(), 1, 1, 1))); // act try { new ObjectMetaData(file) { @Override protected ObjectMapper getObjectMapper() { return objectMapper; } }; } catch (EntityMarshallingException e) { // assert assertTrue(e.getMessage().contains(message)); throw e; } }
private void attachErrorMessage(JsonParseException e) { JsonLocation location = e.getLocation(); File file; if (location.getSourceRef() instanceof File) { file = (File) location.getSourceRef(); } else { file = null; } context.addMessage(file, location.getLineNr(), location.getColumnNr(), e.getLocalizedMessage(), BuildContext.SEVERITY_ERROR, e); }
@Test @RoxableTest(key = "1e94cfd8f281") public void abstractJsonExceptionMapperShouldReturnLineNumberAndColumnNumberWithLocation() { when(jsonProcessingException.getLocation()).thenReturn(new JsonLocation(null, 0, 10000, 20000)); String location = jsonExceptionMapper.getLocationDetails(jsonProcessingException); assertTrue("Location should contain column and line number.", location.contains("10000") && location.contains("20000")); }
public UnrecognizedPropertyException(String paramString1, JsonLocation paramJsonLocation, Class<?> paramClass, String paramString2) { super(paramString1, paramJsonLocation); this._referringClass = paramClass; this._unrecognizedPropertyName = paramString2; }
public JsonMappingException(String paramString, JsonLocation paramJsonLocation) { super(paramString, paramJsonLocation); }
public JsonMappingException(String paramString, JsonLocation paramJsonLocation, Throwable paramThrowable) { super(paramString, paramJsonLocation, paramThrowable); }
public JsonLocation getCurrentLocation() { if (this._location == null) return JsonLocation.NA; return this._location; }
public JsonLocation getTokenLocation() { return getCurrentLocation(); }
public void setLocation(JsonLocation paramJsonLocation) { this._location = paramJsonLocation; }
public JsonLocation getCurrentLocation() { return this.delegate.getCurrentLocation(); }
public JsonLocation getTokenLocation() { return this.delegate.getTokenLocation(); }
public JsonLocation getCurrentLocation() { int i = 1 + (this._inputPtr - this._currInputRowStart); return new JsonLocation(this._ioContext.getSourceReference(), this._currInputProcessed + this._inputPtr - 1L, this._currInputRow, i); }
public JsonLocation getTokenLocation() { return new JsonLocation(this._ioContext.getSourceReference(), getTokenCharacterOffset(), getTokenLineNr(), getTokenColumnNr()); }
public final JsonLocation getStartLocation(Object paramObject) { return new JsonLocation(paramObject, -1L, this._lineNr, this._columnNr); }
public JsonLocation getCurrentLocation() { return JsonLocation.NA; }
public JsonLocation getTokenLocation() { return JsonLocation.NA; }
protected void _reportBase64EOF() throws JsonParseException { throw new JsonParseException("Unexpected end-of-String when base64 content", JsonLocation.NA); }
public final JsonLocation getCurrentLocation() { if (this._location == null) return JsonLocation.NA; return this._location; }
public final JsonLocation getTokenLocation() { return getCurrentLocation(); }
public final void setLocation(JsonLocation paramJsonLocation) { this._location = paramJsonLocation; }