use of org.graalvm.component.installer.remote.CatalogIterable in project graal by oracle.
the class CatalogIterableTest method testUnknownComponentButExistingFile.
/**
* Checks that if user mistypes a filename instead of component ID, an informative note is
* printed.
*/
@Test
public void testUnknownComponentButExistingFile() throws Exception {
exception.expect(FailedOperationException.class);
exception.expectMessage("REMOTE_UnknownComponentMaybeFile");
addRemoteComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip", false);
File mistyped = folder.newFile("mistyped-component.jar");
textParams.add(mistyped.getPath());
CatalogIterable cit = new CatalogIterable(this, this);
assertTrue(cit.iterator().hasNext());
cit.iterator().next();
}
use of org.graalvm.component.installer.remote.CatalogIterable in project graal by oracle.
the class CatalogIterableTest method testMixWildcardsAndLiterals.
@Test
public void testMixWildcardsAndLiterals() throws Exception {
setupCatalog();
textParams.add("r*");
textParams.add("ruby");
CatalogIterable cit = new CatalogIterable(this, this);
Iterator<ComponentParam> comps = cit.iterator();
List<String> fullIds = new ArrayList<>();
for (; comps.hasNext(); ) {
ComponentParam cp = comps.next();
fullIds.add(cp.createMetaLoader().getComponentInfo().getId());
}
assertEquals(3, fullIds.size());
assertEquals("org.graalvm.ruby", fullIds.get(1));
assertEquals("org.graalvm.ruby", fullIds.get(2));
}
use of org.graalvm.component.installer.remote.CatalogIterable in project graal by oracle.
the class CatalogIterableTest method testURLDoesNotExist.
@Test
public void testURLDoesNotExist() throws Exception {
storage.graalInfo.put(BundleConstants.GRAAL_VERSION, "0.33-dev");
addRemoteComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip", false);
textParams.add("ruby");
Handler.bind(url.toString(), new URLConnection(url) {
@Override
public InputStream getInputStream() throws IOException {
connect();
return clu.openStream();
}
@Override
public String getHeaderField(int n) {
try {
connect();
} catch (IOException ex) {
Logger.getLogger(CatalogIterableTest.class.getName()).log(Level.SEVERE, null, ex);
}
return super.getHeaderField(n);
}
@Override
public Map<String, List<String>> getHeaderFields() {
try {
connect();
} catch (IOException ex) {
Logger.getLogger(CatalogIterableTest.class.getName()).log(Level.SEVERE, null, ex);
}
return super.getHeaderFields();
}
@Override
public void connect() throws IOException {
throw new FileNotFoundException();
}
});
CatalogIterable cit = new CatalogIterable(this, this);
ComponentParam rubyComp = cit.iterator().next();
exception.expect(FailedOperationException.class);
exception.expectMessage("REMOTE_ErrorDownloadingNotExist");
rubyComp.createFileLoader().getComponentInfo();
}
use of org.graalvm.component.installer.remote.CatalogIterable in project graal by oracle.
the class ComponentInstaller method processOptions.
int processOptions(LinkedList<String> cmdline) {
if (cmdline.size() < 1) {
env = SIMPLE_ENV;
printDefaultHelp(OptionCategory.USER);
return 1;
}
SimpleGetopt go = createOptions(cmdline);
launch(cmdline);
go = interpretOptions(go);
if (go == null) {
return 0;
}
if (env.hasOption(Commands.OPTION_PRINT_VERSION)) {
printVersion();
return 0;
} else if (env.hasOption(Commands.OPTION_SHOW_VERSION)) {
printVersion();
}
// check only after the version option:
if (cmdHandler == null) {
// NOI18N
error("ERROR_MissingCommand");
}
int srcCount = 0;
if (input.hasOption(Commands.OPTION_FILES)) {
srcCount++;
}
if (input.hasOption(Commands.OPTION_URLS)) {
srcCount++;
}
if (srcCount > 1) {
error("ERROR_MultipleSourcesUnsupported");
}
if (input.hasOption(Commands.OPTION_AUTO_YES)) {
env.setAutoYesEnabled(true);
}
if (input.hasOption(Commands.OPTION_NON_INTERACTIVE)) {
env.setNonInteractive(true);
}
// explicit location
String catalogURL = getExplicitCatalogURL();
String builtinCatLocation = getReleaseCatalogURL();
if (builtinCatLocation == null) {
builtinCatLocation = feedback.l10n("Installer_BuiltingCatalogURL");
}
GraalEditionList editionList = new GraalEditionList(feedback, input, input.getLocalRegistry());
editionList.setDefaultCatalogSpec(builtinCatLocation);
editionList.setOverrideCatalogSpec(catalogURL);
env.setCatalogFactory(editionList);
if (input.hasOption(Commands.OPTION_USE_EDITION)) {
input.getLocalRegistry().setOverrideEdition(input.optValue(Commands.OPTION_USE_EDITION));
}
boolean builtinsImplied = true;
boolean setIterable = true;
if (input.hasOption(Commands.OPTION_FILES)) {
FileIterable fi = new FileIterable(env, env);
fi.setCatalogFactory(editionList);
env.setFileIterable(fi);
// optionally resolve local dependencies against parent directories
// of specified files.
builtinsImplied = false;
if (input.hasOption(Commands.OPTION_LOCAL_DEPENDENCIES)) {
while (env.hasParameter()) {
String s = env.nextParameter();
Path p = SystemUtils.fromUserString(s);
if (p != null) {
Path parent = p.getParent();
if (parent != null && Files.isDirectory(parent)) {
SoftwareChannelSource localSource = new SoftwareChannelSource(parent.toUri().toString(), null);
localSource.setPriority(10000);
editionList.addLocalChannelSource(localSource);
}
}
}
env.resetParameters();
}
setIterable = false;
} else if (input.hasOption(Commands.OPTION_URLS)) {
DownloadURLIterable dit = new DownloadURLIterable(env, env);
dit.setCatalogFactory(editionList);
env.setFileIterable(dit);
setIterable = false;
builtinsImplied = false;
}
if (setIterable) {
env.setFileIterable(new CatalogIterable(env, env));
}
editionList.setRemoteSourcesAllowed(builtinsImplied || env.hasOption(Commands.OPTION_CATALOG) || env.hasOption(Commands.OPTION_FOREIGN_CATALOG));
return -1;
}
use of org.graalvm.component.installer.remote.CatalogIterable in project graal by oracle.
the class CatalogInstallTest method testCheckPostinstMessageLoaded.
@Test
public void testCheckPostinstMessageLoaded() throws Exception {
setupVersion("0.33");
URL x = getClass().getResource("postinst2.jar");
URL rubyURL = new URL("test://release/postinst2.jar");
Handler.bind(rubyURL.toString(), x);
setupCatalog(null);
paramIterable = new CatalogIterable(this, this);
textParams.add("ruby");
InstallCommand cmd = new InstallCommand();
cmd.init(this, withBundle(InstallCommand.class));
cmd.prepareInstallation();
cmd.completeInstallers();
assertFalse(cmd.realInstallers.isEmpty());
for (Installer i : cmd.realInstallers.values()) {
assertNotNull(i.getComponentInfo().getPostinstMessage());
}
}
Aggregations