Examples of JNDIPooledSource


Examples of speculoos.jndi.pool.JNDIPooledSource

    src.stop();
  }

  public void test02NotStarted() throws MapperException {
    /* create source */
    JNDIPooledSource src = new JNDIPooledSource();
    /* configure source */
    src.addParameters(env);
    /* add mapper */
    SearchMapperImpl smi = new SearchMapperImpl();
    VariableString root = new VariableString("cn=${nom}");
    smi.setRoot(root);
    VariableString filter = new VariableString("email=${email}");
    smi.getInputChain().addMapper(new StringVariable("filter", filter));
    smi.setTypeHelper(new TypeHelper());
    src.add("search1", smi);
    /* create mapper */
    try {
      SearchMapper sm = (SearchMapper) src.create("search1",
          new HashMap());
      fail("Not started; Should have thrown exception.");
    } catch (IllegalStateException e) {
      // / OK
    }
View Full Code Here

Examples of speculoos.jndi.pool.JNDIPooledSource

    }
  }

  public void test03UnknownMapper() throws MapperException {
    /* create source */
    JNDIPooledSource src = new JNDIPooledSource();
    /* configure source */
    src.addParameters(env);
    /* add mapper */
    SearchMapperImpl smi = new SearchMapperImpl();
    VariableString root = new VariableString("cn=${nom}");
    smi.setRoot(root);
    VariableString filter = new VariableString("email=${email}");
    smi.getInputChain().addMapper(new StringVariable("filter", filter));
    smi.setTypeHelper(new TypeHelper());
    src.add("search1", smi);
    src.start(env);
    /* create mapper */
    try {
      SearchMapper sm = (SearchMapper) src
          .create("search", new HashMap());
      fail("Not started; Should have thrown exception.");
    } catch (IllegalArgumentException e) {
      // / OK
    }
View Full Code Here

Examples of speculoos.jndi.pool.JNDIPooledSource

   */
  public void test04ConnectionFailure() throws MapperConfigurationException {
    env.put(Context.INITIAL_CONTEXT_FACTORY,
        "speculoos.jndi.pool.PooledSourceTest$MyFactory");
    /* create source */
    JNDIPooledSource src = new JNDIPooledSource();
    /* configure source */
    src.addParameters(env);
    /* add mapper */
    SearchMapperImpl smi = new SearchMapperImpl();
    VariableString root = new VariableString("cn=${nom}");
    smi.setRoot(root);
    VariableString filter = new VariableString("email=${email}");
    smi.getInputChain().addMapper(new StringVariable("filter", filter));
    smi.setTypeHelper(new TypeHelper());
    src.add("search1", smi);
    /* create mapper */
    try {
      src.start(env);
      fail("Not started; Should have thrown exception.");
    } catch (MapperException e) {
      // / OK
    }
  }
View Full Code Here

Examples of speculoos.jndi.pool.JNDIPooledSource

    }
  }

  public void test06Environment() throws MapperException {
    /* create source */
    JNDIPooledSource src = new JNDIPooledSource();
    /* configure source */
    src.addParameters(env);
    /* substitution */
    Map nenv = new HashMap();
    nenv.put("var1", "${toto}");
    nenv.put("var2", "tutu${titi}");
    src.addParameters(nenv);
    /* start */
    Map genv = new HashMap();
    genv.put("toto", "toto");
    genv.put("titi", "titi");
    /* add mapper */
    SearchMapperImpl smi = new SearchMapperImpl();
    VariableString root = new VariableString("cn=${nom}");
    smi.setRoot(root);
    VariableString filter = new VariableString("email=${email}");
    smi.getInputChain().addMapper(new StringVariable("filter", filter));
    smi.setTypeHelper(new TypeHelper());
    src.add("search1", smi);
    src.start(genv);
    /* check environnement is passed to mapper */
    SearchMapperImpl sm = (SearchMapperImpl) src.create("search1", genv);
    assertEquals("Environment badly configured", "tututiti", sm
        .getEnvironment().get("var2"));
    assertEquals("Environment badly configured", "toto", sm
        .getEnvironment().get("toto"));
  }
