use of org.apache.openejb.core.timer.CalendarTimerData in project tomee by apache.
the class EjbTimerImplSerializableTest method timerData.
public static CalendarTimerData timerData() throws Exception {
final BeanContext context = SystemInstance.get().getComponent(ContainerSystem.class).getBeanContext("EJBWithTimer");
final EjbTimerService timer = context.getEjbTimerService();
final MethodContext ctx = context.getMethodContext(EJBWithTimer.class.getMethod("doSthg"));
final ScheduleData sd = ctx.getSchedules().iterator().next();
return new CalendarTimerData(1, (EjbTimerServiceImpl) timer, context.getDeploymentID().toString(), null, ctx.getBeanMethod(), sd.getConfig(), sd.getExpression(), false);
}
use of org.apache.openejb.core.timer.CalendarTimerData in project tomee by apache.
the class EjbTimerImplSerializableTest method jobDataMapSerial.
@Test
public void jobDataMapSerial() throws Exception {
final CalendarTimerData data = timerData();
final EjbTimerServiceImpl timerService = (EjbTimerServiceImpl) timerService();
data.setScheduler(timerService.getScheduler());
// small hack for the test
final Field preventSynch = TimerData.class.getDeclaredField("synchronizationRegistered");
preventSynch.setAccessible(true);
preventSynch.set(data, true);
data.newTimer();
final AbstractTrigger<?> trigger = (AbstractTrigger<?>) data.getTrigger();
trigger.setJobName("my-job");
trigger.setJobGroup("my-group");
final JobDataMap triggerDataMap = trigger.getJobDataMap();
triggerDataMap.put(EjbTimeoutJob.EJB_TIMERS_SERVICE, timerService);
triggerDataMap.put(EjbTimeoutJob.TIMER_DATA, data);
final byte[] serial = serialize(triggerDataMap);
final JobDataMap map = (JobDataMap) deserialize(serial);
assertTrue(map.containsKey(EjbTimeoutJob.EJB_TIMERS_SERVICE));
assertTrue(map.containsKey(EjbTimeoutJob.TIMER_DATA));
}
use of org.apache.openejb.core.timer.CalendarTimerData in project tomee by apache.
the class EjbTimerImplSerializableTest method serializationOfCalendarData.
@Test
public void serializationOfCalendarData() throws Exception {
final CalendarTimerData data = timerData();
final byte[] serial = serialize(data);
final CalendarTimerData dataDeserialized = (CalendarTimerData) deserialize(serial);
assertThat(dataDeserialized, instanceOf(CalendarTimerData.class));
assertEqualsByReflection(data, dataDeserialized, "id");
assertEqualsByReflection(data, dataDeserialized, "deploymentId");
assertEqualsByReflection(data, dataDeserialized, "timeoutMethod");
assertEqualsByReflection(data, dataDeserialized, "info");
}
Aggregations