@Test public void groupAutoCreatedWithDeployPointAndTwoRepos() throws Exception { simpleCatalog(); final String testUrl = http.formatUrl("target", "test"); http.get(testUrl, 404); http.expect(testUrl, 200); http.expect(http.formatUrl("target", "first"), 200); http.expect(http.formatUrl("target", "second"), 200); // targetResponder.approveTargets( "test" ); http.get(testUrl, 200); catalog.setEnabled(false); assertThat(proxyManager.getGroup("test"), nullValue()); catalog.setEnabled(true); final Group group = proxyManager.getGroup("test"); assertThat(group, notNullValue()); assertThat(group.getName(), equalTo("test")); final List<StoreKey> constituents = group.getConstituents(); logger.info("Group constituents: {}", constituents); assertThat(constituents, notNullValue()); assertThat(constituents.size(), equalTo(4)); int idx = 0; StoreKey key = constituents.get(idx); assertThat(key.getType(), equalTo(StoreType.hosted)); assertThat(key.getName(), equalTo("test")); idx++; key = constituents.get(idx); assertThat(key.getType(), equalTo(StoreType.remote)); assertThat(key.getName(), equalTo("test")); idx++; key = constituents.get(idx); assertThat(key.getType(), equalTo(StoreType.remote)); assertThat(key.getName(), equalTo("first")); idx++; key = constituents.get(idx); assertThat(key.getType(), equalTo(StoreType.remote)); assertThat(key.getName(), equalTo("second")); }
@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 repositoryNOTCreatedFromScannedDataDirRulesWhenNameNotTest() 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"); http.get(testUrl, 404); http.expect(testUrl, 200); // targetResponder.approveTargets( "test" ); http.get(testUrl, 200); catalog.setEnabled(false); assertThat(proxyManager.getRemoteRepository("foo"), nullValue()); catalog.setEnabled(true); final RemoteRepository repo = proxyManager.getRemoteRepository("foo"); assertThat(repo, nullValue()); }
@Test public void groupNotAutoCreatedWhenTargetIsInvalid() throws Exception { simpleCatalog(); final String testUrl = http.formatUrl("target", "test"); http.get(testUrl, 404); catalog.setEnabled(false); assertThat(proxyManager.getGroup("test"), nullValue()); catalog.setEnabled(true); final Group group = proxyManager.getGroup("test"); assertThat(group, nullValue()); }
@Test public void repositoryNotAutoCreatedWhenTargetIsInvalid() throws Exception { simpleCatalog(); final String testUrl = http.formatUrl("target", "test"); http.get(testUrl, 404); catalog.setEnabled(false); assertThat(proxyManager.getRemoteRepository("test"), nullValue()); catalog.setEnabled(true); final RemoteRepository repo = proxyManager.getRemoteRepository("test"); assertThat(repo, nullValue()); }
@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)); }