commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r1102599 - /commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
Date Fri, 13 May 2011 08:20:34 GMT
Author: tcurdt
Date: Fri May 13 08:20:34 2011
New Revision: 1102599

URL: http://svn.apache.org/viewvc?rev=1102599&view=rev
Log:
added a test case https://issues.apache.org/jira/browse/JCI-59


Modified:
    commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java

Modified: commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java?rev=1102599&r1=1102598&r2=1102599&view=diff
==============================================================================
--- commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
(original)
+++ commons/proper/jci/trunk/core/src/test/java/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
Fri May 13 08:20:34 2011
@@ -293,7 +293,53 @@ public abstract class AbstractCompilerTe
         assertTrue("jci/Func2.class is not empty", clazzBytesFunc2.length > 0);
     }
 
-
+    /*
+     * https://issues.apache.org/jira/browse/JCI-59
+     */
+    public void testAdditionalTopLevelClassCompile() throws Exception {
+       final JavaCompiler compiler = createJavaCompiler(); 
+
+       final ResourceReader reader = new ResourceReader() {
+           final private Map sources = new HashMap() {
+               private static final long serialVersionUID = 1L;
+               {
+                   put("jci/Simple.java", (
+                       "package jci;\n" +
+                       "public class Simple {\n" +
+                       "  public String toString() {\n" +
+                       "    return \"Simple\";\n" +
+                       "  }\n" +
+                       "}\n" +
+                       "class AdditionalTopLevel {\n" +
+                       "  public String toString() {\n" +
+                       "    return \"AdditionalTopLevel\";\n" +
+                       "  }\n" +
+                       "}").getBytes());
+               }};
+
+           public byte[] getBytes( final String pResourceName ) {
+               return (byte[]) sources.get(pResourceName);
+           }
+
+           public boolean isAvailable( final String pResourceName ) {
+               return sources.containsKey(pResourceName);
+           }
+
+       };
+
+       final MemoryResourceStore store = new MemoryResourceStore();
+       final CompilationResult result = compiler.compile(
+               new String[] {
+                       "jci/Simple.java"
+               }, reader, store);
+
+       assertEquals(toString(result.getErrors()), 0, result.getErrors().length);
+       assertEquals(toString(result.getWarnings()), 0, result.getWarnings().length);
+
+       final byte[] clazzBytes = store.read("jci/Simple.class");
+       assertNotNull(clazzBytes);
+       assertTrue(clazzBytes.length > 0);
+    }
 
     public final String toString( final CompilationProblem[] pProblems ) {
         final StringBuffer sb = new StringBuffer();



Mime
View raw message