JobDetailObjectTest.cs :  » Inversion-of-Control-Dependency-Injection » Spring.net » Spring » Scheduling » Quartz » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Inversion of Control Dependency Injection » Spring.net 
Spring.net » Spring » Scheduling » Quartz » JobDetailObjectTest.cs
/*
* Copyright 2002-2005 the original author or authors.
* 
* 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.
*/

using System;
using System.Collections;

using NUnit.Framework;

using Quartz;
using Quartz.Job;

using Spring.Context.Support;

namespace Spring.Scheduling.Quartz{
    /// <summary>
    /// Tests for <see cref="JobDetailObject" />.
    /// </summary>
    /// <author>Marko Lahma (.NET)</author>
    [TestFixture]
    public class JobDetailObjectTest
    {
        private JobDetailObject jobDetail;

        /// <summary>
        /// Test setup.
        /// </summary>
        [SetUp]
        public void SetUp()
        {               
             jobDetail = new JobDetailObject();
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void TestJobType_Null()
        {
            jobDetail.JobType = null;            
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        public void TestJobType_NonIJob()
        {
            jobDetail.JobType = typeof(object);
            Assert.AreEqual(typeof(object), jobDetail.JobType, "JobDetail did not create same type as expected");
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        public void TestJobType_IJob()
        {
            Type CORRECT_IJOB = typeof (NoOpJob);
            jobDetail.JobType = CORRECT_IJOB;
            Assert.AreEqual(jobDetail.JobType, CORRECT_IJOB, "JobDetail did not register correct job type");
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void TestJobDataAsMap_Null()
        {
            jobDetail.JobDataAsMap = null;
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        public void TestJobDataAsMap_ProperValues()
        {
            IDictionary values = new Hashtable();
            values["baz"] = "foo";
            values["foo"] = 123;
            values["bar"] = null;
            jobDetail.JobDataAsMap = values;
            Assert.AreEqual(values.Count, jobDetail.JobDataMap.Count, "Data of inequal size");
            CollectionAssert.AreEqual(values.Keys, jobDetail.JobDataMap.Keys, "JobDataMap values not equal");
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        public void TestAfterPropertiesSet_Defaults()
        {
            const string objectName = "springJobDetailObject";
            jobDetail.ObjectName = objectName;
            jobDetail.Group = null;
            jobDetail.AfterPropertiesSet();
            Assert.AreEqual(SchedulerConstants.DefaultGroup, jobDetail.Group, "Groups differ");
            Assert.AreEqual(objectName, jobDetail.Name, "Names differ");
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        public void TestAfterPropertiesSet_CustomNameAndGroup()
        {
            const string objectName = "springJobDetailObject";
            const string jobDetailName = "jobDetailName";
            const string jobDetailGroup = "jobDetailGroup";
            jobDetail.ObjectName = objectName;
            jobDetail.Name = jobDetailName;
            jobDetail.Group = jobDetailGroup;
            jobDetail.AfterPropertiesSet();
            Assert.AreEqual(jobDetailGroup, jobDetail.Group, "Groups differ");
            Assert.AreEqual(jobDetailName, jobDetail.Name, "Names differ");
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        public void TestAfterPropertiesSet_ApplicationContextJobDataKeySetWithApplicationContext()
        {
            const string objectName = "springJobDetailObject";
            jobDetail.ObjectName = objectName;
            XmlApplicationContext ctx = new XmlApplicationContext();
            jobDetail.ApplicationContext = ctx;
            string key = "applicationContextJobDataKey";
            jobDetail.ApplicationContextJobDataKey = key;
            jobDetail.AfterPropertiesSet();
            Assert.AreSame(ctx, jobDetail.ApplicationContext, "ApplicationContext was not set correctly");
            Assert.AreSame(ctx, jobDetail.JobDataMap[key], "ApplicationContext was not set to job data map");
        }

        /// <summary>
        /// Tests job detail's property behavior.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void TestAfterPropertiesSet_ApplicationContextJobDataKeySetWithoutApplicationContext()
        {
            const string objectName = "springJobDetailObject";
            jobDetail.ObjectName = objectName;
            jobDetail.ApplicationContextJobDataKey = "applicationContextJobDataKey";
            jobDetail.AfterPropertiesSet();
        }

    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.