Package cn.edu.zju.acm.onlinejudge.bean

Examples of cn.edu.zju.acm.onlinejudge.bean.Configuration


            try {
                ps = conn.prepareStatement(ConfigurationPersistenceImpl.GET_ALL_CONFIGURATIONS);
                ResultSet rs = ps.executeQuery();
                List<Configuration> configurations = new ArrayList<Configuration>();
                while (rs.next()) {
                    Configuration configuration = new Configuration();
                    configuration.setName(rs.getString(DatabaseConstants.CONFIGURATION_NAME));
                    configuration.setValue(rs.getString(DatabaseConstants.CONFIGURATION_VALUE));
                    configuration.setDescription(rs.getString(DatabaseConstants.CONFIGURATION_DESCRIPTION));
                    configurations.add(configuration);
                }
                return configurations;
            } finally {
                Database.dispose(ps);
View Full Code Here


   */
  protected void setUp() throws Exception {
    DatabaseHelper.resetAllTables(false);
   
    List configurations = new ArrayList();
    Configuration configuration1 = new Configuration();
    configuration1.setName("n1");
    configuration1.setValue("v1");
    configuration1.setDescription("d1");
    Configuration configuration2 = new Configuration();
    configuration2.setName("n2");
    configuration2.setValue("v2");
    configuration2.setDescription("d2");
    Configuration configuration3 = new Configuration();
    configuration3.setName("n3");
    configuration3.setValue("v3");
    configuration3.setDescription("d3");
    configurations.add(configuration1);
    configurations.add(configuration2);
    configurations.add(configuration3);
   
    new ConfigurationPersistenceImpl().setConfigurations(configurations, 1)
View Full Code Here

   
    Set nameSet = new HashSet(Arrays.asList(new String[] {"n1", "n2", "n3"}));
    Set valueSet = new HashSet(Arrays.asList(new String[] {"v1", "v2", "v3"}));
    Set descSet = new HashSet(Arrays.asList(new String[] {"d1", "d2", "d3"}));
    for (Iterator it = configurations.iterator(); it.hasNext();) {
      Configuration configuration = (Configuration) it.next();
      assertTrue("wrong name", nameSet.contains(configuration.getName()));
      assertTrue("wrong value", valueSet.contains(configuration.getValue()));
      assertTrue("wrong description", descSet.contains(configuration.getDescription()));
      nameSet.remove(configuration.getName());
      valueSet.remove(configuration.getValue());
      descSet.remove(configuration.getDescription());
     
    }
  }
View Full Code Here

   * Tests setConfigurations method
   * @throws Exception to JUnit
   */
  public void testSetConfigurations1() throws Exception {
    List configurations = new ArrayList();
    Configuration configuration4 = new Configuration();
    configuration4.setName("n4");
    configuration4.setValue("v4");
    configuration4.setDescription("d4");
    Configuration configuration5 = new Configuration();
    configuration5.setName("n5");
    configuration5.setValue("v5");
    configuration5.setDescription("d5");
   
    configurations.add(configuration4);
    configurations.add(configuration5);
    ConfigurationPersistenceImpl persistence = new ConfigurationPersistenceImpl();
   
    persistence.setConfigurations(configurations, 1);
   
    configurations = persistence.getConfigurations();
    assertEquals("size is wrong", 5, configurations.size());
   
   
    Set nameSet = new HashSet(Arrays.asList(new String[] {"n1", "n2", "n3", "n4", "n5"}));
    Set valueSet = new HashSet(Arrays.asList(new String[] {"v1", "v2", "v3", "v4", "v5"}));
    Set descSet = new HashSet(Arrays.asList(new String[] {"d1", "d2", "d3", "d4", "d5"}));
    for (Iterator it = configurations.iterator(); it.hasNext();) {
      Configuration configuration = (Configuration) it.next();
      assertTrue("wrong name", nameSet.contains(configuration.getName()));
      assertTrue("wrong value", valueSet.contains(configuration.getValue()));
      assertTrue("wrong description", descSet.contains(configuration.getDescription()));
      nameSet.remove(configuration.getName());
      valueSet.remove(configuration.getValue());
      descSet.remove(configuration.getDescription());
     
    }
  }
View Full Code Here

   * Tests setConfigurations method
   * @throws Exception to JUnit
   */
  public void testSetConfigurations2() throws Exception {
    List configurations = new ArrayList();
    Configuration configuration1 = new Configuration();
    configuration1.setName("n1");
    configuration1.setValue("nv1");
    configuration1.setDescription("nd1");
    Configuration configuration4 = new Configuration();
    configuration4.setName("n4");
    configuration4.setValue("v4");
    configuration4.setDescription("d4");
   
    configurations.add(configuration1);
    configurations.add(configuration4);
   
    ConfigurationPersistenceImpl persistence = new ConfigurationPersistenceImpl();
   
    persistence.setConfigurations(configurations, 1);
   
    configurations = persistence.getConfigurations();
    assertEquals("size is wrong", 4, configurations.size());
   
   
    Set nameSet = new HashSet(Arrays.asList(new String[] {"n1", "n2", "n3", "n4"}));
    Set valueSet = new HashSet(Arrays.asList(new String[] {"nv1", "v2", "v3", "v4"}));
    Set descSet = new HashSet(Arrays.asList(new String[] {"nd1", "d2", "d3", "d4"}));
    for (Iterator it = configurations.iterator(); it.hasNext();) {
      Configuration configuration = (Configuration) it.next();
      assertTrue("wrong name", nameSet.contains(configuration.getName()));
      assertTrue("wrong value", valueSet.contains(configuration.getValue()));
      assertTrue("wrong description", descSet.contains(configuration.getDescription()));
      nameSet.remove(configuration.getName());
      valueSet.remove(configuration.getValue());
      descSet.remove(configuration.getDescription());
     
    }
  }
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.bean.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.