1 16 package org.apache.cocoon.components.thread; 17 18 import junit.framework.TestCase; 19 20 21 27 public class DefaultThreadFactoryTestCase extends TestCase 28 { 29 31 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 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 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 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 73 public final void testSetDaemon( ) 74 { 75 final DefaultThreadFactory factory = new DefaultThreadFactory( ); 76 factory.setDaemon( false ); 77 78 final Thread thread = factory.newThread( new DummyRunnable( ) ); 79 assertEquals( "daemon mode", false, thread.isDaemon( ) ); 80 } 81 82 85 public final void testSetPriority( ) 86 { 87 final DefaultThreadFactory factory = new DefaultThreadFactory( ); 88 factory.setPriority( Thread.MAX_PRIORITY ); 89 90 final Thread thread = factory.newThread( new DummyRunnable( ) ); 91 assertEquals( "priority", Thread.MAX_PRIORITY, thread.getPriority( ) ); 92 } 93 94 96 102 private static class DummyRunnable implements Runnable 103 { 104 106 109 public void run( ) 110 { 111 } 113 } 114 } 115 | Popular Tags |