package org.sonar.process;
import java.io.File;
+import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
assertThat(commands.isUp()).isTrue();
}
+ @Test
+ public void reset_clears_only_the_memory_space_of_specified_process_number() throws IOException {
+ File dir = temp.newFolder();
+
+ AllProcessesCommands commands = new AllProcessesCommands(dir);
+ for (int i = 0; i < MAX_PROCESSES; i++) {
+ commands.setOperational(i);
+ commands.setUp(i);
+ }
+
+ int resetProcess = 3;
+ DefaultProcessCommands.reset(dir, resetProcess);
+ for (int i = 0; i < MAX_PROCESSES; i++) {
+ assertThat(commands.isOperational(i)).isEqualTo(i != resetProcess);
+ assertThat(commands.isUp(i)).isEqualTo(i != resetProcess);
+ }
+ commands.close();
+ }
+
@Test
public void ask_for_stop() throws Exception {
File dir = temp.newFolder();
}
}
- private void aggregateToParent(Path<FormulaExecutorComponentVisitor.Counters> path, Formula formula, Counter currentCounter) {
+ private static void aggregateToParent(Path<FormulaExecutorComponentVisitor.Counters> path, Formula formula, Counter currentCounter) {
if (!path.isRoot()) {
path.parent().aggregate(formula, currentCounter);
}
});
}
- private AuthorMapper getMapper(SqlSession session) {
+ private static AuthorMapper getMapper(SqlSession session) {
return session.getMapper(AuthorMapper.class);
}
}
updateUsers(context);
}
- private void updateGroupAnyOne(Context context) throws SQLException {
+ private static void updateGroupAnyOne(Context context) throws SQLException {
MassUpdate update = context.prepareMassUpdate().rowPluralName("Group AnyOne");
update.select("select gr1.id from group_roles gr1 " +
"where gr1.role = 'profileadmin' " +
update.execute(GroupAnyOneHandler.INSTANCE);
}
- private void updateOtherGroups(Context context) throws SQLException {
+ private static void updateOtherGroups(Context context) throws SQLException {
MassUpdate update = context.prepareMassUpdate().rowPluralName("Other groups");
update.select("select gr1.group_id from group_roles gr1 " +
"where gr1.role = 'profileadmin' " +
update.execute(OtherGroupsHandler.INSTANCE);
}
- private void updateUsers(Context context) throws SQLException {
+ private static void updateUsers(Context context) throws SQLException {
MassUpdate update = context.prepareMassUpdate().rowPluralName("Users");
update.select("select ur1.user_id from user_roles ur1 " +
"where ur1.role = 'profileadmin' " +