本文整理汇总了Java中org.powermock.api.support.membermodification.MemberMatcher类的典型用法代码示例。如果您正苦于以下问题:Java MemberMatcher类的具体用法?Java MemberMatcher怎么用?Java MemberMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberMatcher类属于org.powermock.api.support.membermodification包,在下文中一共展示了MemberMatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setup
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Before
public void setup() throws Exception {
PowerMockito.replace(
MemberMatcher.method(
JdbcUtil.class,
"getReferredTables",
Connection.class,
String.class,
String.class
)
).with((proxy, method, args) -> new HashSet<>(referredTablesTestRelation.getReferredTableMap().get((String)args[2])));
tableOrderProvider = new TableOrderProviderFactory(PowerMockito.mock(Connection.class), tableOrderStrategy).create();
for (String table : referredTablesTestRelation.getTableListingOrder()) {
final TableContext tableContext = getTableContext(table);
tableContextsMap.put(table, tableContext);
}
}
开发者ID:streamsets,项目名称:datacollector,代码行数:18,代码来源:TestTableOrderProvider.java
示例2: should_load_configuration_from_property_file_with_unsupported_contentMimeType
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test(testName = "loadConfiguration")
public void should_load_configuration_from_property_file_with_unsupported_contentMimeType() throws Exception {
// Given
mockStaticPartial(RestClientConfiguration.class, "loadProperties");
Method[] methods = MemberMatcher.methods(RestClientConfiguration.class, "loadProperties");
expectPrivate(RestClientConfiguration.class, methods[0], "superCoolPath").andReturn(fakePropsWithUnproperContentMimeType);
replay(RestClientConfiguration.class);
// When
RestClientConfiguration configuration = RestClientConfiguration.loadConfiguration("superCoolPath");
// Then
assertEquals(configuration.getJasperReportsServerUrl(), fakePropsWithUnproperContentMimeType.getProperty("url"));
assertEquals(configuration.getContentMimeType(), MimeType.JSON);
assertEquals(configuration.getAcceptMimeType().toString(), fakePropsWithUnproperContentMimeType.getProperty("acceptMimeType"));
assertNull(configuration.getConnectionTimeout());
assertNull(configuration.getReadTimeout());
assertNotNull(configuration.getTrustManagers());
}
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:21,代码来源:RestClientConfigurationTest.java
示例3: should_load_configuration_from_property_file_with_unsupported_acceptMimeType
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test(testName = "loadConfiguration")
public void should_load_configuration_from_property_file_with_unsupported_acceptMimeType() throws Exception {
// Given
mockStaticPartial(RestClientConfiguration.class, "loadProperties");
Method[] methods = MemberMatcher.methods(RestClientConfiguration.class, "loadProperties");
expectPrivate(RestClientConfiguration.class, methods[0], "superCoolPath").andReturn(fakePropsWithUnproperAcceptMimeType);
replay(RestClientConfiguration.class);
// When
RestClientConfiguration configuration = RestClientConfiguration.loadConfiguration("superCoolPath");
// Then
assertEquals(configuration.getJasperReportsServerUrl(), fakePropsWithUnproperAcceptMimeType.getProperty("url"));
assertEquals(configuration.getContentMimeType().toString(), fakePropsWithUnproperAcceptMimeType.getProperty("contentMimeType"));
assertEquals(configuration.getAcceptMimeType(), MimeType.JSON);
assertNull(configuration.getConnectionTimeout());
assertNull(configuration.getReadTimeout());
assertNotNull(configuration.getTrustManagers());
}
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:21,代码来源:RestClientConfigurationTest.java
示例4: should_not_throw_an_exception_with_wrong_contentMimetype
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void should_not_throw_an_exception_with_wrong_contentMimetype() throws Exception {
// Given
Properties fakePropsWithUnproperContentMimeType = new Properties() {{
setProperty("url", "http://localhost:8080/jasperserver-pro/");
setProperty("contentMimeType", "UnacceptableContentMimeType");
}};
mockStaticPartial(RestClientConfiguration.class, "loadProperties");
Method[] methods = MemberMatcher.methods(RestClientConfiguration.class, "loadProperties");
expectPrivate(RestClientConfiguration.class, methods[0], "superCoolPath").andReturn(fakePropsWithUnproperContentMimeType);
replay(RestClientConfiguration.class);
// When
RestClientConfiguration configuration = RestClientConfiguration.loadConfiguration("superCoolPath");
// Then
Assert.assertEquals(configuration.getContentMimeType(), MimeType.JSON);
}
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:20,代码来源:RestClientConfigurationTest.java
示例5: should_not_throw_an_exception_with_wrong_acceptMimetype
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void should_not_throw_an_exception_with_wrong_acceptMimetype() throws Exception {
// Given
Properties fakePropsWithUnproperAcceptMimeType = new Properties() {{
setProperty("url", "http://localhost:8080/jasperserver-pro/");
setProperty("acceptMimeType", "UnacceptableAcceptMimeType");
}};
mockStaticPartial(RestClientConfiguration.class, "loadProperties");
Method[] methods = MemberMatcher.methods(RestClientConfiguration.class, "loadProperties");
expectPrivate(RestClientConfiguration.class, methods[0], "superCoolPath").andReturn(fakePropsWithUnproperAcceptMimeType);
replay(RestClientConfiguration.class);
// When
RestClientConfiguration configuration = RestClientConfiguration.loadConfiguration("superCoolPath");
// Then
Assert.assertEquals(configuration.getAcceptMimeType(), MimeType.JSON);
}
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:20,代码来源:RestClientConfigurationTest.java
示例6: should_not_throw_an_exception_with_wrong_jrs_version
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void should_not_throw_an_exception_with_wrong_jrs_version() throws Exception {
// Given
Properties fakePropsWithUnproperJrsVersion = new Properties() {{
setProperty("url", "http://localhost:8080/jasperserver-pro/");
setProperty("jrsVersion", "6.1");
}};
mockStaticPartial(RestClientConfiguration.class, "loadProperties");
Method[] methods = MemberMatcher.methods(RestClientConfiguration.class, "loadProperties");
expectPrivate(RestClientConfiguration.class, methods[0], "superCoolPath").andReturn(fakePropsWithUnproperJrsVersion);
replay(RestClientConfiguration.class);
// When
RestClientConfiguration configuration = RestClientConfiguration.loadConfiguration("superCoolPath");
// Then
Assert.assertEquals(configuration.getJrsVersion(), JRSVersion.v5_5_0);
}
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:19,代码来源:RestClientConfigurationTest.java
示例7: should_not_throw_an_exception_with_wrong_authintication_type
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void should_not_throw_an_exception_with_wrong_authintication_type() throws Exception {
// Given
Properties fakePropsWithUnproperAuthorizationType = new Properties() {{
setProperty("url", "http://localhost:8080/jasperserver-pro/");
setProperty("authenticationType", "authenticationType");
}};
mockStaticPartial(RestClientConfiguration.class, "loadProperties");
Method[] methods = MemberMatcher.methods(RestClientConfiguration.class, "loadProperties");
expectPrivate(RestClientConfiguration.class, methods[0], "superCoolPath").andReturn(fakePropsWithUnproperAuthorizationType);
replay(RestClientConfiguration.class);
// When
RestClientConfiguration configuration = RestClientConfiguration.loadConfiguration("superCoolPath");
// Then
Assert.assertEquals(configuration.getAuthenticationType(), AuthenticationType.SPRING);
}
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:20,代码来源:RestClientConfigurationTest.java
示例8: should_load_configuration_from_property_file_with_true_in_boolean_values
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void should_load_configuration_from_property_file_with_true_in_boolean_values() throws Exception {
// Given
Properties fakePropsWithUnproperJrsVersion = new Properties() {{
setProperty("url", "http://localhost:8080/jasperserver-pro/");
setProperty("restrictedHttpMethods", "true");
setProperty("logHttpEntity", "true");
setProperty("logHttp", "true");
}};
mockStaticPartial(RestClientConfiguration.class, "loadProperties");
Method[] methods = MemberMatcher.methods(RestClientConfiguration.class, "loadProperties");
expectPrivate(RestClientConfiguration.class, methods[0], "superCoolPath").andReturn(fakePropsWithUnproperJrsVersion);
replay(RestClientConfiguration.class);
// When
RestClientConfiguration configuration = RestClientConfiguration.loadConfiguration("superCoolPath");
assertTrue(configuration.getRestrictedHttpMethods());
assertTrue(configuration.getLogHttp());
assertTrue(configuration.getLogHttpEntity());
}
开发者ID:Jaspersoft,项目名称:jrs-rest-java-client,代码行数:22,代码来源:RestClientConfigurationTest.java
示例9: testExtractCreatedOrUpdated
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExtractCreatedOrUpdated() {
Map<InstanceIdentifier<DataObject>, DataObject> result = new HashMap<>();
PowerMockito.suppress(
MemberMatcher.method(TransactUtils.class, "extractUpdated", AsyncDataChangeEvent.class, Class.class));
PowerMockito.when(TransactUtils.extractUpdated(any(AsyncDataChangeEvent.class), eq(DataObject.class)))
.thenReturn(result);
Map<InstanceIdentifier<DataObject>, DataObject> map = new HashMap<>();
InstanceIdentifier<DataObject> iid = mock(InstanceIdentifier.class);
DataObject db = mock(DataObject.class);
map.put(iid, db);
PowerMockito.suppress(
MemberMatcher.method(TransactUtils.class, "extractCreated", AsyncDataChangeEvent.class, Class.class));
PowerMockito.when(TransactUtils.extractCreated(any(AsyncDataChangeEvent.class), eq(DataObject.class)))
.thenReturn(map);
Map<InstanceIdentifier<DataObject>, DataObject> testResult = new HashMap<>();
testResult.put(iid, db);
Class<DataObject> klazz = DataObject.class;
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes = mock(AsyncDataChangeEvent.class);
assertEquals(testResult, TransactUtils.extractCreatedOrUpdated(changes, klazz));
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:26,代码来源:TransactUtilsTest.java
示例10: testExtractCreatedOrUpdatedOrRemoved
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testExtractCreatedOrUpdatedOrRemoved() {
Map<InstanceIdentifier<DataObject>, DataObject> result = new HashMap<>();
PowerMockito.suppress(MemberMatcher.method(TransactUtils.class, "extractCreatedOrUpdated",
AsyncDataChangeEvent.class, Class.class));
PowerMockito.when(TransactUtils.extractCreatedOrUpdated(any(AsyncDataChangeEvent.class), eq(DataObject.class)))
.thenReturn(result);
Map<InstanceIdentifier<DataObject>, DataObject> map = new HashMap<>();
InstanceIdentifier<DataObject> iid = mock(InstanceIdentifier.class);
DataObject db = mock(DataObject.class);
map.put(iid, db);
PowerMockito.suppress(MemberMatcher.method(TransactUtils.class, "extractRemovedObjects",
AsyncDataChangeEvent.class, Class.class));
PowerMockito.when(TransactUtils.extractRemovedObjects(any(AsyncDataChangeEvent.class), eq(DataObject.class)))
.thenReturn(map);
Map<InstanceIdentifier<DataObject>, DataObject> testResult = new HashMap<>();
testResult.put(iid, db);
Class<DataObject> klazz = DataObject.class;
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes = mock(AsyncDataChangeEvent.class);
assertEquals(testResult, TransactUtils.extractCreatedOrUpdatedOrRemoved(changes, klazz));
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:26,代码来源:TransactUtilsTest.java
示例11: testExtractRemovedObjects
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExtractRemovedObjects() {
Set<InstanceIdentifier<DataObject>> iids = new HashSet<>();
PowerMockito.suppress(
MemberMatcher.method(TransactUtils.class, "extractRemoved", AsyncDataChangeEvent.class, Class.class));
PowerMockito.when(TransactUtils.extractRemoved(any(AsyncDataChangeEvent.class), eq(DataObject.class)))
.thenReturn(iids);
Map<InstanceIdentifier<DataObject>, DataObject> result = new HashMap<>();
PowerMockito.suppress(
MemberMatcher.method(TransactUtils.class, "extractOriginal", AsyncDataChangeEvent.class, Class.class));
PowerMockito.when(TransactUtils.extractOriginal(any(AsyncDataChangeEvent.class), eq(DataObject.class)))
.thenReturn(result);
Class<DataObject> klazz = DataObject.class;
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes = mock(AsyncDataChangeEvent.class);
assertEquals(Maps.filterKeys(result, Predicates.in(iids)), TransactUtils.extractRemovedObjects(changes, klazz));
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:20,代码来源:TransactUtilsTest.java
示例12: testStampInstanceIdentifier
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testStampInstanceIdentifier() {
TransactionBuilder transaction = mock(TransactionBuilder.class);
InstanceIdentifier<?> iid = mock(InstanceIdentifier.class);
TableSchema<GenericTableSchema> tableSchema = mock(TableSchema.class);
ColumnSchema<GenericTableSchema, Map<String,String>> columnSchema = mock(ColumnSchema.class);
InstanceIdentifierCodec instanceIdentifierCodec = mock(InstanceIdentifierCodec.class);
PowerMockito.suppress(MemberMatcher.method(TransactUtils.class, "stampInstanceIdentifierMutation",
TransactionBuilder.class,
InstanceIdentifier.class,
TableSchema.class,
ColumnSchema.class,
InstanceIdentifierCodec.class));
when(TransactUtils.stampInstanceIdentifierMutation(transaction, iid, tableSchema, columnSchema,
instanceIdentifierCodec))
.thenReturn(mock(Mutate.class));
when(transaction.add(any(Operation.class))).thenReturn(transaction);
TransactUtils.stampInstanceIdentifier(transaction, iid, tableSchema, columnSchema, instanceIdentifierCodec);
verify(transaction).add(any(Operation.class));
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:23,代码来源:TransactUtilsTest.java
示例13: testGetOvsdbBridgeAugmentation
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void testGetOvsdbBridgeAugmentation() throws Exception {
Optional<OvsdbBridgeAugmentation> optOvsdbBri = briOperationState.getOvsdbBridgeAugmentation(iid);
verify(briOperationState, times(1)).getBridgeNode(any(InstanceIdentifier.class));
assertNotNull(optOvsdbBri);
assertTrue(optOvsdbBri.equals(Optional.absent()));
suppress(MemberMatcher.method(BridgeOperationalState.class, "getBridgeNode", InstanceIdentifier.class));
Node node = mock(Node.class);
Optional<Node> optNode = Optional.of(node);
when(briOperationState.getBridgeNode(any(InstanceIdentifier.class))).thenReturn(optNode);
OvsdbBridgeAugmentation ovsdbBriAug = mock(OvsdbBridgeAugmentation.class);
when(node.getAugmentation(OvsdbBridgeAugmentation.class)).thenReturn(ovsdbBriAug);
Optional<OvsdbBridgeAugmentation> ovsdbBriAugOptional = briOperationState.getOvsdbBridgeAugmentation(iid);
assertNotNull(ovsdbBriAugOptional);
assertTrue(ovsdbBriAugOptional.get() instanceof OvsdbBridgeAugmentation);
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:18,代码来源:BridgeOperationalStateTest.java
示例14: testGetBridgeTerminationPoint
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void testGetBridgeTerminationPoint() throws Exception {
Optional<TerminationPoint> optTerm = briOperationState.getBridgeTerminationPoint(iid);
verify(briOperationState, times(1)).getBridgeNode(any(InstanceIdentifier.class));
assertNotNull(optTerm);
assertTrue(optTerm.equals(Optional.absent()));
TerminationPoint termPnt = mock(TerminationPoint.class);
List<TerminationPoint> termPntList = new ArrayList<>();
termPntList.add(termPnt);
suppress(MemberMatcher.method(BridgeOperationalState.class, "getBridgeNode", InstanceIdentifier.class));
Node node = mock(Node.class);
Optional<Node> optNode = Optional.of(node);
when(briOperationState.getBridgeNode(any(InstanceIdentifier.class))).thenReturn(optNode);
when(node.getTerminationPoint()).thenReturn(termPntList);
TerminationPointKey termPntKey = mock(TerminationPointKey.class);
when(termPnt.getKey()).thenReturn(termPntKey);
final InstanceIdentifier<?> iid2 = PowerMockito.mock(InstanceIdentifier.class);
//PowerMockito.suppress(MemberMatcher.method(InstanceIdentifier.class, "firstKeyOf", Class.class, Class.class));
//PowerMockito.when(iid2.firstKeyOf(TerminationPoint.class, TerminationPointKey.class)).thenReturn(termPntKey);
Optional<TerminationPoint> optTermPnt = briOperationState.getBridgeTerminationPoint(iid2);
assertNotNull(optTermPnt);
//assertTrue(optTermPnt.get() instanceof TerminationPoint);
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:27,代码来源:BridgeOperationalStateTest.java
示例15: testGetOvsdbTerminationPointAugmentation
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void testGetOvsdbTerminationPointAugmentation() {
Optional<OvsdbTerminationPointAugmentation> optOvsdbTermPoint = briOperationState
.getOvsdbTerminationPointAugmentation(iid);
assertNotNull(optOvsdbTermPoint);
verify(briOperationState, times(1)).getBridgeTerminationPoint(any(InstanceIdentifier.class));
verify(briOperationState, times(1)).getBridgeNode(any(InstanceIdentifier.class));
assertTrue(optOvsdbTermPoint.equals(Optional.absent()));
PowerMockito.suppress(MemberMatcher.method(BridgeOperationalState.class, "getBridgeTerminationPoint",
InstanceIdentifier.class));
TerminationPoint termPoint = mock(TerminationPoint.class);
Optional<TerminationPoint> termPntOptional = Optional.of(termPoint);
when(briOperationState.getBridgeTerminationPoint(any(InstanceIdentifier.class))).thenReturn(termPntOptional);
OvsdbTerminationPointAugmentation ovsdbTermPntAug = mock(OvsdbTerminationPointAugmentation.class);
when(termPoint.getAugmentation(OvsdbTerminationPointAugmentation.class)).thenReturn(ovsdbTermPntAug);
Optional<OvsdbTerminationPointAugmentation> ovsdbTermPointOpt = briOperationState
.getOvsdbTerminationPointAugmentation(iid);
assertNotNull(ovsdbTermPointOpt);
assertTrue(ovsdbTermPointOpt.get() instanceof OvsdbTerminationPointAugmentation);
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:22,代码来源:BridgeOperationalStateTest.java
示例16: testConnected
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void testConnected() throws Exception {
OvsdbConnectionInstance client = mock(OvsdbConnectionInstance.class);
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "connectedButCallBacksNotRegistered",
OvsdbClient.class));
when(ovsdbConnManager.connectedButCallBacksNotRegistered(any(OvsdbClient.class))).thenReturn(client);
doNothing().when(client).registerCallbacks(any());
//TODO: Write unit tests for EntityOwnershipService
when(client.getInstanceIdentifier()).thenReturn(mock(InstanceIdentifier.class));
field(OvsdbConnectionManager.class, "entityConnectionMap").set(ovsdbConnManager, entityConnectionMap);
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "getEntityFromConnectionInstance",
OvsdbConnectionInstance.class));
//TODO: Write unit tests for entity ownership service related code.
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "registerEntityForOwnership",
OvsdbConnectionInstance.class));
ReadOnlyTransaction tx = mock(ReadOnlyTransaction.class);
when(db.newReadOnlyTransaction()).thenReturn(tx);
when(tx.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)))
.thenReturn(mock(CheckedFuture.class));
when(client.getInstanceIdentifier()).thenReturn(mock(InstanceIdentifier.class));
ovsdbConnManager.connected(externalClient);
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:27,代码来源:OvsdbConnectionManagerTest.java
示例17: testConnectedButCallBacksNotRegistered
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testConnectedButCallBacksNotRegistered() throws Exception {
ConnectionInfo key = mock(ConnectionInfo.class);
PowerMockito.mockStatic(SouthboundMapper.class);
when(SouthboundMapper.createConnectionInfo(any(OvsdbClient.class))).thenReturn(key);
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "getInstanceIdentifier", ConnectionInfo.class));
when(ovsdbConnManager.getInstanceIdentifier(key)).thenReturn(mock(InstanceIdentifier.class));
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "getConnectionInstance", ConnectionInfo.class));
when(ovsdbConnManager.getConnectionInstance(key)).thenReturn(null);
OvsdbConnectionInstance client = mock(OvsdbConnectionInstance.class);
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "putConnectionInstance", ConnectionInfo.class,
OvsdbConnectionInstance.class));
doNothing().when(client).createTransactInvokers();
PowerMockito.whenNew(OvsdbConnectionInstance.class).withArguments(any(ConnectionInfo.class),
any(OvsdbClient.class), any(TransactionInvoker.class), any(InstanceIdentifier.class))
.thenReturn(client);
assertEquals("Error, did not receive correct OvsdbConnectionInstance object", client,
ovsdbConnManager.connectedButCallBacksNotRegistered(externalClient));
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:26,代码来源:OvsdbConnectionManagerTest.java
示例18: testDisconnect
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void testDisconnect() throws Exception {
OvsdbNodeAugmentation ovsdbNode = mock(OvsdbNodeAugmentation.class);
ConnectionInfo connectionInfo = mock(ConnectionInfo.class);
when(ovsdbNode.getConnectionInfo()).thenReturn(connectionInfo);
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "getConnectionInstance", ConnectionInfo.class));
OvsdbConnectionInstance ovsdbConnectionInstance = mock(OvsdbConnectionInstance.class);
when(ovsdbConnManager.getConnectionInstance(any(ConnectionInfo.class))).thenReturn(ovsdbConnectionInstance);
when(ovsdbConnectionInstance.getInstanceIdentifier()).thenReturn(mock(InstanceIdentifier.class));
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "removeInstanceIdentifier", ConnectionInfo.class));
// TODO: Write unit tests for entity ownership service related code.
suppress(MemberMatcher.method(OvsdbConnectionManager.class, "unregisterEntityForOwnership",
OvsdbConnectionInstance.class));
ovsdbConnManager.disconnect(ovsdbNode);
verify(ovsdbConnectionInstance).disconnect();
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:19,代码来源:OvsdbConnectionManagerTest.java
示例19: testSetOtherConfig
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testSetOtherConfig() throws Exception {
OpenVSwitch oldEntry = mock(OpenVSwitch.class);
OpenVSwitch openVSwitch = mock(OpenVSwitch.class);
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(openVSwitch.getOtherConfigColumn()).thenReturn(column);
Map<String, String> map = new HashMap<>();
when(column.getData()).thenReturn(map);
when(oldEntry.getOtherConfigColumn()).thenReturn(column);
MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "removeOldConfigs",
ReadWriteTransaction.class, Map.class, OpenVSwitch.class));
MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setNewOtherConfigs",
OvsdbNodeAugmentationBuilder.class, Map.class));
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = mock(OvsdbNodeAugmentationBuilder.class);
Whitebox.invokeMethod(openVSwitchUpdateCommand, "setOtherConfig",
transaction, ovsdbNodeBuilder, oldEntry, openVSwitch);
verify(openVSwitch, times(2)).getOtherConfigColumn();
verify(oldEntry, times(2)).getOtherConfigColumn();
PowerMockito.verifyPrivate(openVSwitchUpdateCommand).invoke("removeOldConfigs",
any(ReadWriteTransaction.class),
any(Map.class), any(OpenVSwitch.class));
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:27,代码来源:OpenVSwitchUpdateCommandTest.java
示例20: testRemoveOldConfigs
import org.powermock.api.support.membermodification.MemberMatcher; //导入依赖的package包/类
@Test
public void testRemoveOldConfigs() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
Map<String, String> oldOtherConfigs = new HashMap<>();
oldOtherConfigs.put("OpenvswitchOtherConfigsKey", "OpenvswitchOtherConfigsValue");
doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class));
//suppress getNodeId()
MemberModifier.suppress(
MemberMatcher.method(OpenVSwitchUpdateCommand.class, "getNodeId", OpenVSwitch.class));
PowerMockito.whenNew(NodeKey.class).withAnyArguments().thenReturn(mock(NodeKey.class));
OpenVSwitch ovs = mock(OpenVSwitch.class);
Whitebox.invokeMethod(openVSwitchUpdateCommand, "removeOldConfigs",
transaction, oldOtherConfigs, ovs);
verify(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class));
}
开发者ID:opendaylight,项目名称:ovsdb,代码行数:17,代码来源:OpenVSwitchUpdateCommandTest.java
注:本文中的org.powermock.api.support.membermodification.MemberMatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论