public void setUp(boolean verbose) { Batch.Builder builder = Batch.builder() .setEnableLoggingConfiguration(true) .addComponents( loader, new EnvironmentInformation("mediumTest", "1.0")); if (verbose) { builder.setBootstrapProperties(Collections.singletonMap("sonar.verbose", "true")); } batch = builder.build(); }
public Batch build() { if (components == null) { throw new IllegalStateException("Batch components are not set"); } return new Batch(this); } }
public synchronized Batch doExecute(Map<String, String> scannerProperties, List<Object> components) { configureLogging(); try { GlobalContainer.create(scannerProperties, components).execute(); } catch (RuntimeException e) { throw handleException(e); } return this; }
@Test public void shoudSetLogListener() { LogOutput logOutput = mock(LogOutput.class); Batch batch = Batch.builder().setLogOutput(logOutput).build(); assertThat(batch.getLoggingConfiguration().getLogOutput()).isEqualTo(logOutput); } }
public AnalysisResult execute() { AnalysisResult result = new AnalysisResult(); Map<String, String> props = new HashMap<>(); props.putAll(tester.globalProperties); props.putAll(taskProperties); Batch.builder() .setGlobalProperties(props) .setEnableLoggingConfiguration(true) .addComponents(new EnvironmentInformation("mediumTest", "1.0"), tester.pluginInstaller, tester.globalRefProvider, tester.qualityProfiles, tester.rulesLoader, tester.branchConfigurationLoader, tester.projectRefProvider, tester.activeRules, tester.serverIssues, tester.settingsLoader, result) .setLogOutput(tester.logOutput) .build().execute(); return result; }
/** * @deprecated since 4.4 use {@link #start()}, {@link #executeTask(Map)} and then {@link #stop()} */ @Deprecated public synchronized Batch execute() { configureLogging(); start().executeTask(bootstrapProperties).stop(); return this; }
/** * @deprecated since 4.4 use {@link #start()}, {@link #executeTask(Map)} and then {@link #stop()} */ @Deprecated public synchronized Batch execute() { configureLogging(); start(); boolean threw = true; try { executeTask(bootstrapProperties); threw = false; } finally { doStop(threw); } return this; }
@Test public void test() throws Exception { setUp(false); loader.withCause = false; thrown.expect(MessageException.class); thrown.expectMessage("Error loading settings"); thrown.expectCause(CoreMatchers.nullValue(Throwable.class)); batch.execute(); }
private void doStop(boolean swallowException) { checkStarted(); configureLogging(); try { bootstrapContainer.stopComponents(swallowException); } catch (RuntimeException e) { throw handleException(e); } this.started = false; }
/** * @since 5.2 */ public Batch executeTask(Map<String, String> analysisProperties, IssueListener issueListener) { checkStarted(); configureTaskLogging(analysisProperties); try { bootstrapContainer.executeTask(analysisProperties, components, issueListener); } catch (RuntimeException e) { throw handleException(e); } return this; }
/** * @since 4.4 */ public synchronized Batch start() { return start(false); }
@Override public void execute(Properties properties) { batch.executeTask((Map) properties); }
/** * @since 4.4 */ public synchronized Batch start() { if (started) { throw new IllegalStateException("Batch is already started"); } configureLogging(); bootstrapContainer = GlobalContainer.create(bootstrapProperties, components); bootstrapContainer.startComponents(); this.started = true; return this; }
public synchronized Batch execute() { return doExecute(this.globalProperties, this.components); }
@Override public void stop() { batch.stop(); }
@Test public void testWithVerbose() throws Exception { setUp(true); thrown.expect(IllegalStateException.class); thrown.expectMessage("Unable to load component class"); batch.execute(); }
@Test public void shouldDisableLoggingConfiguration() { Batch batch = Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .setEnableLoggingConfiguration(false) .build(); assertNull(batch.getLoggingConfiguration()); }
/** * @since 4.4 */ public Batch executeTask(Map<String, String> analysisProperties, Object... components) { checkStarted(); configureTaskLogging(analysisProperties); try { bootstrapContainer.executeTask(analysisProperties, components); } catch (RuntimeException e) { throw handleException(e); } return this; }
public void start() { batch.start(); }
public TaskResult start() { TaskResult result = new TaskResult(); Map<String, String> props = new HashMap<>(); props.putAll(taskProperties); tester.batch.executeTask(props, result); return result; }