本文整理汇总了Java中com.intellij.mock.MockApplicationEx类的典型用法代码示例。如果您正苦于以下问题:Java MockApplicationEx类的具体用法?Java MockApplicationEx怎么用?Java MockApplicationEx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockApplicationEx类属于com.intellij.mock包,在下文中一共展示了MockApplicationEx类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initApplication
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
public void initApplication() {
//if (ApplicationManager.getApplication() instanceof MockApplicationEx) return;
final MockApplicationEx instance = new MockApplicationEx(getTestRootDisposable());
ApplicationManager.setApplication(instance,
new Getter<FileTypeRegistry>() {
@Override
public FileTypeRegistry get() {
return FileTypeManager.getInstance();
}
},
new Getter<EncodingRegistry>() {
@Override
public EncodingRegistry get() {
return EncodingManager.getInstance();
}
},
getTestRootDisposable());
getApplication().registerService(EncodingManager.class, EncodingManagerImpl.class);
}
示例2: testConnectDisconnect
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
@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());
}
示例3: hasBuckDisconnectedThenWeReconnectIfSoSpecified
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
@Test
public void hasBuckDisconnectedThenWeReconnectIfSoSpecified() {
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).disconnectWithRetry();
buckSocket.onClose(0, "FOO");
buckSocket.onConnect(new MockSession());
assertTrue(BuckClientManager.getOrCreateClient(project, handler).isConnected());
}
示例4: hasBuckModuleAttachReceivedNullTargetThenWeShowNone
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
@Test
public void hasBuckModuleAttachReceivedNullTargetThenWeShowNone()
throws NoSuchFieldException, IllegalAccessException {
Extensions.registerAreaClass("IDEA_PROJECT", null);
MockDisposable mockDisposable = new MockDisposable();
MockApplication application = new MockApplicationEx(mockDisposable);
ApplicationManager.setApplication(application, mockDisposable);
BuckEventsConsumer buckEventsConsumer =
new BuckEventsConsumer(new MockProjectEx(new MockDisposable()));
buckEventsConsumer.attach(null, new DefaultTreeModel(null));
Field privateStringField = BuckEventsConsumer.class.getDeclaredField("mTarget");
privateStringField.setAccessible(true);
String fieldValue = (String) privateStringField.get(buckEventsConsumer);
assertEquals(fieldValue, "NONE");
}
示例5: initBuckModule
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
public Project initBuckModule() {
Extensions.registerAreaClass("IDEA_PROJECT", null);
MockDisposable mockDisposable = new MockDisposable();
MockProjectEx project = new MockProjectEx(mockDisposable);
MockApplication application = new MockApplicationEx(mockDisposable);
ApplicationManager.setApplication(application, mockDisposable);
application.registerService(UISettings.class, UISettings.getShadowInstance());
application.registerService(PropertiesComponent.class, new ProjectPropertiesComponentImpl());
FileTypeManager fileTypeManager = EasyMock.createMock(FileTypeManager.class);
EasyMock.expect(
fileTypeManager.getFileTypeByFileName(BuckFileType.INSTANCE.getDefaultExtension()))
.andReturn(BuckFileType.INSTANCE)
.times(3);
EasyMock.replay(fileTypeManager);
application.registerService(FileTypeManager.class, fileTypeManager);
project.addComponent(PsiDocumentManager.class, EasyMock.createMock(PsiDocumentManager.class));
return project;
}
示例6: initApplication
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
public void initApplication() {
//if (ApplicationManager.getApplication() instanceof MockApplicationEx) return;
final MockApplicationEx instance = new MockApplicationEx(getTestRootDisposable());
ApplicationManager.setApplication(instance,
new Getter<FileTypeRegistry>() {
@Override
public FileTypeRegistry get() {
return FileTypeManager.getInstance();
}
},
getTestRootDisposable());
getApplication().registerService(EncodingManager.class, EncodingManagerImpl.class);
}
示例7: setUp
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
final Application old = ApplicationManagerEx.getApplication();
myRootDisposable = Disposer.newDisposable();
MockApplicationEx app = new MockApplicationEx(getRootDisposable()) {
@NotNull
@Override
public Future<?> executeOnPooledThread(@NotNull Runnable action) {
return old != null ? old.executeOnPooledThread(action) : super.executeOnPooledThread(action);
}
};
ApplicationManager.setApplication(app, myRootDisposable);
}
示例8: testMessages
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
@Test
public void testMessages() {
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();
BuckClient client = BuckClientManager.getOrCreateClient(project, handler);
// Set the socket we control
BuckSocket socket = new BuckSocket(handler);
client.setBuckSocket(socket);
client.connect();
assertEquals("", handler.getLastMessage());
socket.onMessage("some text");
assertEquals("some text", handler.getLastMessage());
socket.onMessage("some text 1");
socket.onMessage("some text 2");
socket.onMessage("some text 3");
socket.onMessage("some text 4");
assertEquals("some text 4", handler.getLastMessage());
}
示例9: getApplication
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
public static MockApplicationEx getApplication() {
return (MockApplicationEx)ApplicationManager.getApplication();
}
示例10: createApplication
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
@NotNull
protected MockApplication createApplication(@NotNull Disposable parentDisposable) {
return new MockApplicationEx(parentDisposable);
}
示例11: createApplication
import com.intellij.mock.MockApplicationEx; //导入依赖的package包/类
@Nonnull
protected MockApplication createApplication(@Nonnull Disposable parentDisposable) {
return new MockApplicationEx(parentDisposable);
}