View Javadoc
1   package org.melati.poem.test;
2   
3   import java.util.Enumeration;
4   
5   import org.melati.poem.AccessPoemException;
6   import org.melati.poem.AlreadyInSessionPoemException;
7   import org.melati.poem.Capability;
8   import org.melati.poem.Column;
9   import org.melati.poem.PoemThread;
10  import org.melati.poem.transaction.ToTidyList;
11  
12  /**
13   * @author timp
14   * @since 24 Jan 2007
15   *
16   */
17  public class PoemThreadTest extends PoemTestCase {
18  
19    public PoemThreadTest(String name) {
20      super(name);
21    }
22  
23    protected void setUp() throws Exception {
24      super.setUp();
25    }
26  
27    protected void tearDown() throws Exception {
28      super.tearDown();
29    }
30  
31    /**
32     * Check that exception it thrown.
33     */
34    public void testAlreadyInSession() {
35      try {
36        getDb().beginSession(PoemThread.accessToken());
37        fail("Should have blown up");
38      } catch (AlreadyInSessionPoemException e) { 
39        e = null;
40      }
41    }
42  
43    /**
44     * Called in SessionAnalysisServlet.
45     * Test method for {@link org.melati.poem.PoemThread#openSessions()}.
46     */
47    public void testOpenSessions() {
48      assertEquals(1, PoemThread.openSessions().size());
49    }
50  
51    /**
52     * Test method for {@link org.melati.poem.PoemThread#toTidy()}.
53     */
54    public void testToTidy() {
55      ToTidyList list = PoemThread.toTidy();
56      Enumeration<Object> en = list.elements();
57      int count = 0;
58      while (en.hasMoreElements()) { 
59        count++;
60        en.nextElement();
61      }
62      assertEquals(0, count);
63    }
64  
65    /**
66     * Test method for {@link org.melati.poem.PoemThread#transaction()}.
67     */
68    public void testTransaction() {
69      
70    }
71  
72    /**
73     * Test method for {@link org.melati.poem.PoemThread#inSession()}.
74     */
75    public void testInSession() {
76      
77    }
78  
79    /**
80     * Test method for {@link org.melati.poem.PoemThread#accessToken()}.
81     */
82    public void testAccessToken() {
83      
84    }
85  
86    /**
87     * Test method for {@link org.melati.poem.PoemThread#
88     * setAccessToken(org.melati.poem.AccessToken)}.
89     */
90    public void testSetAccessToken() {
91      
92    }
93  
94    /**
95     * Test method for {@link org.melati.poem.PoemThread#
96     * withAccessToken(org.melati.poem.AccessToken, org.melati.poem.PoemTask)}.
97     */
98    public void testWithAccessToken() {
99      
100   }
101 
102   /**
103    * Not used in Melati.
104    * Test method for {@link org.melati.poem.PoemThread#
105    * assertHasCapability(org.melati.poem.Capability)}.
106    */
107   public void testAssertHasCapability() {
108     Column<?> c = getDb().getCapabilityTable().getNameColumn();
109     Capability canWrite = (Capability)c.firstWhereEq("canRead");
110     assertNotNull(canWrite);
111     PoemThread.assertHasCapability(canWrite);
112     PoemThread.assertHasCapability(null);
113     PoemThread.setAccessToken(getDb().guestAccessToken());
114     try { 
115       PoemThread.assertHasCapability(canWrite);
116       fail("Should have blown up");
117     } catch (AccessPoemException e) { 
118       e = null;
119     }
120   }
121 
122   /**
123    * Test method for {@link org.melati.poem.PoemThread#database()}.
124    */
125   public void testDatabase() {
126     
127   }
128 
129   /**
130    * Test method for {@link org.melati.poem.PoemThread#writeDown()}.
131    */
132   public void testWriteDown() {
133     
134   }
135 
136   /**
137    * Test method for {@link org.melati.poem.PoemThread#commit()}.
138    */
139   public void testCommit() {
140     
141   }
142 
143   /**
144    * Test method for {@link org.melati.poem.PoemThread#rollback()}.
145    */
146   public void testRollback() {
147     
148   }
149 
150 }