Ejemplo n.º 1
0
  @Test
  public void testReplaceCaption() throws Exception {
    ImageCaptionImpl caption = (ImageCaptionImpl) TestHelperDoc.genElem("imgcaption");
    l.setCaption(caption);

    ImageCaptionImpl newCaption = (ImageCaptionImpl) TestHelperDoc.genElem("imgcaption");
    l.replaceChild(newCaption, caption);
    assertTrue(newCaption == l.getCaption());
    assertTrue(newCaption == l.getFirstChild());
    assertTrue(newCaption == l.getLastChild());
  }
Ejemplo n.º 2
0
 @Test(expected = MalformedURLException.class)
 public void testEmptyExtLinkStringThrows() throws Throwable {
   try {
     l.setAttribute("extlink", "");
   } catch (WrappedException e) {
     throw e.getCause();
   }
 }
Ejemplo n.º 3
0
  @Test
  public void testCaptionSetterAndGetter() throws Exception {
    assertNull(l.getCaption());

    ImageCaptionImpl caption = (ImageCaptionImpl) TestHelperDoc.genElem("imgcaption");
    l.setCaption(caption);
    assertTrue(caption == l.getCaption());
    assertTrue(caption == l.getFirstChild());
    assertTrue(caption == l.getLastChild());

    l.setCaption(null);
    assertNull(l.getCaption());
    assertNull(l.getFirstChild());
    assertNull(l.getLastChild());
  }
Ejemplo n.º 4
0
 @Test
 public void testGetLinkTargetGetter() throws Exception {
   assertEquals(l.getSource(), l.getLinkTarget());
   String intLink = "Some other target";
   l.setIntLink(intLink);
   assertEquals(intLink, l.getLinkTarget());
   l.setIntLink(null);
   assertEquals(l.getSource(), l.getLinkTarget());
 }
Ejemplo n.º 5
0
 @Test
 @Ignore
 public void testGetLinkTitleGetter() throws Exception {
   assertEquals(l.getSource(), l.getLinkTitle().getFirstChild().getNodeValue());
   String alt = "Some alt text";
   l.setAlt(alt);
   assertEquals(alt, l.getLinkTitle().getFirstChild().getNodeValue());
   l.setAlt(null);
   assertEquals(l.getSource(), l.getLinkTitle().getFirstChild().getNodeValue());
 }
Ejemplo n.º 6
0
  private void checkVAlign(Wom3ImageVAlign valign, String value) {
    l.setVAlign(valign);
    assertEquals(valign, l.getVAlign());
    assertEquals(value, l.getAttribute("valign"));

    l.setVAlign(null);
    assertEquals("", l.getAttribute("valign"));
    assertNull(l.getVAlign());

    l.setAttribute("valign", value);
    assertEquals(valign, l.getVAlign());
    assertEquals(value, l.getAttribute("valign"));

    l.setAttribute("valign", null);
    assertEquals("", l.getAttribute("valign"));
    assertNull(l.getVAlign());
  }
Ejemplo n.º 7
0
  private void checkFormat(Wom3ImageFormat format, String value) {
    l.setFormat(format);
    assertEquals(format, l.getFormat());
    assertEquals(value, l.getAttribute("format"));

    l.setFormat(null);
    assertEquals("", l.getAttribute("format"));
    assertNull(l.getFormat());

    l.setAttribute("format", value);
    assertEquals(format, l.getFormat());
    assertEquals(value, l.getAttribute("format"));

    l.setAttribute("format", null);
    assertEquals("", l.getAttribute("format"));
    assertNull(l.getFormat());
  }
Ejemplo n.º 8
0
 @Test(expected = IllegalArgumentException.class)
 public void testSetUnknownAttributeThrows() throws Exception {
   l.setAttribute("I don't exist", "Doesn't matter");
 }
Ejemplo n.º 9
0
 @Test
 public void testCanSetSourceAttribute() throws Exception {
   l.setSource("Some Other Page");
 }
Ejemplo n.º 10
0
  @Test
  public void testExtLinkAttribute() throws Exception {
    l.setExtLink(new URL("http://example.com"));
    assertEquals(new URL("http://example.com"), l.getExtLink());
    assertEquals("http://example.com", l.getAttribute("extlink"));

    l.setExtLink(null);
    assertEquals("", l.getAttribute("extlink"));
    assertNull(l.getExtLink());

    l.setAttribute("extlink", "http://example.com");
    assertEquals(new URL("http://example.com"), l.getExtLink());
    assertEquals("http://example.com", l.getAttribute("extlink"));

    l.setAttribute("extlink", null);
    assertEquals("", l.getAttribute("extlink"));
    assertNull(l.getExtLink());
  }
Ejemplo n.º 11
0
  @Test
  public void testUprightAttribute() throws Exception {
    assertFalse(l.isUpright());

    l.setUpright(true);
    assertTrue(l.isUpright());
    assertEquals("upright", l.getAttribute("upright"));

    l.removeAttribute("upright");
    assertFalse(l.isUpright());

    l.setAttribute("upright", "Doesn't matter");
    assertTrue(l.isUpright());
    assertEquals("upright", l.getAttribute("upright"));

    l.setUpright(false);
    assertFalse(l.isUpright());
    assertEquals("", l.getAttribute("upright"));
  }
