Open mvpcortes opened 7 years ago
I create a project-example: https://github.com/marcosvpcortes/fixture-factory-spring-boot-error
I'm using spring-boot-devtools. Without it the project will works... I think it is a minor error
I will try create a fix.... The better way is not use the class to key of the template map? I could use the name of class?
Thanks...
Did you ever get this resolved? I had the same issue today but worked around it by providing my own implementation of FixtureFactory.loadTemplate(String packageName), using the Reflections library (https://github.com/ronmamo/reflections):
` public void loadTemplates(String basePackage) { Iterator i$ = getClassesForPackage(basePackage).iterator();
while(i$.hasNext()) {
Class<?> clazz = (Class)i$.next();
if (!clazz.isInterface() && TemplateLoader.class.isAssignableFrom(clazz)) {
try {
((TemplateLoader)clazz.newInstance()).load();
} catch (Exception var4) {
throw new RuntimeException(String.format("template %s not loaded", clazz.getName()), var4);
}
}
}
}
public Set<Class<? extends BaseBlueprint>> getClassesForPackage(String packageName) {
Reflections reflections = new Reflections(packageName);
return reflections.getSubTypesOf(BaseBlueprint.class);
}
`
There is a bug in the getClassesForPackage utility method that the FixtureFactory uses to find the classes in a package, because of the nested jar files in a spring boot packaged jar. I'm not sure what the Reflections package does differently but it works OK.
Hello @gregjones60
A can not solve the problem. Thanks by your solution.
Hi,
I am use fixture-factory with spring-boot. I need create fixtures for fake some objects.
When I use Fixture.from(MyClass.class).gimme("valid"); the MyClass.class return a class from RestartClassLoader. But the fixture-factory load my fixture using other classloader (Launcher$AppClassLoader).
I think this generate two diff MyClass classes and my application fail to identify they in Map "template" inside of Fixture class.
There is something I can do to avoid this error?
Thanks.