Java 类org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector 实例源码

项目:ant    文件:ModifiedSelectorTest.java   
/**
 * Extracts the real used algorithm name from the ModifiedSelector using
 * 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);
    }
    if (algo.endsWith(">")) {
        algo = algo.substring(0, algo.length() - 1);
    }
    // return the clean value
    return algo;
}
项目:ant    文件:ModifiedSelectorTest.java   
/** Checks whether a cache file is created. */
@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());
    cachefile.delete();
}
项目:ant    文件:ModifiedSelectorTest.java   
/**
 * Tests whether the seldirs attribute is used.
 */
@Test
public void testSeldirs() {
    ModifiedSelector s = new ModifiedSelector();
    StringBuilder sbTrue  = new StringBuilder();
    StringBuilder sbFalse = new StringBuilder();
    for (File file : selectorRule.getFiles()) {
        if (file.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();

    s.getCache().delete();
}
项目:ant    文件:ModifiedSelectorTest.java   
/** Test correct use of cache names. */
@Test
public void testValidateWrongCache() {
    String name = "this-is-not-a-valid-cache-name";
    try {
        ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName();
        cacheName.setValue(name);
        fail("CacheSelector.CacheName accepted invalid value.");
    } catch (BuildException be) {
        assertEquals(name + " is not a legal value for this attribute",
                     be.getMessage());
    }
}
项目:ant    文件:ModifiedSelectorTest.java   
/** Test correct use of cache names. */
@Test
public void testValidateWrongAlgorithm() {
    String name = "this-is-not-a-valid-algorithm-name";
    try {
        ModifiedSelector.AlgorithmName algoName
            = new ModifiedSelector.AlgorithmName();
        algoName.setValue(name);
        fail("CacheSelector.AlgorithmName accepted invalid value.");
    } catch (BuildException be) {
        assertEquals(name + " is not a legal value for this attribute",
                     be.getMessage());
    }
}
项目:ant    文件:ModifiedSelectorTest.java   
/** Test correct use of comparator names. */
@Test
public void testValidateWrongComparator() {
    String name = "this-is-not-a-valid-comparator-name";
    try {
        ModifiedSelector.ComparatorName compName
            = new ModifiedSelector.ComparatorName();
        compName.setValue(name);
        fail("ModifiedSelector.ComparatorName accepted invalid value.");
    } catch (BuildException be) {
        assertEquals(name + " is not a legal value for this attribute",
                     be.getMessage());
    }
}
项目:ant    文件:ModifiedSelectorTest.java   
@Test
public void testEqualComparatorViaSelector() {
    ModifiedSelector s = new ModifiedSelector();
    ModifiedSelector.ComparatorName compName = new ModifiedSelector.ComparatorName();
    compName.setValue("equal");
    s.setComparator(compName);
    try {
        performTests(s, "TTTTTTTTTTTT");
    } finally {
        s.getCache().delete();
    }
}
项目:ant    文件:ModifiedSelectorTest.java   
@Test
@Ignore("not yet supported see note in selector")
public void testRuleComparatorViaSelector() {
    ModifiedSelector s = new ModifiedSelector();
    ModifiedSelector.ComparatorName compName = new ModifiedSelector.ComparatorName();
    compName.setValue("rule");
    s.setComparator(compName);
    try {
        performTests(s, "TTTTTTTTTTTT");
    } finally {
        s.getCache().delete();
    }
}
项目:incubator-netbeans    文件:PathFileSet.java   
public void addModified(ModifiedSelector selector) {
    selectors.addModified(selector);
}
项目:kawa-mirror    文件:Kawac.java   
@Override public void addModified(ModifiedSelector selector) {
  usedMatchingTask = true;
  super.addModified(selector);
}
项目:kawa-fork    文件:Kawac.java   
@Override public void addModified(ModifiedSelector selector) {
  usedMatchingTask = true;
  super.addModified(selector);
}
项目:ai2-kawa    文件:Kawac.java   
@Override public void addModified(ModifiedSelector selector) {
  usedMatchingTask = true;
  super.addModified(selector);
}
项目:kawa    文件:Kawac.java   
@Override public void addModified(ModifiedSelector selector) {
  usedMatchingTask = true;
  super.addModified(selector);
}
项目:ant    文件:ModifiedSelectorTest.java   
public void doDelayUpdateTest(int kind) {
    // no check for 1<=kind<=3 - only internal use therefore check it
    // while development

    // readable form of parameter kind
    String[] kinds = {"task", "target", "build"};

    // setup the "Ant project"
    MockProject project = new MockProject();
    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;
    }
    assertTrue("Cache must be saved after " + kinds[kind - 1] + "Finished-Event.", cache.saved);
    // MockCache doesn't create a file - therefore no cleanup needed
}
项目:ant    文件:AbstractFileSet.java   
/**
 * Add the modified selector.
 * @param selector the <code>ModifiedSelector</code> to add.
 * @since ant 1.6
 */
@Override
public void addModified(ModifiedSelector selector) {
    appendSelector(selector);
}
项目:ant    文件:AbstractSelectorContainer.java   
/**
 * add the modified selector
 * @param selector the selector to add
 * @since ant 1.6
 */
public void addModified(ModifiedSelector selector) {
    appendSelector(selector);
}
项目:ant    文件:SelectorContainer.java   
/**
 * add the modified selector
 * @param selector the selector to add
 * @since ant 1.6
 */
void addModified(ModifiedSelector selector);
项目:ant    文件:BaseSelectorContainer.java   
/**
 * add the modified selector
 * @param selector the selector to add
 * @since ant 1.6
 */
public void addModified(ModifiedSelector selector) {
    appendSelector(selector);
}
项目:ant    文件:Delete.java   
/**
 * add the modified selector
 *
 * @param selector the selector to add
 * @since ant 1.6
 */
@Override
public void addModified(ModifiedSelector selector) {
    usedMatchingTask = true;
    super.addModified(selector);
}
项目:ant    文件:MatchingTask.java   
/**
 * add the modified selector
 * @param selector the selector to add
 * @since ant 1.6
 */
@Override
public void addModified(ModifiedSelector selector) {
    fileset.addModified(selector);
}