[Buix-commits] r1141 - jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx
Author: tchemit Date: 2009-01-11 16:38:54 +0000 (Sun, 11 Jan 2009) New Revision: 1141 Added: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerValidatorTest.java Modified: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java Log: validators has his own test class Modified: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java =================================================================== --- jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2009-01-11 16:38:29 UTC (rev 1140) +++ jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2009-01-11 16:38:54 UTC (rev 1141) @@ -207,65 +207,4 @@ assertEquals(1, files.length); assertTrue(mojo.getUpdater().getMirrorFile(srcFile).lastModified() > oldTime); } - - public void testValidatorOk() throws Exception { - mojo.execute(); - assertEquals(2, mojo.getFiles().length); - - } - - @SuppressWarnings({"unchecked"}) - public void testValidatorErrors() throws Exception { - // init mojo to get alls files to treate - mojo.init(); - String[] files = mojo.getFiles(); - assertEquals(15, mojo.getFiles().length); - mojo.setLog(new SystemStreamLog() { - @Override - public boolean isErrorEnabled() { - return false; - } - - @Override - public void error(Throwable error) { - //do nothing - } - - @Override - public void error(CharSequence content) { - //do nothing - } - - @Override - public void error(CharSequence content, Throwable error) { - //do nothing - } - }); - Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers"); - Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount"); - - fieldCompilers.setAccessible(true); - fieldErrorCount.setAccessible(true); - - // execute mjo on each jaxx file to produce the error - for (String file : files) { - getLog().info("test bad file " + file); - mojo.setFiles(new String[]{file}); - try { - mojo.doAction(); - // should never pass - fail("for file " + file); - } catch (MojoExecutionException e) { - // ok jaxx compiler failed - assertTrue(true); - JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get(); - Map<String, Compiler> compilers = (Map<String, Compiler>) fieldCompilers.get(launchor); - assertEquals(1, compilers.size()); - //Compiler compiler = compilers.values().iterator().next(); - Integer nberrors = (Integer) fieldErrorCount.get(launchor); - assertEquals(1, nberrors.intValue()); - } - } - } - } \ No newline at end of file Copied: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerValidatorTest.java (from rev 1122, jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java) =================================================================== --- jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerValidatorTest.java (rev 0) +++ jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerValidatorTest.java 2009-01-11 16:38:54 UTC (rev 1141) @@ -0,0 +1,76 @@ +package org.codelutin.jaxx; + +import jaxx.compiler.JAXXCompiler; +import jaxx.compiler.JAXXCompilerLaunchor; +import jaxx.runtime.DefaultJAXXContext; +import jaxx.runtime.JAXXContext; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.logging.SystemStreamLog; + +import java.io.File; +import java.lang.reflect.Field; +import java.util.Map; + +public class CompilerValidatorTest extends JaxxBaseTest { + + public void testValidatorOk() throws Exception { + mojo.execute(); + assertEquals(2, mojo.getFiles().length); + + } + + @SuppressWarnings({"unchecked"}) + public void testValidatorErrors() throws Exception { + // init mojo to get alls files to treate + mojo.init(); + String[] files = mojo.getFiles(); + assertEquals(15, mojo.getFiles().length); + mojo.setLog(new SystemStreamLog() { + @Override + public boolean isErrorEnabled() { + return false; + } + + @Override + public void error(Throwable error) { + //do nothing + } + + @Override + public void error(CharSequence content) { + //do nothing + } + + @Override + public void error(CharSequence content, Throwable error) { + //do nothing + } + }); + Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers"); + Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount"); + + fieldCompilers.setAccessible(true); + fieldErrorCount.setAccessible(true); + + // execute mjo on each jaxx file to produce the error + for (String file : files) { + getLog().info("test bad file " + file); + mojo.setFiles(new String[]{file}); + try { + mojo.doAction(); + // should never pass + fail("for file " + file); + } catch (MojoExecutionException e) { + // ok jaxx compiler failed + assertTrue(true); + JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get(); + Map<String, Compiler> compilers = (Map<String, Compiler>) fieldCompilers.get(launchor); + assertEquals(1, compilers.size()); + //Compiler compiler = compilers.values().iterator().next(); + Integer nberrors = (Integer) fieldErrorCount.get(launchor); + assertEquals(1, nberrors.intValue()); + } + } + } + +} \ No newline at end of file Property changes on: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerValidatorTest.java ___________________________________________________________________ Name: svn:mergeinfo +
participants (1)
-
tchemit@users.labs.libre-entreprise.org