Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.DataConfiguration


  static String votes_valid_filename;
  static String votes_bad_filename;
  static String results_filename;
 
  public static void load() {
    DataConfiguration config;
    try {
      config = new DataConfiguration(new PropertiesConfiguration(
          "config.properties"));
      smsDirectory = config.getString("smsdirectory");
      countrycode = config.getString("countrycode");
      voidOnRepeat = config.getBoolean("voidOnRepeatVote", false);
      sql = config.getBoolean("connectToSQL", false);
      logVotes = config.getBoolean("logVotes", false);
      if(logVotes){
        votes_valid_filename = config.getString("votes_valid_filename", "votes_valid.txt");
        votes_bad_filename = config.getString("votes_bad_filename", "votes_bad.txt");
      }

     
      if (sql) {
        db = new DB();
        numQuestions = DB.qID.size();
        qOpts = new ArrayList<Integer>(numQuestions);
        for(int j = 0; j < numQuestions; j++){
          qOpts.add(0);
        }
        for(int i = 0; i < numQuestions;i++){
          int qid = DB.qID.get(i);
          ArrayList<Integer> opts = DB.optID.get(qid);
          qOpts.set(i, opts.size());
        }
      }
      else {
        qOpts = config.getList(Integer.class, "questionOptions");
        if (qOpts.size() > 5) {
          throw new ConfigurationException(
              "Too many questions; maximum 5 supported");
        }
        for(int i:qOpts){
View Full Code Here


        case PROPERTIES:
          url = getResourceAsURL(resource + ".properties");

          if (url != null) {
            result = new DataConfiguration(new PropertiesConfiguration(url));
          }

          break;

        case XML:
          url = getResourceAsURL(resource + ".xml");

          if (url != null) {
            result = new DataConfiguration(new XMLConfiguration(url));
          }

          break;

        default:
View Full Code Here

        case PROPERTIES:
          url = getResourceAsURL(resource + ".properties");

          if (url != null) {
            result = new DataConfiguration(new PropertiesConfiguration(url));
          }

          break;

        case XML:
          url = getResourceAsURL(resource + ".xml");

          if (url != null) {
            result = new DataConfiguration(new XMLConfiguration(url));
          }

          break;

        default:
View Full Code Here

        case PROPERTIES:
          url = getResourceAsURL(resource + ".properties");

          if (url != null) {
            result = new DataConfiguration(new PropertiesConfiguration(url));
          }

          break;

        case XML:
          url = getResourceAsURL(resource + ".xml");

          if (url != null) {
            result = new DataConfiguration(new XMLConfiguration(url));
          }

          break;

        default:
View Full Code Here

    assertTrue(requestURI.toURL().toString().length() > 0); // force resolving the URI to a string

    List<NameValuePair> parsedParams = URLEncodedUtils.parse(requestURI, "UTF-8");
    MockServletRequest mockServletRequest = MockServletRequest.create(parsedParams);
    DataConfiguration params = new DataConfiguration(new ServletRequestConfiguration(mockServletRequest));
    SenseiRequest bRequest = DefaultSenseiJSONServlet.convertSenseiRequest(params);
    assertEquals(aRequest, bRequest);
  }
View Full Code Here

      throws SenseiException, UnsupportedEncodingException, JSONException
  {
    SenseiRequest testRequest = createNonRandomSenseiRequest();
    List<NameValuePair> list = HttpRestSenseiServiceImpl.convertRequestToQueryParams(testRequest);
    MockServletRequest mockServletRequest = MockServletRequest.create(list);
    DataConfiguration params = new DataConfiguration(new ServletRequestConfiguration(mockServletRequest));
    SenseiRequest resultRequest = DefaultSenseiJSONServlet.convertSenseiRequest(params);
    assertEquals(testRequest, resultRequest);
  }
View Full Code Here

    aRequest.setShowExplanation(EXPECTED_SHOW_EXPLANATION);

    SenseiRequest bRequest = new SenseiRequest();
    List<NameValuePair> list = HttpRestSenseiServiceImpl.convertRequestToQueryParams(aRequest);
    MockServletRequest mockServletRequest = MockServletRequest.create(list);
    DataConfiguration params = new DataConfiguration(new ServletRequestConfiguration(mockServletRequest));
    DefaultSenseiJSONServlet.convertScalarParams(bRequest, params);
    assertEquals(aRequest, bRequest);
  }
View Full Code Here

    SenseiRequest bRequest = new SenseiRequest();
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    HttpRestSenseiServiceImpl.convertFacetInitParams(qparams, initParams);
    MockServletRequest mockServletRequest = MockServletRequest.create(qparams);
    DataConfiguration params = new DataConfiguration(new ServletRequestConfiguration(mockServletRequest));
    DefaultSenseiJSONServlet.convertInitParams(bRequest, params);
    assertEquals(aRequest, bRequest);
  }
View Full Code Here

    SenseiRequest bRequest = new SenseiRequest();
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    HttpRestSenseiServiceImpl.convertFacetSpecs(list, facetSpecMap);
    MockServletRequest mockServletRequest = MockServletRequest.create(list);
    DataConfiguration params = new DataConfiguration(new ServletRequestConfiguration(mockServletRequest));
    DefaultSenseiJSONServlet.convertFacetParam(bRequest, params);
    assertEquals(aRequest, bRequest);
  }
View Full Code Here

    SenseiRequest bRequest = new SenseiRequest();
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    HttpRestSenseiServiceImpl.convertSortFieldParams(list, sortFields);
    MockServletRequest mockServletRequest = MockServletRequest.create(list);
    DataConfiguration params = new DataConfiguration(new ServletRequestConfiguration(mockServletRequest));
    DefaultSenseiJSONServlet.convertSortParam(bRequest, params);
    assertEquals(aRequest, bRequest);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.DataConfiguration

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.