Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.Filter


    if (factories.isEmpty()) {
      return Collections.emptyList();
    }
    ArrayList<Filter> rv = new ArrayList<Filter>(factories.size());
    for (Filter.Factory ff : factories) {
      Filter f = ff.create(p, opts);
      if (f != null) {
        rv.add(f);
      }
    }
    return rv;
View Full Code Here


  private HgRepository repo;

  @Test
  public void testSmallBuffer() throws Exception {
    initRepo();
    final Filter kwFilter = createFilter(Filter.Direction.ToRepo);
    final byte[] in = "1\n2\n3\n".getBytes();
    ByteBuffer bb = kwFilter.filter(ByteBuffer.wrap(in));
    final byte[] out = new byte[bb.remaining()];
    bb.get(out);
    Assert.assertArrayEquals(in, out);
  }
View Full Code Here

  }
 
  @Test
  public void testKeywordDrop() throws Exception {
    initRepo();
    final Filter kwFilter = createFilter(Filter.Direction.ToRepo);
    final byte[] in = "1\n$Revision: cf200271439a7ec256151b30bc4360b21db3542e$\n3\n".getBytes();
    ByteBuffer bb = kwFilter.filter(ByteBuffer.wrap(in));
    final byte[] out = new byte[bb.remaining()];
    bb.get(out);
    Assert.assertArrayEquals("1\n$Revision$\n3\n".getBytes(), out);
  }
View Full Code Here

  public void testKeywordSplitInBuffer() throws Exception {
    initRepo();
    final byte[] in1 = "1\n$Id:whatever".getBytes();
    final byte[] in2 = " continues here$\n3\n".getBytes();
    ByteArrayChannel out = new ByteArrayChannel();
    final Filter kwFilter = createFilter(Filter.Direction.ToRepo);
    out.write(kwFilter.filter(ByteBuffer.wrap(in1)));
    out.write(kwFilter.filter(ByteBuffer.wrap(in2)));
    Assert.assertEquals("1\n$Id$\n3\n", new String(out.toArray()));
    // Same as above, to extreme - only $ in the first buffer
    final Filter kwFilter2 = createFilter(Filter.Direction.ToRepo);
    out = new ByteArrayChannel();
    out.write(kwFilter2.filter(ByteBuffer.wrap("1\n$".getBytes())));
    out.write(kwFilter2.filter(ByteBuffer.wrap("Id:whatever continues here$\n3\n".getBytes())));
    Assert.assertEquals("1\n$Id$\n3\n", new String(out.toArray()));
  }
View Full Code Here

  public void testIncompleteKeyword() throws Exception {
    initRepo();
    final byte[] in1 = "1\n$Id:whatever".getBytes();
    final byte[] in2 = " id doesn't close here\n3\n".getBytes();
    ByteArrayChannel out = new ByteArrayChannel();
    final Filter kwFilter = createFilter(Filter.Direction.ToRepo);
    out.write(kwFilter.filter(ByteBuffer.wrap(in1)));
    out.write(kwFilter.filter(ByteBuffer.wrap(in2)));
    byte[] expected = new byte[in1.length + in2.length];
    System.arraycopy(in1, 0, expected, 0, in1.length);
    System.arraycopy(in2, 0, expected, in1.length, in2.length);
    Assert.assertEquals(new String(expected), new String(out.toArray()));
  }
View Full Code Here

 
  @Test
  public void testIncompleteKeywordAtEOF() throws Exception {
    initRepo();
    final byte[] in = "1\n$Id:whatever\n".getBytes();
    final Filter kwFilter = createFilter(Filter.Direction.ToRepo);
    ByteBuffer outBuf = kwFilter.filter(ByteBuffer.wrap(in));
    byte[] out = new byte[outBuf.remaining()];
    outBuf.get(out);
    Assert.assertEquals(new String(in), new String(out));
    //
    // incomplete $kw is stripped of in case of EOF
    final Filter kwFilter2 = createFilter(Filter.Direction.ToRepo);
    outBuf = kwFilter2.filter(ByteBuffer.wrap("1\n$Id:whatever".getBytes()));
    out = new byte[outBuf.remaining()];
    outBuf.get(out);
    Assert.assertEquals("1\n", new String(out));
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.internal.Filter

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.