2

私はspring2とMavenを使用してJavaプロジェクトに取り組んでいます。

私はすでにJSLint4JavaをMavenに組み込んでいますが、今度はさらに検証を行う必要があります。

ビルドには、ホームページや検索ページなど、仕様の妥当性について最終的なHTML出力を自動的にテストしたいコアページがいくつかあります。つまり、Mavenビルドからの有効なXHTML1.1厳密です。最終的なHTML出力を生成するhtmlテンプレートファイルはすべてモジュール化されて分離されているため、コンポーネントを個別に検証することは、1つとして実行されるまで有効にならないため機能しません。

ビルドの各ページをテストするのはかなり遅くなるので、テストしたくありません。検証プロセスで実行したいURLのリストを含むXML構成ファイルを用意することをお勧めします。

Jtidyプロジェクトを見つけましたが、これをMavenビルドに組み込み、検証するために特定のURLを呼び出す方法がわかりません。

誰かがこれまでにこれをしたことがありますか?誰かが私がこれを行うために必要な段階の簡単なウォークスルーを提供できますか?

乾杯

4

1 に答える 1

1

If JTidy is really what you want, there is a Maven JTidy Plugin. It seems to work on files, not on URLs:

  <build>    
    <plugins> 
      <plugin>    
        <groupId>jtidy</groupId>   
        <artifactId>maven-jtidy-plugin</artifactId>    
        <configuration>    
          <srcdir>src/main/resources/html</srcdir>    
          <destdir>target/html</destdir>    
          <properties>src/main/resources/jtidy.properties</properties>    
        </configuration>
        <executions>
          <execution>    
            <goals>    
              <goal>jtidy</goal>    
            </goals>    
          </execution>    
        </executions>    
      </plugin>    
    </plugins>    
  </build>

Unless the plugin is not doing what you want, I wouldn't recommend using exec() (which would need Tidy installed and thus harm portability).

(EDIT: Actually, I'm not sure of what you are trying to achieve exactly, if you want a fully automated solution or not, if you'll need to automate the deployment of application, etc, but here are some more hints.

For something manual, you could maybe use wget to save the generated HTML. For GET:

wget http://www.mypage.com/index.jsp?foo=bar

Or POST with the --post-data option:

wget http://www.mypage.com/index.jsp --post-data="foo=bar"

And then run JTidy. If you want to automate things, you'll have to deploy your application first with the maven cargo plugin. Then, you could use the Ant's Get Task with the antrun plugin. And finally, perform the jtidy validation.

If you want to validate the generated HTML during the build, you'll need to deploy your application and to run some tool against it. You should look at the w3c-markup-validation-filter. Use the maven cargo plugin to deploy your application with the filter (cargo allows to merge web.xml so you can add the filter only for the validation test) and run a set of basic selenium tests to browse your pages and check if the little box injected by the W3cMarkupValidationFilter into the HTML page is green.)

于 2009-11-26T12:26:43.577 に答える