Search in sources :

Example 1 with Observer

use of java.util.Observer in project mockito by mockito.

the class InlineByteBuddyMockMakerTest method is_type_mockable_allows_anonymous.

@Test
public void is_type_mockable_allows_anonymous() {
    Observer anonymous = new Observer() {

        @Override
        public void update(Observable o, Object arg) {
        }
    };
    MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(anonymous.getClass());
    assertThat(mockable.mockable()).isTrue();
    assertThat(mockable.nonMockableReason()).contains("");
}
Also used : Observer(java.util.Observer) MockMaker(org.mockito.plugins.MockMaker) Observable(java.util.Observable) Test(org.junit.Test)

Example 2 with Observer

use of java.util.Observer in project android_frameworks_base by DirtyUnicorns.

the class ContentQueryMapTest method testContentQueryMap.

@MediumTest
public void testContentQueryMap() throws Throwable {
    LooperThread thread = new LooperThread() {

        void go() {
            ContentResolver r = getContext().getContentResolver();
            Settings.System.putString(r, "test", "Value");
            Cursor cursor = r.query(Settings.System.CONTENT_URI, new String[] { Settings.System.NAME, Settings.System.VALUE }, null, null, null);
            final ContentQueryMap cqm = new ContentQueryMap(cursor, Settings.System.NAME, true, null);
            // Get the current state of the CQM. This forces a requery and means that the
            // call to getValues() below won't do a requery().
            cqm.getRows();
            // The cache won't notice changes until the loop runs.
            Settings.System.putString(r, "test", "New Value");
            ContentValues v = cqm.getValues("test");
            String value = v.getAsString(Settings.System.VALUE);
            assertEquals("Value", value);
            // Use an Observer to find out when the cache does update.
            cqm.addObserver(new Observer() {

                public void update(Observable o, Object arg) {
                    // Should have the new values by now.
                    ContentValues v = cqm.getValues("test");
                    String value = v.getAsString(Settings.System.VALUE);
                    assertEquals("New Value", value);
                    Looper.myLooper().quit();
                    cqm.close();
                    mSuccess = true;
                }
            });
            // Give up after a few seconds, if it doesn't.
            new Handler().postDelayed(new Runnable() {

                public void run() {
                    fail("Timed out");
                }
            }, 5000);
        }
    };
    thread.start();
    thread.join();
    if (thread.mError != null)
        throw thread.mError;
    assertTrue(thread.mSuccess);
}
Also used : ContentValues(android.content.ContentValues) ContentQueryMap(android.content.ContentQueryMap) Observer(java.util.Observer) Handler(android.os.Handler) Cursor(android.database.Cursor) Observable(java.util.Observable) ContentResolver(android.content.ContentResolver) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 3 with Observer

use of java.util.Observer in project intellij-community by JetBrains.

the class SelectCvsElementStep method createComponent.

@Override
protected JComponent createComponent() {
    myCvsTree = new CvsTree(myProject, myAllowRootSelection, mySelectionMode, myShowModules, myShowFiles, e -> {
        myErrors.set(Boolean.TRUE);
        ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(e.getMessage(), CvsBundle.message("error.title.cvs.error")), ModalityState.any());
    });
    myCvsTree.init();
    myCvsTree.addSelectionObserver(new Observer() {

        @Override
        public void update(Observable o, Object arg) {
            if (CvsTree.SELECTION_CHANGED.equals(arg)) {
                getWizard().updateStep();
            }
        }
    });
    return myCvsTree;
}
Also used : Observer(java.util.Observer) ModalityState(com.intellij.openapi.application.ModalityState) CvsBundle(com.intellij.CvsBundle) Nullable(org.jetbrains.annotations.Nullable) CvsTree(com.intellij.cvsSupport2.cvsBrowser.CvsTree) LoginPerformer(com.intellij.cvsSupport2.cvsoperations.common.LoginPerformer) CvsRootException(com.intellij.cvsSupport2.connections.CvsRootException) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) VcsException(com.intellij.openapi.vcs.VcsException) Observable(java.util.Observable) Ref(com.intellij.openapi.util.Ref) JdkConstants(org.intellij.lang.annotations.JdkConstants) Collections(java.util.Collections) CvsRootConfiguration(com.intellij.cvsSupport2.config.CvsRootConfiguration) CvsElement(com.intellij.cvsSupport2.cvsBrowser.CvsElement) Consumer(com.intellij.util.Consumer) CvsEnvironment(com.intellij.cvsSupport2.connections.CvsEnvironment) javax.swing(javax.swing) CvsTree(com.intellij.cvsSupport2.cvsBrowser.CvsTree) Observer(java.util.Observer) Observable(java.util.Observable)

