Java Code Examples for org.apache.tools.ant.types.Parameter#setValue()

The following examples show how to use org.apache.tools.ant.types.Parameter#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModuleStateSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testModuleRejectedIfNotEager() throws Exception {
    File cfg = new File(new File(getWorkDir(), "config"), "Modules");
    cfg.mkdirs();
    assertTrue("Created", cfg.isDirectory());
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar("org.my.module", new String[0], m);
    
    File trackingFile = new File(cfg, "org-my-module.xml");
    try (FileWriter w = new FileWriter(trackingFile)) {
        w.write(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                        "<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"\n" +
                        "                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">\n" +
                        "<module name=\"org.my.module\">\n" +
                        "    <param name=\"autoload\">true</param>\n" +
                        "    <param name=\"eager\">false</param>\n" +
                        "    <param name=\"jar\">modules/org-openide-awt.jar</param>\n" +
                        "    <param name=\"reloadable\">false</param>\n" +
                        "    <param name=\"specversion\">7.4.0.1</param>\n" +
                        "</module>\n"
        );
    }

    Parameter p = new Parameter();
    p.setName("acceptEager");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("acceptAutoload");
    p2.setValue("false");
    selector.setParameters(new Parameter[] { p, p2 });
    
    assertFalse("module not accepted", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example 2
Source File: ModuleStateSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testModuleAcceptedIfEager() throws Exception {
    File cfg = new File(new File(getWorkDir(), "config"), "Modules");
    cfg.mkdirs();
    assertTrue("Created", cfg.isDirectory());

    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module/1");
    File aModule = generateJar("org.my.module", new String[0], m);

    File trackingFile = new File(cfg, "org-my-module.xml");
    try (FileWriter w = new FileWriter(trackingFile)) {
        w.write(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                        "<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"\n" +
                        "                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">\n" +
                        "<module name=\"org.my.module\">\n" +
                        "    <param name=\"autoload\">false</param>\n" +
                        "    <param name=\"eager\">true</param>\n" +
                        "    <param name=\"jar\">modules/org-openide-awt.jar</param>\n" +
                        "    <param name=\"reloadable\">false</param>\n" +
                        "    <param name=\"specversion\">7.4.0.1</param>\n" +
                        "</module>\n"
        );
    }

    Parameter p = new Parameter();
    p.setName("acceptEager");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("acceptAutoload");
    p2.setValue("false");
    selector.setParameters(new Parameter[] { p, p2 });

    assertTrue("module accepted", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example 3
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCanExcludeAModule() throws Exception {
    Parameter p = new Parameter();
    p.setName("excludeModules");
    p.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    assertFalse("Refused", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example 4
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCanExcludeOSGiWithAttributes() throws Exception {
    Parameter p = new Parameter();
    p.setName("excludeModules");
    p.setValue("org.eclipse.core.jobs");
    selector.setParameters(new Parameter[] { p });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("Bundle-SymbolicName", "org.eclipse.core.jobs; singleton:=true");
    File aModule = generateJar(new String[0], m);
    assertFalse("Refused", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example 5
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCanShowOnlyExcludedModules() throws Exception {
    Parameter p = new Parameter();
    p.setName("excluded");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("excludeModules");
    p2.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p, p2 });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    assertTrue("Now we are accepting only excluded modules", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example 6
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testIsSelectedForNotAModuleIsStillFalseEvenWeAcceptOnlyExcludedModules() throws IOException {
    Parameter p = new Parameter();
    p.setName("excluded");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("excludeModules");
    p2.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p, p2 });
    
    
    File noModule = generateJar(new String[0], createManifest ());
    assertFalse("Not acceptable", selector.isSelected(getWorkDir(), noModule.toString(), noModule));
}
 
Example 7
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCanExcludeACluster() throws Exception {
    Parameter p = new Parameter();
    p.setName("includeClusters");
    p.setValue("nonexistent");
    selector.setParameters(new Parameter[] { p });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    new File(getWorkDir(), "update_tracking").mkdir();
    assertFalse("Refused", selector.isSelected(getWorkDir().getParentFile(), aModule.toString(), aModule));
}
 
Example 8
Source File: OperatorClientTaskTest.java    From development with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateArguments() {
    final Parameter parameter = new Parameter();
    parameter.setName("key");
    parameter.setValue("value");
    task.addParameter(parameter);

    final Map<String, String> expected = Collections.singletonMap("key",
            "value");
    assertEquals(expected, task.createArguments());
}
 
Example 9
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void doParsingOfUpdateTrackingFiles(int parents) throws Exception {
    File updateTracking = new File(getWorkDir(), "update-tracking");
    updateTracking.mkdirs();
    assertTrue("Created", updateTracking.isDirectory());
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    
    File trackingFile = new File(updateTracking, "org-my-module.xml");
    try (FileWriter w = new FileWriter(trackingFile)) {
        w.write(
                "<?xml version='1.0' encoding='UTF-8'?>\n" +
                        "<module codename='org.apache.tools.ant.module/3'>\n" +
                        "<module_version specification_version='3.22' origin='installer' last='true' install_time='1124194231878'>\n" +
                        "<file name='ant/bin/ant' crc='1536373800'/>\n" +
                        "<file name='ant/bin/ant.bat' crc='3245456472'/>\n" +
                        "<file name='ant/bin/ant.cmd' crc='3819623376'/>\n" +
                        "<file name='ant/bin/antRun' crc='2103827286'/>\n" +
                        "<file name='ant/bin/antRun.bat' crc='2739687679'/>\n" +
                        "<file name='ant/bin/antRun.pl' crc='3955456526'/>\n" +
                        "    </module_version>\n" +
                        "</module>\n"
        );
    }

    StringBuilder sb = new StringBuilder();
    sb.append(trackingFile.getPath());
    
    while (--parents > 0) {
        File x = new File(getWorkDir(), parents + ".xml");
        try (FileWriter xw = new FileWriter(x)) {
            xw.write(
                    "<?xml version='1.0' encoding='UTF-8'?>\n" +
                            "<module codename='" + x + "/3'>\n" +
                                    "<module_version specification_version='3.22' origin='installer' last='true' install_time='1124194231878'>\n" +
                                    "    </module_version>\n" +
                                    "</module>\n"
            );
        }
        
        sb.insert(0, File.pathSeparator);
        sb.insert(0, x.getPath());
    }
    
    Parameter p = new Parameter();
    p.setName("updateTrackingFiles");
    p.setValue(sb.toString());
    selector.setParameters(new Parameter[] { p });
    
    assertTrue("module accepted", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
    assertTrue("its file as well", selector.isSelected(getWorkDir(), "ant/bin/ant.bat", new File(aModule.getParent(), "ant/bin/ant.bat")));
    assertTrue("also the tracking file is accepted", selector.isSelected(getWorkDir(), "update-tracking/" + trackingFile.getName(), trackingFile));
}