@Test public void invalid_bundle_zip() throws Exception { Bundle bundle = new CssAnalyzerBundle("/bundle/invalid-zip-file.zip"); assertThatThrownBy(() -> bundle.deploy(tempFolder.newDir().toPath())) .isInstanceOf(IllegalStateException.class) .hasMessage("Failed to deploy css-bundle (with classpath '/bundle/invalid-zip-file.zip')"); }
@Override public void deploy(Path deployLocation) { this.deployLocation = deployLocation; PROFILER.startDebug("Deploying bundle"); LOG.debug("Deploying css-bundle into {}", deployLocation); InputStream bundle = getClass().getResourceAsStream(bundleLocation); if (bundle == null) { throw new IllegalStateException("css-bundle not found in " + bundleLocation); } try { LOG.debug("Deploying css-bundle to {}", deployLocation.toAbsolutePath()); Zip.extract(bundle, deployLocation); startServerScript = deployLocation.resolve(DEFAULT_STARTUP_SCRIPT).toAbsolutePath().toString(); } catch (Exception e) { throw new IllegalStateException("Failed to deploy css-bundle (with classpath '" + bundleLocation + "')", e); } PROFILER.stopDebug(); }
CssAnalyzerBundle implements Bundle { @Override public void deploy(Path deployLocation) { this.deployLocation = deployLocation; PROFILER.startDebug("Deploying bundle"); LOG.debug("Deploying css-bundle into {}", deployLocation); InputStream bundle = getClass().getResourceAsStream(bundleLocation); if (bundle == null) { throw new IllegalStateException("css-bundle not found in " + bundleLocation); } try { LOG.debug("Deploying css-bundle to {}", deployLocation.toAbsolutePath()); Zip.extract(bundle, deployLocation); startServerScript = deployLocation.resolve(DEFAULT_STARTUP_SCRIPT).toAbsolutePath().toString(); } catch (Exception e) { throw new IllegalStateException("Failed to deploy css-bundle (with classpath '" + bundleLocation + "')", e); } PROFILER.stopDebug(); } }
CssAnalyzerBundle implements Bundle { @Override public void deploy(Path deployLocation) { this.deployLocation = deployLocation; PROFILER.startDebug("Deploying bundle"); LOG.debug("Deploying css-bundle into {}", deployLocation); InputStream bundle = getClass().getResourceAsStream(bundleLocation); if (bundle == null) { throw new IllegalStateException("css-bundle not found in " + bundleLocation); } try { LOG.debug("Deploying css-bundle to {}", deployLocation.toAbsolutePath()); Zip.extract(bundle, deployLocation); startServerScript = deployLocation.resolve(DEFAULT_STARTUP_SCRIPT).toAbsolutePath().toString(); } catch (Exception e) { throw new IllegalStateException("Failed to deploy css-bundle (with classpath '" + bundleLocation + "')", e); } PROFILER.stopDebug(); } CssAnalyzerBundle(); @VisibleForTesting  CssAnalyzerBundle(String bundleLocation); }
CssAnalyzerBundle implements Bundle { @Override public void deploy(Path deployLocation) { this.deployLocation = deployLocation; PROFILER.startDebug("Deploying bundle"); LOG.debug("Deploying css-bundle into {}", deployLocation); InputStream bundle = getClass().getResourceAsStream(bundleLocation); if (bundle == null) { throw new IllegalStateException("css-bundle not found in " + bundleLocation); } try { LOG.debug("Deploying css-bundle to {}", deployLocation.toAbsolutePath()); Zip.extract(bundle, deployLocation); startServerScript = deployLocation.resolve(DEFAULT_STARTUP_SCRIPT).toAbsolutePath().toString(); } catch (Exception e) { throw new IllegalStateException("Failed to deploy css-bundle (with classpath '" + bundleLocation + "')", e); } PROFILER.stopDebug(); } CssAnalyzerBundle(); @VisibleForTesting  CssAnalyzerBundle(String bundleLocation); @Override void deploy(Path deployLocation); @Override String startServerScript(); @Override String resolve(String relativePath); }
CssAnalyzerBundle implements Bundle { @Override public void deploy(Path deployLocation) { this.deployLocation = deployLocation; PROFILER.startDebug("Deploying bundle"); LOG.debug("Deploying css-bundle into {}", deployLocation); InputStream bundle = getClass().getResourceAsStream(bundleLocation); if (bundle == null) { throw new IllegalStateException("css-bundle not found in " + bundleLocation); } try { LOG.debug("Deploying css-bundle to {}", deployLocation.toAbsolutePath()); Zip.extract(bundle, deployLocation); startServerScript = deployLocation.resolve(DEFAULT_STARTUP_SCRIPT).toAbsolutePath().toString(); } catch (Exception e) { throw new IllegalStateException("Failed to deploy css-bundle (with classpath '" + bundleLocation + "')", e); } PROFILER.stopDebug(); } CssAnalyzerBundle(); @VisibleForTesting  CssAnalyzerBundle(String bundleLocation); @Override void deploy(Path deployLocation); @Override String startServerScript(); @Override String resolve(String relativePath);  }