2024-08-16 06:15:52 +02:00
|
|
|
package com.commafeed;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Modifier;
|
2024-08-16 06:40:41 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Comparator;
|
2024-08-16 06:15:52 +02:00
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.reflections.Reflections;
|
|
|
|
|
import org.reflections.scanners.Scanners;
|
|
|
|
|
|
2024-08-16 06:40:41 +02:00
|
|
|
import com.rometools.rome.feed.CopyFrom;
|
2024-08-16 06:15:52 +02:00
|
|
|
import com.rometools.rome.feed.module.Module;
|
|
|
|
|
import com.rometools.rome.io.WireFeedGenerator;
|
|
|
|
|
import com.rometools.rome.io.WireFeedParser;
|
|
|
|
|
|
|
|
|
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
|
|
|
|
|
|
|
|
|
class NativeImageClassesTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void annotationContainsAllRequiredRomeClasses() {
|
|
|
|
|
Reflections reflections = new Reflections("com.rometools");
|
|
|
|
|
Set<Class<?>> classesInAnnotation = Set
|
|
|
|
|
.copyOf(List.of(NativeImageClasses.class.getAnnotation(RegisterForReflection.class).targets()));
|
|
|
|
|
|
2024-08-16 06:40:41 +02:00
|
|
|
List<Class<?>> missingClasses = new ArrayList<>();
|
|
|
|
|
for (Class<?> clazz : List.of(Module.class, Cloneable.class, CopyFrom.class, WireFeedParser.class, WireFeedGenerator.class)) {
|
2024-08-16 06:15:52 +02:00
|
|
|
Set<Class<?>> moduleClasses = new HashSet<>(reflections.get(Scanners.SubTypes.of(clazz).asClass()));
|
2024-08-16 06:40:41 +02:00
|
|
|
moduleClasses.removeIf(c -> c.isInterface() || Modifier.isAbstract(c.getModifiers()) || !Modifier.isPublic(c.getModifiers()));
|
2024-08-16 06:15:52 +02:00
|
|
|
moduleClasses.removeAll(classesInAnnotation);
|
2024-08-16 06:40:41 +02:00
|
|
|
missingClasses.addAll(moduleClasses);
|
2024-08-16 06:15:52 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-16 06:40:41 +02:00
|
|
|
missingClasses.sort(Comparator.comparing(Class::getName));
|
|
|
|
|
missingClasses.forEach(c -> System.out.println(c.getName() + ".class,"));
|
|
|
|
|
Assertions.assertEquals(List.of(), missingClasses);
|
2024-08-16 06:15:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|