本文整理汇总了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);
}
示例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);
}
示例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);
}