Kawai Wiki

Rev

Rev 189 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 189 Rev 196
Line 53... Line 53...
53
    private JdbcUserDAO jdbcUserDAO;
53
    private JdbcUserDAO jdbcUserDAO;
54
    /**
54
    /**
55
     * Attribute jdbcPageDAO of PageActionTest.
55
     * Attribute jdbcPageDAO of PageActionTest.
56
     */
56
     */
57
    private JdbcPageDAO jdbcPageDAO;
57
    private JdbcPageDAO jdbcPageDAO;
58
        /**
-
 
59
         * Attribute beanSession of PageActionTest.
-
 
60
         */
-
 
61
        private BeanSession beanSession;
-
 
-
 
58
    /**
-
 
59
     * Attribute beanSession of PageActionTest.
-
 
60
     */
-
 
61
    private BeanSession beanSession;
62
62
63
    /**
63
    /**
64
     * Default setUp method.
64
     * Default setUp method.
65
     * @throws Exception
65
     * @throws Exception
66
     */
66
     */
67
    @Before
67
    @Before
68
    public void setUp() throws Exception {
68
    public void setUp() throws Exception {
69
69
70
        BeanManager beanManager = new BeanManager();
-
 
71
        BeanConfig beanConfig = new BeanConfig(Page.class, "Pages");
-
 
72
                beanConfig.pk("id", "id", DBTypes.AUTOINCREMENT);
-
 
73
                beanConfig.field("name", DBTypes.STRING);
-
 
74
                beanConfig.field("title", DBTypes.STRING);
-
 
75
                beanConfig.field("body", DBTypes.STRING);
-
 
76
                beanConfig.field("languageId", "language_id", DBTypes.STRING);
-
 
77
                beanConfig.field("systemPage", "system_page", DBTypes.BOOLEANSTRING);
-
 
78
                beanConfig.field("frontPage", "front_page", DBTypes.BOOLEANSTRING);
-
 
79
                beanConfig.field("modifiedById", "modified_by", DBTypes.INTEGER);
-
 
80
                beanConfig.field("modifiedOn", "modified_on", DBTypes.NOW_ON_UPDATE_TIMESTAMP);
-
 
81
                beanConfig.field("createdById", "created_by", DBTypes.INTEGER);
-
 
82
                beanConfig.field("createdOn", "created_on", DBTypes.NOW_ON_INSERT_TIMESTAMP);
-
 
83
                beanConfig.field("deleted", DBTypes.BOOLEANSTRING);
-
 
-
 
70
        BeanManager beanManager = new BeanManager();
-
 
71
        BeanConfig beanConfig = new BeanConfig(Page.class, "Pages");
-
 
72
        beanConfig.pk("id", "id", DBTypes.AUTOINCREMENT);
-
 
73
        beanConfig.field("name", DBTypes.STRING);
-
 
74
        beanConfig.field("title", DBTypes.STRING);
-
 
75
        beanConfig.field("body", DBTypes.STRING);
-
 
76
        beanConfig.field("languageId", "language_id", DBTypes.STRING);
-
 
77
        beanConfig.field("systemPage", "system_page", DBTypes.BOOLEANSTRING);
-
 
78
        beanConfig.field("frontPage", "front_page", DBTypes.BOOLEANSTRING);
-
 
79
        beanConfig.field("modifiedById", "modified_by", DBTypes.INTEGER);
-
 
80
        beanConfig.field("modifiedOn", "modified_on", DBTypes.NOW_ON_UPDATE_TIMESTAMP);
-
 
81
        beanConfig.field("createdById", "created_by", DBTypes.INTEGER);
-
 
82
        beanConfig.field("createdOn", "created_on", DBTypes.NOW_ON_INSERT_TIMESTAMP);
-
 
83
        beanConfig.field("deleted", DBTypes.BOOLEANSTRING);
84
84
85
                beanManager.addBeanConfig(beanConfig);
-
 
-
 
85
        beanManager.addBeanConfig(beanConfig);
86
86
87
                beanConfig = new BeanConfig(User.class, "Users");
-
 
88
                beanConfig.pk("id", DBTypes.AUTOINCREMENT);
-
 
89
                beanConfig.field("username", DBTypes.STRING);
-
 
90
                beanConfig.field("password", DBTypes.STRING);
-
 
91
                beanConfig.field("groupId", "group_id", DBTypes.INTEGER);
-
 
-
 
87
        beanConfig = new BeanConfig(User.class, "Users");
-
 
88
        beanConfig.pk("id", DBTypes.AUTOINCREMENT);
-
 
89
        beanConfig.field("username", DBTypes.STRING);
-
 
90
        beanConfig.field("password", DBTypes.STRING);
-
 
91
        beanConfig.field("groupId", "group_id", DBTypes.INTEGER);
92
92
93
                beanManager.addBeanConfig(beanConfig);
-
 
-
 
93
        beanManager.addBeanConfig(beanConfig);
94
94
95
                Class.forName("com.mysql.jdbc.Driver");
-
 
96
                Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/Kawai?autoReconnect=true", "kawai", "1kawai23");
-
 
97
                beanSession = new MySQLBeanSession(beanManager, conn);
-
 
-
 
95
        Class.forName("com.mysql.jdbc.Driver");
-
 
96
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/Kawai?autoReconnect=true", "kawai", "1kawai23");
-
 
97
        beanSession = new MySQLBeanSession(beanManager, conn);
98
98
99
                userDAO = new JdbcUserDAO(beanSession);
-
 
100
                pageDAO = new JdbcPageDAO(beanSession);
-
 
-
 
99
        userDAO = new JdbcUserDAO(beanSession);
-
 
100
        pageDAO = new JdbcPageDAO(beanSession);
101
101
102
        action = new PageAction(userDAO, pageDAO);
-
 
-
 
102
        action = new PageAction(userDAO, pageDAO);
103
        mockAction = new MockAction(action);
103
        mockAction = new MockAction(action);
104
        action.setInput(mockAction.getInput());
104
        action.setInput(mockAction.getInput());
105
        action.setOutput(mockAction.getOutput());
105
        action.setOutput(mockAction.getOutput());
106
    }
106
    }
