Exemplo n.º 1
0
  @Test
  public void remote() {
    AetherPackageLoader loader = new AetherPackageLoader();
    loader.setRepositoryListener(new ConsoleRepositoryListener());
    loader.setTransferListener(new ConsoleTransferListener());
    loader.load(new FqPackageName("org.renjin.cran", "ACD"));

    System.out.println(Joiner.on("\n").join(loader.getClassLoader().getURLs()));
  }
Exemplo n.º 2
0
  @Test
  public void renjinCoreExcluded() {
    AetherPackageLoader loader = new AetherPackageLoader();
    loader.load(new FqPackageName("org.renjin.test", "beta"));

    // Verify that none of the core libraries are loaded, they are already on
    // the classpath
    assertThat(loader.getClassLoader().getURLs(), not(hasItemInArray(containing("renjin-core"))));
    assertThat(loader.getClassLoader().getURLs(), not(hasItemInArray(containing("gcc-runtime"))));
    assertThat(loader.getClassLoader().getURLs(), not(hasItemInArray(containing("lapack"))));
  }
Exemplo n.º 3
0
  @Test
  public void singleVersionLoaded() {
    AetherPackageLoader loader = new AetherPackageLoader();
    loader.load(new FqPackageName("org.renjin.test", "alpha"));
    loader.load(new FqPackageName("org.renjin.test", "beta"));

    // Verify that none of the core libraries are loaded, they are already on
    // the classpath
    assertThat(
        loader.getClassLoader().getURLs(), hasItemInArray(containing("jackson-core-2.5.1.jar")));
    assertThat(
        loader.getClassLoader().getURLs(),
        not(hasItemInArray(containing("jackson-core-2.0.0.jar"))));
  }
Exemplo n.º 4
0
  private String evaluate(String script) throws IOException {
    AetherPackageLoader aetherLoader = new AetherPackageLoader();
    aetherLoader.setTransferListener(new ConsoleTransferListener());
    aetherLoader.setRepositoryListener(new ConsoleRepositoryListener(System.out));

    Session session =
        new SessionBuilder()
            .bind(ClassLoader.class, aetherLoader.getClassLoader())
            .bind(PackageLoader.class, aetherLoader)
            .build();

    ExpressionVector sexp = RParser.parseAllSource(new StringReader(script));

    SEXP result = session.getTopLevelContext().evaluate(sexp);

    if (result instanceof StringVector) {
      return ((StringVector) result).getElementAsString(0);
    } else {
      throw new AssertionError("Expected string, got: " + result);
    }
  }