Example 4 with Observer

use of java.util.Observer in project android_frameworks_base by crdroidandroid.

the class ContentQueryMapTest method testContentQueryMap.

@MediumTest
public void testContentQueryMap() throws Throwable {
    LooperThread thread = new LooperThread() {

        void go() {
            ContentResolver r = getContext().getContentResolver();
            Settings.System.putString(r, "test", "Value");
            Cursor cursor = r.query(Settings.System.CONTENT_URI, new String[] { Settings.System.NAME, Settings.System.VALUE }, null, null, null);
            final ContentQueryMap cqm = new ContentQueryMap(cursor, Settings.System.NAME, true, null);
            // Get the current state of the CQM. This forces a requery and means that the
            // call to getValues() below won't do a requery().
            cqm.getRows();
            // The cache won't notice changes until the loop runs.
            Settings.System.putString(r, "test", "New Value");
            ContentValues v = cqm.getValues("test");
            String value = v.getAsString(Settings.System.VALUE);
            assertEquals("Value", value);
            // Use an Observer to find out when the cache does update.
            cqm.addObserver(new Observer() {

                public void update(Observable o, Object arg) {
                    // Should have the new values by now.
                    ContentValues v = cqm.getValues("test");
                    String value = v.getAsString(Settings.System.VALUE);
                    assertEquals("New Value", value);
                    Looper.myLooper().quit();
                    cqm.close();
                    mSuccess = true;
                }
            });
            // Give up after a few seconds, if it doesn't.
            new Handler().postDelayed(new Runnable() {

                public void run() {
                    fail("Timed out");
                }
            }, 5000);
        }
    };
    thread.start();
    thread.join();
    if (thread.mError != null)
        throw thread.mError;
    assertTrue(thread.mSuccess);
}
Also used : ContentValues(android.content.ContentValues) ContentQueryMap(android.content.ContentQueryMap) Observer(java.util.Observer) Handler(android.os.Handler) Cursor(android.database.Cursor) Observable(java.util.Observable) ContentResolver(android.content.ContentResolver) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 5 with Observer

use of java.util.Observer in project vorto by eclipse.

the class RestModelRepositoryExtensionFactory method create.

@Override
public Object create() throws CoreException {
    RestModelRepository modelRepository = new RestModelRepository(ConnectionInfoFactory.getConnectionInfo());
    modelRepository.addObserver(new Observer() {

        public void update(Observable o, Object arg) {
            MessageDisplayFactory.getMessageDisplay().display("Upload Status : " + arg.toString());
        }
    });
    return modelRepository;
}
Also used : Observer(java.util.Observer) Observable(java.util.Observable)

Aggregations

Observer (java.util.Observer)36 Observable (java.util.Observable)29 Test (org.junit.Test)12 ContentQueryMap (android.content.ContentQueryMap)6 ContentResolver (android.content.ContentResolver)6 ContentValues (android.content.ContentValues)6 Cursor (android.database.Cursor)6 Handler (android.os.Handler)6 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 Map (java.util.Map)2 Properties (java.util.Properties)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 IJobChangeListener (org.eclipse.core.runtime.jobs.IJobChangeListener)2 Job (org.eclipse.core.runtime.jobs.Job)2 ITestActor (org.getopentest.contracts.ITestActor)2 IDataObject (org.jcryptool.core.operations.dataobject.IDataObject)2 KeyStoreAlias (org.jcryptool.crypto.keystore.backend.KeyStoreAlias)2 ParameterizedConstructorInstantiator (org.mockito.internal.util.reflection.FieldInitializer.ParameterizedConstructorInstantiator)2 CvsBundle (com.intellij.CvsBundle)1