Java 类org.springframework.context.ApplicationEventPublisher 实例源码
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldNotifyListenerOnFileAdded() throws IOException {
final Path torrentFile = TorrentFileCreator.create(torrentsPath.resolve("ubuntu.torrent"), TorrentFileCreator.TorrentType.UBUNTU);
final TorrentFileProvider provider = new TorrentFileProvider(resourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class));
final CountDownLatch createLock = new CountDownLatch(1);
final CountDownLatch deleteLock = new CountDownLatch(1);
final TorrentFileChangeAware listener = new CountDownLatchListener(createLock, deleteLock);
provider.registerListener(listener);
provider.start();
provider.onFileCreate(torrentFile.toFile());
assertThat(createLock.getCount()).isEqualTo(0);
assertThat(deleteLock.getCount()).isEqualTo(1);
provider.stop();
provider.unRegisterListener(listener);
}
项目:springboot-shiro-cas-mybatis
文件:RegisteredServiceSimpleFormControllerTests.java
@Before
public void setUp() throws Exception {
final Map<String, List<Object>> attributes = new HashMap<>();
attributes.put("test", Arrays.asList(new Object[] {"test"}));
this.repository = new StubPersonAttributeDao();
this.repository.setBackingMap(attributes);
this.registeredServiceFactory = new DefaultRegisteredServiceFactory();
this.registeredServiceFactory.setFormDataPopulators(ImmutableList.of(new AttributeFormDataPopulator(this
.repository)));
this.registeredServiceFactory.initializeDefaults();
this.manager = new DefaultServicesManagerImpl(
new InMemoryServiceRegistryDaoImpl());
this.manager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
this.controller = new RegisteredServiceSimpleFormController(this.manager, this.registeredServiceFactory);
}
项目:springboot-shiro-cas-mybatis
文件:DefaultServicesManagerImplTests.java
@Before
public void setUp() throws Exception {
final InMemoryServiceRegistryDaoImpl dao = new InMemoryServiceRegistryDaoImpl();
final List<RegisteredService> list = new ArrayList<>();
final RegisteredServiceImpl r = new RegisteredServiceImpl();
r.setId(2500);
r.setServiceId("serviceId");
r.setName("serviceName");
r.setEvaluationOrder(1000);
list.add(r);
dao.setRegisteredServices(list);
this.defaultServicesManagerImpl = new DefaultServicesManagerImpl(dao);
this.defaultServicesManagerImpl.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
}
项目:springboot-shiro-cas-mybatis
文件:RegisteredServiceThemeBasedViewResolverTests.java
@Before
public void setUp() throws Exception {
this.servicesManager = new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl());
this.servicesManager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
final RegisteredServiceImpl r = new RegisteredServiceImpl();
r.setTheme("myTheme");
r.setId(1000);
r.setName("Test Service");
r.setServiceId("myServiceId");
this.servicesManager.save(r);
final RegisteredServiceImpl r2 = new RegisteredServiceImpl();
r2.setTheme(null);
r2.setId(1001);
r2.setName("Test Service 2");
r2.setServiceId("myDefaultId");
this.servicesManager.save(r2);
this.registeredServiceThemeBasedViewResolver = new RegisteredServiceThemeBasedViewResolver(this.servicesManager);
this.registeredServiceThemeBasedViewResolver.setPrefix("/WEB-INF/view/jsp");
}
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldCallOnFileDeleteBeforeDeletingFileWhenArchiving() throws IOException {
final Path torrentFile = TorrentFileCreator.create(torrentsPath.resolve("ubuntu.torrent"), TorrentFileCreator.TorrentType.UBUNTU);
final TorrentFileProvider provider = Mockito.spy(new TorrentFileProvider(resourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class)));
provider.init();
Mockito.doAnswer(invocation -> {
assertThat(torrentFile.toFile()).exists();
return null;
}).when(provider).onFileDelete(torrentFile.toFile());
provider.onFileCreate(torrentFile.toFile());
provider.moveToArchiveFolder(torrentFile.toFile());
Mockito.verify(provider, Mockito.times(1)).moveToArchiveFolder(torrentFile.toFile());
assertThat(torrentFile.toFile()).doesNotExist();
}
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldNotifyListenerOnFileRemoved() throws IOException {
final Path torrentFile = TorrentFileCreator.create(torrentsPath.resolve("ubuntu.torrent"), TorrentFileCreator.TorrentType.UBUNTU);
final TorrentFileProvider provider = new TorrentFileProvider(resourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class));
provider.onFileCreate(torrentFile.toFile());
final CountDownLatch createLock = new CountDownLatch(1);
final CountDownLatch deleteLock = new CountDownLatch(1);
final TorrentFileChangeAware listener = new CountDownLatchListener(createLock, deleteLock);
provider.registerListener(listener);
provider.onFileDelete(torrentFile.toFile());
provider.unRegisterListener(listener);
assertThat(createLock.getCount()).isEqualTo(1);
assertThat(deleteLock.getCount()).isEqualTo(0);
}
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldUnRegisterListener() throws IOException {
final Path torrentFile = TorrentFileCreator.create(torrentsPath.resolve("ubuntu.torrent"), TorrentFileCreator.TorrentType.UBUNTU);
final Path torrentFile2 = TorrentFileCreator.create(torrentsPath.resolve("audio.torrent"), TorrentFileCreator.TorrentType.AUDIO);
final TorrentFileProvider provider = new TorrentFileProvider(resourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class));
final CountDownLatch createLock = new CountDownLatch(2);
final CountDownLatch deleteLock = new CountDownLatch(2);
final TorrentFileChangeAware listener = new CountDownLatchListener(createLock, deleteLock);
provider.registerListener(listener);
provider.start();
provider.onFileCreate(torrentFile.toFile());
provider.unRegisterListener(listener);
provider.onFileCreate(torrentFile2.toFile());
assertThat(createLock.getCount()).isEqualTo(1);
assertThat(deleteLock.getCount()).isEqualTo(2);
provider.stop();
provider.unRegisterListener(listener);
}
项目:joal
文件:JoalConfigProviderTest.java
@Test
public void shouldWriteConfigurationFile() throws IOException {
new ObjectMapper().writeValue(rewritableResourcePath.resolve("config.json").toFile(), defaultConfig);
try {
final JoalConfigProvider provider = new JoalConfigProvider(new ObjectMapper(), rewritableResourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class));
final Random rand = new Random();
final AppConfiguration newConf = new AppConfiguration(
rand.longs(1, 200).findFirst().getAsLong(),
rand.longs(201, 400).findFirst().getAsLong(),
rand.ints(1, 5).findFirst().getAsInt(),
RandomStringUtils.random(60),
false
);
provider.saveNewConf(newConf);
assertThat(provider.loadConfiguration()).isEqualTo(newConf);
} finally {
Files.deleteIfExists(rewritableResourcePath.resolve("config.json"));
}
}
项目:cas-server-4.2.1
文件:LogoutActionTests.java
@Before
public void onSetUp() throws Exception {
this.request = new MockHttpServletRequest();
this.response = new MockHttpServletResponse();
this.requestContext = mock(RequestContext.class);
final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
when(this.requestContext.getExternalContext()).thenReturn(servletExternalContext);
when(servletExternalContext.getNativeRequest()).thenReturn(request);
when(servletExternalContext.getNativeResponse()).thenReturn(response);
final LocalAttributeMap flowScope = new LocalAttributeMap();
when(this.requestContext.getFlowScope()).thenReturn(flowScope);
this.warnCookieGenerator = new CookieRetrievingCookieGenerator();
this.serviceRegistryDao = new InMemoryServiceRegistryDaoImpl();
this.serviceManager = new DefaultServicesManagerImpl(serviceRegistryDao);
this.serviceManager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
this.serviceManager.reload();
this.warnCookieGenerator.setCookieName("test");
this.ticketGrantingTicketCookieGenerator = new CookieRetrievingCookieGenerator();
this.ticketGrantingTicketCookieGenerator.setCookieName(COOKIE_TGC_ID);
this.logoutAction = new LogoutAction();
this.logoutAction.setServicesManager(this.serviceManager);
}
项目:cas-server-4.2.1
文件:RegisteredServiceSimpleFormControllerTests.java
@Before
public void setUp() throws Exception {
final Map<String, List<Object>> attributes = new HashMap<>();
attributes.put("test", Arrays.asList(new Object[] {"test"}));
this.repository = new StubPersonAttributeDao();
this.repository.setBackingMap(attributes);
this.registeredServiceFactory = new DefaultRegisteredServiceFactory();
this.registeredServiceFactory.setFormDataPopulators(ImmutableList.of(new AttributeFormDataPopulator(this
.repository)));
this.registeredServiceFactory.initializeDefaults();
this.manager = new DefaultServicesManagerImpl(
new InMemoryServiceRegistryDaoImpl());
this.manager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
this.controller = new RegisteredServiceSimpleFormController(this.manager, this.registeredServiceFactory);
}
项目:cas-server-4.2.1
文件:DefaultServicesManagerImplTests.java
@Before
public void setUp() throws Exception {
final InMemoryServiceRegistryDaoImpl dao = new InMemoryServiceRegistryDaoImpl();
final List<RegisteredService> list = new ArrayList<>();
final RegisteredServiceImpl r = new RegisteredServiceImpl();
r.setId(2500);
r.setServiceId("serviceId");
r.setName("serviceName");
r.setEvaluationOrder(1000);
list.add(r);
dao.setRegisteredServices(list);
this.defaultServicesManagerImpl = new DefaultServicesManagerImpl(dao);
this.defaultServicesManagerImpl.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
}
项目:cas-server-4.2.1
文件:RegisteredServiceThemeBasedViewResolverTests.java
@Before
public void setUp() throws Exception {
this.servicesManager = new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl());
this.servicesManager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
final RegisteredServiceImpl r = new RegisteredServiceImpl();
r.setTheme("myTheme");
r.setId(1000);
r.setName("Test Service");
r.setServiceId("myServiceId");
this.servicesManager.save(r);
final RegisteredServiceImpl r2 = new RegisteredServiceImpl();
r2.setTheme(null);
r2.setId(1001);
r2.setName("Test Service 2");
r2.setServiceId("myDefaultId");
this.servicesManager.save(r2);
this.registeredServiceThemeBasedViewResolver = new RegisteredServiceThemeBasedViewResolver(this.servicesManager);
this.registeredServiceThemeBasedViewResolver.setPrefix("/WEB-INF/view/jsp");
}
项目:cmc-claim-store
文件:DocumentGenerator.java
@Autowired
public DocumentGenerator(
CitizenSealedClaimPdfService citizenSealedClaimPdfService,
DefendantPinLetterPdfService defendantPinLetterPdfService,
LegalSealedClaimPdfService legalSealedClaimPdfService,
ApplicationEventPublisher publisher
) {
this.citizenSealedClaimPdfService = citizenSealedClaimPdfService;
this.defendantPinLetterPdfService = defendantPinLetterPdfService;
this.legalSealedClaimPdfService = legalSealedClaimPdfService;
this.publisher = publisher;
}
项目:summer-mqtt
文件:MqttClientEventPublisherTest.java
@Test
public void testPublishDisconnectedEventNullClientId()
{
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(EXCEPTION_MESSAGE_CLIENT_ID);
ApplicationEventPublisher applicationEventPublisher = Mockito
.mock(ApplicationEventPublisher.class);
mqttClientEventPublisher.publishDisconnectedEvent(null, applicationEventPublisher, this);
}
项目:springboot-shiro-cas-mybatis
文件:CentralAuthenticationServiceImplTests.java
/**
* This test checks that the TGT destruction happens properly for a remote registry.
* It previously failed when the deletion happens before the ticket was marked expired because an update was necessary for that.
*
* @throws AuthenticationException
* @throws AbstractTicketException
*/
@Test
public void verifyDestroyRemoteRegistry() throws AbstractTicketException, AuthenticationException {
final MockOnlyOneTicketRegistry registry = new MockOnlyOneTicketRegistry();
final TicketGrantingTicketImpl tgt = new TicketGrantingTicketImpl("TGT-1", mock(Authentication.class),
mock(ExpirationPolicy.class));
final MockExpireUpdateTicketLogoutManager logoutManager = new MockExpireUpdateTicketLogoutManager(registry);
registry.addTicket(tgt);
final CentralAuthenticationServiceImpl cas = new CentralAuthenticationServiceImpl(registry, null, null, logoutManager);
cas.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
cas.destroyTicketGrantingTicket(tgt.getId());
}
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldFailIfFolderDoesNotContainsTorrentFiles() throws IOException {
final TorrentFileProvider provider = new TorrentFileProvider(resourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class));
assertThatThrownBy(() -> provider.getTorrentNotIn(new ArrayList<>()))
.isInstanceOf(NoMoreTorrentsFileAvailableException.class)
.hasMessageContaining("No more torrent file available.");
}
项目:summer-mqtt
文件:MqttClientEventPublisherTest.java
@Test
public void testPublishConnectionLostEvent()
{
ApplicationEventPublisher applicationEventPublisher = Mockito
.mock(ApplicationEventPublisher.class);
mqttClientEventPublisher.publishConnectionLostEvent(CLIENT_ID, true,
applicationEventPublisher, this);
Mockito.verify(applicationEventPublisher, Mockito.atLeast(1))
.publishEvent(Mockito.any(MqttClientConnectionLostEvent.class));
}
项目:springboot-shiro-cas-mybatis
文件:ServiceThemeResolverTests.java
@Before
public void setUp() throws Exception {
this.servicesManager = new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl());
this.servicesManager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
this.serviceThemeResolver = new ServiceThemeResolver();
this.serviceThemeResolver.setDefaultThemeName("test");
this.serviceThemeResolver.setServicesManager(this.servicesManager);
final Map<String, String> mobileBrowsers = new HashMap<>();
mobileBrowsers.put("Mozilla", "theme");
this.serviceThemeResolver.setMobileBrowsers(mobileBrowsers);
}
项目:cas-5.1.0
文件:JsonServiceRegistryDaoTests.java
@Before
public void setUp() {
try {
this.dao = new JsonServiceRegistryDao(RESOURCE, false, mock(ApplicationEventPublisher.class));
} catch (final Exception e) {
throw new IllegalArgumentException(e);
}
}
项目:cas-5.1.0
文件:SamlRegisteredServiceTests.java
@Test
public void verifySavingSamlService() throws Exception {
final SamlRegisteredService service = new SamlRegisteredService();
service.setName(SAML_SERVICE);
service.setServiceId("http://mmoayyed.unicon.net");
service.setMetadataLocation(METADATA_LOCATION);
final JsonServiceRegistryDao dao = new JsonServiceRegistryDao(RESOURCE, false, mock(ApplicationEventPublisher.class));
dao.save(service);
dao.load();
}
项目:cas-5.1.0
文件:SamlRegisteredServiceTests.java
@Test
public void verifySavingInCommonSamlService() throws Exception {
final SamlRegisteredService service = new SamlRegisteredService();
service.setName(SAML_SERVICE);
service.setServiceId("http://mmoayyed.unicon.net");
service.setMetadataLocation(METADATA_LOCATION);
final InCommonRSAttributeReleasePolicy policy = new InCommonRSAttributeReleasePolicy();
final ChainingAttributeReleasePolicy chain = new ChainingAttributeReleasePolicy();
chain.setPolicies(Arrays.asList(policy, new DenyAllAttributeReleasePolicy()));
service.setAttributeReleasePolicy(chain);
final JsonServiceRegistryDao dao = new JsonServiceRegistryDao(RESOURCE, false, mock(ApplicationEventPublisher.class));
dao.save(service);
dao.load();
}
项目:summer-mqtt
文件:MqttClientEventPublisherTest.java
@Test
public void testPublishConnectedEventNullSubscribedTopics()
{
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("'subscribedTopics' must be set!");
ApplicationEventPublisher applicationEventPublisher = Mockito
.mock(ApplicationEventPublisher.class);
mqttClientEventPublisher.publishConnectedEvent(CLIENT_ID, SERVER_URI, null,
applicationEventPublisher, this);
}
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldNotFailIfFileIsNotPresentWhenArchiving() throws IOException {
final Path torrentFile = TorrentFileCreator.create(torrentsPath.resolve("ubuntu.torrent"), TorrentFileCreator.TorrentType.UBUNTU);
final TorrentFileProvider provider = new TorrentFileProvider(resourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class));
try {
provider.moveToArchiveFolder(torrentFile.resolve("dd.torrent").toFile());
} catch (final Throwable throwable) {
fail("should not fail if file were not present.");
}
}
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldMoveTorrentFileToArchivedFolder() throws IOException {
final Path torrentFile = TorrentFileCreator.create(torrentsPath.resolve("ubuntu.torrent"), TorrentFileCreator.TorrentType.UBUNTU);
final TorrentFileProvider provider = new TorrentFileProvider(resourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class));
provider.init();
provider.onFileCreate(torrentFile.toFile());
assertThat(provider.getTorrentCount()).isEqualTo(1);
assertThat(archivedTorrentPath.resolve("ubuntu.torrent")).doesNotExist();
provider.moveToArchiveFolder(torrentFile.toFile());
assertThat(torrentsPath.resolve("ubuntu.torrent")).doesNotExist();
assertThat(archivedTorrentPath.resolve("ubuntu.torrent")).exists();
}
项目:vkmusic
文件:MainFrame.java
@Autowired
public MainFrame(@NonNull ApplicationEventPublisher publisher,
@NonNull AboutFrame aboutFrame) {
super();
this.publisher = publisher;
this.aboutFrame = aboutFrame;
initMenu();
}
项目:cas-5.1.0
文件:ServiceRegistryConfigWatcher.java
/**
* Instantiates a new Json service registry config watcher.
*
* @param serviceRegistryDao the registry to callback
*/
ServiceRegistryConfigWatcher(final ResourceBasedServiceRegistryDao serviceRegistryDao,
final ApplicationEventPublisher eventPublisher) {
try {
this.serviceRegistryDao = serviceRegistryDao;
this.watcher = FileSystems.getDefault().newWatchService();
final WatchEvent.Kind[] kinds = new WatchEvent.Kind[]{ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY};
LOGGER.debug("Created service registry watcher for events of type [{}]", (Object[]) kinds);
this.serviceRegistryDao.getWatchableResource().register(this.watcher, kinds);
this.applicationEventPublisher = eventPublisher;
} catch (final IOException e) {
throw Throwables.propagate(e);
}
}
项目:summer-mqtt
文件:MqttClientEventPublisherTest.java
@Test
public void testPublishConnectedEventNullServerUri()
{
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("'serverUri' must be set!");
ApplicationEventPublisher applicationEventPublisher = Mockito
.mock(ApplicationEventPublisher.class);
mqttClientEventPublisher.publishConnectedEvent(CLIENT_ID, null, SUBSCRIBED_TOPICS_EMPTY,
applicationEventPublisher, this);
}
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldNotBuildIfFolderDoesNotExists() throws FileNotFoundException {
assertThatThrownBy(() -> new TorrentFileProvider(resourcePath.resolve("nop").toString(), Mockito.mock(ApplicationEventPublisher.class)))
.isInstanceOf(FileNotFoundException.class)
.hasMessageStartingWith("Torrent folder '")
.hasMessageEndingWith("' not found.");
}
项目:alfresco-repository
文件:BatchProcessor.java
/**
* Instantiates a new batch processor.
*
* @param processName
* the process name
* @param retryingTransactionHelper
* the retrying transaction helper
* @param collection
* the collection
* @param workerThreads
* the number of worker threads
* @param batchSize
* the number of entries we process at a time in a transaction
* @param applicationEventPublisher
* the application event publisher (may be <tt>null</tt>)
* @param logger
* the logger to use (may be <tt>null</tt>)
* @param loggingInterval
* the number of entries to process before reporting progress
*
* @deprecated Since 3.4, use the {@link BatchProcessWorkProvider} instead of the <tt>Collection</tt>
*/
public BatchProcessor(
String processName,
RetryingTransactionHelper retryingTransactionHelper,
final Collection<T> collection,
int workerThreads, int batchSize,
ApplicationEventPublisher applicationEventPublisher,
Log logger,
int loggingInterval)
{
this(
processName,
retryingTransactionHelper,
new BatchProcessWorkProvider<T>()
{
boolean hasMore = true;
public int getTotalEstimatedWorkSize()
{
return collection.size();
}
public Collection<T> getNextWork()
{
// Only return the collection once
if (hasMore)
{
hasMore = false;
return collection;
}
else
{
return Collections.emptyList();
}
}
},
workerThreads, batchSize,
applicationEventPublisher, logger, loggingInterval);
}
项目:joal
文件:TorrentFileProviderTest.java
@Test
public void shouldAddFileToListOnCreation() throws IOException {
TorrentFileCreator.create(torrentsPath.resolve("ubuntu.torrent"), TorrentFileCreator.TorrentType.UBUNTU);
final TorrentFileProvider provider = new TorrentFileProvider(resourcePath.toString(), Mockito.mock(ApplicationEventPublisher.class));
assertThat(provider.getTorrentCount()).isEqualTo(0);
provider.onFileCreate(torrentsPath.resolve("ubuntu.torrent").toFile());
assertThat(provider.getTorrentCount()).isEqualTo(1);
}
项目:sentry
文件:GameServerService.java
@Autowired
public GameServerService(GameServerRepository gameServerRepository, GameServerMapper gameServerMapper,
GameAdminService gameAdminService, GameQueryService gameQueryService,
ApplicationEventPublisher publisher, MetricRegistry metricRegistry,
SettingService settingService) {
this.gameServerRepository = gameServerRepository;
this.gameServerMapper = gameServerMapper;
this.gameAdminService = gameAdminService;
this.gameQueryService = gameQueryService;
this.publisher = publisher;
this.metricRegistry = metricRegistry;
this.settingService = settingService;
}
项目:sentry
文件:StreamerService.java
@Autowired
public StreamerService(StreamerRepository streamerRepository, StreamerMapper streamerMapper,
SentryProperties sentryProperties, RestTemplate restTemplate,
ApplicationEventPublisher publisher, SettingService settingService) {
this.streamerRepository = streamerRepository;
this.streamerMapper = streamerMapper;
this.sentryProperties = sentryProperties;
this.restTemplate = restTemplate;
this.publisher = publisher;
this.settingService = settingService;
}
项目:java-microservice
文件:EventSourcingServiceImpl.java
@Autowired
public EventSourcingServiceImpl(
EventStoreRepository eventStore,
EventSerializer eventSerializer,
ApplicationEventPublisher eventPublisher
) {
this.eventStoreRepository = eventStore;
this.eventSerializer = eventSerializer;
}
项目:joal
文件:JoalConfigProviderTest.java
@Test
public void shouldFailIfJsonFileIsNotPresent() {
final String fakePath = resourcePath.resolve("nop").toString();
assertThatThrownBy(() -> new JoalConfigProvider(new ObjectMapper(), fakePath, Mockito.mock(ApplicationEventPublisher.class)))
.isInstanceOf(FileNotFoundException.class)
.hasMessageContaining("App configuration file '" + fakePath + File.separator + "config.json' not found.");
}
项目:summer-mqtt
文件:MqttClientEventPublisherTest.java
@Test
public void testPublishConnectedEventNullClientId()
{
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(EXCEPTION_MESSAGE_CLIENT_ID);
ApplicationEventPublisher applicationEventPublisher = Mockito
.mock(ApplicationEventPublisher.class);
mqttClientEventPublisher.publishConnectedEvent(null, SERVER_URI, SUBSCRIBED_TOPICS_EMPTY,
applicationEventPublisher, this);
}
项目:cas-server-4.2.1
文件:CentralAuthenticationServiceImplTests.java
/**
* This test checks that the TGT destruction happens properly for a remote registry.
* It previously failed when the deletion happens before the ticket was marked expired because an update was necessary for that.
*
* @throws AuthenticationException
* @throws AbstractTicketException
*/
@Test
public void verifyDestroyRemoteRegistry() throws AbstractTicketException, AuthenticationException {
final MockOnlyOneTicketRegistry registry = new MockOnlyOneTicketRegistry();
final TicketGrantingTicketImpl tgt = new TicketGrantingTicketImpl("TGT-1", mock(Authentication.class),
mock(ExpirationPolicy.class));
final MockExpireUpdateTicketLogoutManager logoutManager = new MockExpireUpdateTicketLogoutManager(registry);
registry.addTicket(tgt);
final CentralAuthenticationServiceImpl cas = new CentralAuthenticationServiceImpl(registry, null, null, logoutManager);
cas.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
cas.destroyTicketGrantingTicket(tgt.getId());
}
项目:cas-server-4.2.1
文件:ManageRegisteredServicesMultiActionControllerTests.java
@Before
public void setUp() throws Exception {
this.servicesManager = new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl());
this.servicesManager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
this.registeredServiceFactory = new DefaultRegisteredServiceFactory();
this.registeredServiceFactory.initializeDefaults();
this.controller = new ManageRegisteredServicesMultiActionController(this.servicesManager, this
.registeredServiceFactory, "foo");
}
项目:cas-server-4.2.1
文件:ServiceThemeResolverTests.java
@Before
public void setUp() throws Exception {
this.servicesManager = new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl());
this.servicesManager.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
this.serviceThemeResolver = new ServiceThemeResolver();
this.serviceThemeResolver.setDefaultThemeName("test");
this.serviceThemeResolver.setServicesManager(this.servicesManager);
final Map<String, String> mobileBrowsers = new HashMap<>();
mobileBrowsers.put("Mozilla", "theme");
this.serviceThemeResolver.setMobileBrowsers(mobileBrowsers);
}
项目:summer-mqtt
文件:MqttClientEventPublisherTest.java
@Test
public void testPublishConnectionFailureEventNullClientId()
{
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(EXCEPTION_MESSAGE_CLIENT_ID);
ApplicationEventPublisher applicationEventPublisher = Mockito
.mock(ApplicationEventPublisher.class);
mqttClientEventPublisher.publishConnectionFailureEvent(null, true, new Exception(),
applicationEventPublisher, this);
}