View Javadoc

1   package org.ogf.saga.context;
2   
3   import org.junit.Test;
4   import java.lang.reflect.InvocationTargetException;
5   import java.lang.reflect.Method;
6   
7   /* ***************************************************
8   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
9   * ***             http://cc.in2p3.fr/             ***
10  * ***************************************************
11  * File:   ContextDestroyTest
12  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
13  * Date:   16 sept. 2008
14  * ***************************************************
15  * Description:                                      */
16  /**
17   *
18   */
19  public abstract class ContextDestroyTest extends ContextTest {
20  
21      protected ContextDestroyTest(String contextId) throws Exception {
22          super(contextId);
23      }
24  
25      @Test
26      public void destroy() throws Exception {
27          // create context
28          Context context = ContextFactory.createContext();
29          context.setAttribute(Context.TYPE, m_contextId);
30  
31          // destroy context
32          destroyContext(context);
33      }
34  
35      private static void destroyContext(Context context) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
36          Method m = context.getClass().getMethod("destroy");
37          if (m != null) {
38              m.invoke(context);
39          }
40      }
41  }