Ejemplo n.º 1
1
  /** Test of getBindings method, of class Jsr223JRubyEngine. */
  @Test
  public void testGetBindings() throws ScriptException {
    logger1.info("getBindings");
    ScriptEngine instance;
    synchronized (this) {
      System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
      System.setProperty("org.jruby.embed.localvariable.behavior", "persistent");
      ScriptEngineManager manager = new ScriptEngineManager();
      instance = manager.getEngineByName("jruby");
    }

    instance.eval("p = 9.0");
    instance.eval("q = Math.sqrt p");
    Double expResult = 9.0;
    int scope = ScriptContext.ENGINE_SCOPE;
    Bindings result = instance.getBindings(scope);
    assertEquals(expResult, (Double) result.get("p"), 0.01);
    expResult = 3.0;
    assertEquals(expResult, (Double) result.get("q"), 0.01);

    scope = ScriptContext.GLOBAL_SCOPE;
    result = instance.getBindings(scope);
    // Bug of livetribe javax.script package impl.
    // assertTrue(result instanceof SimpleBindings);
    // assertEquals(0, result.size());
    JRubyScriptEngineManager manager2 = new JRubyScriptEngineManager();
    instance = (JRubyEngine) manager2.getEngineByName("jruby");
    result = instance.getBindings(scope);
    assertTrue(result instanceof SimpleBindings);
    assertEquals(0, result.size());

    instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
    instance = null;
  }
