package com.ljm;
import com.MyApplication;
import com.ljm.constant.StrategyEnum;
import com.ljm.service.HandlerStrategyFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @Author: ljm
* @Date: 2024/2/26 10:58
* @Version: v1.0.0
* @Description: TODO
**/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = MyApplication.class)
public class MyTest {
@Autowired
private HandlerStrategyFactory handlerStrategyFactory;
@Test
public void testStrategy() {
handlerStrategyFactory.getHandleStrategy(StrategyEnum.FIRST).handler();
handlerStrategyFactory.getHandleStrategy(StrategyEnum.SECOND).handler();
handlerStrategyFactory.getHandleStrategy(StrategyEnum.THIRD).handler();
handlerStrategyFactory.getHandleStrategy(StrategyEnum.FOUR).handler();
/* 测试结果
Execute First Handler
Execute Second Handler
Execute Third Handler
Execute Four Handler*/
}
}
|