107
107
Line 109... Line 109...
109
     * Test method executeTest.
109
     * Test method executeTest.
110
     */
110
     */
111
    @Ignore
111
    @Ignore
112
    @Test
112
    @Test
113
    public void executeTest() {
113
    public void executeTest() {
114
        action.getInput().setValue("name", "Page");
-
 
115
        action.getInput().setValue("lang", "pt");
-
 
-
 
114
        action.getInput().setValue("name", "Page");
-
 
115
        action.getInput().setValue("lang", "pt");
116
        action.execute();
116
        action.execute();
117
    }
117
    }
118
118
119
    /**
119
    /**
120
     * Test method getLastRevisionsTest.
120
     * Test method getLastRevisionsTest.
121
     */
121
     */
122
    @Ignore
122
    @Ignore
123
    @Test
123
    @Test
124
    public void getLastRevisionsTest() {
124
    public void getLastRevisionsTest() {
125
        action.getInput().setValue("lang", "en_US");
-
 
126
        action.getLastRevisions();
-
 
-
 
125
        action.getInput().setValue("lang", "en_US");
-
 
126
        action.getLastRevisions();
-
 
127
    }
-
 
128
-
 
129
    /**
-
 
130
     * Test method bypassAuthenticationTest.
-
 
131
     */
-
 
132
    @Test
-
 
133
    public void bypassAuthenticationTest() {
-
 
134
        action.bypassAuthentication("getCSS");
-
 
135
        action.bypassAuthentication("getPrintCSS");
-
 
136
        action.bypassAuthentication("getLastRevisions");
-
 
137
    }
-
 
138
-
 
139
    /**
-
 
140
     * Test method beforeValidationTest.
-
 
141
     */
-
 
142
    @Test
-
 
143
    public void beforeValidationTest() {
-
 
144
        action.beforeValidation("");
-
 
145
    }
-
 
146
-
 
147
    /**
-
 
148
     * Test method afterValidationTest.
-
 
149
     */
-
 
150
    @Test
-
 
151
    public void afterValidationTest() {
-
 
152
        action.afterValidation("add", true);
-
 
153
    }
-
 
154
-
 
155
    /**
-
 
156
     * Test method checkPageDoesNotExistTest.
-
 
157
     */
-
 
158
    @Test
-
 
159
    public void checkPageDoesNotExistTest() {
-
 
160
        action.getInput().setValue("newPage", new Page());
-
 
161
        action.checkPageDoesNotExist();
-
 
162
    }
-
 
163
-
 
164
    /**
-
 
165
     * Test method checkNotSystemPageTest.
-
 
166
     */
-
 
167
    @Test
-
 
168
    public void checkNotSystemPageTest() {
-
 
169
        action.getInput().setValue("newPage", new Page());
-
 
170
        action.checkNotSystemPage();
-
 
171
    }
-
 
172
-
 
173
    /**
-
 
174
     * Test method getTest.
-
 
175
     */
-
 
176
    @Test
-
 
177
    public void getTest() {
-
 
178
        action.getInput().setValue("name", "Page1");
-
 
179
        action.getInput().setValue("lang", "pt");
-
 
180
        action.getInput().setValue("revision", -1);
-
 
181
        action.get();
-
 
182
    }
-
 
183
-
 
184
    /**
-
 
185
     * Test method getPreviewTest.
-
 
186
     */
-
 
187
    @Test
-
 
188
    public void getPreviewTest() {
-
 
189
        action.getInput().setValue("name", "Page1");
-
 
190
        action.getInput().setValue("lang", "pt");
-
 
191
        action.getPreview();
-
 
192
    }
-
 
193
-
 
194
    /**
-
 
195
     * Test method getRevisionsTest.
-
 
196
     */
-
 
197
    @Ignore
-
 
198
    @Test
-
 
199
    public void getRevisionsTest() {
-
 
200
        action.getInput().setValue("name", "Page1");
-
 
201
        action.getInput().setValue("lang", "pt");
-
 
202
        action.getRevisions();
127
    }
203
    }
128
204
129
    /**
205
    /**
130
     * Test method prepareValidatorTest.
206
     * Test method prepareValidatorTest.
131
     */
207
     */