use of test.demo.config.User in project today-infrastructure by TAKETODAY.
the class DefaultUserRepository method initData.
@PostConstruct
public void initData() {
log.info("init data: [{}]", this);
users.put("666", new User(1, "Harry Yang", 20, "666", "666", "男", new Date()));
users.put("6666", new User(2, "Harry Yang1", 20, "6666", "6666", "男", new Date()));
users.put("66666", new User(3, "Harry Yang2", 20, "66666", "66666", "男", new Date()));
users.put("666666", new User(4, "Harry Yang3", 20, "666666", "666666", "男", new Date()));
}
use of test.demo.config.User in project today-framework by TAKETODAY.
the class DemoTests method testLogin.
@Test
void testLogin() throws NoSuchBeanDefinitionException, BeanDefinitionStoreException, IOException {
try (StandardApplicationContext context = new StandardApplicationContext()) {
ApplicationPropertySourcesProcessor processor = new ApplicationPropertySourcesProcessor(context);
processor.setPropertiesLocation("info.properties");
processor.postProcessEnvironment();
context.scan("test.demo.service.impl", "test.demo.repository.impl");
context.refresh();
UserService userService = context.getBean(DefaultUserService.class);
UserRepository userDao = context.getBean(UserRepository.class);
DefaultUserRepository userDaoImpl = context.getBean(DefaultUserRepository.class);
assert userDao != userDaoImpl;
User login = userService.login(new User(1, "TODAY", 20, "666", "666", "男", new Date()));
assert login != null : "Login failed";
}
}
use of test.demo.config.User in project today-framework by TAKETODAY.
the class ProfileTests method testProfile.
@Test
void testProfile() throws IOException {
try (StandardApplicationContext context = new StandardApplicationContext()) {
ApplicationPropertySourcesProcessor processor = new ApplicationPropertySourcesProcessor(context);
processor.setPropertiesLocation("info.properties");
processor.postProcessEnvironment();
context.register(ProfileTestConfig.class);
context.refresh();
User user = context.getBean("user", User.class);
assert "TEST".equals(user.getUserName());
}
}
use of test.demo.config.User in project today-framework by TAKETODAY.
the class ApplicationContextTests method testLoadFromCollection.
@Test
void testLoadFromCollection() throws Exception {
try (StandardApplicationContext applicationContext = new StandardApplicationContext()) {
applicationContext.register(ConfigurationBean.class);
applicationContext.refresh();
User bean = applicationContext.getBean(User.class);
bean.setAge(12);
User user = applicationContext.getBean(User.class);
assertThat(bean).isNotNull().isEqualTo(user);
}
}
use of test.demo.config.User in project today-framework by TAKETODAY.
the class CachePutInterceptorTests method testInContext.
@Test
void testInContext() throws Exception {
CacheExpressionOperations operations = new CacheExpressionOperations();
try (StandardApplicationContext context = new StandardApplicationContext()) {
context.register(CachePutConfig.class);
context.refresh();
CachePutInterceptor interceptor = context.getBean(CachePutInterceptor.class);
Method save = CacheUserService.class.getDeclaredMethod("save", User.class);
// CachePut
MethodKey methodKey = new MethodKey(save, CachePut.class);
interceptor.setExpressionOperations(operations);
CacheConfiguration cachePut = operations.getConfig(methodKey);
Cache users = interceptor.getCache("users", cachePut);
User today = new User(1, "TODAY", 20, "666", "666", "男", new Date());
CacheUserService userService = context.getBean(CacheUserService.class);
userService.save(today);
Object by_id_666 = users.get("by_id_666");
assertThat(by_id_666).isEqualTo(today);
User user = userService.getUser("666");
assertThat(today).isEqualTo(user);
user = userService.getUser("666");
assertThat(today).isEqualTo(user);
user = userService.getUser("666");
assertThat(today).isEqualTo(user);
user = userService.getUser("666");
assertThat(today).isEqualTo(user);
assertThat(today).isEqualTo(user).isEqualTo(by_id_666);
// access time no Cacheable Interceptor
assertThat(userService.getAccessTime()).isEqualTo(4);
}
}
Aggregations