001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.thread;
018:
019: import junit.framework.TestCase;
020:
021: /**
022: * The $classType$ class ...
023: *
024: * @author <a href="mailto:giacomo.at.apache.org">Giacomo Pati</a>
025: * @version $Id$
026: */
027: public class DefaultThreadFactoryTestCase extends TestCase {
028: //~ Methods ----------------------------------------------------------------
029:
030: /**
031: * DOCUMENT ME!
032: */
033: public final void testGetPriority() {
034: final DefaultThreadFactory factory = new DefaultThreadFactory();
035: factory.setPriority(Thread.MAX_PRIORITY);
036: assertEquals("priority", Thread.MAX_PRIORITY, factory
037: .getPriority());
038: }
039:
040: /**
041: * DOCUMENT ME!
042: */
043: public final void testIsDaemon() {
044: final DefaultThreadFactory factory = new DefaultThreadFactory();
045: factory.setDaemon(false);
046: assertEquals("daemon mode", false, factory.isDaemon());
047: }
048:
049: /**
050: * DOCUMENT ME!
051: */
052: public final void testNewThread() {
053: final DefaultThreadFactory factory = new DefaultThreadFactory();
054: factory.setDaemon(true);
055: factory.setPriority(Thread.MIN_PRIORITY);
056:
057: final Thread thread = factory.newThread(new DummyRunnable());
058: assertEquals("new thread daemon mode", true, thread.isDaemon());
059: assertEquals("new thread priority", Thread.MIN_PRIORITY, thread
060: .getPriority());
061: assertEquals("factory daemon mode", factory.isDaemon(), thread
062: .isDaemon());
063: assertEquals("factory priority", factory.getPriority(), thread
064: .getPriority());
065: }
066:
067: /**
068: * DOCUMENT ME!
069: */
070: public final void testSetDaemon() {
071: final DefaultThreadFactory factory = new DefaultThreadFactory();
072: factory.setDaemon(false);
073:
074: final Thread thread = factory.newThread(new DummyRunnable());
075: assertEquals("daemon mode", false, thread.isDaemon());
076: }
077:
078: /**
079: * DOCUMENT ME!
080: */
081: public final void testSetPriority() {
082: final DefaultThreadFactory factory = new DefaultThreadFactory();
083: factory.setPriority(Thread.MAX_PRIORITY);
084:
085: final Thread thread = factory.newThread(new DummyRunnable());
086: assertEquals("priority", Thread.MAX_PRIORITY, thread
087: .getPriority());
088: }
089:
090: //~ Inner Classes ----------------------------------------------------------
091:
092: /**
093: * The $classType$ class ...
094: *
095: * @author <a href="mailto:giacomo.at.apache.org">Giacomo Pati</a>
096: * @version $Id$
097: */
098: private static class DummyRunnable implements Runnable {
099: //~ Methods ------------------------------------------------------------
100:
101: /**
102: * DOCUMENT ME!
103: */
104: public void run() {
105: // nothing
106: }
107: }
108: }
|