Index: src/test/java/org/quartz/CronTriggerTest.java =================================================================== --- src/test/java/org/quartz/CronTriggerTest.java (revision 0) +++ src/test/java/org/quartz/CronTriggerTest.java (revision 0) @@ -0,0 +1,47 @@ +/* + * Copyright 2007 OpenSymphony + * + * 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.quartz; + +import junit.framework.TestCase; + +import java.text.ParseException; + +/** + * Unit test for CronTrigger. + */ +public class CronTriggerTest extends TestCase { + + public void testClone() throws ParseException { + CronTrigger trigger = new CronTrigger("test", "testgroup", "0 0 12 * * ?"); + CronTrigger trigger2 = (CronTrigger) trigger.clone(); + + assertEquals( "Cloning failed", trigger, trigger2 ); + + // equals() doesn't test the cron expression + assertEquals( "Cloning failed for the cron expression", + "0 0 12 * * ?", trigger2.getCronExpression() + ); + } + + // http://jira.opensymphony.com/browse/QUARTZ-558 + public void testQuartz558() throws ParseException { + CronTrigger trigger = new CronTrigger("test", "testgroup"); + CronTrigger trigger2 = (CronTrigger) trigger.clone(); + + assertEquals( "Cloning failed", trigger, trigger2 ); + } + +} Index: src/java/org/quartz/CronTrigger.java =================================================================== --- src/java/org/quartz/CronTrigger.java (revision 656) +++ src/java/org/quartz/CronTrigger.java (working copy) @@ -437,7 +437,9 @@ public Object clone() { CronTrigger copy = (CronTrigger) super.clone(); - copy.setCronExpression((CronExpression)cronEx.clone()); + if (cronEx != null) { + copy.setCronExpression((CronExpression)cronEx.clone()); + } return copy; }