public void setUp() throws Exception {
    super.setUp();
    tempDirPath = getTempDir().getAbsolutePath() + File.separator;

    theDaemon = getMockLockssDaemon();
    theDaemon.getAlertManager();
    theDaemon.getPluginManager().setLoadablePluginsReady(true);
    theDaemon.getHashService();
    MockSystemMetrics metrics = new MyMockSystemMetrics();
    metrics.initService(theDaemon);
    theDaemon.setSystemMetrics(metrics);

    theDaemon.setDaemonInited(true);

    Properties props = new Properties();
    props.setProperty(SystemMetrics.PARAM_HASH_TEST_DURATION, "1000");
    props.setProperty(SystemMetrics.PARAM_HASH_TEST_BYTE_STEP, "1024");
    props.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath);
    ConfigurationUtil.setCurrentConfigFromProps(props);

    pluginMgr = theDaemon.getPluginManager();
    pluginMgr.startService();
    theDaemon.getHashService().startService();
    metrics.startService();
    metrics.setHashSpeed(100);

    simPlugin = PluginTestUtil.findPlugin(SimulatedPlugin.class);
  }
Exemple #2
0
  public static void testEnum() throws Exception {
    Builder b = new Builder();
    b.addClasspath(new File("bin"));
    b.setProperty("Export-Package", "test.metatype");
    b.setProperty("-metatype", "*");
    b.build();
    assertEquals(0, b.getErrors().size());
    assertEquals(0, b.getWarnings().size());

    Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.MetatypeTest$Enums.xml");
    IO.copy(r.openInputStream(), System.err);

    Document d = db.parse(r.openInputStream());
    assertEquals(
        "http://www.osgi.org/xmlns/metatype/v1.1.0", d.getDocumentElement().getNamespaceURI());

    Properties p = new Properties();
    p.setProperty("r", "requireConfiguration");
    p.setProperty("i", "ignoreConfiguration");
    p.setProperty("o", "optionalConfiguration");
    Enums enums = Configurable.createConfigurable(Enums.class, (Map<Object, Object>) p);
    assertEquals(Enums.X.requireConfiguration, enums.r());
    assertEquals(Enums.X.ignoreConfiguration, enums.i());
    assertEquals(Enums.X.optionalConfiguration, enums.o());
  }
Exemple #3
0
  static <T> T set(Class<T> interf, Object value) {
    Properties p = new Properties();
    Method ms[] = interf.getMethods();

    for (Method m : ms) {
      p.put(m.getName(), value);
    }
    return Configurable.createConfigurable(interf, (Map<Object, Object>) p);
  }
  public void loadProperty() {

    try {

      File file = new File(confFileName);

      log.debug("file=" + file.getAbsolutePath());

      confProperties = new Properties();
      confProperties.loadFromXML(new FileInputStream(file));

      bonitaApiHost = confProperties.getProperty("bonita.api.host");
      bonitaApiUsername = confProperties.getProperty("bonita.api.username");
      bonitaApiPassword = confProperties.getProperty("bonita.api.password");
      bonitaApiHttpUsername = confProperties.getProperty("bonita.api.http.username");
      bonitaApiHttpPassword = confProperties.getProperty("bonita.api.http.password");
      bonitaApiPath = confProperties.getProperty("bonita.api.path");

      rallyApiHost = confProperties.getProperty("rally.api.host");
      rallyApiHttpUsername = confProperties.getProperty("rally.api.http.username");
      rallyApiHttpPassword = confProperties.getProperty("rally.api.http.password");
      rallyProjectIds = confProperties.getProperty("rally.project.ids");

      // bonitaProcessId=properties.getProperty("bonita.process.xp_code.id");

      workflowServiceUrl = confProperties.getProperty("service.url");

    } catch (Exception e) {
      log.error("", e);
    }
  }
