Package javax.naming

Examples of javax.naming.CompoundName


    assertTrue(empty2.equals(empty1));
  }

  public void testHashCode() throws InvalidNameException {
    log.setMethod("testHashCode()");
    CompoundName name;

    name = new CompoundName("a/b/c", props);
    assertTrue(name.hashCode() == new CompoundName("a/b/c", props)
        .hashCode());
    assertEquals(294, name.hashCode());

    props.put("jndi.syntax.ignorecase", "true");
    props.put("jndi.syntax.trimblanks", "false");
    name = new CompoundName(" A / B / c ", props);
    assertEquals(101466, name.hashCode());

    props.put("jndi.syntax.ignorecase", "false");
    props.put("jndi.syntax.trimblanks", "true");
    name = new CompoundName(" A / B / c ", props);
    assertEquals(230, name.hashCode());

    props.put("jndi.syntax.ignorecase", "true");
    props.put("jndi.syntax.trimblanks", "true");
    name = new CompoundName(" A / B / c ", props);
    assertEquals(294, name.hashCode());
  }
View Full Code Here


  }
   
    public void testToStringRightToLeft() throws Exception{
       
        CompoundName name = new CompoundName("a/b/c", props);
        assertEquals("a/b/c", name.toString());
    }
View Full Code Here

        assertEquals("a/b/c", name.toString());
    }

  private void testBehavior(String str, Properties p) {
    try {
      CompoundName name = new CompoundName(str, p);
      log.log(str + "\t" + name.toString() + "\t" + toString(name));
    } catch (Throwable e) {
      log.log(str + " with props " + p + " causes error", e);
    }
  }
View Full Code Here

    }
  }

  private void testToString(String str, String expected)
      throws InvalidNameException {
    CompoundName name = null;
    try {
            props.put("jndi.syntax.direction", "left_to_right");
      name = new CompoundName(str, props);
      if ("fail".equals(expected)) {
        fail("fail.equals()" + expected);
      }
            assertEquals(expected, name.toString());
            props.put("jndi.syntax.direction", "right_to_left");
            name = new CompoundName(str, props);
            if ("fail".equals(expected)) {
                fail("fail.equals()" + expected);
            }
            assertEquals(expected, name.toString());
    } catch (Exception e) {
      if (!"fail".equals(expected)) {
        fail(str + "," + expected + "," + e.getMessage());
      }
    }
View Full Code Here

    }
  }

  private void assertInvalidName(String str, Properties p) {
    try {
      new CompoundName(str, p);
      fail(str + " with props " + p + " should be an invalid name.");
    } catch (InvalidNameException e) {
    }
  }
View Full Code Here

    }
  }

  public void testWriteReadObject() throws Exception {
    log.setMethod("testWriteReadObject()");
    CompoundName name = new CompoundName("a/b/c/d", props);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream stream = new ObjectOutputStream(bout);
    stream.writeObject(name);
    stream.close();
    ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
        bout.toByteArray()));
    CompoundName name2 = (CompoundName) in.readObject();
    assertTrue(name.equals(name2));
    in.close();
  }
View Full Code Here

    try {
      ObjectInputStream in = new ObjectInputStream(getClass()
                    .getResourceAsStream(
                            "/serialization/javax/naming/CompoundName.ser"));
      CompoundName name = (CompoundName) in.readObject();
      assertEquals(new CompoundName("a/b/c/d", props), name);
      in.close();
    } catch (Exception e) {
      log.log(e);
      throw e;
    }
View Full Code Here

    try {
      ObjectInputStream in = new ObjectInputStream(getClass()
                    .getResourceAsStream(
                            "/serialization/javax/naming/CompoundName_bad.ser"));
      CompoundName name = (CompoundName) in.readObject();
      assertEquals(new CompoundName("a/b/c/d", props), name);
      in.close();
      fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    }
  }
View Full Code Here

    synt.put("jndi.syntax.escape", "$");
    synt.put("jndi.syntax.beginquote", "`");
    synt.put("jndi.syntax.beginquote2", "/");

    String input = "'liberty|valley|army";
    CompoundName name = new CompoundName(input, synt);
    String output = name.toString();
    assertEquals(input, output);

    synt.put("jndi.syntax.separator", new String("||"));
    name = new CompoundName("||", synt);
    assertEquals("||", name.toString());
  }
View Full Code Here

    props2 = (Properties) props.clone();
  }

  public void testConstructor_Simple() throws InvalidNameException {
    log.setMethod("testConstructor_Simple()");
    CompoundName name;

    name = new CompoundName("", props);
    assertNameEmpty(name);
    name = new CompoundName("/", props);
    assertNameEquals(name, "");
    name = new CompoundName("//", props);
    assertNameEquals(name, "", "");
    name = new CompoundName("///", props);
    assertNameEquals(name, "", "", "");
    name = new CompoundName("a", props);
    assertNameEquals(name, "a");
    name = new CompoundName("a/b", props);

    assertNameEquals(name, "a", "b");
    name = new CompoundName("a/b", props);
    assertNameEquals(name, "a", "b");
  }
View Full Code Here

TOP

Related Classes of javax.naming.CompoundName

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.