1 package org.myorg.encconfig.auditor.ejb;
2
3 import javax.naming.Context;
4 import javax.naming.InitialContext;
5 import javax.naming.NamingException;
6
7 import static org.junit.Assert.*;
8
9 import org.junit.After;
10 import org.junit.Before;
11 import org.junit.Ignore;
12 import org.junit.Test;
13 import org.myorg.encconfig.ejb.AuditorRemote;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17
18
19
20
21 @Ignore
22 public abstract class AuditorCheckerITBase {
23 private static final Logger log = LoggerFactory.getLogger(AuditorCheckerITBase.class);
24
25 private String jndiName;
26 private Context jndi;
27
28 protected AuditorCheckerITBase(String jndiName) {
29 this.jndiName=jndiName;
30 }
31
32 @Before
33 public void setUp() {
34 log.info("using {}", jndiName);
35 }
36
37 @After
38 public void tearDown() throws NamingException {
39 if (jndi!=null){
40 log.debug("closing jndi");
41 jndi.close();
42 log.debug("jndi closed");
43 }
44 }
45
46 private AuditorRemote getAuditor() throws NamingException {
47 if (jndi==null) {
48 jndi=new InitialContext();
49 }
50 return (AuditorRemote)jndi.lookup(jndiName);
51 }
52
53
54 @Ignore
55 @Test
56 public void testPublishJMS() throws NamingException {
57 log.info("*** testPublishJMS() ***");
58 assertTrue("publishJMS value not injected",
59 getAuditor().isPublishJMS());
60 }
61
62
63 @Ignore
64 @Test
65 public void testPersistenceContext() throws NamingException {
66 log.info("*** testPersistenceContext() ***");
67 assertTrue("persistence context not injected",
68 getAuditor().havePersistenceContext());
69 }
70
71
72 @Ignore
73 @Test
74 public void testTopic() throws NamingException {
75 log.info("*** testTopic() ***");
76 assertTrue("topic not injected", getAuditor().haveTopic());
77 }
78
79
80 @Ignore
81 @Test
82 public void testConnectionFactory() throws NamingException {
83 log.info("*** testConnectionFactory() ***");
84 assertTrue("connection factory not injected",
85 getAuditor().haveConnectionFactory());
86 }
87
88
89 @Ignore
90 @Test
91 public void testAudit() throws NamingException {
92 log.info("*** testAudit() ***");
93 assertEquals("EJB not properly initialized", 2,
94 getAuditor().audit("hello resources!!!"));
95 }
96 }