Search in sources :

Example 46 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class TestFixedIndexedRepo method testIndex2Compressed.

public void testIndex2Compressed() throws Exception {
    Processor reporter = new Processor();
    FixedIndexedRepo repo = new FixedIndexedRepo();
    Map<String, String> props = new HashMap<String, String>();
    props.put("name", "index2");
    props.put("locations", IO.getFile("testdata/index2.xml.gz").toURI().toString());
    props.put(FixedIndexedRepo.PROP_CACHE, tmp.getAbsolutePath());
    repo.setProperties(props);
    repo.setReporter(reporter);
    assertEquals(56, countBundles(repo));
    assertEquals(0, reporter.getErrors().size());
    assertEquals(0, reporter.getWarnings().size());
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap)

Example 47 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class TestFixedIndexedRepo method testExternalEntitiesNotFetched.

public void testExternalEntitiesNotFetched() throws Exception {
    final AtomicInteger accessCount = new AtomicInteger(0);
    FixedIndexedRepo repo;
    Map<String, String> config;
    Processor reporter = new Processor();
    repo = new FixedIndexedRepo() {

        // A bit of a hack, this makes sure that only OBR can be selected
        protected synchronized void loadAllContentProviders() {
            super.loadAllContentProviders();
            allContentProviders.remove("R5");
        }
    };
    config = new HashMap<String, String>();
    config.put("locations", IO.getFile("testdata/xmlWithDtdRef.xml").getAbsoluteFile().toURI().toString());
    config.put(FixedIndexedRepo.PROP_CACHE, tmp.getAbsolutePath());
    repo.setProperties(config);
    repo.setReporter(reporter);
    repo.list(null);
    repo = new FixedIndexedRepo() {

        protected synchronized void loadAllContentProviders() {
            super.loadAllContentProviders();
            allContentProviders.remove("OBR");
        }
    };
    config = new HashMap<String, String>();
    config.put("locations", IO.getFile("testdata/xmlWithDtdRef.xml").getAbsoluteFile().toURI().toString());
    config.put(FixedIndexedRepo.PROP_CACHE, tmp.getAbsolutePath());
    repo.setProperties(config);
    repo.setReporter(reporter);
    repo.list(null);
    assertEquals("Should not make any HTTP connection.", 0, accessCount.get());
    assertTrue("Should be some ambiguity warnings", reporter.getWarnings().size() > 0);
    assertTrue(reporter.check("Content provider 'OBR' was unable to determine", "No content provider matches the specified index unambiguously. Selected 'OBR' arbitrarily.", "Content provider 'R5' was unable to determine compatibility with index at URL ", "No content provider matches the specified index unambiguously. Selected 'R5' arbitrarily"));
    assertEquals("Should not be any errors", 0, reporter.getErrors().size());
}
Also used : Processor(aQute.bnd.osgi.Processor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 48 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class TestCompressedObrRepo method setUp.

@Override
protected void setUp() throws Exception {
    httpd = new NanoHTTPD(0, IO.getFile("testdata/http"));
    httpdPort = httpd.getPort();
    Sed.file2GzFile(obrSrc, "__httpdPort__", Integer.toString(httpdPort), obrDst);
    reporter = new Processor();
    obr = new FixedIndexedRepo();
    Map<String, String> config = new HashMap<String, String>();
    config.put("name", "obr");
    config.put("locations", new File(obrDst).toURI().toString());
    config.put("type", "OBR");
    obr.setProperties(config);
    obr.setReporter(reporter);
    File tmpFile = File.createTempFile("cache", ".tmp");
    tmpFile.deleteOnExit();
    obr.setCacheDirectory(new File(tmpFile.getAbsolutePath() + ".dir"));
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) NanoHTTPD(test.lib.NanoHTTPD) File(java.io.File)

Example 49 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class SettingsParserTest method testMavenEncryptedPassword.

public void testMavenEncryptedPassword() throws Exception {
    System.setProperty(ConnectionSettings.M2_SETTINGS_SECURITY_PROPERTY, "testresources/settings-security.xml");
    Processor proc = new Processor();
    proc.setProperty("-connection-settings", "testresources/server-maven-encrypted-selection.xml");
    try (ConnectionSettings cs = new ConnectionSettings(proc, new HttpClient())) {
        cs.readSettings();
        List<ServerDTO> serverDTOs = cs.getServerDTOs();
        assertEquals(1, serverDTOs.size());
        ServerDTO s = serverDTOs.get(0);
        assertEquals("encrypted-password", s.id);
        assertEquals("FOOBAR", s.password);
    }
}
Also used : ServerDTO(aQute.bnd.connection.settings.ServerDTO) Processor(aQute.bnd.osgi.Processor) HttpClient(aQute.bnd.http.HttpClient) ConnectionSettings(aQute.bnd.connection.settings.ConnectionSettings)

Example 50 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class HttpClientTest method testCancel.

public void testCancel() throws Exception {
    final long deadline = System.currentTimeMillis() + 1000L;
    try (HttpClient hc = new HttpClient()) {
        Processor p = new Processor();
        p.addBasicPlugin(new ProgressPlugin() {

            @Override
            public Task startTask(String name, int size) {
                return new Task() {

                    @Override
                    public void worked(int units) {
                        System.out.println("Worked " + units);
                    }

                    @Override
                    public void done(String message, Throwable e) {
                        System.out.println("Done " + message + " " + e);
                    }

                    @Override
                    public boolean isCanceled() {
                        System.out.println("Cancel check ");
                        return System.currentTimeMillis() > deadline;
                    }
                };
            }
        });
        hc.setRegistry(p);
        TaggedData tag = hc.build().asTag().go(httpServer.getBaseURI("timeout/50"));
        assertNotNull(tag);
        assertEquals(200, tag.getResponseCode());
        try {
            String s = IO.collect(tag.getInputStream());
            fail();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : Processor(aQute.bnd.osgi.Processor) ProgressPlugin(aQute.bnd.service.progress.ProgressPlugin) HttpClient(aQute.bnd.http.HttpClient) TaggedData(aQute.bnd.service.url.TaggedData) URISyntaxException(java.net.URISyntaxException)

Aggregations

Processor (aQute.bnd.osgi.Processor)185 HashMap (java.util.HashMap)43 File (java.io.File)37 Macro (aQute.bnd.osgi.Macro)29 Workspace (aQute.bnd.build.Workspace)27 Jar (aQute.bnd.osgi.Jar)17 HttpClient (aQute.bnd.http.HttpClient)14 Baseline (aQute.bnd.differ.Baseline)12 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)12 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)10 IOException (java.io.IOException)10 Resource (org.osgi.resource.Resource)10 Info (aQute.bnd.differ.Baseline.Info)8 Version (aQute.bnd.version.Version)8 ArrayList (java.util.ArrayList)8 List (java.util.List)7 ProgressPlugin (aQute.bnd.service.progress.ProgressPlugin)6 Collection (java.util.Collection)6 Properties (java.util.Properties)6 Parameters (aQute.bnd.header.Parameters)5