use of java.util.Observer in project core by jcryptool.
the class IntegratorWizardPage method makeNewKeypair.
protected void makeNewKeypair() {
Job[] preJobs = Job.getJobManager().find(KeyStoreHelper.KEYSTOREHELPER_FAMILY);
int preJobCount = preJobs.length;
KeyStoreHelper.makeKeyPairByWizard(showKeyGroup).addObserver(new Observer() {
public void update(Observable o, final Object arg) {
if (arg != null) {
keyFromKeystoreGroup.getDisplay().syncExec(new Runnable() {
public void run() {
KeyStoreAlias ref = (KeyStoreAlias) arg;
setKeyForShowcase(ref);
}
});
}
}
});
Job[] jobs = Job.getJobManager().find(KeyStoreHelper.KEYSTOREHELPER_FAMILY);
if (jobs.length > preJobCount) {
createNewKeyButton.getDisplay().syncExec(new Runnable() {
public void run() {
buttonTextBeforeJobrunningMsg = createNewKeyButton.getText();
// $NON-NLS-1$
createNewKeyButton.setText(Messages.getString("IntegratorWizardPage.generatingButtonHint"));
disableControls();
}
});
Job job = jobs[jobs.length - 1];
IJobChangeListener listener = new IJobChangeListener() {
public void sleeping(IJobChangeEvent event) {
}
public void done(IJobChangeEvent event) {
createNewKeyButton.getDisplay().syncExec(new Runnable() {
public void run() {
createNewKeyButton.setText(buttonTextBeforeJobrunningMsg);
enableControls();
}
});
}
public void awake(IJobChangeEvent event) {
}
public void aboutToRun(IJobChangeEvent event) {
}
public void running(IJobChangeEvent event) {
}
public void scheduled(IJobChangeEvent event) {
}
};
if (job.getState() != Job.NONE)
job.addJobChangeListener(listener);
else {
listener.done(null);
}
}
}
use of java.util.Observer in project core by jcryptool.
the class AbstractAlgorithmHandler method performOpenEditor.
/**
* Tries to open the given IEditorInput in the Editor associated with the given ID. This method must be executed in
* an async way since a Job may be used to execute the cryptographic operation.
*
* @param input The IEditorInput that shall be displayed
* @param editorId The ID of the Editor that is supposed to open
*/
protected void performOpenEditor(final IEditorInput input, final String editorId) {
Observer dummyObserver = new Observer() {
@Override
public void update(Observable o, Object arg) {
}
};
performOpenEditor(input, editorId, dummyObserver);
}
use of java.util.Observer in project opentest by mcdcorp.
the class SeleniumTestAction method initialize.
@Override
public void initialize() {
super.initialize();
if (!SeleniumTestAction.initialized) {
SeleniumTestAction.initialized = true;
SeleniumTestAction.config = SeleniumHelper.getConfig();
this.getActor().addObserver(new Observer() {
@Override
public void update(Observable eventSource, Object eventData) {
if (eventSource instanceof ITestActor) {
if (eventData == TestActorEvents.TEST_COMPLETED) {
SeleniumTestAction.discardActionsObject();
if (!SeleniumHelper.getConfig().getBoolean("selenium.reuseDriver", false)) {
SeleniumHelper.discardDriver();
}
}
}
}
});
}
this.explicitWaitSec = this.readIntArgument("explicitWaitSec", SeleniumHelper.getExplicitWaitSec());
this.driver = SeleniumHelper.getDriver();
}
use of java.util.Observer in project openkit-java by Dynatrace.
the class BeaconCacheEvictorTest method triggeringEvictionStrategiesInThread.
@Test
public void triggeringEvictionStrategiesInThread() throws Exception {
// given
final Observer[] observers = new Observer[] { null };
final CountDownLatch addObserverLatch = new CountDownLatch(1);
final CyclicBarrier strategyInvokedBarrier = new CyclicBarrier(2);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
observers[0] = (Observer) invocation.getArguments()[0];
addObserverLatch.countDown();
return null;
}
}).when(mockBeaconCache).addObserver(org.mockito.Matchers.any(Observer.class));
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
strategyInvokedBarrier.await();
return null;
}
}).when(mockStrategyTwo).execute();
// first step start the eviction thread
evictor = new BeaconCacheEvictor(mockLogger, mockBeaconCache, mockStrategyOne, mockStrategyTwo);
evictor.start();
// wait until the eviction thread registered itself as observer
addObserverLatch.await();
// verify the observer was set
assertThat(observers[0], is(notNullValue()));
// do some updates
for (int i = 0; i < 10; i++) {
observers[0].update(mock(Observable.class), null);
strategyInvokedBarrier.await();
strategyInvokedBarrier.reset();
}
// stop the stuff and ensure it's invoked
boolean stopped = evictor.stop();
assertThat(stopped, is(true));
assertThat(evictor.isAlive(), is(false));
verify(mockStrategyOne, times(10)).execute();
verify(mockStrategyTwo, times(10)).execute();
}
use of java.util.Observer in project mockito by mockito.
the class DetectingMisusedMatchersTest method should_report_argument_locations_when_argument_matchers_misused.
@Test
public void should_report_argument_locations_when_argument_matchers_misused() {
try {
Observer observer = mock(Observer.class);
misplaced_anyInt_argument_matcher();
misplaced_any_argument_matcher();
misplaced_anyBoolean_argument_matcher();
observer.update(null, null);
validateMockitoUsage();
fail();
} catch (InvalidUseOfMatchersException e) {
assertThat(e).hasMessageContaining("DetectingMisusedMatchersTest.misplaced_anyInt_argument_matcher").hasMessageContaining("DetectingMisusedMatchersTest.misplaced_any_argument_matcher").hasMessageContaining("DetectingMisusedMatchersTest.misplaced_anyBoolean_argument_matcher");
}
}
Aggregations