Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronExpressionSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronExpressionSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronExpressionSerializationTest.java (revision 2430) @@ -0,0 +1,59 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.terracotta.quartz.upgradability.serialization; + + +import java.io.IOException; +import java.text.ParseException; +import java.util.Comparator; +import java.util.TimeZone; + +import org.junit.Test; +import org.quartz.CronExpression; + +import static org.hamcrest.collection.IsArrayContaining.hasItemInArray; +import static org.junit.Assume.assumeThat; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class CronExpressionSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + + @Override + public int compare(CronExpression o1, CronExpression o2) { + if (o1.getCronExpression().equals(o2.getCronExpression()) && o1.getTimeZone().equals(o2.getTimeZone())) { + return 0; + } else { + return -1; + } + } + }; + + @Test + public void testSimpleCron() throws ParseException, IOException, ClassNotFoundException { + CronExpression expression = new CronExpression("0 0 12 * * ?"); + validateSerializedForm(expression, COMPARATOR, "serializedforms/CronExpressionSerializationTest.testSimpleCron.ser"); + } + + @Test + public void testComplexCron() throws ParseException, IOException, ClassNotFoundException { + CronExpression expression = new CronExpression("0 0/5 14,18,20-23 ? JAN,MAR,SEP MON-FRI 2002-2010"); + validateSerializedForm(expression, COMPARATOR, "serializedforms/CronExpressionSerializationTest.testComplexCron.ser"); + } + + @Test + public void testCronWithTimeZone() throws ParseException, IOException, ClassNotFoundException { + assumeThat(TimeZone.getAvailableIDs(), hasItemInArray("Antarctica/South_Pole")); + CronExpression expression = new CronExpression("0 0 12 * * ?"); + expression.setTimeZone(TimeZone.getTimeZone("Antarctica/South_Pole")); + validateSerializedForm(expression, COMPARATOR, "serializedforms/CronExpressionSerializationTest.testCronWithTimeZone.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobKeySerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobKeySerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobKeySerializationTest.java (revision 2430) @@ -0,0 +1,33 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.terracotta.quartz.upgradability.serialization; + + +import java.io.IOException; +import org.junit.Test; +import org.quartz.JobKey; + +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class JobKeySerializationTest { + + @Test + public void testWithoutGroup() throws IOException, ClassNotFoundException { + JobKey key = new JobKey("foo"); + validateSerializedForm(key, "serializedforms/JobKeySerializationTest.testWithoutGroup.ser"); + } + + @Test + public void testWithGroup() throws IOException, ClassNotFoundException { + JobKey key = new JobKey("foo", "bar"); + validateSerializedForm(key, "serializedforms/JobKeySerializationTest.testWithGroup.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/HolidayCalendarSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/HolidayCalendarSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/HolidayCalendarSerializationTest.java (revision 2430) @@ -0,0 +1,77 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Comparator; +import java.util.Date; + +import org.junit.Test; +import org.quartz.impl.calendar.HolidayCalendar; +import org.quartz.impl.calendar.WeeklyCalendar; + +import static java.util.TimeZone.getTimeZone; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class HolidayCalendarSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + + @Override + public int compare(HolidayCalendar o1, HolidayCalendar o2) { + return o1.getExcludedDates().equals(o2.getExcludedDates()) + && (o1.getBaseCalendar() != null) == (o2.getBaseCalendar() != null) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && nullSafeEquals(o1.getTimeZone(), o2.getTimeZone()) ? 0 : -1; + } + }; + + @Test + public void testNoDaysExcluded() throws IOException, ClassNotFoundException { + HolidayCalendar hc = new HolidayCalendar(); + validateSerializedForm(hc, COMPARATOR, "serializedforms/HolidayCalendarSerializationTest.testNoDaysExcluded.ser"); + } + + @Test + public void testOneDayExcluded() throws IOException, ClassNotFoundException { + HolidayCalendar hc = new HolidayCalendar(); + hc.addExcludedDate(new Date(0)); + validateSerializedForm(hc, COMPARATOR, "serializedforms/HolidayCalendarSerializationTest.testOneDayExcluded.ser"); + } + + @Test + public void testTwoDaysExcluded() throws IOException, ClassNotFoundException { + HolidayCalendar hc = new HolidayCalendar(); + hc.addExcludedDate(new Date(378443700000L)); + hc.addExcludedDate(new Date(0)); + validateSerializedForm(hc, COMPARATOR, "serializedforms/HolidayCalendarSerializationTest.testTwoDaysExcluded.ser"); + } + + @Test + public void testExtendedProperties() throws IOException, ClassNotFoundException { + HolidayCalendar wc = new HolidayCalendar(new HolidayCalendar(), getTimeZone("Antarctica/South_Pole")); + wc.setDescription("A Calendar"); + validateSerializedForm(wc, COMPARATOR, "serializedforms/HolidayCalendarSerializationTest.testExtendedProperties.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobDataMapSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobDataMapSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobDataMapSerializationTest.java (revision 2430) @@ -0,0 +1,58 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.terracotta.quartz.upgradability.serialization; + + +import java.io.IOException; +import java.util.Comparator; +import org.junit.Test; +import org.quartz.JobDataMap; + +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class JobDataMapSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + + @Override + public int compare(JobDataMap o1, JobDataMap o2) { + return o1.equals(o2) && o1.isDirty() == o2.isDirty() && o1.getAllowsTransientData() == o2.getAllowsTransientData() ? 0 : -1; + } + }; + + @Test + public void testEmptyMap() throws IOException, ClassNotFoundException { + JobDataMap jdm = new JobDataMap(); + validateSerializedForm(jdm, COMPARATOR, "serializedforms/JobDataMapSerializationTest.testEmptyMap.ser"); + } + + @Test + public void testEmptyAllowTransientsMap() throws IOException, ClassNotFoundException { + JobDataMap jdm = new JobDataMap(); + jdm.setAllowsTransientData(true); + validateSerializedForm(jdm, COMPARATOR, "serializedforms/JobDataMapSerializationTest.testEmptyAllowTransientsMap.ser"); + } + + @Test + public void testOccupiedDirtyMap() throws IOException, ClassNotFoundException { + JobDataMap jdm = new JobDataMap(); + jdm.put("foo", "bar"); + validateSerializedForm(jdm, COMPARATOR, "serializedforms/JobDataMapSerializationTest.testOccupiedDirtyMap.ser"); + } + + @Test + public void testOccupiedCleanMap() throws IOException, ClassNotFoundException { + JobDataMap jdm = new JobDataMap(); + jdm.put("foo", "bar"); + jdm.clearDirtyFlag(); + validateSerializedForm(jdm, COMPARATOR, "serializedforms/JobDataMapSerializationTest.testOccupiedCleanMap.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TriggerKeySerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TriggerKeySerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TriggerKeySerializationTest.java (revision 2430) @@ -0,0 +1,33 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.terracotta.quartz.upgradability.serialization; + + +import java.io.IOException; +import org.junit.Test; +import org.quartz.TriggerKey; + +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class TriggerKeySerializationTest { + + @Test + public void testWithoutGroup() throws IOException, ClassNotFoundException { + TriggerKey key = new TriggerKey("foo"); + validateSerializedForm(key, "serializedforms/TriggerKeySerializationTest.testWithoutGroup.ser"); + } + + @Test + public void testWithGroup() throws IOException, ClassNotFoundException { + TriggerKey key = new TriggerKey("foo", "bar"); + validateSerializedForm(key, "serializedforms/TriggerKeySerializationTest.testWithGroup.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobWrapperSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobWrapperSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobWrapperSerializationTest.java (revision 2430) @@ -0,0 +1,110 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Comparator; + +import org.junit.Test; +import org.quartz.Job; +import org.quartz.JobBuilder; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.JobKey; +import org.terracotta.quartz.wrappers.DefaultWrapperFactory; +import org.terracotta.quartz.wrappers.JobWrapper; +import org.terracotta.quartz.wrappers.TriggerFacade; +import org.terracotta.quartz.wrappers.TriggerWrapper; +import org.terracotta.quartz.wrappers.WrapperFactory; + +import static org.mockito.Mockito.mock; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class JobWrapperSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(JobWrapper o1, JobWrapper o2) { + return (o1.getJobDetailClone() == null) == (o2.getJobDetailClone() == null) ? 0 : -1; + } + }; + + @Test + public void testSimple() throws IOException, ClassNotFoundException { + WrapperFactory factory = new DefaultWrapperFactory(); + JobWrapper jw = factory.createJobWrapper(new DummyJobDetail()); + validateSerializedForm(jw, COMPARATOR, "serializedforms/JobWrapperSerializationTest.testSimple.ser"); + } + + static class DummyJobDetail implements JobDetail { + + @Override + public JobKey getKey() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public String getDescription() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Class getJobClass() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public JobDataMap getJobDataMap() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean isDurable() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean isPersistJobDataAfterExecution() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean isConcurrentExectionDisallowed() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean requestsRecovery() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public JobBuilder getJobBuilder() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Object clone() { + return new DummyJobDetail(); + } + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/DailyCalendarSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/DailyCalendarSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/DailyCalendarSerializationTest.java (revision 2430) @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Comparator; +import java.util.TimeZone; + +import org.junit.Test; +import org.quartz.impl.calendar.DailyCalendar; +import org.quartz.impl.calendar.HolidayCalendar; + +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class DailyCalendarSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(DailyCalendar o1, DailyCalendar o2) { + return o1.getTimeRangeStartingTimeInMillis(0) == o2.getTimeRangeStartingTimeInMillis(0) + && o1.getTimeRangeEndingTimeInMillis(0) == o2.getTimeRangeEndingTimeInMillis(0) + && o1.getInvertTimeRange() == o2.getInvertTimeRange() + && (o1.getBaseCalendar() != null) == (o2.getBaseCalendar() != null) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && nullSafeEquals(o1.getTimeZone(), o2.getTimeZone()) ? 0 : -1; + } + }; + + @Test + public void testWithoutBaseCalendar() throws IOException, ClassNotFoundException { + DailyCalendar dc = new DailyCalendar(3, 4, 5, 6, 7, 8, 9, 10); + validateSerializedForm(dc, COMPARATOR, "serializedforms/DailyCalendarSerializationTest.testWithoutBaseCalendar.ser"); + } + + @Test + public void testWithBaseCalendar() throws IOException, ClassNotFoundException { + DailyCalendar dc = new DailyCalendar(new HolidayCalendar(), 3, 4, 5, 6, 7, 8, 9, 10); + validateSerializedForm(dc, COMPARATOR, "serializedforms/DailyCalendarSerializationTest.testWithBaseCalendar.ser"); + } + + @Test + public void testWithEverything() throws IOException, ClassNotFoundException { + DailyCalendar dc = new DailyCalendar(new HolidayCalendar(), 3, 4, 5, 6, 7, 8, 9, 10); + dc.setDescription("A Calendar"); + dc.setTimeZone(TimeZone.getTimeZone("Antarctica/South_Pole")); + validateSerializedForm(dc, COMPARATOR, "serializedforms/DailyCalendarSerializationTest.testWithEverything.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/BasicUpgradabilityTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/BasicUpgradabilityTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/BasicUpgradabilityTest.java (revision 2430) @@ -0,0 +1,97 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.terracotta.quartz.upgradability; + +import java.util.Properties; + +import org.junit.Test; +import org.quartz.Job; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerFactory; +import org.quartz.SimpleScheduleBuilder; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.impl.StdSchedulerFactory; +import org.terracotta.quartz.AbstractTerracottaJobStore; +import org.terracotta.quartz.TerracottaJobStore; +import org.terracotta.quartz.collections.TimeTrigger; +import org.terracotta.toolkit.builder.ToolkitStoreConfigBuilder; +import org.terracotta.toolkit.internal.ToolkitInternal; +import org.terracotta.toolkit.store.ToolkitConfigFields; + +import static org.mockito.Mockito.*; +import static org.terracotta.upgradability.interaction.MockToolkitFactoryService.allowNonPersistentInteractions; +import static org.terracotta.upgradability.interaction.MockToolkitFactoryService.mockToolkitFor; + +/** + * + * @author cdennis + */ +public class BasicUpgradabilityTest { + + @Test + public void testJobStorage() throws Exception { + ToolkitInternal mock = mockToolkitFor("mocked-not-clustered"); + + Properties props = new Properties(); + props.load(getClass().getResourceAsStream("/org/quartz/quartz.properties")); + props.setProperty(StdSchedulerFactory.PROP_JOB_STORE_CLASS, TerracottaJobStore.class.getName()); + props.setProperty(AbstractTerracottaJobStore.TC_CONFIGURL_PROP, "mocked-not-clustered"); + + SchedulerFactory schedFact = new StdSchedulerFactory(props); + Scheduler scheduler = schedFact.getScheduler(); + try { + scheduler.start(); + + JobDetail jobDetail = JobBuilder.newJob(SomeJob.class).withIdentity("testjob", "testjobgroup").storeDurably().build(); + scheduler.addJob(jobDetail, false); + + Trigger trigger = TriggerBuilder.newTrigger().forJob(jobDetail).withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(10)).build(); + scheduler.scheduleJob(trigger); + } finally { + scheduler.shutdown(); + } + + verify(mock).getStore(eq("_tc_quartz_jobs|DefaultQuartzScheduler"), + refEq(new ToolkitStoreConfigBuilder().consistency(ToolkitConfigFields.Consistency.STRONG).concurrency(1).build()), + isNull(Class.class)); + verify(mock).getStore(eq("_tc_quartz_triggers|DefaultQuartzScheduler"), + refEq(new ToolkitStoreConfigBuilder().consistency(ToolkitConfigFields.Consistency.STRONG).concurrency(1).build()), + isNull(Class.class)); + verify(mock).getStore(eq("_tc_quartz_fired_trigger|DefaultQuartzScheduler"), + refEq(new ToolkitStoreConfigBuilder().consistency(ToolkitConfigFields.Consistency.STRONG).concurrency(1).build()), + isNull(Class.class)); + verify(mock).getStore(eq("_tc_quartz_calendar_wrapper|DefaultQuartzScheduler"), + refEq(new ToolkitStoreConfigBuilder().consistency(ToolkitConfigFields.Consistency.STRONG).concurrency(1).build()), + isNull(Class.class)); + + verify(mock).getSet("_tc_quartz_grp_names|DefaultQuartzScheduler", String.class); + verify(mock).getSet("_tc_quartz_grp_paused_names|DefaultQuartzScheduler", String.class); + verify(mock).getSet("_tc_quartz_blocked_jobs|DefaultQuartzScheduler", JobKey.class); + verify(mock).getSet("_tc_quartz_grp_names_triggers|DefaultQuartzScheduler", String.class); + verify(mock).getSet("_tc_quartz_grp_paused_trogger_names|DefaultQuartzScheduler", String.class); + verify(mock).getSet("_tc_quartz_grp_jobs_testjobgroup|DefaultQuartzScheduler", String.class); + verify(mock).getSet("_tc_quartz_grp_triggers_DEFAULT|DefaultQuartzScheduler", String.class); + + verify(mock).getSortedSet("_tc_time_trigger_sorted_set|DefaultQuartzScheduler", TimeTrigger.class); + verify(mock).shutdown(); + + allowNonPersistentInteractions(mock); + verifyNoMoreInteractions(mock); + } + + static class SomeJob implements Job { + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + //no-op + } + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronCalendarSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronCalendarSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronCalendarSerializationTest.java (revision 2430) @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.text.ParseException; +import java.util.Comparator; + +import org.junit.Test; +import org.quartz.impl.calendar.CronCalendar; +import org.quartz.impl.calendar.HolidayCalendar; + +import static java.util.TimeZone.getTimeZone; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class CronCalendarSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + + @Override + public int compare(CronCalendar o1, CronCalendar o2) { + return o1.getCronExpression().getCronExpression().equals(o2.getCronExpression().getCronExpression()) + && o1.getTimeZone().equals(o2.getTimeZone()) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && (o1.getBaseCalendar() == null) == (o2.getBaseCalendar() == null) + ? 0 : -1; + } + + }; + + @Test + public void testWithoutBase() throws ParseException, IOException, ClassNotFoundException, ParseException { + CronCalendar cc = new CronCalendar("0 0 12 * * ?"); + validateSerializedForm(cc, COMPARATOR, "serializedforms/CronCalendarSerializationTest.testWithoutBase.ser"); + } + + @Test + public void testWithBase() throws ParseException, IOException, ClassNotFoundException { + CronCalendar cc = new CronCalendar(new HolidayCalendar(), "0 0 12 * * ?"); + validateSerializedForm(cc, COMPARATOR, "serializedforms/CronCalendarSerializationTest.testWithBase.ser"); + } + + @Test + public void testWithTimezone() throws ParseException, IOException, ClassNotFoundException { + CronCalendar cc = new CronCalendar(new HolidayCalendar(), "0 0 12 * * ?", getTimeZone("Antarctica/South_Pole")); + validateSerializedForm(cc, COMPARATOR, "serializedforms/CronCalendarSerializationTest.testWithTimezone.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CalendarIntervalTriggerImplSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CalendarIntervalTriggerImplSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CalendarIntervalTriggerImplSerializationTest.java (revision 2430) @@ -0,0 +1,103 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Comparator; +import java.util.Date; +import java.util.TimeZone; + +import org.junit.Test; +import org.quartz.JobDataMap; +import org.quartz.TimeOfDay; +import org.quartz.impl.triggers.CalendarIntervalTriggerImpl; + +import static org.quartz.DateBuilder.IntervalUnit.MINUTE; +import static org.quartz.Trigger.MISFIRE_INSTRUCTION_SMART_POLICY; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class CalendarIntervalTriggerImplSerializationTest { + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(CalendarIntervalTriggerImpl o1, CalendarIntervalTriggerImpl o2) { + return o1.getJobKey().equals(o2.getJobKey()) + && o1.getKey().equals(o2.getKey()) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && (o1.getJobDataMap() == null) == (o2.getJobDataMap() == null) + && o1.getCalendarName().equals(o2.getCalendarName()) + && o1.getStartTime().equals(o2.getStartTime()) + && o1.getEndTime().equals(o2.getEndTime()) + && nullSafeEquals(o1.getNextFireTime(), o2.getNextFireTime()) + && nullSafeEquals(o1.getPreviousFireTime(), o2.getPreviousFireTime()) + && o1.getRepeatInterval() == o2.getRepeatInterval() + && o1.getRepeatIntervalUnit().equals(o2.getRepeatIntervalUnit()) + && o1.getTimeZone().equals(o2.getTimeZone()) + && o1.isPreserveHourOfDayAcrossDaylightSavings() == o2.isPreserveHourOfDayAcrossDaylightSavings() + && o1.isSkipDayIfHourDoesNotExist() == o2.isSkipDayIfHourDoesNotExist() + && o1.getTimesTriggered() == o2.getTimesTriggered() + && nullSafeEquals(o1.getFireInstanceId(), o2.getFireInstanceId()) + && o1.getMisfireInstruction() == o2.getMisfireInstruction() + && o1.getPriority() == o2.getPriority() ? 0 : -1; + } + }; + + /* + private TimeZone timeZone; + + private boolean preserveHourOfDayAcrossDaylightSavings = false; // false is backward-compatible with behavior + + private boolean skipDayIfHourDoesNotExist = false; + + */ + @Test + public void testConstructed() throws IOException, ClassNotFoundException { + CalendarIntervalTriggerImpl cti = new CalendarIntervalTriggerImpl("triggerName", "triggerGroup", "jobName", "jobGroup", new Date(0L), new Date(10000L), MINUTE, 5); + cti.setTimeZone(TimeZone.getTimeZone("Antarctica/South_Pole")); + cti.setPreserveHourOfDayAcrossDaylightSavings(true); + cti.setSkipDayIfHourDoesNotExist(true); + cti.setDescription("A Trigger"); + cti.setJobDataMap(new JobDataMap()); + cti.setCalendarName("calendarName"); + cti.setMisfireInstruction(MISFIRE_INSTRUCTION_SMART_POLICY); + cti.setPriority(5); + + validateSerializedForm(cti, COMPARATOR, "serializedforms/CalendarIntervalTriggerImplSerializationTest.testConstructed.ser"); + } + + @Test + public void testFired() throws IOException, ClassNotFoundException { + CalendarIntervalTriggerImpl cti = new CalendarIntervalTriggerImpl("triggerName", "triggerGroup", "jobName", "jobGroup", new Date(0L), new Date(10000L), MINUTE, 5); + cti.setTimeZone(TimeZone.getTimeZone("Antarctica/South_Pole")); + cti.setPreserveHourOfDayAcrossDaylightSavings(true); + cti.setSkipDayIfHourDoesNotExist(true); + cti.setDescription("A Trigger"); + cti.setJobDataMap(new JobDataMap()); + cti.setCalendarName("calendarName"); + cti.setMisfireInstruction(MISFIRE_INSTRUCTION_SMART_POLICY); + cti.setPriority(5); + + cti.triggered(null); + + validateSerializedForm(cti, COMPARATOR, "serializedforms/CalendarIntervalTriggerImplSerializationTest.testFired.ser"); + + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/SimpleTriggerImplSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/SimpleTriggerImplSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/SimpleTriggerImplSerializationTest.java (revision 2430) @@ -0,0 +1,84 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Comparator; +import java.util.Date; + +import org.junit.Test; +import org.quartz.JobDataMap; +import org.quartz.impl.triggers.SimpleTriggerImpl; + +import static org.quartz.Trigger.MISFIRE_INSTRUCTION_SMART_POLICY; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class SimpleTriggerImplSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(SimpleTriggerImpl o1, SimpleTriggerImpl o2) { + return o1.getJobKey().equals(o2.getJobKey()) + && o1.getKey().equals(o2.getKey()) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && (o1.getJobDataMap() == null) == (o2.getJobDataMap() == null) + && o1.getCalendarName().equals(o2.getCalendarName()) + && o1.getStartTime().equals(o2.getStartTime()) + && o1.getEndTime().equals(o2.getEndTime()) + && nullSafeEquals(o1.getNextFireTime(), o2.getNextFireTime()) + && nullSafeEquals(o1.getPreviousFireTime(), o2.getPreviousFireTime()) + && o1.getRepeatCount() == o2.getRepeatCount() + && o1.getRepeatInterval() == o2.getRepeatInterval() + && o1.getTimesTriggered() == o2.getTimesTriggered() + && nullSafeEquals(o1.getFireInstanceId(), o2.getFireInstanceId()) + && o1.getMisfireInstruction() == o2.getMisfireInstruction() + && o1.getPriority() == o2.getPriority() ? 0 : -1; + } + }; + + @Test + public void testConstructed() throws IOException, ClassNotFoundException { + SimpleTriggerImpl sti = new SimpleTriggerImpl("triggerName", "triggerGroup", "jobName", "jobGroup", new Date(0L), new Date(10000L), 4, 100L); + sti.setDescription("A Trigger"); + sti.setJobDataMap(new JobDataMap()); + sti.setCalendarName("calendarName"); + sti.setMisfireInstruction(MISFIRE_INSTRUCTION_SMART_POLICY); + sti.setPriority(5); + + validateSerializedForm(sti, COMPARATOR, "serializedforms/SimpleTriggerImplSerializationTest.testConstructed.ser"); + } + + @Test + public void testFired() throws IOException, ClassNotFoundException { + SimpleTriggerImpl sti = new SimpleTriggerImpl("triggerName", "triggerGroup", "jobName", "jobGroup", new Date(0L), new Date(10000L), 4, 100L); + sti.setDescription("A Trigger"); + sti.setJobDataMap(new JobDataMap()); + sti.setCalendarName("calendarName"); + sti.setMisfireInstruction(MISFIRE_INSTRUCTION_SMART_POLICY); + sti.setPriority(5); + + sti.triggered(null); + + validateSerializedForm(sti, COMPARATOR, "serializedforms/SimpleTriggerImplSerializationTest.testFired.ser"); + + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TimeTriggerSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TimeTriggerSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TimeTriggerSerializationTest.java (revision 2430) @@ -0,0 +1,50 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.lang.reflect.Constructor; +import java.util.Comparator; +import java.util.Date; + +import org.junit.Test; +import org.quartz.TriggerKey; +import org.terracotta.quartz.collections.TimeTrigger; + +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class TimeTriggerSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(TimeTrigger o1, TimeTrigger o2) { + return o1.compareTo(o2); + } + }; + + @Test + public void testSimple() throws Exception { + //use reflection here to avoid having to publicise the currently package protected constructor + Constructor cons = TimeTrigger.class.getDeclaredConstructor(TriggerKey.class, Date.class, Integer.TYPE); + cons.setAccessible(true); + TimeTrigger tt = cons.newInstance(new TriggerKey("name", "group"), new Date(10), 2); + validateSerializedForm(tt, COMPARATOR, "serializedforms/TimeTriggerSerializationTest.testSimple.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/WeeklyCalendarSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/WeeklyCalendarSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/WeeklyCalendarSerializationTest.java (revision 2430) @@ -0,0 +1,75 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Comparator; + +import org.junit.Test; +import org.quartz.impl.calendar.HolidayCalendar; +import org.quartz.impl.calendar.WeeklyCalendar; + +import static java.util.TimeZone.getTimeZone; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class WeeklyCalendarSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(WeeklyCalendar o1, WeeklyCalendar o2) { + return Arrays.equals(o1.getDaysExcluded(), o2.getDaysExcluded()) + && (o1.getBaseCalendar() != null) == (o2.getBaseCalendar() != null) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && nullSafeEquals(o1.getTimeZone(), o2.getTimeZone()) ? 0 : -1; + } + }; + + @Test + public void testNoDaysExcluded() throws IOException, ClassNotFoundException { + WeeklyCalendar wc = new WeeklyCalendar(); + wc.setDaysExcluded(new boolean[8]); + validateSerializedForm(wc, COMPARATOR, "serializedforms/WeeklyCalendarSerializationTest.testNoDaysExcluded.ser"); + } + + @Test + public void testDefaultExcluded() throws IOException, ClassNotFoundException { + WeeklyCalendar wc = new WeeklyCalendar(); + validateSerializedForm(wc, COMPARATOR, "serializedforms/WeeklyCalendarSerializationTest.testDefaultExcluded.ser"); + } + + @Test + public void testAllDaysExcluded() throws IOException, ClassNotFoundException { + WeeklyCalendar wc = new WeeklyCalendar(); + boolean[] excludeAll = new boolean[8]; + Arrays.fill(excludeAll, true); + wc.setDaysExcluded(excludeAll); + validateSerializedForm(wc, COMPARATOR, "serializedforms/WeeklyCalendarSerializationTest.testAllDaysExcluded.ser"); + } + + @Test + public void testExtendedProperties() throws IOException, ClassNotFoundException { + WeeklyCalendar wc = new WeeklyCalendar(new HolidayCalendar(), getTimeZone("Antarctica/South_Pole")); + wc.setDescription("A Calendar"); + validateSerializedForm(wc, COMPARATOR, "serializedforms/WeeklyCalendarSerializationTest.testExtendedProperties.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronTriggerImplSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronTriggerImplSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/CronTriggerImplSerializationTest.java (revision 2430) @@ -0,0 +1,100 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.text.ParseException; +import java.util.Comparator; +import java.util.Date; +import java.util.TimeZone; + +import org.junit.Test; +import org.quartz.JobDataMap; +import org.quartz.impl.triggers.CronTriggerImpl; + +import static org.quartz.Trigger.MISFIRE_INSTRUCTION_SMART_POLICY; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class CronTriggerImplSerializationTest { + /* + private CronExpression cronEx = null; + private Date startTime = null; + private Date endTime = null; + private Date nextFireTime = null; + private Date previousFireTime = null; + private transient TimeZone timeZone = null; + */ + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(CronTriggerImpl o1, CronTriggerImpl o2) { + return o1.getJobKey().equals(o2.getJobKey()) + && o1.getKey().equals(o2.getKey()) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && (o1.getJobDataMap() == null) == (o2.getJobDataMap() == null) + && o1.getCalendarName().equals(o2.getCalendarName()) + && o1.getStartTime().equals(o2.getStartTime()) + && o1.getEndTime().equals(o2.getEndTime()) + && nullSafeEquals(o1.getNextFireTime(), o2.getNextFireTime()) + && nullSafeEquals(o1.getPreviousFireTime(), o2.getPreviousFireTime()) + && o1.getCronExpression().equals(o2.getCronExpression()) + && nullSafeEquals(o1.getFireInstanceId(), o2.getFireInstanceId()) + && o1.getMisfireInstruction() == o2.getMisfireInstruction() + && o1.getPriority() == o2.getPriority() ? 0 : -1; + } + }; + + /* + private CronExpression cronEx = null; + private Date startTime = null; + private Date endTime = null; + private Date nextFireTime = null; + private Date previousFireTime = null; + private transient TimeZone timeZone = null; + */ + @Test + public void testConstructed() throws IOException, ClassNotFoundException, ParseException { + CronTriggerImpl cti = new CronTriggerImpl("triggerName", "triggerGroup", "jobName", "jobGroup", new Date(0L), new Date(10000L), "0 0 12 * * ?", TimeZone.getTimeZone("Antarctica/South_Pole")); + cti.setDescription("A Trigger"); + cti.setJobDataMap(new JobDataMap()); + cti.setCalendarName("calendarName"); + cti.setMisfireInstruction(MISFIRE_INSTRUCTION_SMART_POLICY); + cti.setPriority(5); + + validateSerializedForm(cti, COMPARATOR, "serializedforms/CronTriggerImplSerializationTest.testConstructed.ser"); + } + + @Test + public void testFired() throws IOException, ClassNotFoundException, ParseException { + CronTriggerImpl cti = new CronTriggerImpl("triggerName", "triggerGroup", "jobName", "jobGroup", new Date(0L), new Date(10000L), "0 0 12 * * ?", TimeZone.getTimeZone("Antarctica/South_Pole")); + cti.setDescription("A Trigger"); + cti.setJobDataMap(new JobDataMap()); + cti.setCalendarName("calendarName"); + cti.setMisfireInstruction(MISFIRE_INSTRUCTION_SMART_POLICY); + cti.setPriority(5); + + cti.triggered(null); + + validateSerializedForm(cti, COMPARATOR, "serializedforms/CronTriggerImplSerializationTest.testFired.ser"); + + } + +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/FiredTriggerSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/FiredTriggerSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/FiredTriggerSerializationTest.java (revision 2430) @@ -0,0 +1,37 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import org.junit.Test; +import org.quartz.TriggerKey; +import org.terracotta.quartz.wrappers.FiredTrigger; + +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class FiredTriggerSerializationTest { + + @Test + public void testSimple() throws IOException, ClassNotFoundException { + FiredTrigger ft = new FiredTrigger("client-id", new TriggerKey("name", "group"), 10, 9); + validateSerializedForm(ft, "serializedforms/FiredTriggerSerializationTest.testSimple.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/AnnualCalendarSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/AnnualCalendarSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/AnnualCalendarSerializationTest.java (revision 2430) @@ -0,0 +1,84 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Calendar; +import java.util.Comparator; +import java.util.Locale; +import java.util.TimeZone; + +import org.junit.Test; +import org.quartz.impl.calendar.AnnualCalendar; +import org.quartz.impl.calendar.HolidayCalendar; + +import static java.util.Calendar.DAY_OF_MONTH; +import static java.util.Calendar.DECEMBER; +import static java.util.Calendar.MONTH; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class AnnualCalendarSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + + @Override + public int compare(AnnualCalendar o1, AnnualCalendar o2) { + return o1.getDaysExcluded().equals(o2.getDaysExcluded()) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && nullSafeEquals(o1.getTimeZone(), o2.getTimeZone()) + && ((o1.getBaseCalendar() == null) == (o2.getBaseCalendar() == null)) + ? 0 : -1; + } + }; + + @Test + public void testNoBaseSimple() throws IOException, ClassNotFoundException { + AnnualCalendar ac = new AnnualCalendar(); + validateSerializedForm(ac, COMPARATOR, "serializedforms/AnnualCalendarSerializationTest.testNoBaseSimple.ser"); + } + + @Test + public void testNoBaseComplex() throws IOException, ClassNotFoundException { + AnnualCalendar ac = new AnnualCalendar(); + Calendar exclude = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ROOT); + exclude.clear(); + exclude.set(MONTH, DECEMBER); + exclude.set(DAY_OF_MONTH, 29); + ac.setDayExcluded(exclude, true); + ac.setTimeZone(TimeZone.getTimeZone("Antarctica/South_Pole")); + ac.setDescription("Annual Calendar"); + validateSerializedForm(ac, COMPARATOR, "serializedforms/AnnualCalendarSerializationTest.testNoBaseComplex.ser"); + } + + @Test + public void testBaseCalendarAndComplex() throws IOException, ClassNotFoundException { + AnnualCalendar ac = new AnnualCalendar(new HolidayCalendar()); + Calendar exclude = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ROOT); + exclude.clear(); + exclude.set(MONTH, DECEMBER); + exclude.set(DAY_OF_MONTH, 29); + ac.setDayExcluded(exclude, true); + ac.setTimeZone(TimeZone.getTimeZone("Antarctica/South_Pole")); + ac.setDescription("Annual Calendar"); + validateSerializedForm(ac, COMPARATOR, "serializedforms/AnnualCalendarSerializationTest.testBaseCalendarAndComplex.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TimeOfDaySerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TimeOfDaySerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TimeOfDaySerializationTest.java (revision 2430) @@ -0,0 +1,39 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.terracotta.quartz.upgradability.serialization; + + +import java.io.IOException; +import org.junit.Test; +import org.quartz.TimeOfDay; + +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class TimeOfDaySerializationTest { + + @Test + public void testMidday() throws IOException, ClassNotFoundException { + TimeOfDay tod = new TimeOfDay(12, 00); + validateSerializedForm(tod, "serializedforms/TimeOfDaySerializationTest.testMidday.ser"); + } + + @Test + public void testMidnight() throws IOException, ClassNotFoundException { + TimeOfDay tod = new TimeOfDay(00, 00); + validateSerializedForm(tod, "serializedforms/TimeOfDaySerializationTest.testMidnight.ser"); + } + + @Test + public void testEagle() throws IOException, ClassNotFoundException { + TimeOfDay tod = new TimeOfDay(20, 17, 40); + validateSerializedForm(tod, "serializedforms/TimeOfDaySerializationTest.testEagle.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobDetailImplSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobDetailImplSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/JobDetailImplSerializationTest.java (revision 2430) @@ -0,0 +1,71 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import org.junit.Test; +import org.quartz.Job; +import org.quartz.JobDataMap; +import org.quartz.impl.JobDetailImpl; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class JobDetailImplSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + + @Override + public int compare(JobDetailImpl o1, JobDetailImpl o2) { + return o1.getName().equals(o2.getName()) && o1.getGroup().equals(o2.getGroup()) + && ((o1.getDescription() == null && o2.getDescription() == null) || o1.getDescription().equals(o2.getDescription())) + && o1.getJobClass().equals(o2.getJobClass()) + && o1.getJobDataMap().equals(o2.getJobDataMap()) + && o1.isDurable() == o2.isDurable() + && o1.requestsRecovery() == o2.requestsRecovery() + ? 0 : -1; + } + }; + + @Test + public void testMinimal() throws IOException, ClassNotFoundException { + JobDetailImpl jdi = new JobDetailImpl(); + jdi.setName("foo"); + jdi.setGroup("bar"); + jdi.setJobClass(Job.class); + validateSerializedForm(jdi, COMPARATOR, "serializedforms/JobDetailImplSerializationTest.testMinimal.ser"); + } + + @Test + public void testComplex() throws IOException, ClassNotFoundException { + JobDetailImpl jdi = new JobDetailImpl(); + jdi.setName("foo"); + jdi.setGroup("bar"); + jdi.setJobClass(Job.class); + + jdi.setDescription("My really fancy and complicated job"); + jdi.setJobDataMap(new JobDataMap(Collections.singletonMap("foo", "bar"))); + jdi.setDurability(true); + jdi.setRequestsRecovery(true); + + validateSerializedForm(jdi, COMPARATOR, "serializedforms/JobDetailImplSerializationTest.testComplex.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/MonthlyCalendarSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/MonthlyCalendarSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/MonthlyCalendarSerializationTest.java (revision 2430) @@ -0,0 +1,76 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Comparator; + +import org.junit.Test; +import org.quartz.impl.calendar.HolidayCalendar; +import org.quartz.impl.calendar.MonthlyCalendar; + +import static java.util.TimeZone.getTimeZone; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class MonthlyCalendarSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + + @Override + public int compare(MonthlyCalendar o1, MonthlyCalendar o2) { + return Arrays.equals(o1.getDaysExcluded(), o2.getDaysExcluded()) + && (o1.getBaseCalendar() != null) == (o2.getBaseCalendar() != null) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && nullSafeEquals(o1.getTimeZone(), o2.getTimeZone()) ? 0 : -1; + } + }; + + @Test + public void testNoDaysExcluded() throws IOException, ClassNotFoundException { + MonthlyCalendar mc = new MonthlyCalendar(); + mc.setDaysExcluded(new boolean[31]); + validateSerializedForm(mc, COMPARATOR, "serializedforms/MonthlyCalendarSerializationTest.testNoDaysExcluded.ser"); + } + + @Test + public void testDefaultExcluded() throws IOException, ClassNotFoundException { + MonthlyCalendar mc = new MonthlyCalendar(); + validateSerializedForm(mc, COMPARATOR, "serializedforms/MonthlyCalendarSerializationTest.testDefaultExcluded.ser"); + } + + @Test + public void testAllDaysExcluded() throws IOException, ClassNotFoundException { + MonthlyCalendar mc = new MonthlyCalendar(); + boolean[] excludeAll = new boolean[31]; + Arrays.fill(excludeAll, true); + mc.setDaysExcluded(excludeAll); + validateSerializedForm(mc, COMPARATOR, "serializedforms/MonthlyCalendarSerializationTest.testAllDaysExcluded.ser"); + } + + @Test + public void testExtendedProperties() throws IOException, ClassNotFoundException { + MonthlyCalendar mc = new MonthlyCalendar(new HolidayCalendar(), getTimeZone("Antarctica/South_Pole")); + mc.setDescription("A Calendar"); + validateSerializedForm(mc, COMPARATOR, "serializedforms/MonthlyCalendarSerializationTest.testExtendedProperties.ser"); + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TriggerWrapperSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TriggerWrapperSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/TriggerWrapperSerializationTest.java (revision 2430) @@ -0,0 +1,261 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Comparator; +import java.util.Date; +import org.junit.Test; +import org.quartz.Calendar; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.quartz.JobKey; +import org.quartz.ScheduleBuilder; +import org.quartz.SchedulerException; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; +import org.quartz.spi.OperableTrigger; +import org.terracotta.quartz.wrappers.DefaultWrapperFactory; +import org.terracotta.quartz.wrappers.TriggerFacade; +import org.terracotta.quartz.wrappers.TriggerWrapper; +import org.terracotta.quartz.wrappers.WrapperFactory; + +import static org.mockito.Mockito.mock; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class TriggerWrapperSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(TriggerWrapper o1, TriggerWrapper o2) { + return o1.jobDisallowsConcurrence() == o2.jobDisallowsConcurrence() + && nullSafeEquals(o1.getLastTerracotaClientId(), o2.getLastTerracotaClientId()) + && o1.getState() == o2.getState() + && (o1.getTriggerClone() == null) == (o2.getTriggerClone() == null) ? 0 : -1; + } + }; + + @Test + public void testSimple() throws IOException, ClassNotFoundException { + WrapperFactory factory = new DefaultWrapperFactory(); + TriggerWrapper tw = factory.createTriggerWrapper(new DummyOperableTrigger(), false); + validateSerializedForm(tw, COMPARATOR, "serializedforms/TriggerWrapperSerializationTest.testSimple.ser"); + } + + @Test + public void testAcquired() throws IOException, ClassNotFoundException { + WrapperFactory factory = new DefaultWrapperFactory(); + TriggerWrapper tw = factory.createTriggerWrapper(new DummyOperableTrigger(), false); + tw.setState(TriggerWrapper.TriggerState.ACQUIRED, "client-id", mock(TriggerFacade.class)); + validateSerializedForm(tw, COMPARATOR, "serializedforms/TriggerWrapperSerializationTest.testAcquired.ser"); + } + + static class DummyOperableTrigger implements OperableTrigger { + + @Override + public void triggered(Calendar calendar) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Date computeFirstFireTime(Calendar calendar) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public CompletedExecutionInstruction executionComplete(JobExecutionContext context, JobExecutionException result) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void updateAfterMisfire(Calendar cal) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void updateWithNewCalendar(Calendar cal, long misfireThreshold) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void validate() throws SchedulerException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setFireInstanceId(String id) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public String getFireInstanceId() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setNextFireTime(Date nextFireTime) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setPreviousFireTime(Date previousFireTime) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setKey(TriggerKey key) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setJobKey(JobKey key) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setDescription(String description) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setCalendarName(String calendarName) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setJobDataMap(JobDataMap jobDataMap) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setPriority(int priority) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setStartTime(Date startTime) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setEndTime(Date endTime) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void setMisfireInstruction(int misfireInstruction) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public TriggerKey getKey() { + return new TriggerKey("name", "group"); + } + + @Override + public JobKey getJobKey() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public String getDescription() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public String getCalendarName() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public JobDataMap getJobDataMap() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public int getPriority() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean mayFireAgain() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Date getStartTime() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Date getEndTime() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Date getNextFireTime() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Date getPreviousFireTime() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Date getFireTimeAfter(Date afterTime) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Date getFinalFireTime() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public int getMisfireInstruction() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public TriggerBuilder getTriggerBuilder() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public ScheduleBuilder getScheduleBuilder() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public int compareTo(Trigger other) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public DummyOperableTrigger clone() { + return new DummyOperableTrigger(); + } + } +} Index: trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/DailyTimeIntervalTriggerImplSerializationTest.java =================================================================== diff -u -N --- trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/DailyTimeIntervalTriggerImplSerializationTest.java (revision 0) +++ trunk/quartz/src/test/java/org/terracotta/quartz/upgradability/serialization/DailyTimeIntervalTriggerImplSerializationTest.java (revision 2430) @@ -0,0 +1,90 @@ +/* + * Copyright 2013 Terracotta, Inc.. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terracotta.quartz.upgradability.serialization; + +import java.io.IOException; +import java.util.Comparator; +import java.util.Date; + +import org.junit.Test; +import org.quartz.JobDataMap; +import org.quartz.TimeOfDay; +import org.quartz.impl.triggers.DailyTimeIntervalTriggerImpl; + +import static org.quartz.DateBuilder.IntervalUnit.MINUTE; +import static org.quartz.Trigger.MISFIRE_INSTRUCTION_SMART_POLICY; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.nullSafeEquals; +import static org.terracotta.upgradability.serialization.SerializationUpgradabilityTesting.validateSerializedForm; + +/** + * + * @author cdennis + */ +public class DailyTimeIntervalTriggerImplSerializationTest { + + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(DailyTimeIntervalTriggerImpl o1, DailyTimeIntervalTriggerImpl o2) { + return o1.getJobKey().equals(o2.getJobKey()) + && o1.getKey().equals(o2.getKey()) + && nullSafeEquals(o1.getDescription(), o2.getDescription()) + && (o1.getJobDataMap() == null) == (o2.getJobDataMap() == null) + && o1.getCalendarName().equals(o2.getCalendarName()) + && o1.getStartTime().equals(o2.getStartTime()) + && o1.getEndTime().equals(o2.getEndTime()) + && nullSafeEquals(o1.getNextFireTime(), o2.getNextFireTime()) + && nullSafeEquals(o1.getPreviousFireTime(), o2.getPreviousFireTime()) + && o1.getRepeatCount() == o2.getRepeatCount() + && o1.getRepeatInterval() == o2.getRepeatInterval() + && o1.getRepeatIntervalUnit().equals(o2.getRepeatIntervalUnit()) + && o1.getDaysOfWeek().equals(o2.getDaysOfWeek()) + && o1.getStartTimeOfDay().equals(o2.getStartTimeOfDay()) + && o1.getEndTimeOfDay().equals(o2.getEndTimeOfDay()) + && o1.getTimesTriggered() == o2.getTimesTriggered() + && nullSafeEquals(o1.getFireInstanceId(), o2.getFireInstanceId()) + && o1.getMisfireInstruction() == o2.getMisfireInstruction() + && o1.getPriority() == o2.getPriority() ? 0 : -1; + } + }; + + @Test + public void testConstructed() throws IOException, ClassNotFoundException { + DailyTimeIntervalTriggerImpl dti = new DailyTimeIntervalTriggerImpl("triggerName", "triggerGroup", "jobName", "jobGroup", new Date(0L), new Date(10000L), new TimeOfDay(10, 45, 30), new TimeOfDay(23, 30, 15), MINUTE, 5); + dti.setDescription("A Trigger"); + dti.setJobDataMap(new JobDataMap()); + dti.setCalendarName("calendarName"); + dti.setMisfireInstruction(MISFIRE_INSTRUCTION_SMART_POLICY); + dti.setPriority(5); + + validateSerializedForm(dti, COMPARATOR, "serializedforms/DailyTimeIntervalTriggerImplSerializationTest.testConstructed.ser"); + } + + @Test + public void testFired() throws IOException, ClassNotFoundException { + DailyTimeIntervalTriggerImpl dti = new DailyTimeIntervalTriggerImpl("triggerName", "triggerGroup", "jobName", "jobGroup", new Date(0L), new Date(10000L), new TimeOfDay(10, 45, 30), new TimeOfDay(23, 30, 15), MINUTE, 5); + dti.setDescription("A Trigger"); + dti.setJobDataMap(new JobDataMap()); + dti.setCalendarName("calendarName"); + dti.setMisfireInstruction(MISFIRE_INSTRUCTION_SMART_POLICY); + dti.setPriority(5); + + dti.triggered(null); + + validateSerializedForm(dti, COMPARATOR, "serializedforms/DailyTimeIntervalTriggerImplSerializationTest.testFired.ser"); + + } +}