Closed beo4 closed 4 years ago
Is there some way we can convert your debugging class into a proper unit test? That would help a lot!
Is there some way we can convert your debugging class into a proper unit test? That would help a lot!
I try
Added a jUnit Test which reproduce the issue in the attached git repo https://github.com/eggsunimediaGmbH/acs-commons/blob/master/core/src/test/java/de/eggs/core/models/HelloWorldModelTest.java
Thanks for the testcase.
It seems that the problematic part is the I18NInjector
. If you don't register this service in your unittest, everything is fine. This injector has been added in ACS AEM Commons, so it matches with your observation.
For me it seems that this I18NInjector has a higher priority than the other injectors and can also handle any injections of objects, which are assignable from I18N (and of course Object
can be assigned from any class).
I would think in 2 different ways now:
Object htlParameter
, but a something more specific class?Additionally, you can can use the @Source
annotation [1] to define which Injector should be used.
[1] https://sling.apache.org/documentation/bundles/models.html#source
@joerghoh reg 1.) With Object class i can handle String and String[] hand overs, thats why it is there. reg 2.) https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/2158
@beo4 Maybe you can use the @Source
annotation in the meantime to fix the issue you face.
Required Information
Expected Behavior
When handing in parameters from htl to SlingModel a String Object is handed to JavaClass
e.g.
corresponding html
data-sly-use.hello="${'de.eggs.core.models.HelloWorldModel' @ linkClasses=['custom-link']}"
Actual Behavior
After installing ACS-Commons > 4.0.0 the handed Object is not a String or String Array anymore, instead a I18N Object is injected
Some more wrong Injection Mapping occure after installing ACS-Commons > 4.0.0 I will provide more later
Steps to Reproduce
Install Project from https://github.com/eggsunimediaGmbH/acs-commons Insert HelloWorld Component
Install ACS-Commons 4.4 Debugging class de.eggs.core.models.HelloWorldModel See that htlParameter property is now I18N class
Links
https://github.com/eggsunimediaGmbH/acs-commons