Ejemplo n.º 12
0
 @Test(expected = IllegalArgumentException.class)
 public void testNegativeHeightStringThrows() throws Exception {
   l.setAttribute("height", "-10");
 }
Ejemplo n.º 13
0
 @Test(expected = IllegalArgumentException.class)
 public void testIllegalHeightStringThrows() throws Exception {
   l.setAttribute("height", "Onehundredtwentyeight");
 }
Ejemplo n.º 14
0
  @Test
  public void testHeightAttribute() throws Exception {
    l.setHeight(128);
    assertEquals((Integer) 128, l.getHeight());
    assertEquals("128", l.getAttribute("height"));

    l.setHeight(null);
    assertEquals("", l.getAttribute("height"));
    assertNull(l.getHeight());

    l.setAttribute("height", "128");
    assertEquals((Integer) 128, l.getHeight());
    assertEquals("128", l.getAttribute("height"));

    l.setAttribute("height", null);
    assertEquals("", l.getAttribute("height"));
    assertNull(l.getHeight());
  }
Ejemplo n.º 15
0
  @Test
  public void testWidthAttribute() throws Exception {
    l.setWidth(128);
    assertEquals((Integer) 128, l.getWidth());
    assertEquals("128", l.getAttribute("width"));

    l.setWidth(null);
    assertEquals("", l.getAttribute("width"));
    assertNull(l.getWidth());

    l.setAttribute("width", "128");
    assertEquals((Integer) 128, l.getWidth());
    assertEquals("128", l.getAttribute("width"));

    l.setAttribute("width", null);
    assertEquals("", l.getAttribute("width"));
    assertNull(l.getWidth());
  }
Ejemplo n.º 16
0
  @Test
  public void testIntLinkAttribute() throws Exception {
    l.setIntLink("Some Page");
    assertEquals("Some Page", l.getIntLink());
    assertEquals("Some Page", l.getAttribute("intlink"));

    l.setIntLink(null);
    assertEquals("", l.getAttribute("intlink"));
    assertNull(l.getIntLink());

    l.setAttribute("intlink", "Some Page");
    assertEquals("Some Page", l.getIntLink());
    assertEquals("Some Page", l.getAttribute("intlink"));

    l.setAttribute("intlink", null);
    assertEquals("", l.getAttribute("intlink"));
    assertNull(l.getIntLink());
  }
Ejemplo n.º 17
0
 @Test(expected = IllegalArgumentException.class)
 public void testCreateIMageLinkWithEmptyPageThrows() throws Exception {
   l.setSource("");
 }
Ejemplo n.º 18
0
 @Test
 public void testSetIntLinkAcceptsEmptyString() throws Exception {
   l.setIntLink("");
   l.setAttribute("intlink", "");
 }
Ejemplo n.º 19
0
 @Test(expected = IllegalArgumentException.class)
 public void testCreateImageLinkWithInvalidPageThrows() throws Exception {
   l.setSource("{}");
 }
Ejemplo n.º 20
0
 @Test
 public void testCreateAndSetSourceWorks() throws Exception {
   l.setSource("Some Page");
   assertEquals("Some Page", l.getSource());
 }
Ejemplo n.º 21
0
 @Test(expected = UnsupportedOperationException.class)
 public void testCannotRemoveSourceAttribute() throws Exception {
   l.setSource(null);
 }
Ejemplo n.º 22
0
 @Test(expected = IllegalArgumentException.class)
 public void testIllegalIntLinkStringThrows() throws Exception {
   l.setAttribute("intlink", "{}");
 }
Ejemplo n.º 23
0
 @Test(expected = IllegalArgumentException.class)
 public void testIllegalFormatStringThrows() throws Exception {
   l.setAttribute("format", "I'm illegal ...");
 }
Ejemplo n.º 24
0
  @Test
  public void testAltAttribute() throws Exception {
    l.setAlt("Some text");
    assertEquals("Some text", l.getAlt());
    assertEquals("Some text", l.getAttribute("alt"));

    l.setAlt(null);
    assertEquals("", l.getAttribute("alt"));
    assertNull(l.getAlt());

    l.setAttribute("alt", "Some text");
    assertEquals("Some text", l.getAlt());
    assertEquals("Some text", l.getAttribute("alt"));

    l.setAttribute("alt", null);
    assertEquals("", l.getAttribute("alt"));
    assertNull(l.getAlt());
  }
Ejemplo n.º 25
0
  @Test
  public void testBorderAttribute() throws Exception {
    assertFalse(l.isBorder());

    l.setBorder(true);
    assertTrue(l.isBorder());
    assertEquals("border", l.getAttribute("border"));

    l.removeAttribute("border");
    assertFalse(l.isBorder());

    l.setAttribute("border", "Doesn't matter");
    assertTrue(l.isBorder());
    assertEquals("border", l.getAttribute("border"));

    l.setBorder(false);
    assertFalse(l.isBorder());
    assertEquals("", l.getAttribute("border"));
  }
Ejemplo n.º 26
0
 @Test(expected = IllegalArgumentException.class)
 public void testIllegalVAlignStringThrows() throws Exception {
   l.setAttribute("valign", "I'm illegal ...");
 }