Ejemplo n.º 2
1
  @Test
  public void testReadBandRasterData() {
    Date startDate = Calendar.getInstance().getTime();
    // Product product = new Product("name", "desc", 100, 200);
    File file =
        TestUtil.getTestFile(
            productsFolder + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL.ZIP");
    // File rasterFile = TestUtil.getTestFile(productsFolder + "mediumImage.tif");
    System.setProperty("snap.dataio.reader.tileWidth", "100");
    System.setProperty("snap.dataio.reader.tileHeight", "200");
    try {

      Product finalProduct = reader.readProductNodes(file, null);
      ProductData data = ProductData.createInstance(ProductData.TYPE_UINT16, 20000);
      data.setElemFloatAt(3, 5);
      reader.readBandRasterData(
          finalProduct.getBandAt(0), 2000, 2000, 100, 200, data, new NullProgressMonitor());
      assertNotEquals(0, data.getElemFloatAt(0));
      assertNotEquals(-1000, data.getElemFloatAt(0));
      assertNotEquals(0, data.getElemFloatAt(1999));
      assertNotEquals(-1000, data.getElemFloatAt(1999));
      assertNotEquals(5, data.getElemFloatAt(3));
      Date endDate = Calendar.getInstance().getTime();
      assertTrue(
          "The load time for the product is too big!",
          (endDate.getTime() - startDate.getTime()) / (60 * 1000) < 30);
    } catch (IOException e) {
      e.printStackTrace();
      assertTrue(e.getMessage(), false);
    }
  }
Ejemplo n.º 3
0
 // This code worked successfully on command-line but never as JUnit test
 // <script>:1: undefined method `+' for nil:NilClass (NoMethodError)
 // raised at "Object obj1 = engine1.eval("$Value + 2010.to_s");"
 // @Test
 public void testMultipleEngineStates() throws ScriptException {
   logger1.info("Multiple Engine States");
   ScriptEngine engine1;
   ScriptEngine engine2;
   synchronized (this) {
     System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
     System.setProperty("org.jruby.embed.localvariable.behavior", "global");
     ScriptEngineManager manager = new ScriptEngineManager();
     List<ScriptEngineFactory> factories = manager.getEngineFactories();
     ScriptEngineFactory factory = null;
     while (factories.iterator().hasNext()) {
       factory = factories.iterator().next();
       if ("ruby".equals(factory.getLanguageName())) {
         break;
       }
     }
     engine1 = factory.getScriptEngine();
     engine2 = factory.getScriptEngine();
   }
   engine1.put("Value", "value of the first engine");
   engine2.put("Value", new Double(-0.0149));
   Object obj1 = engine1.eval("$Value + 2010.to_s");
   Object obj2 = engine2.eval("$Value + 2010");
   assertNotSame(obj1, obj2);
   engine1 = null;
   engine2 = null;
 }
Ejemplo n.º 4
0
  /** Test of invokeFunction method, of class Jsr223JRubyEngine. */
  @Test
  public void testInvokeFunction() throws Exception {
    logger1.info("invokeFunction");
    ScriptEngine instance;
    synchronized (this) {
      System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
      System.setProperty("org.jruby.embed.localvariable.behavior", "transient");
      ScriptEngineManager manager = new ScriptEngineManager();
      instance = manager.getEngineByName("jruby");
    }
    String filename = basedir + "/src/test/ruby/org/jruby/embed/ruby/count_down.rb";
    Reader reader = new FileReader(filename);
    Bindings bindings = new SimpleBindings();
    bindings.put("@month", 6);
    bindings.put("@day", 3);
    instance.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
    Object result = instance.eval(reader, bindings);

    String method = "count_down_birthday";
    bindings.put("@month", 12);
    bindings.put("@day", 3);
    instance.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
    Object[] args = null;
    result = ((Invocable) instance).invokeFunction(method, args);
    assertTrue(((String) result).startsWith("Happy") || ((String) result).startsWith("You have"));

    instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
    instance = null;
  }
Ejemplo n.º 5
0
  /** Test of get method, of class Jsr223JRubyEngine. */
  @Test
  public void testGet() {
    logger1.info("get");
    ScriptEngine instance;
    synchronized (this) {
      System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
      System.setProperty("org.jruby.embed.localvariable.behavior", "transient");
      ScriptEngineManager manager = new ScriptEngineManager();
      instance = manager.getEngineByName("jruby");
    }

    instance.put("abc", "aabc");
    instance.put("@abc", "abbc");
    instance.put("$abc", "abcc");
    String key = "abc";
    Object expResult = "aabc";
    Object result = instance.get(key);
    assertEquals(expResult, result);
    List list = new ArrayList();
    list.add("aabc");
    instance.put("abc", list);
    Map map = new HashMap();
    map.put("Ruby", "Rocks");
    instance.put("@abc", map);
    result = instance.get(key);
    assertEquals(expResult, ((List) result).get(0));
    key = "@abc";
    expResult = "Rocks";
    result = instance.get(key);
    assertEquals(expResult, ((Map) result).get("Ruby"));

    instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
    instance = null;
  }
Ejemplo n.º 6
0
  /** Test of eval method, of class Jsr223JRubyEngine. */
  @Test
  public void testEval_Reader_ScriptContext() throws Exception {
    logger1.info("[eval Reader with ScriptContext]");
    ScriptEngine instance;
    synchronized (this) {
      System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
      System.setProperty("org.jruby.embed.localvariable.behavior", "transient");
      ScriptEngineManager manager = new ScriptEngineManager();
      instance = manager.getEngineByName("jruby");
    }
    String filename = basedir + "/src/test/ruby/org/jruby/embed/ruby/list_printer.rb";
    Reader reader = new FileReader(filename);
    ScriptContext context = new SimpleScriptContext();

    String[] big5 = {"Alaska", "Texas", "California", "Montana", "New Mexico"};
    context.setAttribute("@list", Arrays.asList(big5), ScriptContext.ENGINE_SCOPE);
    StringWriter sw = new StringWriter();
    context.setWriter(sw);
    instance.eval(reader, context);
    String expResult = "Alaska >> Texas >> California >> Montana >> New Mexico: 5 in total";
    assertEquals(expResult, sw.toString().trim());

    instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
    instance = null;
  }
Ejemplo n.º 7
0
  /** Test of compile method, of class Jsr223JRubyEngine. */
  @Test
  public void testCompile_Reader() throws Exception {
    logger1.info("[compile reader]");
    ScriptEngine instance;
    synchronized (this) {
      System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
      System.setProperty("org.jruby.embed.localvariable.behavior", "transient");
      ScriptEngineManager manager = new ScriptEngineManager();
      instance = manager.getEngineByName("jruby");
    }
    String filename = basedir + "/src/test/ruby/org/jruby/embed/ruby/proverbs_of_the_day.rb";
    Reader reader = new FileReader(filename);

    instance.put("$day", -1);
    CompiledScript cs = ((Compilable) instance).compile(reader);
    String result = (String) cs.eval();
    String expResult = "A rolling stone gathers no moss.";
    assertEquals(expResult, result);
    result = (String) cs.eval();
    expResult = "A friend in need is a friend indeed.";
    assertEquals(expResult, result);
    result = (String) cs.eval();
    expResult = "Every garden may have some weeds.";
    assertEquals(expResult, result);

    instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
    instance = null;
  }
Ejemplo n.º 8
0
  /** Test of compile method, of class Jsr223JRubyEngine. */
  @Test
  public void testCompile_String() throws Exception {
    logger1.info("[compile string]");
    ScriptEngine instance;
    synchronized (this) {
      System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
      System.setProperty("org.jruby.embed.localvariable.behavior", "global");
      ScriptEngineManager manager = new ScriptEngineManager();
      instance = manager.getEngineByName("jruby");
    }
    String script =
        "def norman_window(x, y)\n"
            + "return get_area(x, y), get_perimeter(x, y)\n"
            + "end\n"
            + "def get_area(x, y)\n"
            + "x * y + Math::PI / 8.0 * x ** 2.0\n"
            + "end\n"
            + "def get_perimeter(x, y)\n"
            + "x + 2.0 * y + Math::PI / 2.0 * x\n"
            + "end\n"
            + "norman_window(2, 1)";
    CompiledScript cs = ((Compilable) instance).compile(script);
    List<Double> result = (List<Double>) cs.eval();
    assertEquals(3.570796327, result.get(0), 0.000001);
    assertEquals(7.141592654, result.get(1), 0.000001);

    instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
    instance = null;
  }
Ejemplo n.º 9
0
 @Test
 public void testClearVariables() throws ScriptException {
   logger1.info("Clear Variables Test");
   ScriptEngine instance = null;
   synchronized (this) {
     System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
     System.setProperty("org.jruby.embed.localvariable.behavior", "global");
     ScriptEngineManager manager = new ScriptEngineManager();
     instance = manager.getEngineByName("jruby");
   }
   instance.put("gvar", ":Gvar");
   String result = (String) instance.eval("$gvar");
   assertEquals(":Gvar", result);
   instance.getBindings(ScriptContext.ENGINE_SCOPE).remove("gvar");
   instance
       .getContext()
       .setAttribute("org.jruby.embed.clear.variables", true, ScriptContext.ENGINE_SCOPE);
   instance.eval("");
   instance
       .getContext()
       .setAttribute("org.jruby.embed.clear.variables", false, ScriptContext.ENGINE_SCOPE);
   result = (String) instance.eval("$gvar");
   assertNull(result);
   instance = null;
 }
 @Test
 public void testStartServlet() throws Exception {
   String old = System.getProperty("karaf.data");
   System.setProperty("karaf.data", new File("target").getCanonicalPath());
   try {
     MavenDownloadProxyServlet servlet =
         new MavenDownloadProxyServlet(
             runtimeProperties,
             System.getProperty("java.io.tmpdir"),
             null,
             false,
             null,
             null,
             null,
             null,
             0,
             null,
             null,
             null,
             projectDeployer,
             5);
     servlet.start();
   } finally {
     if (old != null) {
       System.setProperty("karaf.data", old);
     }
   }
 }
Ejemplo n.º 11
0
 @Test
 public void testGetProductComponentsOnFileInput() {
   File file =
       TestUtil.getTestFile(
           productsFolder
               + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL/metadata.xml");
   System.setProperty("snap.dataio.reader.tileWidth", "100");
   System.setProperty("snap.dataio.reader.tileHeight", "100");
   try {
     reader.readProductNodes(file, null);
     TreeNode<File> components = reader.getProductComponents();
     assertEquals(3, components.getChildren().length);
     String[] expectedIds = new String[] {"metadata.dim", "metadata.xml", "geolayer.bil"};
     int componentsAsExpected = 0;
     for (TreeNode<File> component : components.getChildren()) {
       for (String expectedValue : expectedIds) {
         if (component.getId().toLowerCase().equals(expectedValue.toLowerCase())) {
           componentsAsExpected++;
         }
       }
     }
     assertEquals(3, componentsAsExpected);
   } catch (IOException e) {
     e.printStackTrace();
     assertTrue(e.getMessage(), false);
   }
 }
Ejemplo n.º 12
0
 @Test
 public void testReadProductNodes() {
   Date startDate = Calendar.getInstance().getTime();
   Product product = new Product("name", "desc", 100, 100);
   File file =
       TestUtil.getTestFile(
           productsFolder + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL.ZIP");
   System.setProperty("snap.dataio.reader.tileWidth", "100");
   System.setProperty("snap.dataio.reader.tileHeight", "100");
   try {
     Product finalProduct = reader.readProductNodes(file, null);
     assertEquals(4, finalProduct.getBands().length);
     assertEquals("WGS84(DD)", finalProduct.getSceneGeoCoding().getGeoCRS().getName().toString());
     assertEquals("SPOTView", finalProduct.getProductType());
     assertEquals(0, finalProduct.getMaskGroup().getNodeCount());
     assertEquals(2713, finalProduct.getSceneRasterWidth());
     assertEquals(2568, finalProduct.getSceneRasterHeight());
     Date endDate = Calendar.getInstance().getTime();
     assertTrue(
         "The load time for the product is too big!",
         (endDate.getTime() - startDate.getTime()) / (60 * 1000) < 30);
   } catch (IOException e) {
     e.printStackTrace();
     assertTrue(e.getMessage(), false);
   }
 }
Ejemplo n.º 13
0
  /** Test of getInterface method, of class Jsr223JRubyEngine. */
  @Test
  public void testGetInterface_Object_Class() throws FileNotFoundException, ScriptException {
    logger1.info("getInterface (with receiver)");
    ScriptEngine instance;
    synchronized (this) {
      System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
      System.setProperty("org.jruby.embed.localvariable.behavior", "transient");
      ScriptEngineManager manager = new ScriptEngineManager();
      instance = manager.getEngineByName("jruby");
    }
    String filename = basedir + "/src/test/ruby/org/jruby/embed/ruby/position_function.rb";
    Reader reader = new FileReader(filename);
    Bindings bindings = instance.getBindings(ScriptContext.ENGINE_SCOPE);
    bindings.put("initial_velocity", 30.0);
    bindings.put("initial_height", 30.0);
    bindings.put("system", "metric");
    Object receiver = instance.eval(reader, bindings);
    Class returnType = PositionFunction.class;
    PositionFunction result =
        (PositionFunction) ((Invocable) instance).getInterface(receiver, returnType);
    double expResult = 75.9;
    double t = 3.0;
    assertEquals(expResult, result.getPosition(t), 0.1);

    expResult = 20.2;
    t = 1.0;
    assertEquals(expResult, result.getVelocity(t), 0.1);

    instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
    instance = null;
  }
Ejemplo n.º 14
0
  /** Test of getInterface method, of class Jsr223JRubyEngine. */
  @Test
  public void testGetInterface_Class() throws FileNotFoundException, ScriptException {
    logger1.info("getInterface (no receiver)");
    ScriptEngine instance;
    synchronized (this) {
      System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
      System.setProperty("org.jruby.embed.localvariable.behavior", "transient");
      ScriptEngineManager manager = new ScriptEngineManager();
      instance = (JRubyEngine) manager.getEngineByName("jruby");
    }
    Class returnType = RadioActiveDecay.class;
    String filename = basedir + "/src/test/ruby/org/jruby/embed/ruby/radioactive_decay.rb";
    Reader reader = new FileReader(filename);
    Bindings bindings = instance.getBindings(ScriptContext.ENGINE_SCOPE);
    bindings.put("$h", 5715); // half-life of Carbon
    instance.eval(reader);
    double expResult = 8.857809480593293;
    RadioActiveDecay result = (RadioActiveDecay) ((Invocable) instance).getInterface(returnType);
    assertEquals(expResult, result.amountAfterYears(10.0, 1000), 0.000001);
    expResult = 18984.81906228128;
    assertEquals(expResult, result.yearsToAmount(10.0, 1.0), 0.000001);

    instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
    instance = null;
  }
Ejemplo n.º 15
0
 @Test
 public void testDefaultDeploymentDir() {
   String homeDirName = getHomeDirName("conf-site/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   System.setProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR, homeDirName);
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getGatewayDeploymentDir(), is(homeDirName + File.separator + "deployments"));
 }
Ejemplo n.º 16
0
 @Test
 public void testForUpdatedDeploymentDir() {
   String homeDirName = getHomeDirName("conf-demo/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   System.setProperty(GatewayConfigImpl.GATEWAY_DATA_HOME_VAR, homeDirName);
   GatewayConfig config = new GatewayConfigImpl();
   assertTrue(("target/test").equalsIgnoreCase(config.getGatewayDeploymentDir()));
 }
 @BeforeClass
 public static void beforeClass() {
   System.setProperty(
       Constants.LOG4J_CONTEXT_SELECTOR, AsyncLoggerContextSelector.class.getName());
   System.setProperty(
       ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "AsyncLoggerTimestampMessageTest.xml");
   System.setProperty(ClockFactory.PROPERTY_NAME, PoisonClock.class.getName());
 }
Ejemplo n.º 18
0
 /**
  * When data dir is set at both system property and configuration level , then system property
  * value should be considered
  */
 @Test
 public void testDataDirSetAsBothSystemPropertyAndConfig() {
   String homeDirName = getHomeDirName("conf-demo/conf/gateway-site.xml");
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, homeDirName);
   System.setProperty(
       GatewayConfigImpl.GATEWAY_DATA_HOME_VAR,
       homeDirName + File.separator + "DataDirSystemProperty");
   GatewayConfig config = new GatewayConfigImpl();
   assertTrue(
       (homeDirName + File.separator + "DataDirSystemProperty")
           .equalsIgnoreCase(config.getGatewayDataDir()));
 }
  @Test
  public void testSystemPropertiesReplacePlacementHoldersInContextXml() throws Exception {
    System.setProperty("red5.root", "/org/red5/server");
    System.setProperty("red5.config_root", "/context_loader_test.xml");
    loader.setContextsConfig("classpath:/org/red5/server/sysprop_context_loader_test.properties");
    loader.init();

    ApplicationContext context = loader.getContext("test_context");

    assertNotNull(context.getBean("testSerializer"));
    assertNotNull(context.getBean("testDeserializer"));
  }
  private static void startXmlRpcWorkflowManager() {
    System.setProperty(
        "java.util.logging.config.file",
        new File("./src/main/resources/logging.properties").getAbsolutePath());

    try {
      System.getProperties().load(new FileInputStream("./src/main/resources/workflow.properties"));
    } catch (Exception e) {
      fail(e.getMessage());
    }
    try {
      luceneCatLoc = Files.createTempDirectory("repo").toString();
      LOG.log(Level.INFO, "Lucene instance repository: [" + luceneCatLoc + "]");
    } catch (Exception e) {
      fail(e.getMessage());
    }

    if (new File(luceneCatLoc).exists()) {
      // blow away lucene cat
      LOG.log(Level.INFO, "Removing workflow instance repository: [" + luceneCatLoc + "]");
      try {
        FileUtils.deleteDirectory(new File(luceneCatLoc));
      } catch (IOException e) {
        fail(e.getMessage());
      }
    }

    System.setProperty(
        "workflow.engine.instanceRep.factory",
        "org.apache.oodt.cas.workflow.instrepo.LuceneWorkflowInstanceRepositoryFactory");
    System.setProperty("org.apache.oodt.cas.workflow.instanceRep.lucene.idxPath", luceneCatLoc);

    try {
      System.setProperty(
          "org.apache.oodt.cas.workflow.repo.dirs",
          "file://" + new File("./src/main/resources/examples").getCanonicalPath());
      System.setProperty(
          "org.apache.oodt.cas.workflow.lifecycle.filePath",
          new File("./src/main/resources/examples/workflow-lifecycle.xml").getCanonicalPath());
    } catch (Exception e) {
      fail(e.getMessage());
    }

    try {
      wmgr = new XmlRpcWorkflowManager(WM_PORT);
      Thread.sleep(MILLIS);
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage());
      fail(e.getMessage());
    }
  }
  private static void stopXmlRpcWorkflowManager() {
    System.setProperty(
        "java.util.logging.config.file",
        new File("./src/main/resources/logging.properties").getAbsolutePath());

    try {
      System.getProperties().load(new FileInputStream("./src/main/resources/workflow.properties"));
    } catch (Exception e) {
      fail(e.getMessage());
    }
    System.setProperty(
        "workflow.engine.instanceRep.factory",
        "org.apache.oodt.cas.workflow.instrepo.LuceneWorkflowInstanceRepositoryFactory");
    System.setProperty("org.apache.oodt.cas.workflow.instanceRep.lucene.idxPath", luceneCatLoc);

    try {
      System.setProperty(
          "org.apache.oodt.cas.workflow.repo.dirs",
          "file://" + new File("./src/main/resources/examples").getCanonicalPath());
      System.setProperty(
          "org.apache.oodt.cas.workflow.lifecycle.filePath",
          new File("./src/main/resources/examples/workflow-lifecycle.xml").getCanonicalPath());
    } catch (Exception e) {
      fail(e.getMessage());
    }

    try {
      wmgr.shutdown();
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage());
      fail(e.getMessage());
    }

    /** Sleep before removing to prevent file not found issues. */
    try {
      Thread.sleep(MILLIS);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    if (new File(luceneCatLoc).exists()) {
      // blow away lucene cat
      LOG.log(Level.INFO, "Removing workflow instance repository: [" + luceneCatLoc + "]");
      try {
        FileUtils.deleteDirectory(new File(luceneCatLoc));
      } catch (IOException e) {
        fail(e.getMessage());
      }
    }
  }
Ejemplo n.º 22
0
  @Before
  public void setUp() throws Exception {
    System.setProperty("disableStartupRunner", "true");
    PHPCoreTests.waitForIndexer();
    PHPCoreTests.waitForAutoBuild();

    project1 = FileUtils.createProject("project1", PHPVersion.PHP5_3);

    IFolder folder = project1.getFolder("src");

    if (!folder.exists()) {
      folder.create(true, true, new NullProgressMonitor());
    }
    file = folder.getFile("test00294081.php");

    InputStream source =
        new ByteArrayInputStream(
            "<?php class MyClass{const constant = 'constant value';function showCons1tant() {echo self::constant;}}$class = new MyClass ();$class->showConstant ();echo $class::constant;?>"
                .getBytes());

    if (!file.exists()) {
      file.create(source, true, new NullProgressMonitor());
    } else {
      file.setContents(source, IFile.FORCE, new NullProgressMonitor());
    }

    PHPCoreTests.waitForIndexer();
    PHPCoreTests.waitForAutoBuild();
  }
  @BeforeClass
  public static void init() throws Exception {

    // these two lines are only needed for ldaps when not running inside the server,
    // because CustomTrustManager is not used when running in CLI
    //
    // these two lines are not needed for starttls
    System.setProperty("javax.net.ssl.trustStore", LC.mailboxd_truststore.value());
    System.setProperty("javax.net.ssl.trustStorePassword", LC.mailboxd_truststore_password.value());

    CliUtil.toolSetup();

    // connConfig.setLocalConfig();
    // TestLdap.TestConfig.useConfig(TestLdap.TestConfig.UBID);
    // TestLdap.TestConfig.useConfig(TestLdap.TestConfig.LEGACY);
  }
Ejemplo n.º 24
0
  @Before
  public void setUp() {
    System.setProperty("nhinc.properties.dir", System.getenv("NHINC_PROPERTIES_DIR"));
    // create first test PseudonymMap
    pseudonymMap_1 = new PseudonymMap();
    pseudonymMap_1.setPseudonymPatientId(pseudoPatientId_1);
    pseudonymMap_1.setPseudonymPatientIdAssigningAuthority(pseudoAuthorityId_1);
    pseudonymMap_1.setRealPatientId(realPatientId_1);
    pseudonymMap_1.setRealPatientIdAssigningAuthority(realAuthorityId_1);

    // create second test PseudonymMap - only difference is pseudoPatientId
    pseudonymMap_2 = new PseudonymMap();
    pseudonymMap_2.setPseudonymPatientId(pseudoPatientId_2);
    pseudonymMap_2.setPseudonymPatientIdAssigningAuthority(pseudoAuthorityId_2);
    pseudonymMap_2.setRealPatientId(realPatientId_2);
    pseudonymMap_2.setRealPatientIdAssigningAuthority(realAuthorityId_2);

    // create third test PseudonymMap - Ids are different
    pseudonymMap_3 = new PseudonymMap();
    pseudonymMap_3.setPseudonymPatientId(pseudoPatientId_3);
    pseudonymMap_3.setPseudonymPatientIdAssigningAuthority(pseudoAuthorityId_3);
    pseudonymMap_3.setRealPatientId(realPatientId_3);
    pseudonymMap_3.setRealPatientIdAssigningAuthority(realAuthorityId_3);

    // initialize contents of internal memory
    PseudonymMapManager.readMap();
  }
Ejemplo n.º 25
0
  /**
   * This reads in the (maven filtered) datasource properties from the test resource directory.
   *
   * @return Properties containing the datasource properties.
   */
  public static Properties getDatasourceProperties() {
    String propertiesNotFoundMessage =
        "Unable to load datasource properties [" + DATASOURCE_PROPERTIES + "]";
    boolean propertiesNotFound = false;

    // Central place to set additional H2 properties
    System.setProperty("h2.lobInDatabase", "true");

    InputStream propsInputStream = PersistenceUtil.class.getResourceAsStream(DATASOURCE_PROPERTIES);
    assertNotNull(propertiesNotFoundMessage, propsInputStream);
    Properties props = new Properties();
    if (propsInputStream != null) {
      try {
        props.load(propsInputStream);
      } catch (IOException ioe) {
        propertiesNotFound = true;
        logger.warn("Unable to find properties, using default H2 properties: " + ioe.getMessage());
        ioe.printStackTrace();
      }
    } else {
      propertiesNotFound = true;
    }

    String password = props.getProperty("password");
    if ("${maven.jdbc.password}".equals(password) || propertiesNotFound) {
      props = getDefaultProperties();
    }

    return props;
  }
Ejemplo n.º 26
0
 @Test
 public void testEmptyConfig() {
   System.setProperty(GatewayConfigImpl.GATEWAY_HOME_VAR, getHomeDirName("conf-empty/conf/empty"));
   GatewayConfig config = new GatewayConfigImpl();
   assertThat(config.getGatewayPort(), is(8888));
   // assertThat( config.getShiroConfigFile(), is( "shiro.ini") );
 }
Ejemplo n.º 27
0
  @Test
  public void testAgentStatMonitor() throws InterruptedException {
    // Given
    final long collectionIntervalMs = 1000 * 1;
    final int numCollectionsPerBatch = 2;
    final int minNumBatchToTest = 2;
    final long totalTestDurationMs =
        collectionIntervalMs + collectionIntervalMs * numCollectionsPerBatch * minNumBatchToTest;
    // When
    System.setProperty("pinpoint.log", "test.");
    AgentStatCollectorFactory agentStatCollectorFactory =
        new AgentStatCollectorFactory(new TestableTransactionCounter());

    AgentStatMonitor monitor =
        new AgentStatMonitor(
            this.dataSender,
            "agentId",
            System.currentTimeMillis(),
            agentStatCollectorFactory,
            collectionIntervalMs,
            numCollectionsPerBatch);
    monitor.start();
    Thread.sleep(totalTestDurationMs);
    monitor.stop();
    // Then
    assertTrue(tBaseRecorder.size() >= minNumBatchToTest);
    for (TAgentStatBatch agentStatBatch : tBaseRecorder) {
      logger.debug("agentStatBatch:{}", agentStatBatch);
      assertTrue(agentStatBatch.getAgentStats().size() <= numCollectionsPerBatch);
    }
  }
Ejemplo n.º 28
0
  protected static void oldWayWithSysProp() {
    System.setProperty("context2", "Spel-context2.xml");
    ApplicationContext ctx =
        new ClassPathXmlApplicationContext("classpath:/com/rooney/spring/spel/Spel-context.xml");

    System.out.println(ctx.getBean("stringBean"));
  }
  @Before
  public void setUp() throws Exception {
    tmpDir =
        new File(
            System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis());
    System.setProperty("zeppelin.dep.localrepo", tmpDir.getAbsolutePath() + "/local-repo");

    tmpDir.mkdirs();

    if (repl == null) {
      Properties p = new Properties();

      repl = new ScaldingInterpreter(p);
      repl.open();
    }

    InterpreterGroup intpGroup = new InterpreterGroup();
    context =
        new InterpreterContext(
            "note",
            "id",
            "title",
            "text",
            new HashMap<String, Object>(),
            new GUI(),
            new AngularObjectRegistry(intpGroup.getId(), null),
            new LinkedList<InterpreterContextRunner>());
  }
  public TestWorkflowDataSourceRepository() throws SQLException, FileNotFoundException {
    // set the log levels
    System.setProperty(
        "java.util.logging.config.file",
        new File("./src/main/resources/logging.properties").getAbsolutePath());

    // first load the example configuration
    try {
      System.getProperties().load(new FileInputStream("./src/main/resources/workflow.properties"));
    } catch (Exception e) {
      fail(e.getMessage());
    }

    // get a temp directory
    File tempDir = null;
    File tempFile;

    try {
      tempFile = File.createTempFile("foo", "bar");
      tempFile.deleteOnExit();
      tempDir = tempFile.getParentFile();
    } catch (Exception e) {
      fail(e.getMessage());
    }

    tmpDirPath = tempDir.getAbsolutePath();
  }