本文整理汇总了Java中org.easymock.IMocksControl.reset方法的典型用法代码示例。如果您正苦于以下问题:Java IMocksControl.reset方法的具体用法?Java IMocksControl.reset怎么用?Java IMocksControl.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easymock.IMocksControl
的用法示例。
在下文中一共展示了IMocksControl.reset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoStart
import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testDoStart() throws Exception {
IMocksControl c = createNiceControl();
BundleContext context = c.createMock(BundleContext.class);
expect(context.getProperty(Constants.FRAMEWORK_UUID)).andReturn("myid");
context.addServiceListener(isA(TopologyManagerExport.class));
expectLastCall();
final Capture<String> filter = newCapture();
expect(context.createFilter(EasyMock.capture(filter)))
.andAnswer(new IAnswer<Filter>() {
public Filter answer() throws Throwable {
return FrameworkUtil.createFilter(filter.getValue());
}
}).times(2);
ServiceReference<?> sref = c.createMock(ServiceReference.class);
Bundle bundle = c.createMock(Bundle.class);
expect(sref.getBundle()).andReturn(bundle).anyTimes();
expect(context.getServiceReferences((String)null, Activator.DOSGI_SERVICES))
.andReturn(new ServiceReference[]{sref});
c.replay();
Activator activator = new Activator();
activator.doStart(context, new DefaultExportPolicy());
c.verify();
c.reset();
c.replay();
activator.doStop(context);
c.verify();
}
示例2: testServiceExportUnexport
import org.easymock.IMocksControl; //导入方法依赖的package包/类
/**
* This tests if the topology manager handles a service marked to be exported correctly by exporting it to
* an available RemoteServiceAdmin and notifying an EndpointListener afterwards.
*
* @throws Exception
*/
@Test
public void testServiceExportUnexport() throws Exception {
IMocksControl c = EasyMock.createControl();
RemoteServiceAdmin rsa = c.createMock(RemoteServiceAdmin.class);
final EndpointListener notifier = c.createMock(EndpointListener.class);
final ServiceReference sref = createUserService(c);
EndpointDescription epd = createEndpoint();
expectServiceExported(c, rsa, notifier, sref, epd);
c.replay();
EndpointRepository endpointRepo = new EndpointRepository();
endpointRepo.setNotifier(notifier);
Executor executor = syncExecutor();
ExportPolicy policy = new DefaultExportPolicy();
TopologyManagerExport exportManager = new TopologyManagerExport(endpointRepo, executor, policy);
exportManager.add(rsa);
exportManager.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, sref));
c.verify();
c.reset();
notifier.endpointRemoved(epd, null);
expectLastCall().once();
c.replay();
exportManager.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, sref));
c.verify();
c.reset();
c.replay();
exportManager.serviceChanged(new ServiceEvent(ServiceEvent.MODIFIED, sref));
c.verify();
c.reset();
c.replay();
exportManager.remove(rsa);
c.verify();
}
示例3: testAddRemove
import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testAddRemove() throws InvalidSyntaxException {
EndpointDescription ep1 = createEndpoint("my");
IMocksControl c = EasyMock.createControl();
ServiceReference<?> sref = createService(c);
RemoteServiceAdmin rsa = c.createMock(RemoteServiceAdmin.class);
EndpointListener notifier = c.createMock(EndpointListener.class);
notifier.endpointAdded(ep1, null);
EasyMock.expectLastCall();
c.replay();
EndpointRepository repo = new EndpointRepository();
repo.setNotifier(notifier);
List<EndpointDescription> endpoints = Arrays.asList(ep1);
repo.addEndpoints(sref, rsa, endpoints);
c.verify();
c.reset();
notifier.endpointRemoved(ep1, null);
EasyMock.expectLastCall();
c.replay();
repo.removeRemoteServiceAdmin(rsa);
c.verify();
}
示例4: testCloseAll
import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testCloseAll() {
IMocksControl c = EasyMock.createControl();
EndpointDescription endpoint = c.createMock(EndpointDescription.class);
RemoteServiceAdminCore rsac = c.createMock(RemoteServiceAdminCore.class);
c.replay();
ImportRegistrationImpl i1 = new ImportRegistrationImpl(endpoint, rsac);
ImportRegistrationImpl i2 = new ImportRegistrationImpl(i1);
ImportRegistrationImpl i3 = new ImportRegistrationImpl(i2);
assertEquals(i1, i1.getParent());
assertEquals(i1, i2.getParent());
assertEquals(i1, i3.getParent());
c.verify();
c.reset();
rsac.removeImportRegistration(EasyMock.eq(i2));
EasyMock.expectLastCall().once();
c.replay();
i2.close();
c.verify();
c.reset();
rsac.removeImportRegistration(EasyMock.eq(i1));
EasyMock.expectLastCall().once();
rsac.removeImportRegistration(EasyMock.eq(i3));
EasyMock.expectLastCall().once();
c.replay();
i3.closeAll();
c.verify();
}
示例5: testAddRelatedLink
import org.easymock.IMocksControl; //导入方法依赖的package包/类
/**
* Test of method
* {@link RedmineItsFacade#addRelatedLink(String, java.net.URL, String)}
*/
@Test
public void testAddRelatedLink() {
try {
LOGGER.info("------ testAddRelatedLink -------");
IMocksControl control = EasyMock.createStrictControl();
RedmineManager redmineManager = control.createMock(RedmineManager.class);
Issue expectedIssue = new Issue();
expectedIssue.setId(42);
expectedIssue
.setNotes("Related URL: \"description\":http://myredmine.org");
RedmineItsFacade instance = new RedmineItsFacade(redmineManager);
control.reset();
redmineManager.update(expectedIssue);
expectLastCall();
control.replay();
instance.addRelatedLink("42", new URL("http://myredmine.org"),
"description");
control.verify();
} catch (Exception e) {
LOGGER.error("Unexpected error: " + e.getMessage(), e);
fail("Unexpected error: " + e.getMessage());
}
}
示例6: testLoadGroupByGroupname
import org.easymock.IMocksControl; //导入方法依赖的package包/类
/**
* Test de la méthode {@link RedmineSecurityRealm#loadGroupByGroupname}
*/
@Test
public void testLoadGroupByGroupname() {
LOGGER.info("------ testLoadGroupByGroupname -------");
try {
IMocksControl control = createStrictControl();
final RedmineManager redmineManager = control.createMock(RedmineManager.class);
RedmineSecurityRealm instance = new RedmineSecurityRealm(
"url", "key") {
/**
* {@inheritDoc}
*
* @see com.bouygtel.jenkins.redmine.RedmineSecurityRealm#getUserRedmineManager(java.lang.String,
* java.lang.String)
*/
@Override
RedmineManager getUserRedmineManager(String username, String password) {
assertThat(username, is("username"));
assertThat(password, is("password"));
return redmineManager;
}
};
control.reset();
control.replay();
GroupDetails result = instance.loadGroupByGroupname("groupname");
assertThat(result, is((GroupDetails) new RedmineGroupDetails("groupname")));
control.verify();
} catch (Exception e) {
LOGGER.error("Erreur imprévue: " + e.getMessage(), e);
Assert.fail("Erreur imprévue: " + e.getMessage());
}
}
示例7: testCloneAndClose
import org.easymock.IMocksControl; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testCloneAndClose() {
IMocksControl c = EasyMock.createControl();
EndpointDescription endpoint = c.createMock(EndpointDescription.class);
RemoteServiceAdminCore rsac = c.createMock(RemoteServiceAdminCore.class);
ServiceRegistration sr = c.createMock(ServiceRegistration.class);
ServiceReference sref = c.createMock(ServiceReference.class);
EasyMock.expect(sr.getReference()).andReturn(sref).anyTimes();
c.replay();
ImportRegistrationImpl i1 = new ImportRegistrationImpl(endpoint, rsac);
ImportRegistrationImpl i2 = new ImportRegistrationImpl(i1);
ImportRegistrationImpl i3 = new ImportRegistrationImpl(i2);
try {
i2.setImportedServiceRegistration(sr);
assertTrue("An exception should be thrown here !", false);
} catch (IllegalStateException e) {
// must be thrown here
}
i1.setImportedServiceRegistration(sr);
assertEquals(i1, i1.getParent());
assertEquals(i1, i2.getParent());
assertEquals(i1, i3.getParent());
assertEquals(endpoint, i1.getImportedEndpointDescription());
assertEquals(endpoint, i2.getImportedEndpointDescription());
assertEquals(endpoint, i3.getImportedEndpointDescription());
c.verify();
c.reset();
rsac.removeImportRegistration(EasyMock.eq(i3));
EasyMock.expectLastCall().once();
c.replay();
i3.close();
i3.close(); // shouldn't change anything
assertNull(i3.getImportedEndpointDescription());
c.verify();
c.reset();
rsac.removeImportRegistration(EasyMock.eq(i1));
EasyMock.expectLastCall().once();
c.replay();
i1.close();
c.verify();
c.reset();
rsac.removeImportRegistration(EasyMock.eq(i2));
EasyMock.expectLastCall().once();
sr.unregister();
EasyMock.expectLastCall().once();
c.replay();
i2.close();
c.verify();
}
示例8: testAddingRemoved
import org.easymock.IMocksControl; //导入方法依赖的package包/类
@SuppressWarnings({
"unchecked", "rawtypes"
})
@Test
public void testAddingRemoved() throws InvalidSyntaxException {
IMocksControl c = EasyMock.createControl();
DistributionProvider provider = c.createMock(DistributionProvider.class);
ServiceReference<DistributionProvider> providerRef = c.createMock(ServiceReference.class);
EasyMock.expect(providerRef.getProperty(RemoteConstants.REMOTE_INTENTS_SUPPORTED)).andReturn("");
EasyMock.expect(providerRef.getProperty(RemoteConstants.REMOTE_CONFIGS_SUPPORTED)).andReturn("");
BundleContext context = c.createMock(BundleContext.class);
String filterSt = String.format("(objectClass=%s)", DistributionProvider.class.getName());
Filter filter = FrameworkUtil.createFilter(filterSt);
EasyMock.expect(context.createFilter(filterSt)).andReturn(filter);
EasyMock.expect(context.getService(providerRef)).andReturn(provider);
ServiceRegistration rsaReg = c.createMock(ServiceRegistration.class);
EasyMock.expect(context.registerService(EasyMock.isA(String.class), EasyMock.isA(ServiceFactory.class),
EasyMock.isA(Dictionary.class)))
.andReturn(rsaReg).atLeastOnce();
context.addServiceListener(EasyMock.isA(ServiceListener.class), EasyMock.isA(String.class));
EasyMock.expectLastCall();
final BundleContext apiContext = c.createMock(BundleContext.class);
c.replay();
DistributionProviderTracker tracker = new DistributionProviderTracker(context) {
protected BundleContext getAPIContext() {
return apiContext;
};
};
tracker.addingService(providerRef);
c.verify();
c.reset();
rsaReg.unregister();
EasyMock.expectLastCall();
EasyMock.expect(context.ungetService(providerRef)).andReturn(true);
c.replay();
tracker.removedService(providerRef, rsaReg);
c.verify();
}
示例9: testFindNameFor
import org.easymock.IMocksControl; //导入方法依赖的package包/类
/**
* Test de la méthode {@link RedmineUserNameResolver#findNameFor(hudson.model.User)}
*/
@Test
public void testFindNameFor() {
LOGGER.info("------ testFindNameFor -------");
try {
IMocksControl control = createStrictControl();
final RedmineManager redmineManager = control.createMock(RedmineManager.class);
User user = control.createMock(User.class);
com.taskadapter.redmineapi.bean.User userRedmine = new com.taskadapter.redmineapi.bean.User();
userRedmine.setMail("[email protected]");
userRedmine.setFullName("User fullName");
RedmineUserNameResolver instance = new RedmineUserNameResolver() {
/**
* {@inheritDoc}
*
* @see com.bouygtel.jenkins.redmine.RedmineUserNameResolver#getRedmineManager()
*/
@Override
RedmineManager getRedmineManager() {
return null;
}
};
assertThat(instance.findNameFor(user), nullValue());
// Name matching
instance = new RedmineUserNameResolver() {
/**
* {@inheritDoc}
*
* @see com.bouygtel.jenkins.redmine.RedmineUserNameResolver#getRedmineManager()
*/
@Override
RedmineManager getRedmineManager() {
return redmineManager;
}
};
control.reset();
expect(user.getId()).andReturn("userLogin");
expect(redmineManager.getUserByLogin("userLogin")).andReturn(userRedmine);
control.replay();
assertThat(instance.findNameFor(user), is("User fullName"));
control.verify();
// User not found
control.reset();
expect(user.getId()).andReturn("userLogin");
expect(redmineManager.getUserByLogin("userLogin")).andThrow(
new NotFoundException("User not found for test"));
control.replay();
assertThat(instance.findNameFor(user), nullValue());
control.verify();
} catch (Exception e) {
LOGGER.error("Erreur imprévue: " + e.getMessage(), e);
fail("Erreur imprévue: " + e.getMessage());
}
}
示例10: testFindMailAddressFor
import org.easymock.IMocksControl; //导入方法依赖的package包/类
/**
* Test de la méthode {@link RedmineMailAddressResolver#findMailAddressFor(hudson.model.User)}
*/
@Test
public void testFindMailAddressFor() {
LOGGER.info("------ testFindMailAddressFor -------");
try {
IMocksControl control = createStrictControl();
final RedmineManager redmineManager = control.createMock(RedmineManager.class);
RedmineMailAddressResolver instance = new RedmineMailAddressResolver() {
/**
* {@inheritDoc}
*
* @see com.bouygtel.jenkins.redmine.RedmineMailAddressResolver#getRedmineManager()
*/
@Override
RedmineManager getRedmineManager() {
return redmineManager;
}
};
User user = control.createMock(User.class);
com.taskadapter.redmineapi.bean.User userRedmine = new com.taskadapter.redmineapi.bean.User();
userRedmine.setMail("[email protected]");
control.reset();
expect(user.getId()).andReturn("userId");
expect(redmineManager.getUserByLogin("userId")).andReturn(userRedmine);
control.replay();
String email = instance.findMailAddressFor(user);
LOGGER.info("Email: {}", email);
assertThat(email, is("[email protected]"));
control.verify();
// User invalid
control.reset();
expect(user.getId()).andReturn("userId");
expect(redmineManager.getUserByLogin("userId")).andThrow(new NotFoundException("User not found for test"));
control.replay();
assertThat(instance.findMailAddressFor(user), nullValue());
control.verify();
// None Redmine realm
instance = new RedmineMailAddressResolver() {
/**
* {@inheritDoc}
*
* @see com.bouygtel.jenkins.redmine.RedmineMailAddressResolver#getRedmineManager()
*/
@Override
RedmineManager getRedmineManager() {
return null;
}
};
control.reset();
control.replay();
assertThat(instance.findMailAddressFor(user), nullValue());
control.verify();
} catch (Exception e) {
LOGGER.error("Erreur imprévue: " + e.getMessage(), e);
fail("Erreur imprévue: " + e.getMessage());
}
}