/** * Checks whether all the classes in client and common modules contain * {@link InterfaceAudience} annotations. */ @Test public void testInterfaceAudienceAnnotation() throws ClassNotFoundException, IOException, LinkageError { // find classes that are: // In the main jar // AND are not in a hadoop-compat module // AND are public // NOT test classes // AND NOT generated classes // AND are NOT annotated with InterfaceAudience // AND are NOT from Clover rewriting sources ClassFinder classFinder = new ClassFinder( new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), new Not((FileNameFilter)new TestFileNameFilter()), new And(new PublicClassFilter(), new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new Not(new IsInterfaceStabilityClassFilter()), new Not(new InterfaceAudienceAnnotatedClassFilter()), new Not(new CloverInstrumentationFilter())) ); Set<Class<?>> classes = classFinder.findClasses(false); LOG.info("These are the classes that DO NOT have @InterfaceAudience annotation:"); for (Class<?> clazz : classes) { LOG.info(clazz); } Assert.assertEquals("All classes should have @InterfaceAudience annotation", 0, classes.size()); }
/** * Checks whether all the classes in client and common modules that are marked * InterfaceAudience.Public also have {@link InterfaceStability} annotations. */ @Test public void testInterfaceStabilityAnnotation() throws ClassNotFoundException, IOException, LinkageError { // find classes that are: // In the main jar // AND are not in a hadoop-compat module // AND are public // NOT test classes // AND NOT generated classes // AND are annotated with InterfaceAudience.Public // AND NOT annotated with InterfaceStability ClassFinder classFinder = new ClassFinder( new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), new Not((FileNameFilter)new TestFileNameFilter()), new And(new PublicClassFilter(), new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new InterfaceAudiencePublicAnnotatedClassFilter(), new Not(new IsInterfaceStabilityClassFilter()), new Not(new InterfaceStabilityAnnotatedClassFilter())) ); Set<Class<?>> classes = classFinder.findClasses(false); LOG.info("These are the classes that DO NOT have @InterfaceStability annotation:"); for (Class<?> clazz : classes) { LOG.info(clazz); } Assert.assertEquals("All classes that are marked with @InterfaceAudience.Public should " + "have @InterfaceStability annotation as well", 0, classes.size()); }
/** * Checks whether all the classes in client and common modules contain * {@link InterfaceAudience} annotations. */ @Test public void testInterfaceAudienceAnnotation() throws ClassNotFoundException, IOException, LinkageError { // find classes that are: // In the main jar // AND are public // NOT test classes // AND NOT generated classes // AND are NOT annotated with InterfaceAudience ClassFinder classFinder = new ClassFinder( new MainCodeResourcePathFilter(), new Not((FileNameFilter)new TestFileNameFilter()), new And(new PublicClassFilter(), new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new Not(new IsInterfaceStabilityClassFilter()), new Not(new InterfaceAudienceAnnotatedClassFilter())) ); Set<Class<?>> classes = classFinder.findClasses(false); LOG.info("These are the classes that DO NOT have @InterfaceAudience annotation:"); for (Class<?> clazz : classes) { LOG.info(clazz); } Assert.assertEquals("All classes should have @InterfaceAudience annotation", 0, classes.size()); }
/** * Checks whether all the classes in client and common modules that are marked * InterfaceAudience.Public also have {@link InterfaceStability} annotations. */ @Test public void testInterfaceStabilityAnnotation() throws ClassNotFoundException, IOException, LinkageError { // find classes that are: // In the main jar // AND are public // NOT test classes // AND NOT generated classes // AND are annotated with InterfaceAudience.Public // AND NOT annotated with InterfaceStability ClassFinder classFinder = new ClassFinder( new MainCodeResourcePathFilter(), new Not((FileNameFilter)new TestFileNameFilter()), new And(new PublicClassFilter(), new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new InterfaceAudiencePublicAnnotatedClassFilter(), new Not(new IsInterfaceStabilityClassFilter()), new Not(new InterfaceStabilityAnnotatedClassFilter())) ); Set<Class<?>> classes = classFinder.findClasses(false); LOG.info("These are the classes that DO NOT have @InterfaceStability annotation:"); for (Class<?> clazz : classes) { LOG.info(clazz); } Assert.assertEquals("All classes that are marked with @InterfaceAudience.Public should " + "have @InterfaceStability annotation as well", 0, classes.size()); }
/** * Checks whether all the classes in client and common modules contain * {@link InterfaceAudience} annotations. */ @Ignore @Test public void testInterfaceAudienceAnnotation() throws ClassNotFoundException, IOException, LinkageError { // find classes that are: // In the main jar // AND are not in a hadoop-compat module // AND are public // NOT test classes // AND NOT generated classes // AND are NOT annotated with InterfaceAudience // AND are NOT from Clover rewriting sources ClassFinder classFinder = new ClassFinder( new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), new Not((FileNameFilter)new TestFileNameFilter()), new And(new PublicClassFilter(), new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new Not(new ShadedProtobufClassFilter()), new Not(new IsInterfaceStabilityClassFilter()), new Not(new InterfaceAudienceAnnotatedClassFilter()), new Not(new CloverInstrumentationFilter())) ); Set<Class<?>> classes = classFinder.findClasses(false); if (!classes.isEmpty()) { LOG.info("These are the classes that DO NOT have @InterfaceAudience annotation:"); for (Class<?> clazz : classes) { LOG.info(Objects.toString(clazz)); } } Assert.assertEquals("All classes should have @InterfaceAudience annotation", 0, classes.size()); }
/** * Checks whether all the classes in client and common modules that are marked * InterfaceAudience.Public do not have {@link InterfaceStability} annotations. */ @Ignore @Test public void testNoInterfaceStabilityAnnotationForPublicAPI() throws ClassNotFoundException, IOException, LinkageError { // find classes that are: // In the main jar // AND are not in a hadoop-compat module // AND are public // NOT test classes // AND NOT generated classes // AND are annotated with InterfaceAudience.Public // AND annotated with InterfaceStability ClassFinder classFinder = new ClassFinder( new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), new Not((FileNameFilter)new TestFileNameFilter()), new And(new PublicClassFilter(), new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new Not(new ShadedProtobufClassFilter()), new InterfaceAudiencePublicAnnotatedClassFilter(), new Not(new IsInterfaceStabilityClassFilter()), new InterfaceStabilityAnnotatedClassFilter()) ); Set<Class<?>> classes = classFinder.findClasses(false); if (!classes.isEmpty()) { LOG.info("These are the @InterfaceAudience.Public classes that have @InterfaceStability " + "annotation:"); for (Class<?> clazz : classes) { LOG.info(Objects.toString(clazz)); } } Assert.assertEquals("All classes that are marked with @InterfaceAudience.Public should not " + "have @InterfaceStability annotation", 0, classes.size()); }
/** * Checks whether all the classes in client and common modules that are marked * InterfaceAudience.Public do not have {@link InterfaceStability} annotations. */ @Ignore @Test public void testInterfaceStabilityAnnotationForLimitedAPI() throws ClassNotFoundException, IOException, LinkageError { // find classes that are: // In the main jar // AND are not in a hadoop-compat module // AND are public // NOT test classes // AND NOT generated classes // AND are annotated with InterfaceAudience.LimitedPrivate // AND NOT annotated with InterfaceStability ClassFinder classFinder = new ClassFinder( new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), new Not((FileNameFilter)new TestFileNameFilter()), new And(new PublicClassFilter(), new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new Not(new ShadedProtobufClassFilter()), new InterfaceAudienceLimitedPrivateAnnotatedNotConfigClassFilter(), new Not(new IsInterfaceStabilityClassFilter()), new Not(new InterfaceStabilityAnnotatedClassFilter())) ); Set<Class<?>> classes = classFinder.findClasses(false); if (!classes.isEmpty()) { LOG.info("These are the @InterfaceAudience.LimitedPrivate classes that DO NOT " + "have @InterfaceStability annotation:"); for (Class<?> clazz : classes) { LOG.info(Objects.toString(clazz)); } } Assert.assertEquals("All classes that are marked with @InterfaceAudience.LimitedPrivate " + "should have @InterfaceStability annotation", 0, classes.size()); }
private Set<Class<?>> findPublicClasses() throws ClassNotFoundException, IOException, LinkageError { ClassFinder classFinder = new ClassFinder(new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), new Not((FileNameFilter) new TestFileNameFilter()), new And(new PublicClassFilter(), new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new Not(new ShadedProtobufClassFilter()), new InterfaceAudiencePublicAnnotatedClassFilter())); Set<Class<?>> classes = classFinder.findClasses(false); return classes; }