summaryrefslogtreecommitdiff
path: root/qpid/java/common/src/test/java/org/apache/qpid/thread/ThreadFactoryTest.java
blob: 9932633cb94056bdcf8385dec98bce04fe72b9ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.apache.qpid.thread;

import junit.framework.TestCase;

public class ThreadFactoryTest extends TestCase
{
    public void testThreadFactory()
    {
        Class threadFactoryClass = null;
        try
        {
            threadFactoryClass = Class.forName(System.getProperty("qpid.thread_factory",
                    "org.apache.qpid.thread.DefaultThreadFactory"));            
        }
        // If the thread factory class was wrong it will flagged way before it gets here.
        catch(Exception e)
        {            
            fail("Invalid thread factory class");
        }
        
        assertEquals(threadFactoryClass, Threading.getThreadFactory().getClass());
    }
    
    public void testThreadCreate()
    {
        Runnable r = new Runnable(){
          
            public void run(){
                
            }            
        };
        
        Thread t = null;
        try
        {
            t = Threading.getThreadFactory().createThread(r,5);
        }
        catch(Exception e)
        {
            fail("Error creating thread using Qpid thread factory");
        }
        
        assertNotNull(t);
        assertEquals(5,t.getPriority());
    }
}