/** * 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; }
@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()); }
@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "CoderMalfunctionError", args = {java.lang.Exception.class} ) public void testConstructor_Null() { CoderMalfunctionError e = new CoderMalfunctionError(null); assertNull(e.getCause()); }
/** * @tests serialization/deserialization compatibility. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "Verifies serialization.", method = "!SerializationSelf", args = {} ) public void testSerializationSelf() throws Exception { SerializationTest.verifySelf(new CoderMalfunctionError(null)); }
/** * @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)); }
@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 } }
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 } }
@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); }
public void testConstructor_Normal() { Exception ex = new Exception(); CoderMalfunctionError e = new CoderMalfunctionError(ex); assertSame(ex, e.getCause()); }
public void testConstructor_Null() { CoderMalfunctionError e = new CoderMalfunctionError(null); assertNull(e.getCause()); }
/** * @tests serialization/deserialization compatibility. */ public void testSerializationSelf() throws Exception { SerializationTest.verifySelf(new CoderMalfunctionError(null)); }
/** * @tests serialization/deserialization compatibility with RI. */ public void testSerializationCompatibility() throws Exception { SerializationTest.verifyGolden(this, new CoderMalfunctionError(null)); }