|
| 1 | +/** |
| 2 | + * Copyright (C) 2010-2015 eBusiness Information, Excilys Group |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed To in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | +package org.androidannotations.generation; |
| 17 | + |
| 18 | +import java.io.File; |
| 19 | +import java.io.IOException; |
| 20 | + |
| 21 | +import org.androidannotations.internal.AndroidAnnotationProcessor; |
| 22 | +import org.androidannotations.testutils.AAProcessorTestHelper; |
| 23 | +import org.junit.Before; |
| 24 | +import org.junit.Test; |
| 25 | + |
| 26 | +public class GenerateFinalClassesFlagTest extends AAProcessorTestHelper { |
| 27 | + |
| 28 | + @Before |
| 29 | + public void setUp() { |
| 30 | + addManifestProcessorParameter(ActivityInManifest.class); |
| 31 | + addProcessor(AndroidAnnotationProcessor.class); |
| 32 | + ensureOutputDirectoryIsEmpty(); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void generateFinalClass() throws IOException { |
| 37 | + addProcessorParameter("generateFinalClasses", "true"); |
| 38 | + |
| 39 | + CompileResult result = compileFiles(ActivityInManifest.class); |
| 40 | + File generatedFile = toGeneratedFile(ActivityInManifest.class); |
| 41 | + |
| 42 | + assertCompilationSuccessful(result); |
| 43 | + |
| 44 | + assertGeneratedClassMatches(generatedFile, "public final class ActivityInManifest_"); |
| 45 | + } |
| 46 | + |
| 47 | + @Test |
| 48 | + public void generateNonFinalClass() throws IOException { |
| 49 | + addProcessorParameter("generateFinalClasses", "false"); |
| 50 | + |
| 51 | + CompileResult result = compileFiles(ActivityInManifest.class); |
| 52 | + File generatedFile = toGeneratedFile(ActivityInManifest.class); |
| 53 | + |
| 54 | + assertCompilationSuccessful(result); |
| 55 | + |
| 56 | + assertGeneratedClassMatches(generatedFile, "public class ActivityInManifest_"); |
| 57 | + } |
| 58 | +} |
0 commit comments