use of org.dbflute.hook.AccessContext.AccessDateProvider in project dbflute-core by dbflute.
the class AccessContextTest method test_getValue_whenAccessContextProvider_Tx.
public void test_getValue_whenAccessContextProvider_Tx() throws Exception {
// ## Arrange ##
AccessContext accessContext = new AccessContext();
final String dateExp = "2013-02-02 12:34:56";
accessContext.setAccessDateProvider(new AccessDateProvider() {
public Date provideDate() {
return toDate(dateExp);
}
});
final String timestampExp = "2013-02-02 12:34:56";
accessContext.setAccessTimestampProvider(new AccessTimestampProvider() {
public Timestamp provideTimestamp() {
return toTimestamp(timestampExp);
}
});
accessContext.setAccessUserProvider(new AccessUserProvider() {
public String provideUser() {
return "foo";
}
});
accessContext.setAccessProcessProvider(new AccessProcessProvider() {
public String provideProcess() {
return "bar";
}
});
accessContext.setAccessModuleProvider(new AccessModuleProvider() {
public String provideModule() {
return "qux";
}
});
AccessContext.setAccessContextOnThread(accessContext);
// ## Act & Assert ##
assertNotNull(dateExp, AccessContext.getAccessDateOnThread());
assertNotNull(timestampExp, AccessContext.getAccessTimestampOnThread());
assertEquals("foo", AccessContext.getAccessUserOnThread());
assertEquals("bar", AccessContext.getAccessProcessOnThread());
assertEquals("qux", AccessContext.getAccessModuleOnThread());
}
Aggregations