コード例 #1
0
 @Test
 public void uiSample() throws Exception {
   start("samples/ui.groovy", "--classpath=.:src/test/resources");
   String result = FileUtil.readEntirely(new URL("http://localhost:8080").openStream());
   assertTrue("Wrong output: " + result, result.contains("Hello World"));
   result =
       FileUtil.readEntirely(new URL("http://localhost:8080/css/bootstrap.min.css").openStream());
   assertTrue("Wrong output: " + result, result.contains("container"));
 }
コード例 #2
0
 @Test
 public void jobWebSample() throws Exception {
   start("samples/job.groovy", "samples/web.groovy", "foo=bar");
   String output = this.outputCapture.getOutputAndRelease();
   assertTrue(
       "Wrong output: " + output, output.contains("completed with the following parameters"));
   String result = FileUtil.readEntirely(new URL("http://localhost:8080").openStream());
   assertEquals("World!", result);
 }
コード例 #3
0
  public void testUpdate() throws Exception {
    /*
     * For updated file to be equals to updated.xml, we have to fix the line separator to the
     * one used in updated.xml, in order for this test to works in all platforms (default line
     * separator used in updater being platform dependent
     */
    XmlModuleDescriptorUpdater.LINE_SEPARATOR = "\n";
    File dest = new File("build/updated-test.xml");
    dest.deleteOnExit();
    Map resolvedRevisions = new HashMap();
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), "2.5");
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule6", "trunk", "latest.integration"),
        "6.3");

    Map resolvedBranches = new HashMap();
    resolvedBranches.put(ModuleRevisionId.newInstance("yourorg", "yourmodule3", "3.1"), "branch1");
    resolvedBranches.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), null);

    GregorianCalendar cal = new GregorianCalendar();
    cal.set(2005, 2, 22, 14, 32, 54);

    Ivy ivy = Ivy.newInstance();
    ivy.setVariable("myvar", "myconf1");
    XmlModuleDescriptorUpdater.update(
        XmlModuleUpdaterTest.class.getResource("test-update.xml"),
        dest,
        getUpdateOptions(ivy.getSettings(), resolvedRevisions, "release", "mynewrev", cal.getTime())
            .setResolvedBranches(resolvedBranches));

    assertTrue(dest.exists());
    String expected =
        FileUtil.readEntirely(
            new BufferedReader(
                new InputStreamReader(
                    XmlModuleUpdaterTest.class.getResourceAsStream("updated.xml"))));
    String updated = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)));
    assertEquals(expected, updated);
  }
コード例 #4
0
  public void testPatternWithoutOrganisation() throws Exception {
    report
        .getProject()
        .setProperty("ivy.settings.file", "test/repositories/IVY-729/ivysettings.xml");
    report.setOutputname("test-no-org");
    report.setTodir(cache);
    report.execute();

    File reportFile = new File(cache, "test-no-org.xml");
    assertTrue(reportFile.exists());
    String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));

    // check presence of the modules
    assertTrue(g.indexOf("<module organisation=\"null\" name=\"a\"") != -1);
    assertTrue(g.indexOf("<module organisation=\"null\" name=\"b\"") != -1);
    assertTrue(g.indexOf("<module organisation=\"null\" name=\"c\"") != -1);
  }
コード例 #5
0
  public void testSimple() throws Exception {
    report.setOrganisation("org1");
    report.setOutputname("testsimple");
    report.setTodir(cache);
    report.execute();

    File reportFile = new File(cache, "testsimple.xml");
    assertTrue(reportFile.exists());
    String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));

    // check presence of the modules
    assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.1\"") != -1);
    assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.2\"") != -1);
    assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.3\"") != -1);
    assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.4\"") != -1);
    assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.5\"") != -1);
    assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.6\"") != -1);
  }
コード例 #6
0
  public void testBranchBeforeModule() throws Exception {
    report
        .getProject()
        .setProperty("ivy.settings.file", "test/repositories/IVY-716/ivysettings.xml");
    report.setOutputname("testbranch");
    report.setTodir(cache);
    report.execute();

    File reportFile = new File(cache, "testbranch.xml");
    assertTrue(reportFile.exists());
    String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));

    // check presence of the modules
    assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.1\"") != -1);

    // check presence of the branches
    assertTrue(g.indexOf("<revision name=\"1.0\" branch=\"branch1\"") != -1);
    assertTrue(g.indexOf("<revision name=\"1.0\" branch=\"branch2\"") != -1);
  }
