osgi icon indicating copy to clipboard operation
osgi copied to clipboard

[ds annotation tck] ConstructorInjection test does not honor default values

Open laeubi opened this issue 2 years ago • 7 comments

ConstructorInjection testcase currently fails when one do not set the field-collection-type attribute with the following error:

java.lang.AssertionError: [reference[@name='multiple']/@field-collection-type for node testConstructorInjection] 
Expecting actual not to be null
	at org.osgi.test.support.xpath.AbstractXPathAssert.hasValue(AbstractXPathAssert.java:87)
	at org.osgi.test.cases.component.annotations.junit.DS14AnnotationsTestCase.testConstructorInjection(DS14AnnotationsTestCase.java:530)

The spec says about this:

The type of objects set in the collection are specified by the field-collection-type attribute in the component description:

  • service - The bound service object. This is the default field collection type.

Also looking at the schema the attribute is marked as optional with a default of service

<attribute name="field-collection-type" type="scr:Tfield-collection-type" default="service" use="optional" />

I therefore thing that here

https://github.com/osgi/osgi/blob/8ab4f46152fe43176b2a157f32e205a94487a481/org.osgi.test.cases.component.annotations/src/org/osgi/test/cases/component/annotations/junit/DS14AnnotationsTestCase.java#L530-L531

it must also accept the case that the value is not specified what will mean default attribute value is used.

laeubi avatar Nov 22 '23 12:11 laeubi

Could you Pplease add a Test? here that covers this issue?

stbischof avatar Nov 22 '23 12:11 stbischof

Yes, the test should be hasOptionalValue instead of hasValue to allow for the default value of service.

bjhargrave avatar Nov 22 '23 12:11 bjhargrave

Could you Pplease add a Test? here that covers this issue?

I'm not aware that TCKs itself has tests :-)

laeubi avatar Nov 22 '23 13:11 laeubi

so please fixe a test or make it more distinct

stbischof avatar Nov 22 '23 13:11 stbischof

I'm not aware that TCKs itself has tests :-)

You referenced the tests above. osgi/org.osgi.test.cases.component.annotations/src/org/osgi/test/cases/component/annotations/junit/DS14AnnotationsTestCase.java

bjhargrave avatar Nov 22 '23 13:11 bjhargrave

@bjhargrave I mean there is no test that tests that the TCK itself is correct right?

laeubi avatar Nov 22 '23 14:11 laeubi

I mean there is no test that tests that the TCK itself is correct right?

That is a bit meta. We don't have tests to test the tests...

bjhargrave avatar Nov 22 '23 14:11 bjhargrave