KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > thread > DefaultThreadFactoryTestCase


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.thread;
17
18 import junit.framework.TestCase;
19
20
21 /**
22  * The $classType$ class ...
23  *
24  * @author <a HREF="mailto:giacomo.at.apache.org">Giacomo Pati</a>
25  * @version $Id$
26  */

27 public class DefaultThreadFactoryTestCase extends TestCase
28 {
29     //~ Methods ----------------------------------------------------------------
30

31     /**
32      * DOCUMENT ME!
33      */

34     public final void testGetPriority( )
35     {
36         final DefaultThreadFactory factory = new DefaultThreadFactory( );
37         factory.setPriority( Thread.MAX_PRIORITY );
38         assertEquals( "priority", Thread.MAX_PRIORITY, factory.getPriority( ) );
39     }
40
41     /**
42      * DOCUMENT ME!
43      */

44     public final void testIsDaemon( )
45     {
46         final DefaultThreadFactory factory = new DefaultThreadFactory( );
47         factory.setDaemon( false );
48         assertEquals( "daemon mode", false, factory.isDaemon( ) );
49     }
50
51     /**
52      * DOCUMENT ME!
53      */

54     public final void testNewThread( )
55     {
56         final DefaultThreadFactory factory = new DefaultThreadFactory( );
57         factory.setDaemon( true );
58         factory.setPriority( Thread.MIN_PRIORITY );
59
60         final Thread JavaDoc thread = factory.newThread( new DummyRunnable( ) );
61         assertEquals( "new thread daemon mode", true, thread.isDaemon( ) );
62         assertEquals( "new thread priority", Thread.MIN_PRIORITY,
63                       thread.getPriority( ) );
64         assertEquals( "factory daemon mode", factory.isDaemon( ),
65                       thread.isDaemon( ) );
66         assertEquals( "factory priority", factory.getPriority( ),
67                       thread.getPriority( ) );
68     }
69
70     /**
71      * DOCUMENT ME!
72      */

73     public final void testSetDaemon( )
74     {
75         final DefaultThreadFactory factory = new DefaultThreadFactory( );
76         factory.setDaemon( false );
77
78         final Thread JavaDoc thread = factory.newThread( new DummyRunnable( ) );
79         assertEquals( "daemon mode", false, thread.isDaemon( ) );
80     }
81
82     /**
83      * DOCUMENT ME!
84      */

85     public final void testSetPriority( )
86     {
87         final DefaultThreadFactory factory = new DefaultThreadFactory( );
88         factory.setPriority( Thread.MAX_PRIORITY );
89
90         final Thread JavaDoc thread = factory.newThread( new DummyRunnable( ) );
91         assertEquals( "priority", Thread.MAX_PRIORITY, thread.getPriority( ) );
92     }
93
94     //~ Inner Classes ----------------------------------------------------------
95

96     /**
97      * The $classType$ class ...
98      *
99      * @author <a HREF="mailto:giacomo.at.apache.org">Giacomo Pati</a>
100      * @version $Id$
101      */

102     private static class DummyRunnable implements Runnable JavaDoc
103     {
104         //~ Methods ------------------------------------------------------------
105

106         /**
107          * DOCUMENT ME!
108          */

109         public void run( )
110         {
111             // nothing
112
}
113     }
114 }
115
Popular Tags