Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BA9A04183 for ; Fri, 13 May 2011 08:20:57 +0000 (UTC) Received: (qmail 9149 invoked by uid 500); 13 May 2011 08:20:57 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 9099 invoked by uid 500); 13 May 2011 08:20:57 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 9092 invoked by uid 99); 13 May 2011 08:20:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 May 2011 08:20:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 May 2011 08:20:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 03F7B2388A39; Fri, 13 May 2011 08:20:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@commons.apache.org From: tcurdt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110513082035.03F7B2388A39@eris.apache.org> 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();