コード例 #7
0
  public void testVariableReplacement() throws Exception {
    /*
     * For updated file to be equals to updated.xml, we have to fix the line separator to the
     * one used in updated.xml, in order for this test to works in all platforms (default line
     * separator used in updater being platform dependent
     */
    XmlModuleDescriptorUpdater.LINE_SEPARATOR = "\n";
    File dest = new File("build/updated-test2.xml");
    dest.deleteOnExit();
    Map resolvedRevisions = new HashMap();
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), "2.5");
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule6", "trunk", "latest.integration"),
        "6.3");

    Map resolvedBranches = new HashMap();
    resolvedBranches.put(ModuleRevisionId.newInstance("yourorg", "yourmodule3", "3.1"), "branch1");
    resolvedBranches.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), null);

    GregorianCalendar cal = new GregorianCalendar();
    cal.set(2005, 2, 22, 14, 32, 54);

    Ivy ivy = Ivy.newInstance();
    ivy.setVariable("myorg", "myorg");
    ivy.setVariable("mymodule", "mymodule");
    ivy.setVariable("myrev", "myrev");
    ivy.setVariable("mystatus", "integration");
    ivy.setVariable("mypubdate", "20050322143254");
    ivy.setVariable("mylicense", "MyLicense");
    ivy.setVariable("mylicenseurl", "http://www.my.org/mymodule/mylicense.html");
    ivy.setVariable("myorgurl", "http://www.myorg.org/");
    ivy.setVariable("ivyrep", "ivyrep");
    ivy.setVariable("ivyrepurl", "http://www.jayasoft.fr/org/ivyrep/");
    ivy.setVariable("ivyreppattern", "[organisation]/[module]/ivy-[revision].xml");
    ivy.setVariable("ivys", "true");
    ivy.setVariable("artifacts", "false");
    ivy.setVariable("homepage", "http://www.my.org/mymodule/");
    ivy.setVariable("includefile", "imported-configurations-with-mapping.xml");
    ivy.setVariable("mydesc", "desc 1");
    ivy.setVariable("visibility", "public");
    ivy.setVariable("myvar", "myconf1");
    ivy.setVariable("deprecated", "20050115");
    ivy.setVariable("myartifact1", "myartifact1");
    ivy.setVariable("mytype", "jar");
    ivy.setVariable("mymodule2", "mymodule2");
    ivy.setVariable("mymodule2rev", "2.0");
    ivy.setVariable("changing", "true");
    ivy.setVariable("transitive", "false");
    ivy.setVariable("targetconf", "yourconf1");
    ivy.setVariable("art9-1", "yourartifact9-1");
    ivy.setVariable("conf3", "myconf3");
    ivy.setVariable("includename", "your.*");
    ivy.setVariable("includeext", "xml");
    ivy.setVariable("excludename", "toexclude");
    ivy.setVariable("excludemodule", "*servlet*");
    ivy.setVariable("excludematcher", "glob");
    ivy.setVariable("excludeorg", "acme");
    ivy.setVariable("excludeartifact", "test");
    ivy.setVariable("excludetype", "source");
    ivy.setVariable("yourorg", "yourorg");
    ivy.setVariable("yourmodule", ".*");
    ivy.setVariable("all", "all");
    ivy.setVariable("regexp", "regexp");
    ivy.setVariable("theirrev", "1.0, 1.1");

    XmlModuleDescriptorUpdater.update(
        XmlModuleUpdaterTest.class.getResource("test-update-withvar.xml"),
        dest,
        getUpdateOptions(ivy.getSettings(), resolvedRevisions, "release", "mynewrev", cal.getTime())
            .setResolvedBranches(resolvedBranches));

    assertTrue(dest.exists());
    String expected =
        FileUtil.readEntirely(
            new BufferedReader(
                new InputStreamReader(
                    XmlModuleUpdaterTest.class.getResourceAsStream("updated.xml"))));
    String updated = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)));
    assertEquals(expected, updated);
  }
コード例 #8
0
 @Test
 public void actuatorSample() throws Exception {
   start("samples/actuator.groovy");
   String result = FileUtil.readEntirely(new URL("http://localhost:8080").openStream());
   assertEquals("{\"message\":\"Hello World!\"}", result);
 }
コード例 #9
0
 @Test
 public void webSample() throws Exception {
   start("samples/web.groovy");
   String result = FileUtil.readEntirely(new URL("http://localhost:8080").openStream());
   assertEquals("World!", result);
 }