Comments (11)
I agree with the use case, but disagree with the enabled
property.
If someone specifies
@InjectConfiguration(withFactoryConfig =
@WithFactoryConfiguration(factoryPid = "Blub", location = "?", name = "test"))
Then the properties
are NOT_SET
. This should mean that the configuration is not updated, and I think that if it is being updated that that is a bug.
Do you feel up to making a PR for this?
from osgi-test.
I'll take a look into it
from osgi-test.
here is a check
from osgi-test.
I'll check this out
from osgi-test.
I made a short test and it worked with @WithConfiguration but not with @WithFactoryConfiguration.
This test fails with cs == null:
static final String MY_PID = "my.fpid";
@Test
@WithFactoryConfiguration(factoryPid = MY_PID)
public void testMethodConfigurationFactoryEmtpy() throws Exception {
Configuration cs = ConfigUtil.getConfigsByServicePid(ca, MY_PID);
assertThat(cs).isNotNull();
}
The config is in the configuration manager, but it cannot be found using the provided filter in `ConfigUtil.getConfigsByPid'. This belong to the name that was generated by config admin.
This test succeeds:
static final String MY_OTHER_PID = "my.other.pid";
@Test
@WithFactoryConfiguration(factoryPid = MY_OTHER_PID, name = "myname")
public void testMethodConfigurationFactoryNameEmtpy() throws Exception {
Configuration cs = ConfigUtil.getConfigsByServicePid(ca, MY_OTHER_PID + "~myname");
assertThat(cs).isNotNull();
}
I also debugged both test cases and realized that The update method was called in both tests:
This test also fails with getting a null
value for the configuration parameter c:
@WithFactoryConfiguration(factoryPid = ConfigAnnotationParamVariants2.MY_PID, name = "test")
public class ConfigAnnotationParamVariants2 {
static final String MY_PID = "my.pid";
@Test
public void test_Parameter_Configuration(@InjectConfiguration(MY_PID) Configuration c) throws Exception {
Assertions.assertThat(c)
.isNotNull();
}
}
Here as well the update method on the config admin is called in the codeline linked above.
I realized that the injecing boolean paramter is always false
in all described cases.
I not getting through, what is done here exactly. Further I dont thing that it is possible to distinguish between when someone wants update called on the config admin or what I wanted, that update was not called.
If we see the not-set flag as indicator, to not update the config admin, wehy do we have a line to update nevertheless. This confuses me a bit ;-)
from osgi-test.
To be clear, I looked for a way to get an empty configuration injected with no Configuration#update
calls upfront.
from osgi-test.
I can confirm that this works, without any update calls:
If we want a different behavior, how to deal with this case, we should document it somewhere.
In general I am ok with releasing this feature in this state and making the behavior consistent in the next release. Especially, if it is too difficult to implement. I can also help, but without introduction I takes too long to understand all different cases.
from osgi-test.
This test fails with cs == null:
static final String MY_PID = "my.fpid";
@Test
@WithFactoryConfiguration(factoryPid = MY_PID)
public void testMethodConfigurationFactoryEmtpy() throws Exception {
Configuration cs = ConfigUtil.getConfigsByServicePid(ca, MY_PID);
assertThat(cs).isNotNull();
}
This is user error - there is no configuration with pid
MY_PID
. There is a factory configuration with factoryPid
MY_PID
and an unknown pid
of the form MYPID + "~" + "someString"
. There is a similar problem with the other failing test.
I also debugged both test cases and realized that The update method was called in both tests:
This is required - if you declare your configuration at Class or Test level using a @WithConfiguration
or @WithFactoryConfiguration
then it must be updated. If not then no configuration will ever be available (i.e. calling listConfigurations
will not include the configuration you want). The only way to get a configuration which does not have update
called is by using @InjectConfiguration
from osgi-test.
To be clear, I looked for a way to get an empty configuration injected with no Configuration#update calls upfront.
You appear to have found the way to do this:
It is the only way.
from osgi-test.
This is required - if you declare your configuration at Class or Test level using a
@WithConfiguration
or@WithFactoryConfiguration
then it must be updated. If not then no configuration will ever be available (i.e. callinglistConfigurations
will not include the configuration you want). The only way to get a configuration which does not haveupdate
called is by using@InjectConfiguration
Ok, I see your point.
This is then related to the fact, that all configurations are fetched from config admin list and there is (currently) no other source for empty configuration entries.
I am fine with this current solution. But we should document it :-)
from osgi-test.
I am fine with this current solution. But we should document it :-)
We need a proper documentation site, but for now what we have is this
from osgi-test.
Related Issues (20)
- Add some descriptive documentation HOT 6
- osgi-test-example-mvn / org.osgi.test.example.player.test.PlayerTest are not executed HOT 4
- Need to obtain code coverage reports and interactive debugging within intellij and gradle plugin HOT 9
- Service instance are kept between different BundleContext's, Tests and test Classes HOT 4
- Provide a Junit5 Extension to start an OSGi-Connect-Framework as part of the test without any need for special setup HOT 4
- @ServiceSource should give a meaningfull error if no services are found HOT 3
- @ServiceSource should support ServiceAware<ServiceType> HOT 4
- readme link to codeql broken HOT 2
- NPE with @WithFactoryConfiguration HOT 15
- [cm] Support Systemproperties in Property HOT 4
- [cm] either create unbound config, or provide an option for it. HOT 3
- Weird behaviour when using `ConfigurationExtension` and standard config files HOT 10
- waitForRemoval and wait for modification Method for ServiceAware HOT 2
- use @With(Factory)Configuration in Annotations of User
- org.osgi.test.junit5.cm.test.ConfigAnnotationTest makes Tests lazy
- Move examples to Java 11? HOT 8
- Replacement in @WithFactoryConfigutation Properties and Factorys name
- Release 1.3.0 HOT 11
- Regression - WithConfiguration is no longer inherited
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osgi-test.