Package com.aragost.javahg

Examples of com.aragost.javahg.BaseRepository


public class RevertCommandTest extends AbstractTestCase {

    @Test
    public void testNothingToRevert() throws IOException {
        BaseRepository repo = getTestRepository();
        createChangeset();
        RevertCommand.on(repo).all().execute();
    }
View Full Code Here


        RevertCommand.on(repo).all().execute();
    }
   
    @Test
    public void testRevertToParent() throws IOException {
        BaseRepository repo = getTestRepository();
        writeFile("a", "a");
        commit();
        writeFile("a", "aa");
        RevertCommand.on(repo).execute("a");
        Assert.assertEquals("a", readFile("a"));
View Full Code Here

        Assert.assertArrayEquals(data.getBytes(), result);
    }

    @Test
    public void testLargeFile() throws IOException, InterruptedException {
        BaseRepository repo = getTestRepository();
        byte[] s = new byte[1024];
        File file = new File(repo.getDirectory(), "large");
        FileOutputStream out = new FileOutputStream(file);
        for (int i = 0; i < 1024; i++) {
            out.write(s);
        }
        out.close();
View Full Code Here

        command.executeToStream();
    }

    @Test
    public void testServerRefCount() throws IOException {
        BaseRepository repo = getTestRepository();
        BaseRepository repo2 = getTestRepository2();
        writeFile("a");
        commit();
        Bundle bundle = IncomingCommand.on(repo2).execute(repo);
        Repository repo3 = bundle.getOverlayRepository();
        Assert.assertSame(repo2.getServerPool(), repo3.getServerPool());
        ServerPool pool = repo2.getServerPool();
        Assert.assertEquals(1, pool.getServers().size());
        Assert.assertNotNull(pool.getServers().get(0).getProcess());
        repo2.close();
        Assert.assertNotNull(pool.getServers().get(0).getProcess());
        Server server = pool.getServers().get(0);
        bundle.close();
        Assert.assertNull(server.getProcess());
        Assert.assertTrue(pool.getServers().isEmpty());
View Full Code Here

        Assert.assertTrue(pool.getServers().isEmpty());
    }

    @Test
    public void testConfigChanges() throws IOException {
        BaseRepository repo = getTestRepository();
        GenericCommand cmd = new GenericCommand(repo, "version") {
            {
                {
                    cmdAppend("--config", "ui.username=xxx");
                }
            }
        };
        cmd.execute();
        writeFile("A");
        repo.workingCopy().add("A");
        try {
            // The previous config change is not forgotten
            CommitCommand commit = CommitCommand.on(repo).message("m");
            Changeset cs = commit.execute();
            assertFailedExecution(commit, "Username is " + cs.getUser());
View Full Code Here

    }

    /** validate that clone requiring auth will use auth in hgrc */
    @Test
    public void testCloneRequiringAuth() throws Exception {
        BaseRepository repoA = getTestRepository();

        writeFile(repoA, "x", "abc");
        AddCommand.on(repoA).execute();
        CommitCommand.on(repoA).message("added x").user("user").execute();

View Full Code Here

     * @throws IOException
     */
    private String retrieveStartupStderr(RepositoryConfiguration conf) throws IOException {
        conf.setHgrcPath(Utils.resourceAsFile("/missing-extension.hgrc").getPath());
        File dir = Files.createTempDir();
        BaseRepository repo = Repository.create(conf, dir);
        String stderr = getFirstServer(repo).getStartupStderr();
        repo.close();
        deleteTempDir(dir);
        return stderr;
    }
View Full Code Here

   
    @Test
    public void testServerIdle() throws InterruptedException {
        RepositoryConfiguration conf = makeRepoConf();
        conf.setServerIdleTime(1);
        BaseRepository repo = Repository.create(conf, Files.createTempDir());

        Assert.assertEquals(1, repo.getServerPool().getNumIdleServers());

        Thread.sleep(2000);

        Assert.assertEquals(0, repo.getServerPool().getNumIdleServers());
        LogCommand.on(repo).execute();
        Assert.assertEquals(1, repo.getServerPool().getNumIdleServers());
    }
View Full Code Here

    private static final int NUMBER_OF_THREADS = 20;
    private static volatile Random RANDOM = new Random(0);

    @Test
    public void stressTest() throws InterruptedException {
        BaseRepository repo = getTestRepository();
        Stats stats = new Stats();
        List<StressThread> threads = Lists.newArrayList();
        for (int i = 0; i < NUMBER_OF_THREADS; i++) {
            StressThread t = new StressThread(CYCLES_PER_THREAD, i, stats, repo);
            t.start();
            threads.add(t);
        }

        for (StressThread cycleThread : threads) {
            cycleThread.join();
        }
        Assert.assertEquals(2 * CYCLES_PER_THREAD * NUMBER_OF_THREADS, stats.changes + stats.noChanges);
        System.err.println("Cache stats: " + repo.getCacheStats());
    }
View Full Code Here

    @Test
    public void stressTestConcurrency() throws InterruptedException, IOException {
        RepositoryConfiguration conf = makeRepoConf();
        conf.setConcurrency(3);
        BaseRepository repo = Repository.create(conf, Files.createTempDir());

        Stats stats = new Stats();
        List<StressThread> threads = Lists.newArrayList();

        // Write some initial changesets
        writeFile(repo, "a", "123");
        AddCommand.on(repo).execute();
        CommitCommand.on(repo).message("a").user("setup").execute();
        writeFile(repo, "b", "123");
        AddCommand.on(repo).execute();
        CommitCommand.on(repo).message("b").user("setup").execute();
        writeFile(repo, "c", "123");
        AddCommand.on(repo).execute();
        CommitCommand.on(repo).message("c").user("setup").execute();

        for (int i = 0; i < NUMBER_OF_THREADS; i++) {
            StressThread t = new StressThread2(CYCLES_PER_THREAD * 10, i, stats, repo);
            t.start();
            threads.add(t);
        }

        for (StressThread cycleThread : threads) {
            cycleThread.join();
        }
        Assert.assertEquals(20 * CYCLES_PER_THREAD * NUMBER_OF_THREADS, stats.changes + stats.noChanges);
        System.err.println("Cache stats: " + repo.getCacheStats());
    }
View Full Code Here

TOP

Related Classes of com.aragost.javahg.BaseRepository

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.