Search in sources :

Example 6 with Language

use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.

the class SubmissionPersistenceImplTest method testSearchSubmissions6.

/**
	 * Tests searchSubmissions method
	 * @throws Exception to JUnit
	 */
public void testSearchSubmissions6() throws Exception {
    List submissions = null;
    SubmissionCriteria criteria = new SubmissionCriteria();
    criteria.setLanguages(Arrays.asList(new Object[] { language1, language3 }));
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] { submission1, submission3, submission4 }), submissions);
    criteria.setLanguages(Arrays.asList(new Object[] { language2 }));
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(Arrays.asList(new Object[] { submission2 }), submissions);
    criteria.setLanguages(Arrays.asList(new Object[] { new Language(4, "x", "x", "x", "x") }));
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
    criteria.setLanguages(new ArrayList());
    submissions = persistence.searchSubmissions(criteria, 0, 100);
    checkSubmissions(new ArrayList(), submissions);
}
Also used : Language(cn.edu.zju.acm.onlinejudge.bean.enumeration.Language) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) SubmissionCriteria(cn.edu.zju.acm.onlinejudge.bean.request.SubmissionCriteria)

Example 7 with Language

use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.

the class ShowLanguagesAction method execute.

/**
     * ShowLanguagesAction
     * 
     * <pre>
     * </pre>
     * 
     * @param mapping
     *            action mapping
     * @param form
     *            action form
     * @param request
     *            http servlet request
     * @param response
     *            http servlet response
     * 
     * @return action forward instance
     * 
     * @throws Exception
     *             any errors happened
     */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
    // check admin
    ActionForward forward = this.checkAdmin(mapping, context);
    if (forward != null) {
        return forward;
    }
    List<Language> languages = PersistenceManager.getInstance().getLanguagePersistence().getAllLanguages();
    context.setAttribute("Languages", languages);
    return this.handleSuccess(mapping, context, "success");
}
Also used : Language(cn.edu.zju.acm.onlinejudge.bean.enumeration.Language) ActionForward(org.apache.struts.action.ActionForward)

Example 8 with Language

use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.

the class ContestPersistenceImplTest method testDeleteLanguage1.

/**
	 * Tests deleteLanguage method
	 * @throws Exception to JUnit
	 */
public void testDeleteLanguage1() throws Exception {
    List languages = persistence.getAllLanguages();
    for (int i = 0; i < 3; ++i) {
        Language language = (Language) languages.get(i);
        long id = language.getId();
        persistence.deleteLanguage(id, 10);
    }
    languages = persistence.getAllLanguages();
    assertEquals("wrong size", 0, languages.size());
}
Also used : Language(cn.edu.zju.acm.onlinejudge.bean.enumeration.Language) List(java.util.List) ArrayList(java.util.ArrayList)

Example 9 with Language

use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.

the class ContestPersistenceImplTest method testGetAllLanguages.

/**
	 * Tests getAllLanguages method
	 * @throws Exception to JUnit
	 */
public void testGetAllLanguages() throws Exception {
    List languages = persistence.getAllLanguages();
    for (int i = 0; i < 3; ++i) {
        Language language = (Language) languages.get(i);
        long id = language.getId();
        assertEquals("wrong name", "language" + id, language.getName());
        assertEquals("wrong desc", "Language " + id, language.getDescription());
        assertEquals("wrong options", "options" + id, language.getOptions());
        assertEquals("wrong compiler", "compiler" + id, language.getCompiler());
    }
}
Also used : Language(cn.edu.zju.acm.onlinejudge.bean.enumeration.Language) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with Language

use of cn.edu.zju.acm.onlinejudge.bean.enumeration.Language in project zoj by licheng.

the class ContestPersistenceImplTest method testCreateLanguage.

/**
	 * Tests createLanguage method
	 * @throws Exception to JUnit
	 */
public void testCreateLanguage() throws Exception {
    persistence.createLanguage(new Language(4, "language4", "Language 4", "compiler4", "options4"), 10);
    List languages = persistence.getAllLanguages();
    for (int i = 0; i < 4; ++i) {
        Language language = (Language) languages.get(i);
        long id = language.getId();
        assertEquals("wrong name", "language" + id, language.getName());
        assertEquals("wrong desc", "Language " + id, language.getDescription());
        assertEquals("wrong options", "options" + id, language.getOptions());
        assertEquals("wrong compiler", "compiler" + id, language.getCompiler());
    }
}
Also used : Language(cn.edu.zju.acm.onlinejudge.bean.enumeration.Language) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Language (cn.edu.zju.acm.onlinejudge.bean.enumeration.Language)21 ArrayList (java.util.ArrayList)12 PreparedStatement (java.sql.PreparedStatement)8 Submission (cn.edu.zju.acm.onlinejudge.bean.Submission)7 ResultSet (java.sql.ResultSet)7 List (java.util.List)7 PersistenceException (cn.edu.zju.acm.onlinejudge.persistence.PersistenceException)6 Connection (java.sql.Connection)6 SQLException (java.sql.SQLException)6 Date (java.util.Date)5 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)4 Limit (cn.edu.zju.acm.onlinejudge.bean.Limit)3 Problemset (cn.edu.zju.acm.onlinejudge.bean.Problemset)3 JudgeReply (cn.edu.zju.acm.onlinejudge.bean.enumeration.JudgeReply)3 ActionForward (org.apache.struts.action.ActionForward)3 Course (cn.edu.zju.acm.onlinejudge.bean.Course)2 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)2 Reference (cn.edu.zju.acm.onlinejudge.bean.Reference)2 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)2 SubmissionCriteria (cn.edu.zju.acm.onlinejudge.bean.request.SubmissionCriteria)2