@Test
 public void testAll() {
   final FormatterStringSkipPrefix fp = new FormatterStringSkipPrefix("a");
   assertEquals("bco", fp.getFormattedValue("abco"));
   assertEquals("bc", fp.getFormattedValue("abc"));
   assertEquals("bco", fp.getFormattedValue("bco"));
   assertEquals("bc", fp.getFormattedValue("bc"));
   CommonsTestHelper.testToStringImplementation(fp);
 }
Ejemplo n.º 2
0
 @Test
 public void testMultithreadedDOM() {
   CommonsTestHelper.testInParallel(
       100,
       new IThrowingRunnable() {
         public void run() throws Exception {
           assertNotNull(DOMReader.readXMLDOM(new ClassPathResource("xml/buildinfo.xml")));
         }
       });
 }
Ejemplo n.º 3
0
  @Test
  public void testCreation() {
    assertNotNull(new MicroContainer());

    IMicroContainer e = new MicroContainer();
    assertNotNull(e);
    assertFalse(e.hasParent());
    assertFalse(e.hasChildren());
    assertNull(e.getAllChildren());
    assertNull(e.getFirstChild());
    assertNull(e.getLastChild());
    assertTrue(e.getAllChildrenRecursive().isEmpty());
    assertEquals(0, e.getChildCount());
    assertNotNull(e.getNodeName());
    assertNotNull(e.getNodeValue());
    assertTrue(e.isEqualContent(e.getClone()));
    assertSame(EMicroNodeType.CONTAINER, e.getType());
    CommonsTestHelper.testToStringImplementation(e);

    e.appendElement("any");
    assertNotNull(e);
    assertTrue(e.isEqualContent(e.getClone()));

    assertTrue(e.isEqualContent(e));
    assertFalse(e.isEqualContent(null));
    assertFalse(e.isEqualContent(new MicroDocument()));

    assertTrue(new MicroContainer().isEqualContent(new MicroContainer()));
    e = new MicroContainer();
    e.appendText("text");
    assertFalse(new MicroContainer().isEqualContent(e));
    final IMicroNode[] aChildNodes = {new MicroText("any")};

    e = new MicroContainer(aChildNodes);
    assertNotNull(e);
    assertTrue(e.hasChildren());
    assertEquals(1, e.getChildCount());
    assertTrue(e.getFirstChild().isText());
    assertTrue(e.getLastChild().isText());

    // Insert at index
    e.insertAtIndex(0, new MicroCDATA("other"));
    e.insertAtIndex(500000, new MicroElement("e"));

    assertEquals(3, e.getChildCount());
    assertTrue(e.getFirstChild().isCDATA());
    assertTrue(e.getLastChild().isElement());
  }
  @Test
  public void testAll() throws IOException {
    final NonBlockingByteArrayOutputStream baos = new NonBlockingByteArrayOutputStream();
    final WrappedOutputStream ws = new WrappedOutputStream(baos);
    ws.write('a');
    ws.write(CharsetManager.getAsBytes("bc", CCharset.CHARSET_ISO_8859_1_OBJ));
    ws.write(CharsetManager.getAsBytes("cde", CCharset.CHARSET_ISO_8859_1_OBJ), 1, 1);
    ws.flush();
    ws.close();
    assertEquals("abcd", baos.getAsString(CCharset.CHARSET_ISO_8859_1_OBJ));
    CommonsTestHelper.testToStringImplementation(ws);

    try {
      new WrappedOutputStream(null).close();
      fail();
    } catch (final NullPointerException ex) {
    }
  }