Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlMeta


  @Test
  public void shouldAssignSpecifiedSourceEncoding() throws Exception {
    String html = this.subject.generate();

    HtmlMeta contentType = this.getPage(html).getFirstByXPath("//meta");
    assertThat(contentType.getContentAttribute(), is("text/html; charset=" + SOURCE_ENCODING));
  }
View Full Code Here


  public void shouldDefaultSourceEncodingWhenUnspecified() throws Exception {
    when(this.generatorConfiguration.getSourceEncoding()).thenReturn(null);

    String html = this.subject.generate();

    HtmlMeta contentType = this.getPage(html).getFirstByXPath("//meta");
    assertThat(contentType.getContentAttribute(), is("text/html; charset=" + SpecRunnerHtmlGenerator.DEFAULT_SOURCE_ENCODING));
  }
View Full Code Here

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        HtmlMeta meta = (HtmlMeta) elementIterator.next();
        assertEquals( meta.getAttribute( "http-equiv" ), "Content-Type" );
        assertEquals( meta.getAttribute( "content" ), "text/html; charset=UTF-8" );

        HtmlTitle title = (HtmlTitle) elementIterator.next();
        assertNotNull( title );

        HtmlStyle style = (HtmlStyle) elementIterator.next();
        assertNotNull( style );

        HtmlLink link = (HtmlLink) elementIterator.next();
        assertNotNull( link );

        meta = (HtmlMeta) elementIterator.next();
        assertEquals( meta.getAttribute( "name" ), "author" );
        assertEquals( meta.getAttribute( "content" ).trim(), "John Doe" );

        meta = (HtmlMeta) elementIterator.next();
        assertEquals( meta.getAttribute( "name" ), "Date-Revision-yyyymmdd" );
        assertEquals( meta.getAttribute( "content" ), new SimpleDateFormat( "yyyyMMdd" ).format( new Date() ) );

        meta = (HtmlMeta) elementIterator.next();
        assertEquals( meta.getAttribute( "http-equiv" ), "Content-Language" );
        assertEquals( meta.getAttribute( "content" ), "en" );

        meta = (HtmlMeta) elementIterator.next();
        assertEquals( meta.getAttribute( "name" ), "description" );
        assertEquals( meta.getAttribute( "content" ), "Free Web tutorials" );

        meta = (HtmlMeta) elementIterator.next();
        assertEquals( meta.getAttribute( "name" ), "keywords" );
        assertEquals( meta.getAttribute( "content" ), "HTML,CSS,XML,JavaScript" );

        HtmlBase base = (HtmlBase) elementIterator.next();
        assertEquals( base.getAttribute( "href" ), "http://maven.apache.org/" );
    }
View Full Code Here

            throws Exception
    {
        HtmlPage page = htmlPage( file );
        assertNotNull( page );

        HtmlMeta author = (HtmlMeta) page.getElementsByName( "author" ).get( 0 );
        assertNotNull( author );
        assertTrue( author.toString().indexOf( "Ligature Æ" ) > 0 );
        assertEquals( "Ligature \u00C6", author.getContentAttribute() );

        author = (HtmlMeta) page.getElementsByName( "author" ).get( 1 );
        assertNotNull( author );
        assertTrue( author.toString().indexOf( "Ampersand &" ) > 0 );
        assertEquals( "Ampersand &", author.getContentAttribute() );

        author = (HtmlMeta) page.getElementsByName( "author" ).get( 2 );
        assertNotNull( author );
        assertTrue( author.toString().indexOf( "Less than <" ) > 0 );
        assertEquals( "Less than <", author.getContentAttribute() );

        author = (HtmlMeta) page.getElementsByName( "author" ).get( 3 );
        assertNotNull( author );
        assertTrue( author.toString().indexOf( "Greater than &gt;" ) > 0 );
        assertEquals( "Greater than >", author.getContentAttribute() );

        author = (HtmlMeta) page.getElementsByName( "author" ).get( 4 );
        assertNotNull( author );
        assertTrue( author.getContentAttribute().equals( "Apostrophe '" ) );
        assertEquals( "Apostrophe '", author.getContentAttribute() );

        author = (HtmlMeta) page.getElementsByName( "author" ).get( 5 );
        assertNotNull( author );
        assertTrue( author.toString().indexOf( "Quote &quot;" ) > 0 );
        assertEquals( "Quote \"", author.getContentAttribute() );

        author = (HtmlMeta) page.getElementsByName( "author" ).get( 6 );
        assertNotNull( author );
        assertTrue( author.toString().indexOf( "test@email.com" ) > 0 );
        assertEquals( "test@email.com", author.getContentAttribute() );

        author = (HtmlMeta) page.getElementsByName( "author" ).get( 7 );
        assertNotNull( author );
        assertTrue( author.toString().indexOf( "test&#169;email.com" ) > 0 );
        assertEquals( "test\u00A9email.com", author.getContentAttribute() );

        HtmlElement element = page.getHtmlElementById( "contentBox" );
        assertNotNull( element );
        HtmlDivision division = (HtmlDivision) element;
        assertNotNull( division );
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.html.HtmlMeta

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.