Search in sources :

Example 6 with MockDisposable

use of com.facebook.buck.intellij.ideabuck.test.util.MockDisposable in project buck by facebook.

the class BuckClientTest method testConnectDisconnect.

@Test
public void testConnectDisconnect() {
    Extensions.registerAreaClass("IDEA_PROJECT", null);
    MockDisposable mockDisposable = new MockDisposable();
    MockApplication application = new MockApplicationEx(mockDisposable);
    ApplicationManager.setApplication(application, mockDisposable);
    Project project = new MockProjectEx(new MockDisposable());
    TestBuckEventHandler handler = new TestBuckEventHandler();
    BuckSocket buckSocket = new BuckSocket(handler);
    BuckClientManager.getOrCreateClient(project, handler).setBuckSocket(buckSocket);
    BuckClientManager.getOrCreateClient(project, handler).connect();
    buckSocket.onConnect(new MockSession());
    BuckClientManager.getOrCreateClient(project, handler).disconnectWithoutRetry();
    buckSocket.onClose(0, "FOO");
    assertFalse(BuckClientManager.getOrCreateClient(project, handler).isConnected());
}
Also used : Project(com.intellij.openapi.project.Project) MockApplicationEx(com.intellij.mock.MockApplicationEx) MockSession(com.facebook.buck.intellij.ideabuck.test.util.MockSession) MockApplication(com.intellij.mock.MockApplication) MockDisposable(com.facebook.buck.intellij.ideabuck.test.util.MockDisposable) MockProjectEx(com.intellij.mock.MockProjectEx) Test(org.junit.Test)

Aggregations

MockDisposable (com.facebook.buck.intellij.ideabuck.test.util.MockDisposable)6 MockApplication (com.intellij.mock.MockApplication)6 MockProjectEx (com.intellij.mock.MockProjectEx)6 MockApplicationEx (com.intellij.mock.MockApplicationEx)5 Test (org.junit.Test)4 Project (com.intellij.openapi.project.Project)3 MockSession (com.facebook.buck.intellij.ideabuck.test.util.MockSession)2 MyMockApplication (com.facebook.buck.intellij.ideabuck.test.util.MyMockApplication)2 ProjectPropertiesComponentImpl (com.intellij.ide.util.ProjectPropertiesComponentImpl)1 Mock (com.intellij.mock.Mock)1 MockFileDocumentManagerImpl (com.intellij.mock.MockFileDocumentManagerImpl)1 MockProject (com.intellij.mock.MockProject)1 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)1 PsiDocumentManager (com.intellij.psi.PsiDocumentManager)1 Field (java.lang.reflect.Field)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 EasyMock (org.easymock.EasyMock)1