Java 类java.nio.charset.CoderMalfunctionError 实例源码

项目:TimberdoodleApp    文件:MessageInputBox.java   
/**
 * Tries to encode inputBuffer into encodeBuffer using charsetEncoder and shows a warning if an
 * error occurred.
 *
 * @param inputBuffer The characters to be encoded.
 * @return An overflow or underflow CoderResult or null if encoding failed.
 */
private CoderResult tryEncodeMessage(CharBuffer inputBuffer) {
    // Encode message
    encodeBuffer.position(0);
    charsetEncoder.reset();
    CoderResult result = null;
    boolean gotException = false;
    try {
        result = charsetEncoder.encode(inputBuffer, encodeBuffer, true);
    } catch (CoderMalfunctionError ex) {
        gotException = true;
    }

    // Inform user if encoding failed and return null
    if (gotException || result.isError()) {
        showToastAndErrorVibrate(R.string.messageInputBox_encodingMessageFailed);
        return null;
    }

    // Return successful CoderResult
    return result;
}
项目:In-the-Box-Fork    文件:CoderMalfunctionErrorTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "CoderMalfunctionError",
    args = {java.lang.Exception.class}
)
public void testConstructor_Normal() {
    Exception ex = new Exception();
    CoderMalfunctionError e = new CoderMalfunctionError(ex);
    assertSame(ex, e.getCause());
}
项目:In-the-Box-Fork    文件:CoderMalfunctionErrorTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "CoderMalfunctionError",
    args = {java.lang.Exception.class}
)
public void testConstructor_Null() {
    CoderMalfunctionError e = new CoderMalfunctionError(null);
    assertNull(e.getCause());
}
项目:In-the-Box-Fork    文件:CoderMalfunctionErrorTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies serialization.",
    method = "!SerializationSelf",
    args = {}
)
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new CoderMalfunctionError(null));
}
项目:In-the-Box-Fork    文件:CoderMalfunctionErrorTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies serialization.",
    method = "!SerializationGolden",
    args = {}
)
public void testSerializationCompatibility() throws Exception {
    SerializationTest.verifyGolden(this, new CoderMalfunctionError(null));

}
项目:In-the-Box-Fork    文件:CharsetEncoderTest.java   
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Regression test checks CoderMalfunctionError",
    method = "encode",
    args = {java.nio.CharBuffer.class}
)
public void test_EncodeLjava_nio_CharBuffer() throws Exception {
    MockMalfunctionCharset cs = new MockMalfunctionCharset("mock", null);
    try {
        cs.encode(CharBuffer.wrap("AB"));
        fail("should throw CoderMalfunctionError");
    } catch (CoderMalfunctionError e) {
        // expected
    }
}
项目:cn1    文件:CharsetEncoderTest.java   
public void test_EncodeLjava_nio_CharBuffer() throws Exception {
    MockMalfunctionCharset cs = new MockMalfunctionCharset("mock", null);
    try {
        cs.encode(CharBuffer.wrap("AB"));
        fail("should throw CoderMalfunctionError");// NON-NLS-1$
    } catch (CoderMalfunctionError e) {
        // expected
    }
}
项目:freeVM    文件:CharsetEncoderTest.java   
public void test_EncodeLjava_nio_CharBuffer() throws Exception {
    MockMalfunctionCharset cs = new MockMalfunctionCharset("mock", null);
    try {
        cs.encode(CharBuffer.wrap("AB"));
        fail("should throw CoderMalfunctionError");// NON-NLS-1$
    } catch (CoderMalfunctionError e) {
        // expected
    }
}
项目:freeVM    文件:CharsetEncoderTest.java   
public void test_EncodeLjava_nio_CharBuffer() throws Exception {
    MockMalfunctionCharset cs = new MockMalfunctionCharset("mock", null);
    try {
        cs.encode(CharBuffer.wrap("AB"));
        fail("should throw CoderMalfunctionError");// NON-NLS-1$
    } catch (CoderMalfunctionError e) {
        // expected
    }
}
项目:pi    文件:PiUncaughtExceptionHandlerTest.java   
@Test
public void shouldNotExitOnCoderMalfunctionErrorOrAnythingOtherThanVirtualMachineError() {
    // setup
    Error error = new CoderMalfunctionError(null);

    // act
    piUncaughtExceptionHandler.uncaughtException(thread, error);

    // assert
    verify(log).error("Exception in thread " + threadName, error);
    verify(log, never()).fatal("!!!!!!!!!!!!!!!!!!!  Error caught: " + error.getMessage() + ", exiting PI !!!!!!!!!!!!!!!!!!");
    PowerMockito.verifyZeroInteractions(System.class);
}
项目:p2p-core    文件:PiUncaughtExceptionHandlerTest.java   
@Test
public void shouldNotExitOnCoderMalfunctionErrorOrAnythingOtherThanVirtualMachineError() {
    // setup
    Error error = new CoderMalfunctionError(null);

    // act
    piUncaughtExceptionHandler.uncaughtException(thread, error);

    // assert
    verify(log).error("Exception in thread " + threadName, error);
    verify(log, never()).fatal("!!!!!!!!!!!!!!!!!!!  Error caught: " + error.getMessage() + ", exiting PI !!!!!!!!!!!!!!!!!!");
    PowerMockito.verifyZeroInteractions(System.class);
}
项目:cn1    文件:CoderMalfunctionErrorTest.java   
public void testConstructor_Normal() {
    Exception ex = new Exception();
    CoderMalfunctionError e = new CoderMalfunctionError(ex);
    assertSame(ex, e.getCause());
}
项目:cn1    文件:CoderMalfunctionErrorTest.java   
public void testConstructor_Null() {
    CoderMalfunctionError e = new CoderMalfunctionError(null);
    assertNull(e.getCause());
}
项目:cn1    文件:CoderMalfunctionErrorTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new CoderMalfunctionError(null));
}
项目:cn1    文件:CoderMalfunctionErrorTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {
    SerializationTest.verifyGolden(this, new CoderMalfunctionError(null));

}
项目:freeVM    文件:CoderMalfunctionErrorTest.java   
public void testConstructor_Normal() {
    Exception ex = new Exception();
    CoderMalfunctionError e = new CoderMalfunctionError(ex);
    assertSame(ex, e.getCause());
}
项目:freeVM    文件:CoderMalfunctionErrorTest.java   
public void testConstructor_Null() {
    CoderMalfunctionError e = new CoderMalfunctionError(null);
    assertNull(e.getCause());
}
项目:freeVM    文件:CoderMalfunctionErrorTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new CoderMalfunctionError(null));
}
项目:freeVM    文件:CoderMalfunctionErrorTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {
    SerializationTest.verifyGolden(this, new CoderMalfunctionError(null));

}
项目:freeVM    文件:CoderMalfunctionErrorTest.java   
public void testConstructor_Normal() {
    Exception ex = new Exception();
    CoderMalfunctionError e = new CoderMalfunctionError(ex);
    assertSame(ex, e.getCause());
}
项目:freeVM    文件:CoderMalfunctionErrorTest.java   
public void testConstructor_Null() {
    CoderMalfunctionError e = new CoderMalfunctionError(null);
    assertNull(e.getCause());
}
项目:freeVM    文件:CoderMalfunctionErrorTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new CoderMalfunctionError(null));
}
项目:freeVM    文件:CoderMalfunctionErrorTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {
    SerializationTest.verifyGolden(this, new CoderMalfunctionError(null));

}