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

📄 ftptest.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        }        getProject().executeTarget("symlink-file-setup");        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {"alpha/beta/gamma/"});        ds.setFollowSymlinks(true);        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},                     new String[] {"alpha/beta/gamma"});    }    // father and child pattern test    public void testOrderOfIncludePatternsIrrelevant() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        String [] expectedFiles = {"alpha/beta/beta.xml",                                   "alpha/beta/gamma/gamma.xml"};        String [] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" };        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {"alpha/be?a/**", "alpha/beta/gamma/"});        ds.scan();        compareFiles(ds, expectedFiles, expectedDirectories);        // redo the test, but the 2 include patterns are inverted        ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {"alpha/beta/gamma/", "alpha/be?a/**"});        ds.scan();        compareFiles(ds, expectedFiles, expectedDirectories);    }    public void testPatternsDifferInCaseScanningSensitive() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {"alpha/", "ALPHA/"});        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/beta.xml",                                       "alpha/beta/gamma/gamma.xml"},                     new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});    }    public void testPatternsDifferInCaseScanningInsensitive() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {"alpha/", "ALPHA/"});        ds.setCaseSensitive(false);        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/beta.xml",                                       "alpha/beta/gamma/gamma.xml"},                     new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});    }    public void testFullpathDiffersInCaseScanningSensitive() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {            "alpha/beta/gamma/gamma.xml",            "alpha/beta/gamma/GAMMA.XML"        });        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},                     new String[] {});    }    public void testFullpathDiffersInCaseScanningInsensitive() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {            "alpha/beta/gamma/gamma.xml",            "alpha/beta/gamma/GAMMA.XML"        });        ds.setCaseSensitive(false);        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},                     new String[] {});    }    public void testParentDiffersInCaseScanningSensitive() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"});        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/beta.xml",                                       "alpha/beta/gamma/gamma.xml"},                     new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});    }    public void testParentDiffersInCaseScanningInsensitive() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"});        ds.setCaseSensitive(false);        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/beta.xml",                                       "alpha/beta/gamma/gamma.xml"},                     new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});    }    public void testExcludeOneFile() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {            "**/*.xml"        });        ds.setExcludes(new String[] {            "alpha/beta/b*xml"        });        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},                     new String[] {});    }    public void testExcludeHasPrecedence() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {            "alpha/**"        });        ds.setExcludes(new String[] {            "alpha/**"        });        ds.scan();        compareFiles(ds, new String[] {},                     new String[] {});    }    public void testAlternateIncludeExclude() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setIncludes(new String[] {            "alpha/**",            "alpha/beta/gamma/**"        });        ds.setExcludes(new String[] {            "alpha/beta/**"        });        ds.scan();        compareFiles(ds, new String[] {},                     new String[] {"alpha"});    }    public void testAlternateExcludeInclude() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setExcludes(new String[] {            "alpha/**",            "alpha/beta/gamma/**"        });        ds.setIncludes(new String[] {            "alpha/beta/**"        });        ds.scan();        compareFiles(ds, new String[] {},                     new String[] {});    }    /**     * Test inspired by Bug#1415.     */    public void testChildrenOfExcludedDirectory() {        if (!loginSuceeded) {            return;        }        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        getProject().executeTarget("children-of-excluded-dir-setup");        FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setExcludes(new String[] {"alpha/**"});        ds.scan();        compareFiles(ds, new String[] {"delta/delta.xml"},                    new String[] {"delta"});        ds = myFTPTask.newScanner(ftp);        if (!changeRemoteDir(remoteTmpDir)) {            return;        }        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));        ds.setExcludes(new String[] {"alpha"});        ds.scan();        compareFiles(ds, new String[] {"alpha/beta/beta.xml",                                       "alpha/beta/gamma/gamma.xml",                                        "delta/delta.xml"},                     new String[] {"alpha/beta", "alpha/beta/gamma", "delta"});    }        /**     * This class enables the use of the log messages as a way of testing      * the number of files actually transferred.     * It uses the ant regular expression mechanism to get a regex parser     * to parse the log output.     */    private class CountLogListener extends DefaultLogger {        private Vector lastMatchGroups = null;        private RegexpMatcher matcher = new RegexpMatcherFactory().newRegexpMatcher();        /**         * The only constructor for a CountLogListener         * @param pattern a regular expression pattern.  It should have          * one parenthesized group and that group should contain the         * number desired.         */        public CountLogListener(String pattern) {            super();            this.matcher.setPattern(pattern);        }                        /*          * @param event the build event that is being logged.         */        public void messageLogged(BuildEvent event) {            String message = event.getMessage();            if (this.matcher.matches(message)) {                lastMatchGroups = this.matcher.getGroups(message);            }            super.messageLogged(event);        }                /**         * returns the desired number that results from parsing the log         * message         * @return the number of files indicated in the desired message or -1         * if a matching log message was never found.         */        public int getCount() {            if (this.lastMatchGroups == null) {                return -1;            }            return Integer.parseInt((String) this.lastMatchGroups.get(1));        }    }        /**     * This class enables the use of the log to count the number

⌨️ 快捷键说明

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