当前位置: 首页>>代码示例>>Java>>正文


Java ManagedEnvironment.onConnect方法代码示例

本文整理汇总了Java中li.cil.oc.api.network.ManagedEnvironment.onConnect方法的典型用法代码示例。如果您正苦于以下问题:Java ManagedEnvironment.onConnect方法的具体用法?Java ManagedEnvironment.onConnect怎么用?Java ManagedEnvironment.onConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在li.cil.oc.api.network.ManagedEnvironment的用法示例。


在下文中一共展示了ManagedEnvironment.onConnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNodeConnectivity

import li.cil.oc.api.network.ManagedEnvironment; //导入方法依赖的package包/类
@Test
public void testNodeConnectivity() throws Exception {
	setupOpenComputersApiMock();

	ICodeGenerator generator = new PeripheralCodeGenerator();

	Map<String, IMethodExecutor> methods = Maps.newHashMap();
	Class<? extends ManagedEnvironment> cls = generateClass("TestClass\u2654", SemiAwareTargetClass.class, ImmutableSet.<Class<?>> of(), methods, generator);

	final SemiAwareTargetClass target = mock(SemiAwareTargetClass.class);
	ManagedEnvironment o = cls.getConstructor(SemiAwareTargetClass.class).newInstance(target);

	Node node = mock(Node.class);

	o.onConnect(node);
	verifyOcSpecificConnectCall(target, node);

	o.onDisconnect(node);
	verifyOcSpecificDisconnectCall(target, node);
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:21,代码来源:EnvironmentGeneratorTest.java

示例2: testConnectivity

import li.cil.oc.api.network.ManagedEnvironment; //导入方法依赖的package包/类
@Test
public void testConnectivity() throws Exception {
	final Node node = setupOpenComputersApiMock();

	ICodeGenerator generator = new PeripheralCodeGenerator();

	Map<String, IMethodExecutor> methods = Maps.newHashMap();
	Class<? extends ManagedEnvironment> cls = generateClass("TestClass\u2653", AwareTargetClass.class, ImmutableSet.<Class<?>> of(), methods, generator);

	final AwareTargetClass target = mock(AwareTargetClass.class);
	ManagedEnvironment o = cls.getConstructor(AwareTargetClass.class).newInstance(target);

	ContextEnvironment environment = mock(ContextEnvironment.class);
	final String nodeAddress = "node_11";
	when(node.address()).thenReturn(nodeAddress);
	when(node.host()).thenReturn(environment);
	when(environment.node()).thenReturn(node);

	final OpenComputersEnv env = mock(OpenComputersEnv.class);
	final IArchitectureAccess access = mock(IArchitectureAccess.class);
	when(env.createAccess(node, environment)).thenReturn(access);
	ModuleOpenComputers.ENV = env;

	o.onConnect(node);
	verify(target).addComputer(access);
	verifyOcSpecificConnectCall(target, node);

	o.onDisconnect(node);
	verify(target).removeComputer(access);
	verifyOcSpecificDisconnectCall(target, node);
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:32,代码来源:EnvironmentGeneratorTest.java

示例3: testCommonConnectivity

import li.cil.oc.api.network.ManagedEnvironment; //导入方法依赖的package包/类
@Test
public void testCommonConnectivity() throws Exception {
	final Node node = setupOpenComputersApiMock();

	ICodeGenerator generator = new PeripheralCodeGenerator();

	Map<String, IMethodExecutor> methods = Maps.newHashMap();
	Class<? extends ManagedEnvironment> cls = generateClass("TestClass\u2658", CommonAwareTargetClass.class, ImmutableSet.<Class<?>> of(), methods, generator);

	final CommonAwareTargetClass target = mock(CommonAwareTargetClass.class);
	ManagedEnvironment o = cls.getConstructor(CommonAwareTargetClass.class).newInstance(target);

	ContextEnvironment environment = mock(ContextEnvironment.class);
	final String nodeAddress = "node_13";
	when(node.address()).thenReturn(nodeAddress);
	when(node.host()).thenReturn(environment);
	when(environment.node()).thenReturn(node);

	final OpenComputersEnv env = mock(OpenComputersEnv.class);
	final IArchitectureAccess access = mock(IArchitectureAccess.class);
	when(env.createAccess(node, environment)).thenReturn(access);
	ModuleOpenComputers.ENV = env;

	o.onConnect(node);
	verify(target).addComputer(access);

	o.onDisconnect(node);
	verify(target).removeComputer(access);
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:30,代码来源:EnvironmentGeneratorTest.java


注:本文中的li.cil.oc.api.network.ManagedEnvironment.onConnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。