@Test
  public void repositoryCreatedFromScannedDataDirRules() throws Exception {
    final URL u =
        Thread.currentThread()
            .getContextClassLoader()
            .getResource("data/autoprox/simple-factory.groovy");
    final File f = new File(u.getPath());

    final File scriptFile = new File(autoproxDataDir, f.getName());
    FileUtils.copyFile(f, scriptFile);

    System.out.println("Parsing rules for: " + name.getMethodName());
    catalog.parseRules();

    final String testUrl = http.formatUrl("target", "test");

    logger.info("\n\nSETTING UP / VERIFYING REMOTE SERVER EXPECTATIONS");
    http.get(testUrl, 404);
    http.expect(testUrl, 200);
    //        targetResponder.approveTargets( "test" );
    http.get(testUrl, 200);
    logger.info("DONE: SETTING UP / VERIFYING REMOTE SERVER EXPECTATIONS\n\n");

    catalog.setEnabled(false);
    assertThat(proxyManager.getRemoteRepository("test"), nullValue());
    catalog.setEnabled(true);

    final RemoteRepository repo = proxyManager.getRemoteRepository("test");

    assertThat(repo, notNullValue());
    assertThat(repo.getName(), equalTo("test"));
    assertThat(repo.getUrl(), equalTo(testUrl));
  }
  @Test
  public void run() throws Exception {
    final String repo1 = "repo1";
    final String path = "org/foo/bar/maven-metadata.xml";

    server.registerException(server.formatUrl(repo1, path), "upstream error");

    RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
    remote1.setMetadata(Location.CONNECTION_TIMEOUT_SECONDS, Integer.toString(1));

    remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);

    try {
      client.content().get(remote, repo1, path);
    } catch (final AproxClientException e) {
      assertThat(e.getStatusCode(), equalTo(HttpStatus.SC_BAD_GATEWAY));
    }
  }
  @Test
  public void repositoryAutoCreated() throws Exception {
    simpleCatalog();

    final String testUrl = http.formatUrl("target", "test");
    http.get(testUrl, 404);
    http.expect(testUrl, 200);
    http.expect(testUrl, 200);
    //        targetResponder.approveTargets( "test" );
    http.get(testUrl, 200);

    catalog.setEnabled(false);
    assertThat(proxyManager.getRemoteRepository("test"), nullValue());
    catalog.setEnabled(true);

    final RemoteRepository repo = proxyManager.getRemoteRepository("test");

    assertThat(repo, notNullValue());
    assertThat(repo.getName(), equalTo("test"));
    assertThat(repo.getUrl(), equalTo(testUrl));
  }