1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of 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, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tools.metalava 18 19 import com.android.tools.metalava.testing.java 20 import org.junit.Test 21 22 class DuplicateClassTest : DriverTest() { 23 24 @Test Test duplicate classesnull25 fun `Test duplicate classes`() { 26 check( 27 sourceFiles = 28 arrayOf( 29 java( 30 """ 31 package test.pkg; 32 33 public class Foo {} 34 """ 35 ), 36 java( 37 "src2/test/pkg/Foo.java", 38 """ 39 package test.pkg; 40 41 public class Foo {} 42 """ 43 ) 44 ), 45 expectedIssues = 46 """ 47 src2/test/pkg/Foo.java:3: warning: Attempted to register test.pkg.Foo twice; once from TESTROOT/src/test/pkg/Foo.java and this one from TESTROOT/src2/test/pkg/Foo.java [DuplicateSourceClass] 48 """, 49 ) 50 } 51 } 52