1 package org.ogf.saga.context;
2
3 import org.junit.Test;
4 import org.ogf.saga.session.Session;
5 import org.ogf.saga.session.SessionFactory;
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public abstract class ContextInfoTest extends ContextTest {
20 private static String ALL_CONTEXTS = "all";
21
22 protected ContextInfoTest() throws Exception {
23 super(ALL_CONTEXTS);
24 }
25
26 protected ContextInfoTest(String contextId) throws Exception {
27 super(contextId);
28 }
29
30 @Test
31 public void info() throws Exception {
32
33
34 if (this.m_contextId.equals(ALL_CONTEXTS)) {
35 Session session = SessionFactory.createSession();
36 Context[] contexts = session.listContexts();
37 for (int i=0; i<contexts.length; i++) {
38 Context context = contexts[i];
39
40
41 System.out.println("Security context: "+context.getAttribute(Context.TYPE));
42
43 System.out.println(context);
44 }
45 session.close();
46 } else {
47 Session session = SessionFactory.createSession(false);
48 Context context = ContextFactory.createContext();
49 context.setAttribute(Context.TYPE, m_contextId);
50
51
52 this.updateContextAttributes(context);
53
54
55 try {
56 session.addContext(context);
57 } catch(Exception e) {
58 System.out.println(" Context not initialized ["+e.getMessage()+"]");
59 }
60
61
62 System.out.println(context);
63 session.close();
64 }
65 }
66 }