Examples of ModifiedSelector


Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

    /**
     * Factory method from base class. This should be overriden in child
     * classes to return a specific Selector class (like here).
     */
    public BaseSelector getInstance() {
        return new ModifiedSelector();
    }
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

        File base  = new File("base");
        File file1 = new File("file1");
        File file2 = new File("file2");

        // setup the selector
        ModifiedSelector sel = new ModifiedSelector();
        sel.setProject(project);
        sel.setUpdate(true);
        sel.setDelayUpdate(true);
        // sorry - otherwise we will get a ClassCastException because the MockCache
        // is loaded by two different classloader ...
        sel.setClassLoader(this.getClass().getClassLoader());
        sel.addClasspath(testclasses);

        sel.setAlgorithmClass("org.apache.tools.ant.types.selectors.MockAlgorithm");
        sel.setCacheClass("org.apache.tools.ant.types.selectors.MockCache");
        sel.configure();

        // get the cache, so we can check our things
        MockCache cache = (MockCache)sel.getCache();

        // the test
        assertFalse("Cache must not be saved before 1st selection.", cache.saved);
        sel.isSelected(base, "file1", file1);
        assertFalse("Cache must not be saved after 1st selection.", cache.saved);
        sel.isSelected(base, "file2", file2);
        assertFalse("Cache must not be saved after 2nd selection.", cache.saved);
        switch (kind) {
            case 1 : project.fireTaskFinished();   break;
            case 2 : project.fireTargetFinished(); break;
            case 3 : project.fireBuildFinished()break;
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

     * its toString() method.
     * @param classname  the classname from the algorithm to use
     * @return  the algorithm part from the toString() (without brackets)
     */
    private String getAlgoName(String classname) {
        ModifiedSelector sel = new ModifiedSelector();
        // add the test classes to its classpath
        sel.addClasspath(testclasses);
        sel.setAlgorithmClass(classname);
        // let the selector do its checks
        sel.validate();
        // extract the algorithm name (and config) from the selectors output
        String s1 = sel.toString();
        int posStart = s1.indexOf("algorithm=") + 10;
        int posEnd   = s1.indexOf(" comparator=");
        String algo  = s1.substring(posStart, posEnd);
        // '<' and '>' are only used if the algorithm has properties
        if (algo.startsWith("<")) algo = algo.substring(1);
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

            // initialize test environment (called "bed")
            makeBed();

            // Configure the selector
            ModifiedSelector s = (ModifiedSelector)getSelector();
            s.setDelayUpdate(false);
            s.addParam("cache.cachefile", cachefile);

            ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName();
            cacheName.setValue("propertyfile");
            s.setCache(cacheName);

            s.setUpdate(true);

            selectionString(s);

            // evaluate correctness
            assertTrue("Cache file is not created.", cachefile.exists());
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

        doTest(comp);
    }


    public void testEqualComparatorViaSelector() {
        ModifiedSelector s = (ModifiedSelector)getSelector();
        ModifiedSelector.ComparatorName compName = new ModifiedSelector.ComparatorName();
        compName.setValue("equal");
        s.setComparator(compName);
        try {
            performTests(s, "TTTTTTTTTTTT");
        } finally {
            s.getCache().delete();
        }
    }
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

        }
    }


    public void _testRuleComparatorViaSelector() { //not yet supported see note in selector
        ModifiedSelector s = (ModifiedSelector)getSelector();
        ModifiedSelector.ComparatorName compName = new ModifiedSelector.ComparatorName();
        compName.setValue("rule");
        s.setComparator(compName);
        try {
            performTests(s, "TTTTTTTTTTTT");
        } finally {
            s.getCache().delete();
        }
    }
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

    /**
     * Tests whether the seldirs attribute is used.
     */
    public void testSeldirs() {
        ModifiedSelector s = (ModifiedSelector)getSelector();
        try {
            makeBed();

            StringBuffer sbTrue  = new StringBuffer();
            StringBuffer sbFalse = new StringBuffer();
            for (int i=0; i<filenames.length; i++) {
                if (files[i].isDirectory()) {
                    sbTrue.append("T");
                    sbFalse.append("F");
                } else {
                    sbTrue.append("T");
                    sbFalse.append("T");
                }
            }

            s.setSeldirs(true);
            performTests(s, sbTrue.toString());
            s.getCache().delete();

            s.setSeldirs(false);
            performTests(s, sbFalse.toString());
            s.getCache().delete();

        } finally {
            cleanupBed();
            if (s!=null) s.getCache().delete();
        }
    }
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

     * <li> try third time --> should select only the file with modified
     *      content </li>
     */
    public void testScenario1() {
        BFT bft = null;
        ModifiedSelector s = null;
        try {
            //
            // *****  initialize test environment (called "bed")  *****
            //
            makeBed();
            String results = null;

            // Configure the selector - only defaults are used
            s = (ModifiedSelector)getSelector();

            //
            // *****  First Run  *****
            // the first call should get all files, because nothing is in
            // the cache
            //
            performTests(s, "TTTTTTTTTTTT");

            //
            // *****  Second Run  *****
            // the second call should get no files, because no content
            // has changed
            //
            performTests(s, "TFFFFFFFFFFT");

            //
            // *****  make some files dirty  *****
            //

            // these files are made dirty --> 3+4 with different content
            String f2name = "tar/bz2/asf-logo-huge.tar.bz2";
            String f3name = "asf-logo.gif.md5";
            String f4name = "copy.filterset.filtered";

            // AccessObject to the test-Ant-environment
            bft = new BFT();
            // give some values (via property file) to that environment
            bft.writeProperties("f2name="+f2name);
            bft.writeProperties("f3name="+f3name);
            bft.writeProperties("f4name="+f4name);
            // call the target for making the files dirty
            bft.doTarget("modifiedselectortest-makeDirty");

            //
            // *****  Third Run  *****
            // third call should get only those files, which CONTENT changed
            // (no timestamp changes required!)
            results = selectionString(s);

            //
            // *****  Check the result  *****
            //

            // Mark all files which should be selected as (T)rue and all others
            // as (F)alse. Directories are always selected so they always are
            // (T)rue.
            StringBuffer expected = new StringBuffer();
            for (int i=0; i<filenames.length; i++) {
                String ch = "F";
                if (files[i].isDirectory()) ch = "T";
                // f2name shouldn't be selected: only timestamp has changed!
                if (filenames[i].equalsIgnoreCase(f3name)) ch = "T";
                if (filenames[i].equalsIgnoreCase(f4name)) ch = "T";
                expected.append(ch);
            }

            assertEquals(
                "Wrong files selected. Differing files: "       // info text
                + resolve(diff(expected.toString(), results))// list of files
                expected.toString(),                            // expected result
                results                                         // result
            );

        } finally {
            // cleanup the environment
            cleanupBed();
            if (s!=null) s.getCache().delete();
            if (bft!=null) bft.deletePropertiesfile();
        }
    }
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

     * its toString() method.
     * @param classname  the classname from the algorithm to use
     * @return  the algorithm part from the toString() (without brackets)
     */
    private String getAlgoName(String classname) {
        ModifiedSelector sel = new ModifiedSelector();
        sel.setProject(selectorRule.getProject());
        // add the test classes to its classpath
        sel.addClasspath(testclasses);
        sel.setAlgorithmClass(classname);
        // let the selector do its checks
        sel.validate();
        // extract the algorithm name (and config) from the selectors output
        String s1 = sel.toString();
        int posStart = s1.indexOf("algorithm=") + 10;
        int posEnd   = s1.indexOf(" comparator=");
        String algo  = s1.substring(posStart, posEnd);
        // '<' and '>' are only used if the algorithm has properties
        if (algo.startsWith("<")) algo = algo.substring(1);
View Full Code Here

Examples of org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

    @Test
    public void testCreatePropertiesCacheViaModifiedSelector() {
        File cachefile = new File(selectorRule.getProject().getBaseDir(), "cachefile.properties");
   
        // Configure the selector
        ModifiedSelector s = new ModifiedSelector();
        s.setDelayUpdate(false);
        s.addParam("cache.cachefile", cachefile);

        ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName();
        cacheName.setValue("propertyfile");
        s.setCache(cacheName);

        s.setUpdate(true);

        selectorRule.selectionString(s);

        // evaluate correctness
        assertTrue("Cache file is not created.", cachefile.exists());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.