Skip to content

Commit

Permalink
Reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
josiahhaswell committed Oct 7, 2021
1 parent 9b606ab commit 4201489
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 65 deletions.
Expand Up @@ -20,9 +20,7 @@
@SuppressWarnings({"PMD.DoNotUseThreads"})
public abstract class AbstractAsynchronousObjectTracker<T> implements Tracker<T>, EventListener<T> {

/**
* immutable state
*/
/** immutable state */
final Module host;

final Kernel kernel;
Expand Down Expand Up @@ -192,9 +190,7 @@ private boolean isTracked(EventType type, T target) {
}
}

static final class ObjectThreadEventSource extends AbstractEventSource {

}
static final class ObjectThreadEventSource extends AbstractEventSource {}

static final class ObjectEventDispatchState<T> {

Expand Down
Expand Up @@ -84,9 +84,7 @@ public void start() {
}
}

/**
* waits for initialization
*/
/** waits for initialization */
public void initialize() {
synchronized (this) {
while (!source.running) {
Expand Down
Expand Up @@ -31,14 +31,12 @@
import java.util.logging.Logger;
import lombok.val;

/**
* not really sure if this is a good idea or not
*/
/** not really sure if this is a good idea or not */
@SuppressWarnings({
"PMD.DoNotUseThreads",
"PMD.AvoidFieldNameMatchingTypeName",
"PMD.UnusedPrivateMethod",
"PMD.DataflowAnomalyAnalysis"
"PMD.DoNotUseThreads",
"PMD.AvoidFieldNameMatchingTypeName",
"PMD.UnusedPrivateMethod",
"PMD.DataflowAnomalyAnalysis"
})
@SuppressFBWarnings
public class ModuleThread implements Startable, Stoppable, TaskQueue, Runnable, VolatileStorage {
Expand Down Expand Up @@ -210,7 +208,7 @@ private void handleFailure(Coordinate coordinate, Throwable ex) {
Events.create(
module, StatusType.FAILED.unresolvable(FAILURE_TEMPLATE, coordinate, ex.getMessage())));
module.getLifecycle().setState(Lifecycle.State.Failed);
log.log(Level.WARNING, FAILURE_TEMPLATE, new Object[]{coordinate, ex.getMessage()});
log.log(Level.WARNING, FAILURE_TEMPLATE, new Object[] {coordinate, ex.getMessage()});
log.log(Level.FINE, "Reason: ", ex);
}

Expand Down
Expand Up @@ -8,15 +8,13 @@
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
//@Disabled("Need to figure out why these are flaky")
// @Disabled("Need to figure out why these are flaky")
public class ModuleListenerTestCase extends ShellTestCase {

static {
Expand Down
Expand Up @@ -96,9 +96,9 @@ protected void startPlugins(String... plugins) {
protected void startAndWait(int expectedCount, String... plugins) {
startPlugins(plugins);
while (kernel.getModuleManager().getModules().stream()
.filter(t -> t.getLifecycle().getState() == Lifecycle.State.Active)
.count()
!= expectedCount) {
.filter(t -> t.getLifecycle().getState() == Lifecycle.State.Active)
.count()
!= expectedCount) {
Thread.sleep(200);
}
}
Expand Down Expand Up @@ -131,9 +131,9 @@ protected void restartKernel() {

protected void runAsync(String... args) {
new Thread(
() -> {
run(args);
})
() -> {
run(args);
})
.start();
}

Expand Down Expand Up @@ -201,12 +201,15 @@ protected void installAndWaitForModuleCount(int count, Installable... modules) {

val failedCount = new AtomicInteger(0);
EventListener<Object> listener;
kernel.addEventListener(listener = new EventListener<Object>() {
@Override
public void onEvent(EventType type, Event<Object> event) {
failedCount.incrementAndGet();
}
}, ModuleEvents.INSTALL_FAILED);
kernel.addEventListener(
listener =
new EventListener<Object>() {
@Override
public void onEvent(EventType type, Event<Object> event) {
failedCount.incrementAndGet();
}
},
ModuleEvents.INSTALL_FAILED);

try {
install(modules);
Expand Down
Expand Up @@ -28,35 +28,28 @@
@Clean(value = Clean.Mode.After, context = Clean.Context.Method)
public class ServiceTrackerTest {

/**
* mocks
*/
@Mock
private EventListener<?> listener;
/** mocks */
@Mock private EventListener<?> listener;

/**
* state
*/
@Inject
private Zephyr zephyr;
/** state */
@Inject private Zephyr zephyr;

@Inject
private ModuleContext context;
@Inject
private ModuleLifecycleManager lifecycleManager;
@Inject private ModuleContext context;
@Inject private ModuleLifecycleManager lifecycleManager;

@RepeatedTest(10)
void ensureTrackingServiceProducesServiceInInstalledTestPlugin() {
val tracker = context.trackServices(t -> true);
tracker.addEventListener(listener, ServiceEvents.REGISTERED);
tracker.addEventListener(new EventListener<Object>() {
tracker.addEventListener(
new EventListener<Object>() {

@Override
public void onEvent(EventType type, Event<Object> event) {
System.out.println(event);

}
}, ServiceEvents.REGISTERED);
@Override
public void onEvent(EventType type, Event<Object> event) {
System.out.println(event);
}
},
ServiceEvents.REGISTERED);
zephyr.install(ProjectPlugins.TEST_PLUGIN_1.getUrl());
zephyr.install(ProjectPlugins.TEST_PLUGIN_2.getUrl());
lifecycleManager.start(t -> t.getCoordinate().getName().contains("2"));
Expand Down
Expand Up @@ -32,16 +32,15 @@ public ClasspathModuleResourceProvider(Module module, String... locations) {
this(module, false, locations);
}

public ClasspathModuleResourceProvider(Module module, boolean searchSubAssemblies,
String... locations) {
public ClasspathModuleResourceProvider(
Module module, boolean searchSubAssemblies, String... locations) {
this.module = Objects.requireNonNull(module, "Module must not be null");
validate(locations);
this.locations = Arrays.asList(locations);
this.resources = new LinkedHashMap<>();
this.searchSubAssemblies = searchSubAssemblies;
}


@Override
public LoadableResource getResource(String name) {
return resources.get(name);
Expand Down
Expand Up @@ -11,8 +11,8 @@ public static ModuleResourceProviderBuilder classpath(@NonNull Module module) {
return new ModuleResourceProviderBuilder(module, false);
}

public static ModuleResourceProviderBuilder classpath(@NonNull Module module,
boolean searchSubAssemblies) {
public static ModuleResourceProviderBuilder classpath(
@NonNull Module module, boolean searchSubAssemblies) {
return new ModuleResourceProviderBuilder(module, searchSubAssemblies);
}

Expand Down
Expand Up @@ -30,13 +30,13 @@

@SuppressFBWarnings
@SuppressWarnings({
"PMD.UseVarargs",
"PMD.ArrayIsStoredDirectly",
"PMD.UnusedPrivateMethod",
"PMD.DoNotCallSystemExit",
"PMD.FinalizeOverloaded",
"PMD.AvoidDuplicateLiterals",
"PMD.DoNotUseThreads"
"PMD.UseVarargs",
"PMD.ArrayIsStoredDirectly",
"PMD.UnusedPrivateMethod",
"PMD.DoNotCallSystemExit",
"PMD.FinalizeOverloaded",
"PMD.AvoidDuplicateLiterals",
"PMD.DoNotUseThreads"
})
public class KernelLauncher implements EntryPoint, EntryPointRegistry {

Expand Down

0 comments on commit 4201489

Please sign in to comment.