com.ling.spring.event.TestEvent.java Source code

Java tutorial

Introduction

Here is the source code for com.ling.spring.event.TestEvent.java

Source

/*
 * Copyright 2005-2020 Daxia Team All rights reserved.
 * Support: zhangzhen
 * License: Daxia Team license
 */
package com.ling.spring.event;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring-event.xml")
public class TestEvent {
    @Autowired
    private ApplicationContext applicationContext;

    @Test
    public void testEvent() {
        applicationContext.publishEvent(new ContentEvent("?"));
        try {
            Thread.currentThread().sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}