/** * Creates a Packaged program from the given command line options. * * @return A PackagedProgram (upon success) */ PackagedProgram buildProgram(ProgramOptions options) throws FileNotFoundException, ProgramInvocationException { String[] programArgs = options.getProgramArgs(); String jarFilePath = options.getJarFilePath(); List<URL> classpaths = options.getClasspaths(); if (jarFilePath == null) { throw new IllegalArgumentException("The program JAR file was not specified."); } File jarFile = new File(jarFilePath); // Check if JAR file exists if (!jarFile.exists()) { throw new FileNotFoundException("JAR file does not exist: " + jarFile); } else if (!jarFile.isFile()) { throw new FileNotFoundException("JAR file is not a file: " + jarFile); } // Get assembler class String entryPointClass = options.getEntryPointClassName(); PackagedProgram program = entryPointClass == null ? new PackagedProgram(jarFile, classpaths, programArgs) : new PackagedProgram(jarFile, classpaths, entryPointClass, programArgs); program.setSavepointRestoreSettings(options.getSavepointRestoreSettings()); return program; }
String[] programArgs = options.getProgramArgs(); String jarFilePath = options.getJarFilePath(); List<URL> classpaths = options.getClasspaths(); final List<URI> libjars = options.getLibjars(); final List<URI> files = options.getFiles(); String entryPointClass = options.getEntryPointClassName(); new PackagedProgram(jarFile, classpaths, entryPointClass, libjars, files, programArgs); program.setSavepointRestoreSettings(options.getSavepointRestoreSettings());
@Test public void testNonExistingJarFile() throws Exception { ProgramOptions options = mock(ProgramOptions.class); when(options.getJarFilePath()).thenReturn("/some/none/existing/path"); try { frontend.buildProgram(options); fail("should throw an exception"); } catch (FileNotFoundException e) { // that's what we want } }
libjars = extractMultipleURIOption(LIBJARS_OPTION.getLongOpt(), line); files = extractMultipleURIOption(FILES_OPTION.getLongOpt(), line);
@Test public void testFileNotJarFile() throws Exception { ProgramOptions options = mock(ProgramOptions.class); when(options.getJarFilePath()).thenReturn(getNonJarFilePath()); try { frontend.buildProgram(options); fail("should throw an exception"); } catch (ProgramInvocationException e) { // that's what we want } }
/** * Creates a Packaged program from the given command line options. * * @return A PackagedProgram (upon success) */ PackagedProgram buildProgram(ProgramOptions options) throws FileNotFoundException, ProgramInvocationException { String[] programArgs = options.getProgramArgs(); String jarFilePath = options.getJarFilePath(); List<URL> classpaths = options.getClasspaths(); if (jarFilePath == null) { throw new IllegalArgumentException("The program JAR file was not specified."); } File jarFile = new File(jarFilePath); // Check if JAR file exists if (!jarFile.exists()) { throw new FileNotFoundException("JAR file does not exist: " + jarFile); } else if (!jarFile.isFile()) { throw new FileNotFoundException("JAR file is not a file: " + jarFile); } // Get assembler class String entryPointClass = options.getEntryPointClassName(); PackagedProgram program = entryPointClass == null ? new PackagedProgram(jarFile, classpaths, programArgs) : new PackagedProgram(jarFile, classpaths, entryPointClass, programArgs); program.setSavepointRestoreSettings(options.getSavepointRestoreSettings()); return program; }
throws FileNotFoundException, ProgramInvocationException String[] programArgs = options.getProgramArgs(); String jarFilePath = options.getJarFilePath(); List<URL> classpaths = options.getClasspaths(); String entryPointClass = options.getEntryPointClassName(); new PackagedProgram(jarFile, classpaths, entryPointClass, programArgs); program.setSavepointRestoreSettings(options.getSavepointRestoreSettings());