1   package com.atlassian.plugins.codegen.modules.common.servlet;
2   
3   import com.atlassian.plugins.codegen.AbstractModuleCreatorTestCase;
4   
5   import org.junit.Before;
6   import org.junit.Test;
7   
8   import static junit.framework.Assert.assertEquals;
9   
10  /**
11   * @since 3.6
12   */
13  public class ServletContextListenerTest extends AbstractModuleCreatorTestCase<ServletContextListenerProperties>
14  {
15      public ServletContextListenerTest()
16      {
17          super("servlet-context-listener", new ServletContextListenerModuleCreator());
18      }
19      
20      @Before
21      public void setupProps() throws Exception
22      {
23          setProps(new ServletContextListenerProperties(PACKAGE_NAME + ".MyServletContextListener"));
24          props.setIncludeExamples(false);
25      }
26  
27      @Test
28      public void classFileIsGenerated() throws Exception
29      {
30          getSourceFile(PACKAGE_NAME, "MyServletContextListener");
31      }
32  
33      @Test
34      public void unitTestFileIsGenerated() throws Exception
35      {
36          getTestSourceFile(TEST_PACKAGE_NAME, "MyServletContextListenerTest");
37      }
38  
39      @Test
40      public void moduleHasDefaultKey() throws Exception
41      {
42          assertEquals("my-servlet-context-listener",
43                       getGeneratedModule().attributeValue("key"));
44      }
45      
46      @Test
47      public void moduleHasClass() throws Exception
48      {
49          assertEquals(PACKAGE_NAME + ".MyServletContextListener", getGeneratedModule().attributeValue("class"));
50      }
51  }