Package org.exoplatform.services.document.diff

Examples of org.exoplatform.services.document.diff.Revision


   public void testEmptySequences() throws Exception
   {
      String[] emptyOrig = {};
      String[] emptyRev = {};
      DiffService diffService = new DiffServiceImpl(getAlgo());
      Revision revision = diffService.diff(emptyOrig, emptyRev);

      assertEquals("revision size is not zero", 0, revision.size());
   }
View Full Code Here


   public void testOriginalEmpty() throws Exception
   {
      String[] emptyOrig = {};
      String[] rev = {"1", "2", "3"};
      DiffService diffService = new DiffServiceImpl(getAlgo());
      Revision revision = diffService.diff(emptyOrig, rev);

      assertEquals("revision size should be one", 1, revision.size());
      assertTrue(revision.getDelta(0) instanceof AddDelta);
   }
View Full Code Here

   public void testRevisedEmpty() throws Exception
   {
      String[] orig = {"1", "2", "3"};
      String[] emptyRev = {};
      DiffService diffService = new DiffServiceImpl(getAlgo());
      Revision revision = diffService.diff(orig, emptyRev);

      assertEquals("revision size should be one", 1, revision.size());
      assertTrue(revision.getDelta(0) instanceof DeleteDelta);
   }
View Full Code Here

   }

   public void testDeleteAll() throws Exception
   {
      DiffService diffService = new DiffServiceImpl(getAlgo());
      Revision revision = diffService.diff(original, empty);
      assertEquals(1, revision.size());
      assertTrue(revision.getDelta(0) instanceof DeleteDelta);
      assertTrue(diffService.compare(revision.patch(original), empty));
   }
View Full Code Here

   }

   public void testTwoDeletes() throws Exception
   {
      DiffService diffService = new DiffServiceImpl(getAlgo());
      Revision revision = diffService.diff(original, rev1);
      assertEquals(2, revision.size());
      assertTrue(revision.getDelta(0) instanceof DeleteDelta);
      assertTrue(revision.getDelta(1) instanceof DeleteDelta);
      assertTrue(diffService.compare(revision.patch(original), rev1));
      assertEquals("3d2" + DiffService.NL + "< [3] three" + DiffService.NL + "9d7" + DiffService.NL + "< [9] nine"
         + DiffService.NL, revision.toString());
   }
View Full Code Here

   }

   public void testChangeAtTheEnd() throws Exception
   {
      DiffService diffService = new DiffServiceImpl(getAlgo());
      Revision revision = diffService.diff(original, rev2);
      assertEquals(1, revision.size());
      assertTrue(revision.getDelta(0) instanceof ChangeDelta);
      assertTrue(diffService.compare(revision.patch(original), rev2));
      assertEquals("d7 3" + DiffService.NL + "a9 2" + DiffService.NL + "[7] seven revised" + DiffService.NL
         + "[8] eight revised" + DiffService.NL, revision.toRCSString());
   }
View Full Code Here

   public void testPatchFailed() throws Exception
   {
      try
      {
         DiffService diffService = new DiffServiceImpl(getAlgo());
         Revision revision = diffService.diff(original, rev2);
         assertTrue(!diffService.compare(revision.patch(rev1), rev2));
         fail("Exception not thrown");
      }
      catch (Exception e)
      {
      }
View Full Code Here

      Object[] orig = new String[]{"[1] one", "[2] two", "[3] three", "[4] four", "[5] five", "[6] six"};

      Object[] rev = new String[]{"[3] three", "[1] one", "[5] five", "[2] two", "[6] six", "[4] four"};

      DiffService diffService = new DiffServiceImpl(getAlgo());
      Revision revision = diffService.diff(orig, rev);
      Object[] patched = revision.patch(orig);
      assertTrue(diffService.compare(patched, rev));
   }
View Full Code Here

      Object[] rev =
         new String[]{"one revised", "two revised", "[2] two", "[3] three", "five revised", "six revised", "[5] five"};

      DiffService diffService = new DiffServiceImpl(getAlgo());
      Revision revision = diffService.diff(orig, rev);
      Object[] patched = revision.patch(orig);
      assertTrue(diffService.compare(patched, rev));
   }
View Full Code Here

      DiffService diffService = new DiffServiceImpl(getAlgo());

      for (int seed = 0; seed < 10; seed++)
      {
         Object[] shuffle = ((DiffServiceImpl)diffService).shuffle(orig);
         Revision revision = diffService.diff(orig, shuffle);
         Object[] patched = revision.patch(orig);
         if (!diffService.compare(patched, shuffle))
         {
            fail("iter " + seed + " revisions differ after patch");
         }
      }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.document.diff.Revision

Copyright © 2018 www.massapicom. 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.