@Override public void onException(ChannelException e) { if (connectionTag == expectedTag) { onChannelException(e); } else { logger.trace().log("Mux dropping failure from defunct view"); } }
/** * Logs a trace message, evaluating and concatenating components only if trace * is enabled. * * @param components message components, which will be evaluated with * {@link String#valueOf(Object)} */ private void logTrace(Object... components) { if (logger.trace().shouldLog()) { StringBuffer buffer = new StringBuffer(); for (Object c : components) { buffer.append(c); } logger.trace().log(buffer.toString()); } }
/** * Tests that editor can set content + selection correctly * * @param content * @throws OperationException */ protected void testContent(String content) throws OperationException { logger.trace().logXml("Testing: " + content); setContent(editor, content); }
/** * Logs the ops from a delta message. * * @param prefix message to print before each op message * @param delta delta to log */ private void logDelta(String prefix, TransformedWaveletDelta delta) { if (logger.trace().shouldLog()) { logTrace(prefix + summariseDelta(delta)); } }
logger.trace().logLazyObjects("Multiplexer disconnected in state ", state , ", reconnecting."); state = State.RECONNECTING;
/** * Tests that editor can set content + selection correctly * * @param content * @throws OperationException */ protected void testContent(String content) throws OperationException { logger.trace().logXml("Testing: " + content); setContent(editor, content); }
if (logger.trace().shouldLog()) { logTrace("Outgoing " + summariseDelta(delta));
/** * Test that content makes editor at least minHeight pixels tall * * @param content * @param minHeight * @throws OperationException */ protected void testMinHeight(String content, int minHeight) throws OperationException { // Compute a message identifying the test String msg = content + " should be at least " + minHeight + " pixels tall"; logger.trace().logXml("Testing: " + msg); // Measure height setContent(editor, content); int height = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, height >= minHeight); }
@Override public void onClosed() { if (connectionTag == expectedTag) { reconnect(null); } else { logger.trace().log("Mux dropping onClosed from defunct view"); } }
/** * Test that content makes editor at least minHeight pixels tall * * @param content * @param minHeight * @throws OperationException */ protected void testMinHeight(String content, int minHeight) throws OperationException { // Compute a message identifying the test String msg = content + " should be at least " + minHeight + " pixels tall"; logger.trace().logXml("Testing: " + msg); // Measure height setContent(editor, content); int height = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, height >= minHeight); }
@Override public void onConnected() { if (connectionTag == expectedTag) { OperationChannelMultiplexerImpl.this.onConnected(); } else { logger.trace().log("Mux dropping onConnected from defunct view"); } }
@Override public void onDelta(TransformedWaveletDelta delta) throws ChannelException { try { if (logger.trace().shouldLog()) { logger.trace().log("Received delta: ", delta); } cc.onServerDelta(delta); } catch (TransformException e) { throw new ChannelException(ResponseCode.INVALID_OPERATION, "Operation channel failed on server delta: " + this + ", " + deltaChannel + ", " + cc, e, Recoverable.NOT_RECOVERABLE, null, null); } catch (OperationException e) { throw new ChannelException( e.isSchemaViolation() ? ResponseCode.SCHEMA_VIOLATION : ResponseCode.INVALID_OPERATION, "Operation channel failed on server delta: " + this + ", " + deltaChannel + ", " + cc, e, Recoverable.NOT_RECOVERABLE, null, null); } }
/** * Tests that firstContent makes editor roughly the same as secondContent * * @param firstContent * @param secondContent * @param maxDelta * @throws OperationException */ protected void testRoughlyEqualHeight(String firstContent, String secondContent, int maxDelta) throws OperationException { // Compute a message identifying the test String msg = firstContent + " should be within " + maxDelta + " pixel height of " + secondContent; logger.trace().logXml("Testing: " + msg); // Measure heights setContent(editor, firstContent); int firstHeight = editor.getWidget().getOffsetHeight(); setContent(editor, secondContent); int secondHeight = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, Math.abs(firstHeight - secondHeight) <= maxDelta); }
/** * Receive (transformed) server operation from the wave server, if any is available. * * @return the next server operation, if any is received from the server (and makes it * through transformation), null otherwise */ public WaveletOperation receive() { if (serverOperations.isEmpty()) { return null; } else { WaveletOperation op = serverOperations.remove(0); logger.trace().log("Processing server op ", op); return op; } }
/** * Tests that firstContent makes editor roughly the same as secondContent * * @param firstContent * @param secondContent * @param maxDelta * @throws OperationException */ protected void testRoughlyEqualHeight(String firstContent, String secondContent, int maxDelta) throws OperationException { // Compute a message identifying the test String msg = firstContent + " should be within " + maxDelta + " pixel height of " + secondContent; logger.trace().logXml("Testing: " + msg); // Measure heights setContent(editor, firstContent); int firstHeight = editor.getWidget().getOffsetHeight(); setContent(editor, secondContent); int secondHeight = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, Math.abs(firstHeight - secondHeight) <= maxDelta); }
@Override public WaveletOperation receive() { if (state == State.CLOSED) { // TODO(anorth): throw an exception here after Wally doesn't do this. logger.error().log("Cannot receive from closed operation channel: " + this); return null; } else { return cc.receive(); } }
logger.trace().log("Unacknowledged delta, expected to be applied at version ", unacknowledged.getTargetVersion().getVersion()); return; logger.trace().log("Nothing to send"); getLastSignature(), ops); if (logger.isModuleEnabled() && logger.trace().shouldLog()) { logger.trace().log("Sending delta to server with last known server version " + unacknowledged.getTargetVersion(), unacknowledged);
/** * Tests that applying an operation causes exception * TODO(user): consider testing for specific exception types * * @param startContent * @param operation */ private void testOperationFailure( String startContent, Nindo nindo) { // Compute a message identifying the test String msg = startContent + " + " + nindo + " => FAIL"; logger.trace().logXml("Testing: " + msg); try { // Execute the operation on starting content setContent(editor, startContent); DocOp docOp = getDocOpFromNindo(nindo); editor.getContent().consume(docOp); } catch (Throwable e) { // Test succeeds return; } // We didn't get the exception fail(msg); }