本文整理了Java中org.easymock.classextension.EasyMock.createControl()
方法的一些代码示例,展示了EasyMock.createControl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.createControl()
方法的具体详情如下:
包路径:org.easymock.classextension.EasyMock
类名称:EasyMock
方法名:createControl
暂无
代码示例来源:origin: org.easymock/easymockclassextension
@Override
public IMocksControl createControl() {
IMocksControl ctrl = EasyMock.createControl();
controls.add(ctrl);
return ctrl;
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testDescribeAvailabilityZonesInRegion_NoZones() {
IMocksControl control = createControl();
EC2Client client = control.createMock(EC2Client.class);
AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class);
expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient);
expect(regionClient.describeAvailabilityZonesInRegion("emptyRegion")).andReturn(
ImmutableSet.<AvailabilityZoneInfo> of());
Set<String> regions = ImmutableSet.of("emptyRegion");
control.replay();
DescribeAvailabilityZonesInRegion regionIdToZoneId = new DescribeAvailabilityZonesInRegion(client, Suppliers
.ofInstance(regions));
assertEquals(regionIdToZoneId.get(), ImmutableMap.<String, String> of());
control.verify();
}
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testDescribeAvailabilityZonesInRegion_BestEffort() {
IMocksControl control = createControl();
EC2Client client = control.createMock(EC2Client.class);
AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class);
AvailabilityZoneInfo info1 = control.createMock(AvailabilityZoneInfo.class);
AvailabilityZoneInfo info2 = control.createMock(AvailabilityZoneInfo.class);
HttpCommand command = control.createMock(HttpCommand.class);
HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
command, null);
expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient);
expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion1")).andReturn(
ImmutableSet.of(info1));
expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception);
expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion2")).andReturn(
ImmutableSet.of(info2));
expect(info1.getZone()).andStubReturn("zone1");
expect(info2.getZone()).andStubReturn("zone2");
Set<String> regions = ImmutableSet.of("accessibleRegion1", "inaccessibleRegion", "accessibleRegion2");
control.replay();
Map<String, Set<String>> expectedResult = ImmutableMap.<String, Set<String>> builder().put("accessibleRegion1",
ImmutableSet.of("zone1")).put("accessibleRegion2", ImmutableSet.of("zone2")).build();
DescribeAvailabilityZonesInRegion regionIdToZoneId = new DescribeAvailabilityZonesInRegion(client, Suppliers
.ofInstance(regions));
assertEquals(Maps.transformValues(regionIdToZoneId.get(), Suppliers.<Set<String>> supplierFunction()),
expectedResult);
control.verify();
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testDescribeAvailabilityZonesInRegion_RethrowIfNoneFound() {
IMocksControl control = createControl();
EC2Client client = control.createMock(EC2Client.class);
AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class);
HttpCommand command = control.createMock(HttpCommand.class);
HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...",
command, null);
expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient);
expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception);
Set<String> regions = ImmutableSet.of("inaccessibleRegion");
control.replay();
DescribeAvailabilityZonesInRegion regionIdToZoneId = new DescribeAvailabilityZonesInRegion(client, Suppliers
.ofInstance(regions));
try {
regionIdToZoneId.get();
fail("expected exception");
} catch (HttpResponseException e) {
assertEquals(e, exception);
}
control.verify();
}
内容来源于网络,如有侵权,请联系作者删除!