Exemple #5
0
  public static void testSpecialConversions() throws URISyntaxException {
    Properties p = new Properties();
    p.put("enumv", "A");
    p.put("pattern", ".*");
    p.put("clazz", "java.lang.Object");
    p.put("constructor", "http://www.aQute.biz");

    SpecialConversions trt =
        Configurable.createConfigurable(SpecialConversions.class, (Map<Object, Object>) p);
    assertEquals(SpecialConversions.X.A, trt.enumv());
    assertEquals(".*", trt.pattern().pattern());
    assertEquals(Object.class, trt.clazz());
    assertEquals(new URI("http://www.aQute.biz"), trt.constructor());
  }
  public static void testParseRunProperties() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("src/test/ws"));
    Project project = ws.getProject("p1");

    ProjectLauncherImpl launcher = new ProjectLauncherImpl(project);
    launcher.prepare();

    String arg = launcher.getRunVM().iterator().next();
    String s = "-D" + LauncherConstants.LAUNCHER_PROPERTIES + "=";
    String propertiesPath = arg.substring(s.length());
    Matcher matcher = Pattern.compile("^([\"'])(.*)\\1$").matcher(propertiesPath);
    if (matcher.matches()) {
      propertiesPath = matcher.group(2);
    }

    Properties launchProps = new Properties();
    launchProps.load(new FileInputStream(new File(propertiesPath)));
    assertEquals(
        new File("src/test/ws/p1/generated/p1.jar").getAbsolutePath(),
        launchProps.get("launch.bundles"));
  }
  public static void main(String[] args) throws Exception {

    Properties configFile = new Properties();
    configFile.load(new FileInputStream("my_config.properties"));
    myConnString = configFile.getProperty("MYCONN");

    try {
      mysqlConn = DriverManager.getConnection(myConnString);
      myStm = mysqlConn.createStatement();
      myStm.executeQuery("set wait_timeout = 7200");
    } catch (Exception e) {
      System.out.println("MySQL Offline.");
      System.exit(1);
    }

    getBlogs();

    Thread.sleep(1000); // For cleaning mongo cursos

    myStm.close();
  }
Exemple #8
0
 /**
  * Take all the properties and translate them to actual values. This method takes the set
  * properties and traverse them over all entries, including the default properties for that
  * properties. The values no longer contain macros.
  *
  * @return A new Properties with the flattened values
  */
 public Properties getFlattenedProperties() {
   // Some macros only work in a lower processor, so we
   // do not report unknown macros while flattening
   flattening = true;
   try {
     Properties flattened = new Properties();
     Properties source = domain.getProperties();
     for (Enumeration<?> e = source.propertyNames(); e.hasMoreElements(); ) {
       String key = (String) e.nextElement();
       if (!key.startsWith("_"))
         if (key.startsWith("-")) flattened.put(key, source.getProperty(key));
         else flattened.put(key, process(source.getProperty(key)));
     }
     return flattened;
   } finally {
     flattening = false;
   }
 }
Exemple #9
0
  public void init() throws ServletException {

    final String CONFIG_PATH = getServletContext().getRealPath("/") + "config.ini";
    final String APPLICATION_NAME = getServletContext().getServletContextName();

    BasicConfigurator.configure();

    FileInputStream config_file = null;
    File config = new File(CONFIG_PATH);

    if (config.canRead()) {
      log.debug("Parsing " + CONFIG_PATH);
      try {
        config_file = new FileInputStream(CONFIG_PATH);
      } catch (java.io.FileNotFoundException e) {
        throw new ServletException(e);
      }

      Properties config_prop = new Properties();

      try {
        config_prop.load(config_file);
      } catch (java.io.IOException e) {
        throw new ServletException(e);
      }
      this.config = config_prop;

      log.debug("Parsing finished");
    } else {
      log.fatal("Error, cannot read " + CONFIG_PATH);
    }

    log.debug("maximumRecords : " + this.config.getProperty("default_maximumRecords"));
    log.debug("srw_header_file: " + this.config.getProperty("srw_header_file"));
    log.debug("srw_diag: " + this.config.getProperty("srw_diag_file"));
    // log.debug("server_list:     " + this.config.getProperty("server_list"));

    try {
      FileReader fis =
          new FileReader(
              getServletContext().getRealPath("/") + this.config.getProperty("srw_header_file"));
      BufferedReader in1 = new BufferedReader(fis);
      fis =
          new FileReader(
              getServletContext().getRealPath("/") + this.config.getProperty("srw_footer_file"));
      BufferedReader in2 = new BufferedReader(fis);
      fis =
          new FileReader(
              getServletContext().getRealPath("/") + this.config.getProperty("srw_diag_file"));
      BufferedReader in3 = new BufferedReader(fis);
      try {
        String line = null;

        while ((line = in1.readLine()) != null) {
          this.SRW_HEADER = this.SRW_HEADER + line;
        }
        while ((line = in2.readLine()) != null) {
          this.SRW_FOOTER = this.SRW_FOOTER + line;
        }
        while ((line = in3.readLine()) != null) {
          this.SRW_DIAG = this.SRW_DIAG + line;
        }
      } finally {
        in1.close();
        in2.close();
        in3.close();
      }

    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }