Package org.waveprotocol.wave.model.operation.testing

Source Code of org.waveprotocol.wave.model.operation.testing.DocumentDomainLargeTest

/**
* 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.operation.testing;


import junit.framework.TestCase;

import org.waveprotocol.wave.model.document.bootstrap.BootstrapDocument;
import org.waveprotocol.wave.model.document.operation.DocOp;
import org.waveprotocol.wave.model.document.util.DocOpScrub;
import org.waveprotocol.wave.model.operation.testing.DomainRandomTester.FailureException;
import org.waveprotocol.wave.model.operation.testing.DomainRandomTester.Log;


public class DocumentDomainLargeTest extends TestCase {

  private final int NUM_ITERATIONS = 50; // NOTE: increase if you test changes to doc ops
  DomainRandomTester<BootstrapDocument, DocOp> t;

  boolean expectFailure = false;

  @Override
  public void setUp() {
    DocOpScrub.setShouldScrubByDefault(false);
  }

  public void testDataOpEquivalence() {
    createTester();
    t.testDataOperationEquivalence(NUM_ITERATIONS);
  }

  public void testInversion() {
    createTester();
    t.testOperationInversion(NUM_ITERATIONS);
  }

  public void testCompose() {
    createTester();
    t.testCompositionOnInitialState(NUM_ITERATIONS);
    t.testCompositionAssociativity(NUM_ITERATIONS);
    t.testSimpleComposition(NUM_ITERATIONS);
  }

  public void testTransform() {
    createTester();
    t.testTransformDiamondProperty(NUM_ITERATIONS);
  }

  protected void createTester() {
    createTester(new DocumentDomain(), new DocOpGenerator());
  }

  protected void createTester(DocumentDomain d, RandomOpGenerator<BootstrapDocument, DocOp> g) {
    t = new DomainRandomTester<BootstrapDocument, DocOp>(new Log() {
        @Override
        public void inconsistent(String... lines) {
          if (!expectFailure) {
            for (String line : lines) {
              System.err.println(line);
            }
          }
          throw new FailureException();
        }

        @Override
        public void fatal(Throwable exception, String... lines) {
          exception.printStackTrace();
          for (String line : lines) {
            System.err.println(line);
          }
          fail("EXCEPTION THROWN");
        }

        @Override
        public void info(String... lines) {
          for (String line : lines) {
            System.out.println(line);
          }
        }
      }, d, g);
  }
}
TOP

Related Classes of org.waveprotocol.wave.model.operation.testing.DocumentDomainLargeTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.