Java 8 CharacterCodingException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CharacterCodingException class.

This code example shows how to use the following methods:
        Invocation invocation = new InvocationBuilder().method("canThrowException").toInvocation(); 
        MethodInfo info = new MethodInfo(invocation); 
 
        //then 
        assertFalse(info.isValidException(new Exception())); 
        assertTrue(info.isValidException(new CharacterCodingException())); 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:
        } catch (MockitoException e) {}
    } 
 
    @Test 
    public void should_pass_proper_checked_exception() throws Throwable { 
        validator.validate(new ThrowsException(new CharacterCodingException()), invocation);
    } 
 
    @Test(expected = MockitoException.class) 
    public void should_fail_invalid_checked_exception() throws Throwable { 
        validator.validate(new ThrowsException(new IOException()), invocation);
    } 
     
    @Test 
    public void should_pass_RuntimeExceptions() throws Throwable { 
        validator.validate(new ThrowsException(new Error()), invocation);
        validator.validate(new ThrowsException(new RuntimeException()), invocation);
    } 
     
    @Test(expected = MockitoException.class) 
7
CodeRank
This code example shows how to use the following methods:
        Invocation invocation = new InvocationBuilder().method("canThrowException").toInvocation(); 
        MethodInfo info = new MethodInfo(invocation); 
 
        //then 
        assertFalse(info.isValidException(new Exception())); 
        assertTrue(info.isValidException(new CharacterCodingException())); 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getCause, getMessage
 * Test CharacterCodingException 
 */ 
public class CharacterCodingExceptionTest extends TestCase {
 
	public void testConstructor() { 
		CharacterCodingException ex = new CharacterCodingException();
		assertTrue(ex instanceof IOException);
		assertNull(ex.getCause());
		assertNull(ex.getMessage());
	} 
 
    /** 
     * @tests serialization/deserialization compatibility. 
     */ 
    public void testSerializationSelf() throws Exception {
 
        SerializationTest.verifySelf(new CharacterCodingException());
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:
        } catch (MockitoException e) {}
    } 
 
    @Test
    public void should_pass_proper_checked_exception() throws Throwable {
        validator.validate(new ThrowsException(new CharacterCodingException()), invocation);
    } 
 
    @Test(expected = MockitoException.class)
    public void should_fail_invalid_checked_exception() throws Throwable {
        validator.validate(new ThrowsException(new IOException()), invocation);
    } 
     
    @Test
    public void should_pass_RuntimeExceptions() throws Throwable {
        validator.validate(new ThrowsException(new Error()), invocation);
        validator.validate(new ThrowsException(new RuntimeException()), invocation);
    } 
     
    @Test(expected = MockitoException.class)
6
CodeRank
This code example shows how to use the following methods:getMessage
  protected long doGetField(byte[] bytes, int start, int length) throws ParseException {
    Date date = null;
    try { 
      date = format.parse(Text.decode(bytes, start, length));
    } catch (CharacterCodingException e) {
      throw new ParseException(e.getMessage(), 0);
    } 
    calendar.setTime(date);
    return calendar.getTimeInMillis() / 1000;
  } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
    Date date = null;
    try { 
      String decoded = Text.decode(bytes, start, length);
      date = format.parse(decoded);
    } catch (CharacterCodingException e) {
      throw new ParseException(e.getMessage(), 0);
    } 
    calendar.setTime(date);
    return calendar.get(Calendar.WEEK_OF_YEAR);
  } 
 
  private void initCalendar() { 
 
    // code copied over from UDFWeekOfYear implementation 
    calendar.setFirstDayOfWeek(Calendar.MONDAY);
    calendar.setMinimalDaysInFirstWeek(4);
  } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
				cr.throwException();
			} 
		} catch (CharacterCodingException x) {
			// Substitution is always enabled, 
			// so this shouldn't happen 
			throw new JSONException(x.getMessage(), x);
		} 
 
		int bytesLength = byteBuf.position();
		byte[] copy = new byte[bytesLength];
		System.arraycopy(bytes, 0, copy, 0, bytesLength);
		return copy;
	} 
 
	private static int scale(int len, float expansionFactor) {
		// We need to perform double, not float, arithmetic; otherwise 
		// we lose low order bits when len is larger than 2**24. 
		return (int) (len * (double) expansionFactor);
	} 
 
5
CodeRank
This code example shows how to use the following methods:getMessage
                cr.throwException();
            } 
        } catch (CharacterCodingException x) {
            // Substitution is always enabled, 
            // so this shouldn't happen 
            throw new JSONException(x.getMessage(), x);
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:toString
        SerializableTile newTile = new SerializableTile();
 
        try { 
            newTile.fromBytes(sTile.asBytes());
        } catch (CharacterCodingException e) {
            fail(e.toString());
        } 
 
        assertEquals(2, newTile.getHeaders().size());
        assertEquals("abc", newTile.getHeaders().get("abc"));
        assertEquals("12345", newTile.getHeaders().get("12345"));
        assertTrue(Arrays.equals(tileData, newTile.getTileData()));
    } 
 
    @Test
    public void testSerializeTilesNoData() { 
        HashMap<String, String> headers = new HashMap<String, String>();
        headers.put("abc", "abc");
        headers.put("12345", "12345");
 
5
CodeRank
See Code Examples for Java 8 CharacterCodingException Methods: