当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationEventPublisher类代码示例

本文整理汇总了Java中org.springframework.context.ApplicationEventPublisher的典型用法代码示例。如果您正苦于以下问题:Java ApplicationEventPublisher类的具体用法?Java ApplicationEventPublisher怎么用?Java ApplicationEventPublisher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ApplicationEventPublisher类属于org.springframework.context包,在下文中一共展示了ApplicationEventPublisher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldNotifyListenerOnFileAdded

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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);
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:19,代码来源:TorrentFileProviderTest.java

示例2: setUp

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RegisteredServiceSimpleFormControllerTests.java

示例3: setUp

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:DefaultServicesManagerImplTests.java

示例4: setUp

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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");

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例5: shouldCallOnFileDeleteBeforeDeletingFileWhenArchiving

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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();
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:17,代码来源:TorrentFileProviderTest.java

示例6: shouldNotifyListenerOnFileRemoved

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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);
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:19,代码来源:TorrentFileProviderTest.java

示例7: shouldUnRegisterListener

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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);
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:22,代码来源:TorrentFileProviderTest.java

示例8: shouldWriteConfigurationFile

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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"));
    }
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:22,代码来源:JoalConfigProviderTest.java

示例9: onSetUp

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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);
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:27,代码来源:LogoutActionTests.java

示例10: setUp

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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");
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:22,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例11: DocumentGenerator

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@Autowired
public DocumentGenerator(
    CitizenSealedClaimPdfService citizenSealedClaimPdfService,
    DefendantPinLetterPdfService defendantPinLetterPdfService,
    LegalSealedClaimPdfService legalSealedClaimPdfService,
    ApplicationEventPublisher publisher
) {
    this.citizenSealedClaimPdfService = citizenSealedClaimPdfService;
    this.defendantPinLetterPdfService = defendantPinLetterPdfService;
    this.legalSealedClaimPdfService = legalSealedClaimPdfService;
    this.publisher = publisher;
}
 
开发者ID:hmcts,项目名称:cmc-claim-store,代码行数:13,代码来源:DocumentGenerator.java

示例12: testPublishDisconnectedEventNullClientId

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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);
}
 
开发者ID:christophersmith,项目名称:summer-mqtt,代码行数:10,代码来源:MqttClientEventPublisherTest.java

示例13: verifyDestroyRemoteRegistry

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:CentralAuthenticationServiceImplTests.java

示例14: shouldFailIfFolderDoesNotContainsTorrentFiles

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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.");
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:9,代码来源:TorrentFileProviderTest.java

示例15: testPublishConnectionLostEvent

import org.springframework.context.ApplicationEventPublisher; //导入依赖的package包/类
@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));
}
 
开发者ID:christophersmith,项目名称:summer-mqtt,代码行数:11,代码来源:MqttClientEventPublisherTest.java


注:本文中的org.springframework.context.ApplicationEventPublisher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。