⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basictests.java

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        File dir = new File(thisTest.getWorkingCopy(), "dir");        dir.mkdir();        // create dir/foo.c        File fileC = new File(dir, "foo.c");        new FileOutputStream(fileC).close();        // create dir/foo.o (should be ignored)        File fileO = new File(dir, "foo.o");        new FileOutputStream(fileO).close();        // add dir        client.add(dir.getAbsolutePath(), true);        thisTest.getWc().addItem("dir", null);        thisTest.getWc().setItemTextStatus("dir",Status.Kind.added);        thisTest.getWc().addItem("dir/foo.c", "");        thisTest.getWc().setItemTextStatus("dir/foo.c",Status.Kind.added);        thisTest.getWc().addItem("dir/foo.o", "");        thisTest.getWc().setItemTextStatus("dir/foo.o",Status.Kind.ignored);        thisTest.getWc().setItemNodeKind("dir/foo.o", NodeKind.unknown);        // test the working copy status        thisTest.checkStatus();    }    /**     * test the basis SVNClient.import functionality with files that should be     * ignored     * @throws Throwable     */    public void testBasicImportIgnores() throws Throwable    {        // create working copy        OneTest thisTest = new OneTest();        // create dir        File dir = new File(thisTest.getWorkingCopy(), "dir");        dir.mkdir();        // create dir/foo.c        File fileC = new File(dir, "foo.c");        new FileOutputStream(fileC).close();        // create dir/foo.o (should be ignored)        File fileO = new File(dir, "foo.o");        new FileOutputStream(fileO).close();        // import dir        addExpectedCommitItem(thisTest.getWCPath(),                null, "dir", NodeKind.none, CommitItemStateFlags.Add);        client.doImport(dir.getAbsolutePath(), thisTest.getUrl()+"/dir",                "log message for import", true);        // remove dir        removeDirectoryWithContent(dir);        // udpate the working copy        assertEquals("wrong revision from update", 2,                client.update(thisTest.getWCPath(), null, true));        thisTest.getWc().addItem("dir", null);        thisTest.getWc().addItem("dir/foo.c", "");        // test the working copy status        thisTest.checkStatus();    }    /**     * test the basic SVNClient.info functionality     * @throws Throwable     */    public void testBasicInfo() throws Throwable    {        // create the working copy        OneTest thisTest = new OneTest();        // get the item information and test it        Info info = client.info(thisTest.getWCPath()+"/A/mu");        assertEquals("wrong revision from info", 1,                info.getLastChangedRevision());        assertEquals("wrong schedule kind from info", ScheduleKind.normal,                info.getSchedule());        assertEquals("wrong node kind from info", NodeKind.file,                info.getNodeKind());    }    /**     * test the basic SVNClient.logMessage functionality     * @throws Throwable     */    public void testBasicLogMessage() throws Throwable    {        // create the working copy        OneTest thisTest = new OneTest();        // get the commit message of the initial import and test it        LogMessage lm[] = client.logMessages(thisTest.getWCPath(), null,                null, false, true);        assertEquals("wrong number of objects", 1, lm.length);        assertEquals("wrong message", "Log Message", lm[0].getMessage());        assertEquals("wrong revision", 1, lm[0].getRevisionNumber());        assertEquals("wrong user", "jrandom", lm[0].getAuthor());        assertNotNull("changed paths set", lm[0].getChangedPaths());        ChangePath cp[] = lm[0].getChangedPaths();        assertEquals("wrong number of chang pathes", 20, cp.length);        assertEquals("wrong path", "/A", cp[0].getPath());        assertEquals("wrong copy source rev", -1, cp[0].getCopySrcRevision());        assertNull("wrong copy source path", cp[0].getCopySrcPath());        assertEquals("wrong action", 'A', cp[0].getAction());    }    /**     * test the basic SVNClient.getVersionInfo functionality     * @throws Throwable     * @since 1.2     */    public void testBasicVersionInfo() throws Throwable    {        // create the working copy        OneTest thisTest = new OneTest();        assertEquals("wrong version info","1",                client.getVersionInfo(thisTest.getWCPath(), null, false));            }    /**     * test the baisc SVNClient locking functionality     * @throws Throwable     * @since 1.2     */    public void testBasicLocking() throws Throwable    {        // build the first working copy        OneTest thisTest = new OneTest();        client.propertySet(thisTest.getWCPath()+"/A/mu",                           PropertyData.NEEDS_LOCK, "*", false);        addExpectedCommitItem(thisTest.getWCPath(),                thisTest.getUrl(), "A/mu",NodeKind.file,                CommitItemStateFlags.PropMods);        assertEquals("bad revision number on commit", 2,                     client.commit(new String[] {thisTest.getWCPath()},                                   "message", true));        File f = new File(thisTest.getWCPath()+"/A/mu");        assertEquals("file should be read only now", false, f.canWrite());        client.lock(new String[] {thisTest.getWCPath()+"/A/mu"},                                "comment", false);        assertEquals("file should be read write now", true, f.canWrite());        client.unlock(new String[]{thisTest.getWCPath()+"/A/mu"},                false);        assertEquals("file should be read only now", false, f.canWrite());        client.lock(new String[]{thisTest.getWCPath()+"/A/mu"},                           "comment", false);        assertEquals("file should be read write now", true, f.canWrite());        addExpectedCommitItem(thisTest.getWCPath(),                thisTest.getUrl(), "A/mu",NodeKind.file,                    0);        assertEquals("rev number from commit",-1, client.commit(                new String[]{thisTest.getWCPath()},"message", true));        assertEquals("file should be read write now", true, f.canWrite());        try        {            // Attempt to lock an invalid path            client.lock(new String[]{thisTest.getWCPath()+"/A/mu2"}, "comment",                        false);            fail("missing exception");        }        catch (ClientException expected)        {        }    }    /**     * test the baisc SVNClient.info2 functionality      * @throws Throwable     * @since 1.2     */    public void testBasicInfo2() throws Throwable    {        // build the first working copy        OneTest thisTest = new OneTest();        Info2[] infos = client.info2(thisTest.getWCPath(), null, null, false);        assertEquals("this should return 1 info object", 1, infos.length);        infos = client.info2(thisTest.getWCPath(), null, null, true);        assertEquals("this should return 21 info objects", 21, infos.length);        infos = client.info2(thisTest.getWCPath(), new Revision.Number(1),                             new Revision.Number(1), true);        assertEquals("this should return 21 info objects", 21, infos.length);    }    /**     * test the basic SVNClient.merge functionality     * @throws Throwable     * @since 1.2     */    public void testBasicMerge() throws Throwable    {        // build the test setup        OneTest thisTest = new OneTest();                // create branches directory in the repository        addExpectedCommitItem(null, thisTest.getUrl(), "branches", NodeKind.none,              CommitItemStateFlags.Add);        client.mkdir(new String[]{thisTest.getUrl() + "/branches"}, "log_msg");        // copy A to branches        addExpectedCommitItem(null, thisTest.getUrl(), "branches/A", NodeKind.none,                CommitItemStateFlags.Add);        client.copy(thisTest.getUrl() + "/A", thisTest.getUrl() + "/branches/A", "create A branch", Revision.HEAD);        // update the WC so that it has the branches folder        client.update(thisTest.getWCPath(), Revision.HEAD, true);        // modify file A/mu        File mu = new File(thisTest.getWorkingCopy(), "A/mu");        PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));        muPW.print("appended mu text");        muPW.close();        thisTest.getWc().setItemWorkingCopyRevision("A/mu", 4);        thisTest.getWc().setItemContent("A/mu",                thisTest.getWc().getItemContent("A/mu") + "appended mu text");        addExpectedCommitItem(thisTest.getWCPath(),                thisTest.getUrl(), "A/mu",NodeKind.file,                CommitItemStateFlags.TextMods);        // modify file A/D/G/rho        File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");        PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));        rhoPW.print("new appended text for rho");        rhoPW.close();        thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 4);        thisTest.getWc().setItemContent("A/D/G/rho",                thisTest.getWc().getItemContent("A/D/G/rho")                + "new appended text for rho");        addExpectedCommitItem(thisTest.getWCPath(),                thisTest.getUrl(), "A/D/G/rho",NodeKind.file,                CommitItemStateFlags.TextMods);        // commit the changes        assertEquals("wrong revision number from commit",              client.commit(new String[]{thisTest.getWCPath()}, "log msg",                      true), 4);        // merge changes in A to branches/A        String branchPath = thisTest.getWCPath() + "/branches/A";        String modUrl = thisTest.getUrl() + "/A";        // test --dry-run        client.merge(modUrl, new Revision.Number(2), modUrl, Revision.HEAD, branchPath, false, true, false, true);        // now do the real merge        client.merge(modUrl, new Revision.Number(2), modUrl, Revision.HEAD, branchPath, false, true, false, false);                // commit the changes so that we can verify merge        addExpectedCommitItem(thisTest.getWCPath(),                thisTest.getUrl(), "branches/A/mu",NodeKind.file,                CommitItemStateFlags.TextMods);        addExpectedCommitItem(thisTest.getWCPath(),                thisTest.getUrl(), "branches/A/D/G/rho",NodeKind.file,                CommitItemStateFlags.TextMods);        assertEquals("wrong revision number from commit",              client.commit(new String[]{thisTest.getWCPath()}, "log msg",                      true), 5);     }    /**     * test the basic SVNClient.isAdminDirectory functionality     * @throws Throwable     * @since 1.2     */    public void testBasicIsAdminDirectory() throws Throwable    {        // build the test setup        OneTest thisTest = new OneTest();        Notify2 notify = new Notify2(){            public void onNotify(NotifyInformation info)            {                client.isAdminDirectory(".svn");            }        };        client.notification2(notify);        // update the test        assertEquals("wrong revision number from update",                client.update(thisTest.getWCPath(), null, true), 1);    }    public void testBasicCancelOperation() throws Throwable    {        // build the test setup        OneTest thisTest = new OneTest();        Notify2 notify = new Notify2(){            public void onNotify(NotifyInformation info)            {                try                {                    client.cancelOperation();                }                catch (ClientException e)                {                    fail(e.getMessage());                }            }        };        client.notification2(notify);        // update the test to try to cancel an operation        try        {            client.update(thisTest.getWCPath(), null, true);            fail("missing exception for canceled operation");        }        catch (ClientException e)        {            // this is expected        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -