--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.ce.async;
+
+import org.sonar.server.async.AsyncExecution;
+
+public class SynchronousAsyncExecution implements AsyncExecution {
+ @Override
+ public void addToQueue(Runnable r) {
+ r.run();
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.ce.async;
+
+import javax.annotation.ParametersAreNonnullByDefault;
import org.sonar.ce.CeQueueModule;
import org.sonar.ce.CeTaskCommonsModule;
import org.sonar.ce.StandaloneCeDistributedInformation;
+import org.sonar.ce.async.SynchronousAsyncExecution;
import org.sonar.ce.cleaning.CeCleaningModule;
import org.sonar.ce.db.ReadOnlyPropertiesDao;
import org.sonar.ce.log.CeProcessLogging;
import org.sonar.process.ProcessProperties;
import org.sonar.process.Props;
import org.sonar.process.logging.LogbackHelper;
-import org.sonar.server.async.AsyncExecutionModule;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.component.index.ComponentIndexer;
import org.sonar.server.computation.task.projectanalysis.ProjectAnalysisTaskModule;
UriReader.class,
ServerImpl.class,
DefaultOrganizationProviderImpl.class,
- AsyncExecutionModule.class);
+ SynchronousAsyncExecution.class);
}
private static void populateLevel4(ComponentContainer container, Props props) {
--- /dev/null
+package org.sonar.ce.async;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SynchronousAsyncExecutionTest {
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private SynchronousAsyncExecution underTest = new SynchronousAsyncExecution();
+
+ @Test
+ public void addToQueue_fails_with_NPE_if_Runnable_is_null() {
+ expectedException.expect(NullPointerException.class);
+
+ underTest.addToQueue(null);
+ }
+
+ @Test
+ public void addToQueue_executes_Runnable_synchronously() {
+ Set<String> s = new HashSet<>();
+
+ underTest.addToQueue(() -> s.add("done"));
+
+ assertThat(s).containsOnly("done");
+ }
+}
assertThat(picoContainer.getParent().getComponentAdapters()).hasSize(
CONTAINER_ITSELF
+ 6 // level 3
- + 2 // AsyncExecutionModule
);
assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize(
CONTAINER_ITSELF