1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.webapp;
20
21 import static org.easymock.EasyMock.*;
22
23 import javax.el.ELContext;
24 import javax.el.ELContextEvent;
25 import javax.el.ELContextListener;
26 import javax.faces.application.Application;
27 import javax.faces.context.FacesContext;
28
29 import junit.framework.TestCase;
30
31 import org.apache.myfaces.test.mock.MockFacesContext12;
32 import org.easymock.IMocksControl;
33 import org.easymock.classextension.EasyMock;
34
35
36
37
38
39 public class FacesELContextListenerTest extends TestCase
40 {
41
42
43
44
45 public void testContextCreated()
46 {
47 FacesELContextListener listener = new FacesELContextListener();
48 IMocksControl mockControl = EasyMock.createControl();
49 ELContext elctx = mockControl.createMock(ELContext.class);
50 MockFacesContext12 facesctx = new MockFacesContext12();
51 Application app = mockControl.createMock(Application.class);
52 facesctx.setApplication(app);
53 ELContextEvent event = mockControl.createMock(ELContextEvent.class);
54 expect(event.getELContext()).andReturn(elctx);
55 elctx.putContext(eq(FacesContext.class), same(facesctx));
56 ELContextListener elctxListener = mockControl.createMock(ELContextListener.class);
57 expect(app.getELContextListeners()).andReturn(new ELContextListener[] { elctxListener });
58 elctxListener.contextCreated(same(event));
59 mockControl.replay();
60 listener.contextCreated(event);
61 mockControl.verify();
62 }
63
64 }