View Full Code Here

Examples of speculoos.jndi.pool.JNDIPooledSource

   *
   *
   */
  public void test07IdempotentRelease() throws MapperException {
    /* create source */
    JNDIPooledSource src = new JNDIPooledSource();
    /* configure source */
    src.addParameters(env);
    /* substitution */
    Map nenv = new HashMap();
    nenv.put("var1", "${toto}");
    nenv.put("var2", "tutu${titi}");
    src.addParameters(nenv);
    /* start */
    Map genv = new HashMap();
    genv.put("toto", "toto");
    genv.put("titi", "titi");
    /* add mapper */
    SearchMapperImpl smi = new SearchMapperImpl("search1");
    VariableString root = new VariableString("ou=Personnes");
    smi.setRoot(root);
    VariableString filter = new VariableString(
        "(fullName=${self.name} ${self.surname})");
    smi.getInputChain().addMapper(new StringVariable("filter", filter));
    smi.setTypeHelper(new TypeHelper());
      src.add("search1", smi);
    src.start(genv);
    /* check environnement is passed to mapper */
    SearchMapperImpl sm = (SearchMapperImpl) src.create("search1", genv);
    /* populate input */
    Personne input = new Personne();
    input.setName("NAQUIN");
    input.setSurname("thiery");
    Map h = new HashMap();
    h.put("name","name");
    h.put("surname","surname");
    sm.setOutput(Personne.class,h);
    sm.map(input, null);
    src.release(sm);
    try {
      src.release(sm);
    } catch (Exception e) {
      fail("Multiple releases should not throw exceptions");
    }
  }
View Full Code Here

Examples of speculoos.jndi.pool.JNDIPooledSource

   * @throws MapperException
   *
   */
  public void test08NoMapAfterSearchRelease() throws MapperException {
    /* create source */
    JNDIPooledSource src = new JNDIPooledSource();
    /* configure source */
    src.addParameters(env);
    /* substitution */
    Map nenv = new HashMap();
    nenv.put("var1", "${toto}");
    nenv.put("var2", "tutu${titi}");
    src.addParameters(nenv);
    /* start */
    Map genv = new HashMap();
    genv.put("toto", "toto");
    genv.put("titi", "titi");
    /* add mapper */
    SearchMapperImpl smi = new SearchMapperImpl("search1");
    VariableString root = new VariableString("ou=Personnes");
    smi.setRoot(root);
    VariableString filter = new VariableString(
        "(fullName=${self.name} ${self.surname})");
    smi.getInputChain().addMapper(new StringVariable("filter", filter));
    smi.setTypeHelper(new TypeHelper());
      src.add("search1", smi);
    src.start(genv);
    /* check environnement is passed to mapper */
    SearchMapperImpl sm = (SearchMapperImpl) src.create("search1", genv);
    /* populate input */
    Personne input = new Personne();
    input.setName("NAQUIN");
    input.setSurname("thiery");
    Map h = new HashMap();
    h.put("name","name");
    h.put("surname","surname");
    sm.setOutput(Personne.class,h);
    sm.map(input, null);
    src.release(sm);
    try {
      input.setSurname("thiery");
      sm.map(input, null);
      fail("Map should fail after  releases");
    } catch (Exception e) {
View Full Code Here

Examples of speculoos.jndi.pool.JNDIPooledSource

  public void test09CustomConnectionFactory()
      throws MapperConfigurationException {
    env.put(JNDIPooledSource.FACTORY,
        "speculoos.jndi.PooledSourceTest$MyCnxFactory");
    /* create source */
    JNDIPooledSource src = new JNDIPooledSource();
    /* configure source */
    src.addParameters(env);
    /* add mapper */
    SearchMapperImpl smi = new SearchMapperImpl();
    VariableString root = new VariableString("cn=${nom}");
    smi.setRoot(root);
    VariableString filter = new VariableString("email=${email}");
    smi.getInputChain().addMapper(new StringVariable("filter", filter));
    smi.setTypeHelper(new TypeHelper());
    src.add("search1", smi);
    /* create mapper */
    src.start(env);
    src.stop();
  }
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.