@@ -0,0 +1,2377 @@
+/*%0A * Copyright 2012 Google Inc. All Rights Reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.google.errorprone.bugpatterns;%0A%0Aimport com.google.errorprone.CompilationTestHelper;%0Aimport com.google.errorprone.bugpatterns.InvalidStringEquality;%0Aimport com.google.errorprone.matchers.DescribingMatcher;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.io.File;%0Aimport java.net.URL;%0A%0A/**%0A * @author Bill Pugh (bill.pugh@gmail.com)%0A */%0Apublic abstract class BugPatternUnitTest %7B%0A%0A    protected CompilationTestHelper compilationHelper;%0A    protected String testname;%0A%0A    protected void setScanner(com.google.errorprone.Scanner scanner) %7B%0A%0A        Class%3C?%3E c = scanner.getClass().getEnclosingClass();%0A        if (c == null)%0A            throw new IllegalArgumentException(%22Scanner must be an inner class%22);%0A        if (!DescribingMatcher.class.isAssignableFrom(c))%0A            throw new IllegalArgumentException(%22Bad outer class for scanner: %22%0A                    + c);%0A        testname = c.getSimpleName();%0A        compilationHelper = new CompilationTestHelper(%0A                scanner);%0A    %7D%0A%0A    public void testPositiveCase() throws Exception %7B%0A        String name = testname + %22PositiveCases.java%22;%0A        URL resource = this.getClass().getResource(name);%0A        if (resource == null)%0A            throw new RuntimeException(%22Could not find resource %22 + name);%0A        compilationHelper.assertCompileFailsWithMessages(new File(resource%0A                .toURI()));%0A    %7D%0A%0A    public void testNegativeCase() throws Exception %7B%0A        String name = testname + %22NegativeCases.java%22;%0A        URL resource = this.getClass().getResource(name);%0A        if (resource == null)%0A            throw new RuntimeException(%22Could not find resource %22 + name);%0A        compilationHelper.assertCompileSucceeds(new File(resource.toURI()));%0A%0A    %7D%0A%0A%7D%0A

Add abstract base class for bug pattern unit tests