You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wave-commits@incubator.apache.org by wi...@apache.org on 2016/11/18 14:35:25 UTC
[8/8] incubator-wave git commit: remove testing dependencies from
compile (move tests sources to test server)
remove testing dependencies from compile (move tests sources to test server)
Project: http://git-wip-us.apache.org/repos/asf/incubator-wave/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-wave/commit/314ddcc7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-wave/tree/314ddcc7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-wave/diff/314ddcc7
Branch: refs/heads/fix/dependendices-2016
Commit: 314ddcc70c3241d28db2bdcfc19e28ef979d25e0
Parents: 854d560
Author: wisebaldone <wi...@apache.org>
Authored: Sat Nov 19 00:34:53 2016 +1000
Committer: wisebaldone <wi...@apache.org>
Committed: Sat Nov 19 00:34:53 2016 +1000
----------------------------------------------------------------------
wave/build.gradle | 49 +-
.../robots/testing/OperationServiceHelper.java | 120 --
.../rpc/testing/FakeServerRpcController.java | 84 --
.../util/testing/ExceptionLogHandler.java | 65 -
.../box/server/util/testing/Matchers.java | 172 ---
.../server/util/testing/TestingConstants.java | 66 -
.../client/testing/UndercurrentHarness.java | 380 -----
.../testing/public/UndercurrentHarness.html | 86 --
.../conversation/testing/BlipTestUtils.java | 94 --
.../testing/FakeConversationView.java | 159 --
.../wave/model/testing/BasicFactories.java | 239 ---
.../wave/model/testing/DeltaTestUtil.java | 199 ---
.../wave/model/testing/DocOpCreator.java | 266 ----
.../wave/model/testing/ExtraAsserts.java | 92 --
.../wave/model/testing/Factory.java | 34 -
.../wave/model/testing/FakeDocument.java | 81 -
.../model/testing/FakeHashedVersionFactory.java | 45 -
.../wave/model/testing/FakeIdGenerator.java | 44 -
.../model/testing/FakeSilentOperationSink.java | 69 -
.../wave/model/testing/FakeWaveView.java | 229 ---
.../model/testing/FakeWaveletDataListener.java | 320 ----
.../wave/model/testing/FakeWaveletListener.java | 58 -
.../wave/model/testing/GenericGWTTestBase.java | 77 -
.../wave/model/testing/GenericTestBase.java | 70 -
.../model/testing/MockParticipationHelper.java | 111 --
.../MockWaveletOperationContextFactory.java | 61 -
.../wave/model/testing/ModelTestUtils.java | 61 -
.../model/testing/OpBasedWaveletFactory.java | 194 ---
.../wave/model/testing/OpMatchers.java | 94 --
.../model/testing/RandomDocOpGenerator.java | 1421 ------------------
.../model/testing/RandomNindoGenerator.java | 776 ----------
.../wave/model/testing/RandomProviderImpl.java | 72 -
.../wave/model/testing/Response.java | 107 --
.../wave/model/testing/TestOperations.java | 87 --
.../wave/model/testing/WaveletDataFactory.java | 63 -
.../robots/testing/OperationServiceHelper.java | 120 ++
.../rpc/testing/FakeServerRpcController.java | 84 ++
.../util/testing/ExceptionLogHandler.java | 65 +
.../box/server/util/testing/Matchers.java | 172 +++
.../server/util/testing/TestingConstants.java | 66 +
.../client/testing/UndercurrentHarness.java | 380 +++++
.../testing/public/UndercurrentHarness.html | 86 ++
.../conversation/testing/BlipTestUtils.java | 94 ++
.../testing/FakeConversationView.java | 159 ++
.../wave/model/testing/BasicFactories.java | 239 +++
.../wave/model/testing/DeltaTestUtil.java | 199 +++
.../wave/model/testing/DocOpCreator.java | 266 ++++
.../wave/model/testing/ExtraAsserts.java | 92 ++
.../wave/model/testing/Factory.java | 34 +
.../wave/model/testing/FakeDocument.java | 81 +
.../model/testing/FakeHashedVersionFactory.java | 45 +
.../wave/model/testing/FakeIdGenerator.java | 44 +
.../model/testing/FakeSilentOperationSink.java | 69 +
.../wave/model/testing/FakeWaveView.java | 229 +++
.../model/testing/FakeWaveletDataListener.java | 320 ++++
.../wave/model/testing/FakeWaveletListener.java | 58 +
.../wave/model/testing/GenericGWTTestBase.java | 77 +
.../wave/model/testing/GenericTestBase.java | 70 +
.../model/testing/MockParticipationHelper.java | 111 ++
.../MockWaveletOperationContextFactory.java | 61 +
.../wave/model/testing/ModelTestUtils.java | 61 +
.../model/testing/OpBasedWaveletFactory.java | 194 +++
.../wave/model/testing/OpMatchers.java | 94 ++
.../model/testing/RandomDocOpGenerator.java | 1421 ++++++++++++++++++
.../model/testing/RandomNindoGenerator.java | 776 ++++++++++
.../wave/model/testing/RandomProviderImpl.java | 72 +
.../wave/model/testing/Response.java | 107 ++
.../wave/model/testing/TestOperations.java | 87 ++
.../wave/model/testing/WaveletDataFactory.java | 63 +
69 files changed, 6114 insertions(+), 6127 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/build.gradle
----------------------------------------------------------------------
diff --git a/wave/build.gradle b/wave/build.gradle
index 24d0dcb..1b1971a 100644
--- a/wave/build.gradle
+++ b/wave/build.gradle
@@ -133,24 +133,24 @@ dependencies {
[group: "org.atmosphere", name: "atmosphere-guice", version: "0.8.3"], // [?, ?]
[group: "org.atmosphere", name: "atmosphere-runtime", version: "2.1.0"], // [?, ?]
[group: "org.bouncycastle", name: "bcprov-jdk16", version: "1.45"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-annotations", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-client", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-continuation", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-http", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-io", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-proxy", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-security", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-server", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-servlet", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-servlets", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-util", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-webapp", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty", name: "jetty-xml", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty.websocket", name: "websocket-api", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty.websocket", name: "websocket-client", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty.websocket", name: "websocket-common", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty.websocket", name: "websocket-server", version: "9.2.14.v20151106"], // [?, ?]
- [group: "org.eclipse.jetty.websocket", name: "websocket-servlet", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-annotations", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-client", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-continuation", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-http", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-io", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-proxy", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-security", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-server", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-servlet", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-servlets", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-util", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-webapp", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty", name: "jetty-xml", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty.websocket", name: "websocket-api", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty.websocket", name: "websocket-client", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty.websocket", name: "websocket-common", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty.websocket", name: "websocket-server", version: "9.2.14.v20151106"], // [?, ?]
+ [group: "org.eclipse.jetty.websocket", name: "websocket-servlet", version: "9.2.14.v20151106"], // [?, ?]
[group: "org.jdom", name: "jdom", version: "1.1.3"], // [?, ?]
[group: "org.mongodb", name: "mongo-java-driver", version: "2.11.2"], // [?, ?]
[group: "org.slf4j", name: "slf4j-api", version: "1.6.1"], // [?, ?]
@@ -161,12 +161,7 @@ dependencies {
[group: "net.oauth.core", name: "oauth-provider", version: "20100527"], // [?, ?]
[group: "net.oauth.core", name: "oauth", version: "20100527"], // [?, ?]
[group: "net.oauth.core", name: "oauth-consumer", version: "20100527"], // [?, ?]
- //TODO: Following are included due to tests being in the main src directory
- [group: "org.mockito", name: "mockito-all", version: "1.9.5"], // [?, ?]
- [group: "org.hamcrest", name: "hamcrest-all", version: "1.3"] // [?, ?]
-
)
- compile fileTree(dir: 'dependencies/compile', include: "**/*.jar") // [?, ?]
compile fileTree(dir: '../pst/build/libs', include: '**/*.jar') // [?, ?]
generateGXP (
[group: "com.google.gxp", name: "google-gxp", version: "0.2.4-beta"] // [?, ?]
@@ -180,18 +175,10 @@ dependencies {
)
testCompile(
[group: 'junit', name: 'junit', version: '4.12'], // [?, ?]
- [group: "org.ow2.asm", name: "asm", version: "5.0.4"], // [?, ?]
- [group: "cglib", name: "cglib", version: "2.2"], // [?, ?]
- [group: "com.novocode", name: "junit-interface", version: "0.11"], // [?, ?]
- [group: "emma", name: "emma", version: "2.0.5312"], // [?, ?]
- [group: "emma", name: "emma_ant", version: "2.1.5320"], // [?, ?]
[group: "org.hamcrest", name: "hamcrest-all", version: "1.3"], // [?, ?]
[group: "org.jmock", name: "jmock-junit3", version: "2.6.0"], // [?, ?]
[group: "org.jmock", name: "jmock", version: "2.6.0"], // [?, ?]
[group: "org.mockito", name: "mockito-all", version: "1.9.5"], // [?, ?]
- //[group: "com.google.gwt", name: "gwt-dev", version: "2.8.0"], // [?, ?]
- //[group: "com.google.gwt", name: "gwt-user", version: "2.8.0"], // [?, ?]
- //[group: "com.google.gwt", name: "gwt-codeserver", version: "2.8.0"], // [?, ?]
)
}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/box/server/robots/testing/OperationServiceHelper.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/server/robots/testing/OperationServiceHelper.java b/wave/src/main/java/org/waveprotocol/box/server/robots/testing/OperationServiceHelper.java
deleted file mode 100644
index 814f972..0000000
--- a/wave/src/main/java/org/waveprotocol/box/server/robots/testing/OperationServiceHelper.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.box.server.robots.testing;
-
-import static org.mockito.Mockito.mock;
-
-import com.google.wave.api.data.converter.EventDataConverter;
-import com.google.wave.api.data.converter.v22.EventDataConverterV22;
-
-import org.waveprotocol.box.server.robots.OperationContextImpl;
-import org.waveprotocol.box.server.robots.RobotWaveletData;
-import org.waveprotocol.box.server.robots.operations.OperationService;
-import org.waveprotocol.box.server.robots.util.ConversationUtil;
-import org.waveprotocol.box.server.waveserver.WaveletProvider;
-import org.waveprotocol.wave.model.conversation.ObservableConversation;
-import org.waveprotocol.wave.model.conversation.WaveletBasedConversation;
-import org.waveprotocol.wave.model.id.IdURIEncoderDecoder;
-import org.waveprotocol.wave.model.id.WaveletName;
-import org.waveprotocol.wave.model.operation.SilentOperationSink;
-import org.waveprotocol.wave.model.operation.wave.BasicWaveletOperationContextFactory;
-import org.waveprotocol.wave.model.operation.wave.WaveletOperation;
-import org.waveprotocol.wave.model.testing.BasicFactories;
-import org.waveprotocol.wave.model.testing.FakeIdGenerator;
-import org.waveprotocol.wave.model.version.HashedVersionFactory;
-import org.waveprotocol.wave.model.version.HashedVersionFactoryImpl;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-import org.waveprotocol.wave.model.wave.ParticipationHelper;
-import org.waveprotocol.wave.model.wave.data.DocumentFactory;
-import org.waveprotocol.wave.model.wave.data.DocumentOperationSink;
-import org.waveprotocol.wave.model.wave.data.ObservableWaveletData;
-import org.waveprotocol.wave.model.wave.data.WaveletData;
-import org.waveprotocol.wave.model.wave.data.impl.EmptyWaveletSnapshot;
-import org.waveprotocol.wave.model.wave.data.impl.WaveletDataImpl;
-import org.waveprotocol.wave.model.wave.opbased.OpBasedWavelet;
-import org.waveprotocol.wave.util.escapers.jvm.JavaUrlCodec;
-
-/**
- * Helper for testing {@link OperationService}. Puts a single empty
- * conversational wavelet with one participant in the operation context.
- *
- * @author ljvderijk@google.com (Lennard de Rijk)
- */
-public class OperationServiceHelper {
-
- private static final IdURIEncoderDecoder URI_CODEC =
- new IdURIEncoderDecoder(new JavaUrlCodec());
- private static final HashedVersionFactory HASH_FACTORY = new HashedVersionFactoryImpl(URI_CODEC);
- private static final DocumentFactory<? extends DocumentOperationSink> DOCUMENT_FACTORY =
- BasicFactories.observablePluggableMutableDocumentFactory();
-
- private final WaveletProvider waveletProvider;
- private final OperationContextImpl context;
-
- /**
- * Constructs a new {@link OperationServiceHelper} with a wavelet with the
- * name and participant that are passed in.
- *
- * @param waveletName the name of the empty wavelet to open in the context.
- * @param participant the participant that should be on that empty wavelet.
- */
- public OperationServiceHelper(WaveletName waveletName, ParticipantId participant) {
- waveletProvider = mock(WaveletProvider.class);
- EventDataConverter converter = new EventDataConverterV22();
-
- ObservableWaveletData waveletData = WaveletDataImpl.Factory.create(DOCUMENT_FACTORY).create(
- new EmptyWaveletSnapshot(waveletName.waveId, waveletName.waveletId, participant,
- HASH_FACTORY.createVersionZero(waveletName), 0L));
- waveletData.addParticipant(participant);
-
- BasicWaveletOperationContextFactory CONTEXT_FACTORY =
- new BasicWaveletOperationContextFactory(participant);
-
- SilentOperationSink<WaveletOperation> executor =
- SilentOperationSink.Executor.<WaveletOperation, WaveletData>build(waveletData);
- OpBasedWavelet wavelet =
- new OpBasedWavelet(waveletData.getWaveId(), waveletData, CONTEXT_FACTORY,
- ParticipationHelper.DEFAULT, executor, SilentOperationSink.VOID);
-
- // Make a conversation with an empty root blip
- WaveletBasedConversation.makeWaveletConversational(wavelet);
- ConversationUtil conversationUtil = new ConversationUtil(FakeIdGenerator.create());
- ObservableConversation conversation = conversationUtil.buildConversation(wavelet).getRoot();
- conversation.getRootThread().appendBlip();
-
- context = new OperationContextImpl(waveletProvider, converter, conversationUtil);
- context.putWavelet(waveletName.waveId, waveletName.waveletId,
- new RobotWaveletData(waveletData, HASH_FACTORY.createVersionZero(waveletName)));
- }
-
- /**
- * @return the {@link WaveletProvider} mock
- */
- public WaveletProvider getWaveletProvider() {
- return waveletProvider;
- }
-
- /**
- * @return the {@link OperationContextImpl} with the empty wavelet opened.
- */
- public OperationContextImpl getContext() {
- return context;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/box/server/rpc/testing/FakeServerRpcController.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/server/rpc/testing/FakeServerRpcController.java b/wave/src/main/java/org/waveprotocol/box/server/rpc/testing/FakeServerRpcController.java
deleted file mode 100644
index fa45cd6..0000000
--- a/wave/src/main/java/org/waveprotocol/box/server/rpc/testing/FakeServerRpcController.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.box.server.rpc.testing;
-
-import static org.waveprotocol.box.server.util.testing.TestingConstants.USER;
-
-import com.google.protobuf.RpcCallback;
-
-import org.waveprotocol.box.server.rpc.ServerRpcController;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-
-
-/**
- * An {@code RpcController} that just handles error text and failure condition.
- */
-public class FakeServerRpcController implements ServerRpcController {
- private boolean failed = false;
- private String errorText = null;
-
- @Override
- public String errorText() {
- return errorText;
- }
-
- @Override
- public boolean failed() {
- return failed;
- }
-
- @Override
- public boolean isCanceled() {
- return false;
- }
-
- @Override
- public void notifyOnCancel(RpcCallback<Object> arg) {
- }
-
- @Override
- public void reset() {
- failed = false;
- errorText = null;
- }
-
- @Override
- public void setFailed(String error) {
- failed = true;
- errorText = error;
- }
-
- @Override
- public void startCancel() {
- }
-
- @Override
- public ParticipantId getLoggedInUser() {
- return ParticipantId.ofUnsafe(USER);
- }
-
- @Override
- public void cancel() {
- }
-
- @Override
- public void run() {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/box/server/util/testing/ExceptionLogHandler.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/server/util/testing/ExceptionLogHandler.java b/wave/src/main/java/org/waveprotocol/box/server/util/testing/ExceptionLogHandler.java
deleted file mode 100644
index 7ea3550..0000000
--- a/wave/src/main/java/org/waveprotocol/box/server/util/testing/ExceptionLogHandler.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.box.server.util.testing;
-
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-/**
- * A log handler which throws a runtime exception at and above a set log level.
- * Useful for catching erroneous conditions during testing, which are only
- * reported to the logs.
- *
- * @author mk.mateng@gmail.com (Michael Kuntzman)
- */
-public class ExceptionLogHandler extends Handler {
- /** The integer value of the minimum fatal log level. */
- private final int fatalLevel;
-
- /**
- * Constructs an ExceptionLogHandler that throws a runtime exception at and above the specified
- * log level.
- *
- * @param fatalLevel the minimum log level for which to throw an exception.
- */
- public ExceptionLogHandler(Level fatalLevel) {
- this.fatalLevel = fatalLevel.intValue();
- }
-
- /**
- * @throws RuntimeException if the log record is at or above the fatal log level.
- */
- @Override
- public void publish(LogRecord record) {
- if (record.getLevel().intValue() >= fatalLevel) {
- throw new RuntimeException(record.getLevel() + ": " + record.getMessage(),
- record.getThrown());
- }
- }
-
- @Override
- public void flush() {
- }
-
- @Override
- public void close() {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/box/server/util/testing/Matchers.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/server/util/testing/Matchers.java b/wave/src/main/java/org/waveprotocol/box/server/util/testing/Matchers.java
deleted file mode 100644
index 72be27a..0000000
--- a/wave/src/main/java/org/waveprotocol/box/server/util/testing/Matchers.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.box.server.util.testing;
-
-import org.hamcrest.Description;
-import org.hamcrest.TypeSafeMatcher;
-
-import java.util.Collection;
-
-/**
- * Additional matchers to go with JUnit4's assertThat and assumeThat.
- *
- * @author mk.mateng@gmail.com (Michael Kuntzman)
- */
-// TODO(Michael): Maybe move this class to the libraries repository/branch.
-public class Matchers {
- /**
- * Nicer aliases for some of the methods in this class, which may conflict with methods in other
- * packages (potential conficts noted for each alias).
- */
- public static class Aliases {
- /**
- * Alias for "containsString". May conflict with "org.mockito.Mockito.contains".
- *
- * @param substring to look for.
- * @return a matcher for checking that a string contains the specified substring.
- */
- public static TypeSafeMatcher<String> contains(final String substring) {
- return containsString(substring);
- }
-
- /**
- * Alias for "matchesRegex". May conflict with "org.mockito.Mockito.matches".
- *
- * @param regularExpression to match against.
- * @return a matcher for checking that a string matches the specified regular expression.
- */
- public static TypeSafeMatcher<String> matches(final String regularExpression) {
- return matchesRegex(regularExpression);
- }
- }
-
- /**
- * A more user-friendly version of org.junit.matchers.JUnitMatchers.hasItem(T element). Allows a
- * more verbose failure than assertTrue(collection.contains(item)). The matcher produces
- * "Expected: a collection containing '...' got: '...'", whereas assertTrue produces merely
- * "AssertionFailedError".
- * Usage: static import, then assertThat(collection, contains(item)).
- *
- * @param item to look for.
- * @return a matcher for checking that a collection contains the specified item.
- */
- public static <T> TypeSafeMatcher<Collection<? super T>> contains(final T item) {
- return new TypeSafeMatcher<Collection<? super T>>() {
- @Override
- public boolean matchesSafely(Collection<? super T> collection) {
- return collection.contains(item);
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("a collection containing ").appendValue(item);
- }
- };
- }
-
- /**
- * Same as JUnitMatchers.containsString. Allows a more verbose failure than
- * assertTrue(str.contains(substring)).
- * Usage: static import, then assertThat(str, containsString(substring)).
- *
- * @param substring to look for.
- * @return a matcher for checking that a string contains the specified substring.
- */
- public static TypeSafeMatcher<String> containsString(final String substring) {
- return new TypeSafeMatcher<String>() {
- @Override
- public boolean matchesSafely(String str) {
- return str.contains(substring);
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("a string containing ").appendValue(substring);
- }
- };
- }
-
- /**
- * The negative version of "contains" for a collection. Allows a more verbose failure than
- * assertFalse(collection.contains(item)).
- * Usage: static import, then assertThat(collection, doesNotContain(item)).
- *
- * @param item to look for.
- * @return a matcher for checking that a collection does not contain the specified item.
- */
- public static <T> TypeSafeMatcher<Collection<? super T>> doesNotContain(final T item) {
- return new TypeSafeMatcher<Collection<? super T>>() {
- @Override
- public boolean matchesSafely(Collection<? super T> collection) {
- return !collection.contains(item);
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("a collection NOT containing ").appendValue(item);
- }
- };
- }
-
- /**
- * The negative version of "contains" for a string (or "containsString"). Allows a more verbose
- * failure than assertFalse(str.contains(substring)).
- * Usage: static import, then assertThat(str, doesNotContain(substring)).
- *
- * @param substring to look for.
- * @return a matcher for checking that a string contains the specified substring.
- */
- public static TypeSafeMatcher<String> doesNotContain(final String substring) {
- return new TypeSafeMatcher<String>() {
- @Override
- public boolean matchesSafely(String str) {
- return !str.contains(substring);
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("a string NOT containing ").appendValue(substring);
- }
- };
- }
-
- /**
- * Allows a more verbose failure than assertTrue(str.matches(regex)). The matcher produces
- * "Expected: a string matching regex '...' got: '...'", whereas assertTrue produces merely
- * "AssertionFailedError".
- * Usage: static import, then assertThat(str, matchesRegex(regex)).
- *
- * @param regularExpression to match against.
- * @return a matcher for checking that a string matches the specified regular expression.
- */
- public static TypeSafeMatcher<String> matchesRegex(final String regularExpression) {
- return new TypeSafeMatcher<String>() {
- @Override
- public boolean matchesSafely(String str) {
- return str.matches(regularExpression);
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("a string matching regex ").appendValue(regularExpression);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/box/server/util/testing/TestingConstants.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/server/util/testing/TestingConstants.java b/wave/src/main/java/org/waveprotocol/box/server/util/testing/TestingConstants.java
deleted file mode 100644
index ed0d95f..0000000
--- a/wave/src/main/java/org/waveprotocol/box/server/util/testing/TestingConstants.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.box.server.util.testing;
-
-import org.waveprotocol.wave.model.id.WaveId;
-import org.waveprotocol.wave.model.id.WaveletId;
-import org.waveprotocol.wave.model.id.WaveletName;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-
-/**
- * Commonly used constants for unit testing. Some constants taken from
- * previously existing test cases.
- *
- * @author mk.mateng@gmail.com (Michael Kuntzman)
- */
-// TODO(Michael): Maybe move this class to the libraries repository/branch.
-public interface TestingConstants {
- public static final String BLIP_ID = "b+blip";
-
- public static final String MESSAGE = "The quick brown fox jumps over the lazy dog";
-
- public static final String MESSAGE2 = "Why's the rum gone?";
-
- public static final String MESSAGE3 = "There is no spoon";
-
- public static final String DOMAIN = "host.com";
-
- public static final String OTHER_USER_NAME = "other";
-
- public static final String OTHER_USER = OTHER_USER_NAME + "@" + DOMAIN;
-
- public static final ParticipantId OTHER_PARTICIPANT = new ParticipantId(OTHER_USER);
-
- public static final int PORT = 9876;
-
- public static final String USER_NAME = "user";
-
- public static final String USER = USER_NAME + "@" + DOMAIN;
-
- public static final char[] PASSWORD = "password".toCharArray();
-
- public static final ParticipantId PARTICIPANT = new ParticipantId(USER);
-
- public static final WaveId WAVE_ID = WaveId.of(DOMAIN, "w+wave");
-
- public static final WaveletId WAVELET_ID = WaveletId.of(DOMAIN, "wavelet");
-
- public static final WaveletName WAVELET_NAME = WaveletName.of(WAVE_ID, WAVELET_ID);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/wave/client/testing/UndercurrentHarness.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/wave/client/testing/UndercurrentHarness.java b/wave/src/main/java/org/waveprotocol/wave/client/testing/UndercurrentHarness.java
deleted file mode 100644
index 48a6753..0000000
--- a/wave/src/main/java/org/waveprotocol/wave/client/testing/UndercurrentHarness.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.waveprotocol.wave.client.testing;
-
-import com.google.gwt.core.client.Duration;
-import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.RepeatingCommand;
-import com.google.gwt.dom.client.Document;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.Command;
-
-import org.waveprotocol.wave.client.StageOne;
-import org.waveprotocol.wave.client.StageThree;
-import org.waveprotocol.wave.client.StageTwo;
-import org.waveprotocol.wave.client.StageZero;
-import org.waveprotocol.wave.client.Stages;
-import org.waveprotocol.wave.client.common.safehtml.SafeHtmlBuilder;
-import org.waveprotocol.wave.client.common.util.AsyncHolder;
-import org.waveprotocol.wave.client.concurrencycontrol.MuxConnector;
-import org.waveprotocol.wave.client.doodad.DoodadInstallers;
-import org.waveprotocol.wave.client.doodad.attachment.AttachmentManagerProvider;
-import org.waveprotocol.wave.client.doodad.attachment.testing.FakeAttachmentsManager;
-import org.waveprotocol.wave.client.util.ClientFlags;
-import org.waveprotocol.wave.client.util.NullTypedSource;
-import org.waveprotocol.wave.client.util.OverridingTypedSource;
-import org.waveprotocol.wave.client.wavepanel.impl.toolbar.color.ComplexColorPicker;
-import org.waveprotocol.wave.client.wavepanel.impl.toolbar.color.SampleCustomColorPicker;
-import org.waveprotocol.wave.common.bootstrap.FlagConstants;
-import org.waveprotocol.wave.concurrencycontrol.channel.WaveViewService;
-import org.waveprotocol.wave.model.conversation.Conversation;
-import org.waveprotocol.wave.model.conversation.ConversationBlip;
-import org.waveprotocol.wave.model.conversation.ConversationThread;
-import org.waveprotocol.wave.model.conversation.ConversationView;
-import org.waveprotocol.wave.model.conversation.WaveBasedConversationView;
-import org.waveprotocol.wave.model.document.util.XmlStringBuilder;
-import org.waveprotocol.wave.model.id.IdGenerator;
-import org.waveprotocol.wave.model.schema.SchemaProvider;
-import org.waveprotocol.wave.model.schema.conversation.ConversationSchemas;
-import org.waveprotocol.wave.model.testing.BasicFactories;
-import org.waveprotocol.wave.model.testing.FakeIdGenerator;
-import org.waveprotocol.wave.model.util.CollectionUtils;
-import org.waveprotocol.wave.model.util.ReadableStringMap.ProcV;
-import org.waveprotocol.wave.model.util.StringMap;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-import org.waveprotocol.wave.model.wave.data.DocumentFactory;
-import org.waveprotocol.wave.model.wave.data.ObservableWaveletData;
-import org.waveprotocol.wave.model.wave.data.ReadableWaveletData;
-import org.waveprotocol.wave.model.wave.data.WaveViewData;
-import org.waveprotocol.wave.model.wave.data.impl.WaveViewDataImpl;
-import org.waveprotocol.wave.model.wave.data.impl.WaveletDataImpl;
-import org.waveprotocol.wave.model.wave.opbased.OpBasedWavelet;
-import org.waveprotocol.wave.model.wave.opbased.WaveViewImpl;
-import org.waveprotocol.wave.model.wave.opbased.WaveViewImpl.WaveletConfigurator;
-import org.waveprotocol.wave.model.wave.opbased.WaveViewImpl.WaveletFactory;
-
-/**
- * Kicks off some initial actions for development purposes.
- *
- */
-public class UndercurrentHarness implements EntryPoint {
-
- private UndercurrentHarness() {
- }
-
- private static boolean loaded;
-
- /**
- * Runs the harness script.
- */
- @Override
- public void onModuleLoad() {
- AttachmentManagerProvider.init(new FakeAttachmentsManager());
- if (loaded) {
- return;
- }
- loaded = true;
-
- final Timeline timeline = new Timeline();
- new Stages() {
-
- @Override
- protected AsyncHolder<StageZero> createStageZeroLoader() {
- return new StageZero.DefaultProvider() {
-
- @Override
- protected void onStageInit() {
- timeline.add("stage0_start");
- }
-
- @Override
- protected void onStageLoaded() {
- timeline.add("stage0_end");
- }
-
- @Override
- protected UncaughtExceptionHandler createUncaughtExceptionHandler() {
- return GWT.getUncaughtExceptionHandler();
- }
- };
- }
-
- @Override
- protected AsyncHolder<StageOne> createStageOneLoader(StageZero zero) {
- return new StageOne.DefaultProvider(zero) {
- @Override
- protected void onStageInit() {
- timeline.add("stage1_start");
- }
-
- @Override
- protected void onStageLoaded() {
- timeline.add("stage1_end");
- }
-
- @Override
- protected Element createWaveHolder() {
- return Document.get().getElementById("initialHtml");
- }
- };
- }
-
- @Override
- protected AsyncHolder<StageTwo> createStageTwoLoader(StageOne one) {
- return new StageTwo.DefaultProvider(one, null) {
-
- @Override
- protected void onStageInit() {
- timeline.add("stage2_start");
- }
-
- @Override
- protected void onStageLoaded() {
- timeline.add("stage2_end");
- }
-
- @Override
- protected void fetchWave(Accessor<WaveViewData> whenReady) {
- timeline.add("fakewave_start");
- WaveViewData fake = WaveFactory.create(getDocumentRegistry());
- timeline.add("fakewave_end");
- whenReady.use(fake);
- }
-
- @Override
- protected ParticipantId createSignedInUser() {
- return ParticipantId.ofUnsafe("nobody@example.com");
- }
-
- @Override
- protected String createSessionId() {
- return "session";
- }
-
- @Override
- protected MuxConnector createConnector() {
- return new MuxConnector() {
- @Override
- public void connect(Command whenOpened) {
- if (whenOpened != null) {
- whenOpened.execute();
- }
- }
-
- @Override
- public void close() {
- // Ignore
- }
- };
- }
-
- @Override
- protected WaveViewService createWaveViewService() {
- // The vacuous MuxConnector should avoid the need for a
- // communication layer.
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected SchemaProvider createSchemas() {
- return new ConversationSchemas();
- }
- };
- }
-
- @Override
- protected AsyncHolder<StageThree> createStageThreeLoader(StageTwo two) {
- ClientFlags.resetWithSourceForTesting(OverridingTypedSource.of(new NullTypedSource())
- .withBoolean(FlagConstants.ENABLE_UNDERCURRENT_EDITING, true)
- .build());
-
- // Only for test additional color pickers
- new SampleCustomColorPicker(ComplexColorPicker.getInstance());
-
- return new StageThree.DefaultProvider(two) {
- @Override
- protected void onStageInit() {
- timeline.add("stage3_start");
- }
-
- @Override
- protected void onStageLoaded() {
- timeline.add("stage3_end");
- }
- };
- }
- }.load(new Command() {
- @Override
- public void execute() {
- showInfo(timeline);
- }
- });
- }
-
- /**
- * Populates the info box. Continuously reports which element has browser
- * focus, and reports timing information for the stage loading.
- *
- * @param timeline timeline to report
- */
- private static void showInfo(Timeline timeline) {
- Element timeBox = Document.get().getElementById("timeline");
- timeline.dump(timeBox);
-
- Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
- private final Element activeBox = Document.get().getElementById("active");
-
- @Override
- public boolean execute() {
- Element e = getActiveElement();
- String text = (e != null ? e.getTagName() + " id:" + e.getId() : "none");
- activeBox.setInnerText(text);
- return true;
- }
-
- private native Element getActiveElement() /*-{
- return $doc.activeElement;
- }-*/;
- }, 1000);
- }
-
- /**
- * Creates a sample wave with a conversation in it.
- */
- private final static class WaveFactory {
-
- /**
- * Creates a sample wave.
- *
- * @param docFactory factory/registry for documents in the wave
- * @return the wave state of the sample wave.
- */
- public static WaveViewDataImpl create(DocumentFactory<?> docFactory) {
- // Create a sample wave.
- WaveViewData sampleData = createSampleWave();
-
- // Now build one that has the same setup state as that required by
- // undercurrent (complex issue with the per-document output sinks).
- WaveViewDataImpl newData = WaveViewDataImpl.create(sampleData.getWaveId());
- WaveletDataImpl.Factory copier = WaveletDataImpl.Factory.create(docFactory);
- for (ReadableWaveletData src : sampleData.getWavelets()) {
- WaveletDataImpl copied = copier.create(src);
- for (ParticipantId p : src.getParticipants()) {
- copied.addParticipant(p);
- }
- copied.setVersion(copied.getVersion());
- copied.setHashedVersion(src.getHashedVersion());
- copied.setLastModifiedTime(src.getLastModifiedTime());
- newData.addWavelet(copied);
- }
- return newData;
- }
-
- /** @return a sample wave with a conversation in it. */
- private static WaveViewData createSampleWave() {
- final ParticipantId sampleAuthor = ParticipantId.ofUnsafe("nobody@example.com");
- IdGenerator gen = FakeIdGenerator.create();
- final WaveViewDataImpl waveData = WaveViewDataImpl.create(gen.newWaveId());
- final DocumentFactory<?> docFactory = BasicFactories.fakeDocumentFactory();
- final ObservableWaveletData.Factory<?> waveletDataFactory =
- new ObservableWaveletData.Factory<WaveletDataImpl>() {
- private final ObservableWaveletData.Factory<WaveletDataImpl> inner =
- WaveletDataImpl.Factory.create(docFactory);
-
- @Override
- public WaveletDataImpl create(ReadableWaveletData data) {
- WaveletDataImpl wavelet = inner.create(data);
- waveData.addWavelet(wavelet);
- return wavelet;
- }
- };
- WaveletFactory<OpBasedWavelet> waveletFactory = BasicFactories
- .opBasedWaveletFactoryBuilder()
- .with(waveletDataFactory)
- .with(sampleAuthor)
- .build();
-
- WaveViewImpl<?> wave = WaveViewImpl.create(
- waveletFactory, waveData.getWaveId(), gen, sampleAuthor, WaveletConfigurator.ADD_CREATOR);
-
- // Build a conversation in that wave.
- ConversationView v = WaveBasedConversationView.create(wave, gen);
- Conversation c = v.createRoot();
- ConversationThread root = c.getRootThread();
- sampleReply(root.appendBlip());
- write(root.appendBlip());
- write(root.appendBlip());
- write(root.appendBlip());
-
- return waveData;
- }
-
- private static void write(ConversationBlip blip) {
- org.waveprotocol.wave.model.document.Document d = blip.getContent();
- d.emptyElement(d.getDocumentElement());
- d.appendXml(XmlStringBuilder.createFromXmlString("<body><line></line>Hello World</body>"));
- }
-
- private static void sampleReply(ConversationBlip blip) {
- write(blip);
- ConversationThread thread = blip.addReplyThread(8);
- write(thread.appendBlip());
- }
-
- private static void biggerSampleReply(ConversationBlip blip) {
- write(blip);
- ConversationThread thread = blip.addReplyThread();
- sampleReply(thread.appendBlip());
- sampleReply(thread.appendBlip());
- write(thread.appendBlip());
- }
- }
-
- private static class Timeline {
- private final StringMap<Integer> events = CollectionUtils.createStringMap();
- private final Duration duration = new Duration();
-
- void add(String name) {
- events.put(name, duration.elapsedMillis());
- }
-
- void dump(Element timeBox) {
- final SafeHtmlBuilder timeHtml = new SafeHtmlBuilder();
- timeHtml.appendHtmlConstant("<table cellpadding='0' cellspacing='0'>");
- events.each(new ProcV<Integer>() {
- @Override
- public void apply(String key, Integer value) {
- timeHtml.appendHtmlConstant("<tr><td>");
- timeHtml.appendEscaped(key);
- timeHtml.appendHtmlConstant(":</td><td>");
- timeHtml.appendEscaped("" + value);
- timeHtml.appendHtmlConstant("</td></tr>");
- }
- });
- timeHtml.appendHtmlConstant("</table>");
- timeBox.setInnerHTML(timeHtml.toSafeHtml().asString());
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/wave/client/testing/public/UndercurrentHarness.html
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/wave/client/testing/public/UndercurrentHarness.html b/wave/src/main/java/org/waveprotocol/wave/client/testing/public/UndercurrentHarness.html
deleted file mode 100644
index a7ac1a3..0000000
--- a/wave/src/main/java/org/waveprotocol/wave/client/testing/public/UndercurrentHarness.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<html>
- <head>
- <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
- <meta name="gwt:property" content="locale=en">
- <title>Undercurrent Harness</title>
- <style type='text/css'>
- /* Full screen box. */
- body {
- position: absolute;
- margin: 0;
- padding: 0;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
-
- /*
- * Arial seems to be the only non-ugly sans-serif font that renders roughly the same on both
- * Chrome and Firefox. e.g., 'sans-serif' on Firefox is a nicer mystery font, because it is
- * wider, but Chrome binds 'sans-serif' to 'arial'.
- */
- font-family: arial;
- font-size: small;
- }
-
- /* Fixed-width and horizontally centered, in a way that works on IE. */
- #initialHtml {
- position: absolute;
- left: 50%;
- right: 50%;
- top: 4em; /* Enough space for the header. */
- bottom: 4em;
- /* Expand out of the center line, aiming for ~70-75 character blip widths. */
- margin-left: -250px;
- margin-right: -250px;
- border: 1px solid lightGray;
- }
-
- #info {
- position: absolute;
- z-index: 100;
- right: 20px;
- top: 20px;
- padding: 0.2em;
- width: 10em;
- border: 1px solid black;
- background-color: lightGray;
- }
-
- #timeline {
- margin-left: 1em;
- }
-
- </style>
- </head>
- <body>
- <h2>Undercurrent Test Harness</h2>
- <div id='initialHtml'></div>
- <div id='info'>
- Active: <span id='active'></span><br/>
- Timing:
- <div id='timeline'></div>
- </div>
- <script type='text/javascript' src='waveharness.nocache.js'>
- </script>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/wave/model/conversation/testing/BlipTestUtils.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/wave/model/conversation/testing/BlipTestUtils.java b/wave/src/main/java/org/waveprotocol/wave/model/conversation/testing/BlipTestUtils.java
deleted file mode 100644
index 4bdf453..0000000
--- a/wave/src/main/java/org/waveprotocol/wave/model/conversation/testing/BlipTestUtils.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.wave.model.conversation.testing;
-
-import org.waveprotocol.wave.model.conversation.Blips;
-import org.waveprotocol.wave.model.conversation.ConversationBlip;
-import org.waveprotocol.wave.model.conversation.TitleHelper;
-
-import org.waveprotocol.wave.model.document.ReadableWDocument;
-import org.waveprotocol.wave.model.document.indexed.IndexedDocument;
-import org.waveprotocol.wave.model.document.operation.automaton.DocumentSchema;
-import org.waveprotocol.wave.model.document.raw.impl.Element;
-import org.waveprotocol.wave.model.document.raw.impl.Node;
-import org.waveprotocol.wave.model.document.raw.impl.Text;
-import org.waveprotocol.wave.model.document.util.DocHelper;
-import org.waveprotocol.wave.model.document.util.DocProviders;
-import org.waveprotocol.wave.model.document.util.LineContainers;
-import org.waveprotocol.wave.model.document.util.XmlStringBuilder;
-
-/**
- * Utility functions used by conversation tests.
- *
- */
-public final class BlipTestUtils {
-
- // Non-instantiatable class
- private BlipTestUtils() {
- }
-
- /**
- * Returns the position of the body element in an initial, empty, blip.
- */
- public static int getInitialBlipBodyPosition() {
- IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build(
- TitleHelper.emptyDocumentWithTitle(),
- DocumentSchema.NO_SCHEMA_CONSTRAINTS);
- return getBodyPosition(d);
- }
-
-
- /**
- * Returns the position of the body element of the given blip.
- */
- public static int getBodyPosition(ConversationBlip blip) {
- return getBodyPosition(blip.getContent());
- }
-
- /**
- * Returns the position of the body element of the given document or 0 if the
- * document has no body.
- */
- public static <N, E extends N> int getBodyPosition(ReadableWDocument<N, E, ?> doc) {
- N body = DocHelper.getElementWithTagName(doc, Blips.BODY_TAGNAME);
- if (body == null) return 0;
- return doc.getLocation(body);
- }
-
- /**
- * Wrap the given xml string containing a blip body in an XmlStringBuilder
- * and prepend an empty head.
- */
- public static XmlStringBuilder prependHead(String body) {
- return XmlStringBuilder.createEmpty()
- .append(Blips.INITIAL_HEAD)
- .append(XmlStringBuilder.createFromXmlString(body));
- }
-
- /**
- * Returns a blip whose contents are the given lines.
- */
- public static String debugBlipWrap(String ... lines) {
- return XmlStringBuilder.createEmpty()
- .append(Blips.INITIAL_HEAD)
- .append(XmlStringBuilder.createFromXmlString(LineContainers.debugContainerWrap(lines)))
- .toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/wave/model/conversation/testing/FakeConversationView.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/wave/model/conversation/testing/FakeConversationView.java b/wave/src/main/java/org/waveprotocol/wave/model/conversation/testing/FakeConversationView.java
deleted file mode 100644
index 85b2fd9..0000000
--- a/wave/src/main/java/org/waveprotocol/wave/model/conversation/testing/FakeConversationView.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.wave.model.conversation.testing;
-
-import org.waveprotocol.wave.model.conversation.ObservableConversationView;
-import org.waveprotocol.wave.model.conversation.WaveBasedConversationView;
-import org.waveprotocol.wave.model.conversation.WaveletBasedConversation;
-import org.waveprotocol.wave.model.id.IdGenerator;
-import org.waveprotocol.wave.model.id.WaveId;
-import org.waveprotocol.wave.model.schema.SchemaProvider;
-import org.waveprotocol.wave.model.schema.conversation.ConversationSchemas;
-import org.waveprotocol.wave.model.testing.FakeIdGenerator;
-import org.waveprotocol.wave.model.testing.FakeWaveView;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-import org.waveprotocol.wave.model.wave.data.DocumentFactory;
-import org.waveprotocol.wave.model.wave.opbased.ObservableWaveView;
-
-import java.util.Collection;
-
-/**
- * A fake conversation view. The view is fully functioning but not attached to
- * any communication channels.
- *
- * @author anorth@google.com (Alex North)
- */
-public final class FakeConversationView implements ObservableConversationView {
-
- private final static SchemaProvider DEFAULT_SCHEMAS = new ConversationSchemas();
-
- public final static class Builder {
- private SchemaProvider schemas;
- private IdGenerator idGenerator;
- private WaveId waveId;
- private ParticipantId viewer;
- private DocumentFactory<?> docFactory;
-
- private Builder() {
- }
-
- public Builder with(DocumentFactory<?> docFactory) {
- this.docFactory = docFactory;
- return this;
- }
-
- public Builder with(SchemaProvider schemas) {
- this.schemas = schemas;
- return this;
- }
-
- public Builder with(IdGenerator idGenerator) {
- this.idGenerator = idGenerator;
- return this;
- }
-
- public Builder with(WaveId wid) {
- this.waveId = wid;
- return this;
- }
-
- public Builder with(ParticipantId viewer) {
- this.viewer = viewer;
- return this;
- }
-
- public FakeConversationView build() {
- if (schemas == null) {
- schemas = DEFAULT_SCHEMAS;
- }
- if (idGenerator == null) {
- idGenerator = FakeIdGenerator.create();
- }
- if (waveId == null) {
- waveId = idGenerator.newWaveId();
- }
-
- FakeWaveView waveView = FakeWaveView.builder(schemas) // \u2620
- .with(docFactory) // \u2620
- .with(idGenerator) // \u2620
- .with(waveId) // \u2620
- .with(viewer) // \u2620
- .build();
-
- return new FakeConversationView(WaveBasedConversationView.create(waveView, idGenerator));
- }
- }
-
- /** Creates a new conversation view builder. */
- public static Builder builder() {
- return new Builder();
- }
-
- /** The backing conversation view. */
- private final WaveBasedConversationView view;
-
- private FakeConversationView(WaveBasedConversationView view) {
- this.view = view;
- }
-
- @Override
- public String getId() {
- return view.getId();
- }
-
- @Override
- public WaveletBasedConversation createConversation() {
- return view.createConversation();
- }
-
- @Override
- public WaveletBasedConversation createRoot() {
- return view.createRoot();
- }
-
- @Override
- public WaveletBasedConversation getConversation(String conversationId) {
- return view.getConversation(conversationId);
- }
-
- @Override
- public Collection<? extends WaveletBasedConversation> getConversations() {
- return view.getConversations();
- }
-
- @Override
- public WaveletBasedConversation getRoot() {
- return view.getRoot();
- }
-
- @Override
- public void addListener(Listener listener) {
- view.addListener(listener);
- }
-
- @Override
- public void removeListener(Listener listener) {
- view.removeListener(listener);
- }
-
- public ObservableWaveView getWaveView() {
- return view.getWaveView();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/wave/model/testing/BasicFactories.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/wave/model/testing/BasicFactories.java b/wave/src/main/java/org/waveprotocol/wave/model/testing/BasicFactories.java
deleted file mode 100644
index f23e93b..0000000
--- a/wave/src/main/java/org/waveprotocol/wave/model/testing/BasicFactories.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.wave.model.testing;
-
-import org.waveprotocol.wave.model.document.Document;
-import org.waveprotocol.wave.model.document.ObservableDocument;
-import org.waveprotocol.wave.model.document.indexed.IndexedDocument;
-import org.waveprotocol.wave.model.document.operation.DocInitialization;
-import org.waveprotocol.wave.model.document.operation.DocOp;
-import org.waveprotocol.wave.model.document.operation.automaton.DocumentSchema;
-import org.waveprotocol.wave.model.document.raw.impl.Element;
-import org.waveprotocol.wave.model.document.raw.impl.Node;
-import org.waveprotocol.wave.model.document.raw.impl.Text;
-import org.waveprotocol.wave.model.document.util.DocProviders;
-import org.waveprotocol.wave.model.document.util.DocumentImpl;
-import org.waveprotocol.wave.model.document.util.DocumentProvider;
-import org.waveprotocol.wave.model.operation.SilentOperationSink;
-import org.waveprotocol.wave.model.schema.SchemaCollection;
-import org.waveprotocol.wave.model.schema.SchemaProvider;
-import org.waveprotocol.wave.model.util.Preconditions;
-import org.waveprotocol.wave.model.wave.data.DocumentFactory;
-import org.waveprotocol.wave.model.wave.data.MuteDocumentFactory;
-import org.waveprotocol.wave.model.wave.data.impl.ObservablePluggableMutableDocument;
-import org.waveprotocol.wave.model.wave.data.impl.PluggableMutableDocument;
-import org.waveprotocol.wave.model.wave.data.impl.WaveletDataImpl;
-
-import java.util.Map;
-
-/**
- * Static factory for creating various document factories and builders whose
- * document schemas come from the provider set using
- * {@link #setSchemaProvider(SchemaProvider)}. If no provider is set the empty
- * provider is used. This should only be used for tests of the core model.
- *
- */
-public class BasicFactories {
-
- /**
- * Provider of {@link Document}s based on the {@link DocProviders#POJO} DOM
- * implementation.
- */
- private static final DocumentProvider<Document> DOC_PROVIDER = new DocumentProvider<Document>() {
- @Override
- public Document create(String tagName, Map<String, String> attributes) {
- IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.create(tagName, attributes);
- return new DocumentImpl(DocProviders.createTrivialSequencer(doc), doc);
- }
-
- @Override
- public Document parse(String text) {
- IndexedDocument<Node, Element, Text> doc = DocProviders.POJO.parse(text);
- return new DocumentImpl(DocProviders.createTrivialSequencer(doc), doc);
- }
- };
-
- /**
- * Provider of {@link ObservableDocument}s based on the
- * {@link DocProviders#POJO} DOM implementation and a trivial sequence.
- */
- private static final DocumentProvider<ObservablePluggableMutableDocument> OBS_DOC_PROVIDER =
- new DocumentProvider<ObservablePluggableMutableDocument>() {
- @Override
- public ObservablePluggableMutableDocument create(
- String tagName, Map<String, String> attributes) {
- // FIXME(ohler): this is inefficient.
- return build(DocProviders.POJO.create(tagName, attributes).asOperation());
- }
-
- @Override
- public ObservablePluggableMutableDocument parse(String text) {
- // FIXME(ohler): this is inefficient.
- return build(DocProviders.POJO.parse(text).asOperation());
- }
-
- private ObservablePluggableMutableDocument build(DocInitialization init) {
- ObservablePluggableMutableDocument doc =
- new ObservablePluggableMutableDocument(DocumentSchema.NO_SCHEMA_CONSTRAINTS, init);
- doc.init(SilentOperationSink.VOID);
- return doc;
- }
- };
-
- private static SchemaProvider schemas = SchemaCollection.empty();
-
- /**
- * Sets the schema provider that will provide schemas for the factories
- * returned from the methods of this class.
- */
- public static void setSchemaProvider(SchemaProvider value) {
- schemas = value;
- }
-
- /**
- * Returns the current schema provider.
- */
- protected static SchemaProvider getSchemas() {
- return schemas;
- }
-
- /**
- * Returns a new fake wave view builder whose document schemas comes from the
- * current provider.
- */
- public static FakeWaveView.Builder fakeWaveViewBuilder() {
- return FakeWaveView.builder(getSchemas());
- }
-
- /**
- * Returns a new op-based wavelet factory builder whose document schemas comes
- * from the current provider.
- */
- public static OpBasedWaveletFactory.Builder opBasedWaveletFactoryBuilder() {
- return OpBasedWaveletFactory.builder(getSchemas());
- }
-
- /**
- * Returns a new wavelet data impl factory whose document schemas comes from
- * the current provider.
- */
- public static WaveletDataImpl.Factory waveletDataImplFactory() {
- return WaveletDataImpl.Factory.create(observablePluggableMutableDocumentFactory());
- }
-
- /**
- * Returns a mute document factory whose document schemas comes from the
- * current provider.
- */
- public static MuteDocumentFactory muteDocumentFactory() {
- return new MuteDocumentFactory(getSchemas());
- }
-
- /**
- * Returns a fake document factory whose document schemas comes from the
- * current provider.
- */
- public static FakeDocument.Factory fakeDocumentFactory() {
- return FakeDocument.Factory.create(getSchemas());
- }
-
- /**
- * Returns a plugable mutable document factory whose document schemas comes
- * from the current provider.
- */
- public static DocumentFactory<? extends PluggableMutableDocument>
- pluggableMutableDocumentFactory() {
- return PluggableMutableDocument.createFactory(getSchemas());
- }
-
- /**
- * Returns an observable pluggable mutable document factory whose document
- * schemas comes from the current provider.
- */
- public static DocumentFactory<? extends ObservablePluggableMutableDocument>
- observablePluggableMutableDocumentFactory() {
- return ObservablePluggableMutableDocument.createFactory(getSchemas());
- }
-
- /**
- * Returns a provider of {@link Document}s.
- *
- * Provided documents have no schema constraints: consider using
- * {@link MuteDocumentFactory} instead.
- *
- * TODO(anorth): Remove this method in favor of one specifying a schema.
- */
- public static DocumentProvider<Document> documentProvider() {
- return DOC_PROVIDER;
- }
-
- /**
- * Returns a provider of observable mutable documents.
- *
- * Provided documents have no schema constraints: consider using
- * {@link MuteDocumentFactory} instead.
- *
- * TODO(anorth): Change generic type to ObservableDocument after fixing
- * callers.
- *
- * TODO(anorth): Remove this method in favor of one specifying a schema.
- */
- public static DocumentProvider<ObservablePluggableMutableDocument> observableDocumentProvider() {
- return OBS_DOC_PROVIDER;
- }
-
- /**
- * Creates an observable mutable document with some schema, content, and sink.
- */
- public static ObservableDocument createDocument(DocumentSchema schema,
- String initialContent, SilentOperationSink<? super DocOp> sink) {
- Preconditions.checkNotNull(sink, "Sink can't be null");
- DocInitialization init = DocProviders.POJO.parse(initialContent).asOperation();
- ObservablePluggableMutableDocument doc = new ObservablePluggableMutableDocument(schema, init);
- doc.init(sink);
- return doc;
- }
-
- /**
- * Creates an observable mutable document with some schema and a sink.
- */
- public static ObservableDocument createDocument(
- DocumentSchema schema, SilentOperationSink<? super DocOp> sink) {
- return createDocument(schema, "", sink);
- }
-
- /**
- * Creates an observable mutable document with some schema.
- */
- public static ObservableDocument createDocument(DocumentSchema schema) {
- return createDocument(schema, "", SilentOperationSink.VOID);
- }
-
- /**
- * Creates an observable mutable document with some schema and initial content
- */
- public static ObservableDocument createDocument(
- DocumentSchema schema, String initialContent) {
- return createDocument(schema, initialContent, SilentOperationSink.VOID);
- }
-
- protected BasicFactories() {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/314ddcc7/wave/src/main/java/org/waveprotocol/wave/model/testing/DeltaTestUtil.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/wave/model/testing/DeltaTestUtil.java b/wave/src/main/java/org/waveprotocol/wave/model/testing/DeltaTestUtil.java
deleted file mode 100755
index 2bd7021..0000000
--- a/wave/src/main/java/org/waveprotocol/wave/model/testing/DeltaTestUtil.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.waveprotocol.wave.model.testing;
-
-import org.waveprotocol.wave.model.document.operation.DocOp;
-import org.waveprotocol.wave.model.document.operation.impl.DocOpBuilder;
-import org.waveprotocol.wave.model.operation.wave.AddParticipant;
-import org.waveprotocol.wave.model.operation.wave.BlipContentOperation;
-import org.waveprotocol.wave.model.operation.wave.NoOp;
-import org.waveprotocol.wave.model.operation.wave.RemoveParticipant;
-import org.waveprotocol.wave.model.operation.wave.TransformedWaveletDelta;
-import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation;
-import org.waveprotocol.wave.model.operation.wave.WaveletDelta;
-import org.waveprotocol.wave.model.operation.wave.WaveletOperation;
-import org.waveprotocol.wave.model.operation.wave.WaveletOperationContext;
-import org.waveprotocol.wave.model.util.CollectionUtils;
-import org.waveprotocol.wave.model.version.HashedVersion;
-import org.waveprotocol.wave.model.wave.Constants;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
-
-/**
- * A bunch of utility functions to make testing easier.
- *
- * @author zdwang@google.com (David Wang)
- */
-public class DeltaTestUtil {
- private static final WaveletOperationContext DUMMY = new WaveletOperationContext(null, 0L, 0L);
-
- private final ParticipantId author;
- private final Random random = new Random(42);
-
- /**
- * Creates a {@link DeltaTestUtil} with which operations authored by the given
- * author can readily be made.
- */
- public DeltaTestUtil(String author) {
- this(new ParticipantId(author));
- }
-
- /**
- * Creates a {@link DeltaTestUtil} with which operations authored by the given
- * author can readily be made.
- */
- public DeltaTestUtil(ParticipantId author) {
- this.author = author;
- }
-
- public ParticipantId getAuthor() {
- return author;
- }
-
- /**
- * Creates an XmlDelete with the given data.
- */
- public WaveletOperation delete(int posStart, String characters, int remaining) {
- DocOp op = new DocOpBuilder()
- .retain(posStart)
- .deleteCharacters(characters)
- .retain(remaining)
- .build();
- BlipContentOperation blipOp = new BlipContentOperation(
- new WaveletOperationContext(author, 0L, 1), op);
- WaveletBlipOperation waveOp = new WaveletBlipOperation("blip id", blipOp);
- return waveOp;
- }
-
- /**
- * Wrap an op with a delta.
- */
- public TransformedWaveletDelta delta(long targetVersion, WaveletOperation op) {
- return TransformedWaveletDelta.cloneOperations(author,
- HashedVersion.unsigned(targetVersion + 1), 0L, Arrays.asList(op));
- }
-
- /**
- * Create a delta with a single NoOp operation.
- *
- * @param initialVersion The version before the operation.
- */
- public TransformedWaveletDelta noOpDelta(long initialVersion) {
- return makeTransformedDelta(0L, HashedVersion.unsigned(initialVersion + 1), 1);
- }
-
- /** Create a NoOp operation. */
- public NoOp noOp() {
- return new NoOp(new WaveletOperationContext(author, 0L, 1L));
- }
-
- /** Create an AddParticipant operation. */
- public AddParticipant addParticipant(ParticipantId participant) {
- return new AddParticipant(new WaveletOperationContext(author, 0L, 1L), participant);
- }
-
- /** Creates a RemoveParticipant operation. */
- public RemoveParticipant removeParticipant(ParticipantId participant) {
- return new RemoveParticipant(new WaveletOperationContext(author, 0L, 1L), participant);
- }
-
- /**
- * A docop that is empty. i.e. does nothing to the document. The document must
- * also be empty, otherwise the operation is invalid.
- */
- public WaveletOperation noOpDocOp(String blipId) {
- WaveletOperationContext context = new WaveletOperationContext(author, 0L, 1L);
- BlipContentOperation blipOp = new BlipContentOperation(context, (new DocOpBuilder()).build());
- return new WaveletBlipOperation(blipId, blipOp);
- }
-
- /**
- * Creates an XmlInsert with the given data.
- */
- public WaveletOperation insert(int pos, String text, int remaining,
- HashedVersion resultingVersion) {
- DocOpBuilder builder = new DocOpBuilder();
- builder.retain(pos).characters(text);
- if (remaining > 0) {
- builder.retain(remaining);
- }
- BlipContentOperation blipOp = new BlipContentOperation(
- new WaveletOperationContext(author, 0L, 1, resultingVersion), builder.build());
- WaveletBlipOperation waveOp = new WaveletBlipOperation("blip id", blipOp);
- return waveOp;
- }
-
- /**
- * Builds a random client delta.
- */
- public WaveletDelta makeDelta(HashedVersion targetVersion, long timestamp, int numOps) {
- List<WaveletOperation> ops = CollectionUtils.newArrayList();
- WaveletOperationContext context =
- new WaveletOperationContext(author, Constants.NO_TIMESTAMP, 1);
- for (int i = 0; i < numOps; ++i) {
- ops.add(randomOp(context));
- }
- return new WaveletDelta(author, targetVersion, ops);
- }
-
- /**
- * Builds a no-op client delta.
- */
- public WaveletDelta makeNoOpDelta(HashedVersion targetVersion, long timestamp, int numOps) {
- List<WaveletOperation> ops = CollectionUtils.newArrayList();
- WaveletOperationContext context =
- new WaveletOperationContext(author, Constants.NO_TIMESTAMP, 1);
- for (int i = 0; i < numOps; ++i) {
- ops.add(new NoOp(context));
- }
- return new WaveletDelta(author, targetVersion, ops);
- }
-
- /**
- * Builds a random transformed delta.
- */
- public TransformedWaveletDelta makeTransformedDelta(long applicationTimestamp,
- HashedVersion resultingVersion, int numOps) {
- List<WaveletOperation> ops = CollectionUtils.newArrayList();
- for (int i = 0; i < numOps; ++i) {
- ops.add(randomOp(DUMMY));
- }
- return TransformedWaveletDelta.cloneOperations(author, resultingVersion, applicationTimestamp,
- ops);
- }
-
- /**
- * Creates a random op. The result is unlikely to be applicable to any
- * wavelet, but is generated such that we are fairly certain that it will be
- * unique so we can identify it when it completes a round-trip.
- */
- private WaveletOperation randomOp(WaveletOperationContext context) {
- DocOp blipOp = new DocOpBuilder()
- .retain(Math.abs(random.nextInt()) / 2 + 1)
- .characters("createRndOp#" + random.nextInt())
- .build();
- return new WaveletBlipOperation("createRndId#" + random.nextInt(),
- new BlipContentOperation(context, blipOp));
- }
-}