You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by "John D. Ament" <jo...@apache.org> on 2017/11/30 18:05:29 UTC
Reading microprofile-config.properties from a WAR file in an
Arquillian test
I have the following deployment used in an Arquillian test:
@Deployment
public static WebArchive createDeployment() {
String propertyName = SimpleGetApi.class.getName()+"/mp-rest/url";
String value = getStringURL();
return ShrinkWrap.create(WebArchive.class)
.addClass(SimpleGetApi.class)
.addAsManifestResource(new StringAsset(propertyName+"="+value),
"microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
When I use this, Geronimo Config says it can't find the property. When I
instead change to use a JAR file, it's loaded correctly.
So is this file in the right location in the WAR?
fa5a7db1-3692-4d52-b663-302c2a91241b.war:
/WEB-INF/
/WEB-INF/classes/
/WEB-INF/classes/org/
/WEB-INF/classes/org/eclipse/
/WEB-INF/classes/org/eclipse/microprofile/
/WEB-INF/classes/org/eclipse/microprofile/rest/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
/META-INF/
/META-INF/microprofile-config.properties
/META-INF/beans.xml
Or should GConfig be looking for it in WEB-INF/classes/META-INF?
And the other half of my question, is this a GConfig issue or a MP Config
issue?
John
Re: Reading microprofile-config.properties from a WAR file in an
Arquillian test
Posted by Mark Struberg <st...@yahoo.de>.
It's pretty easy to tackle. Do a this.getClass().getClassLoader().getResources("META-INF/microprofile-config.properties") and print out the URLs.
If there is no hit then the arquillian adapter doesn't provide full functionality.
LieGrue,
strub
> Am 30.11.2017 um 20:02 schrieb Romain Manni-Bucau <rm...@gmail.com>:
>
> SW respect what you do bit agree it lack a classes metainf api shortcut.
>
> Isnt an adpater bug once well placed?
>
> Le 30 nov. 2017 19:16, "John D. Ament" <jo...@apache.org> a écrit :
> And that doesn't work either for GConfig at least (granted, this is an arquillian test against a WAR file on Weld, so I'm not sure if there's classloader behavior at play here either). Do I just need to check to see if I can getResource("META-INF/microprofile-config.properties") ?
>
> 94b1dd18-16f9-4945-b91a-47b49009a9a5.war:
> /WEB-INF/
> /WEB-INF/classes/
> /WEB-INF/classes/org/
> /WEB-INF/classes/org/eclipse/
> /WEB-INF/classes/org/eclipse/microprofile/
> /WEB-INF/classes/org/eclipse/microprofile/rest/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
> /WEB-INF/classes/META-INF/
> /WEB-INF/classes/META-INF/microprofile-config.properties
> /WEB-INF/beans.xml
>
> On Thu, Nov 30, 2017 at 1:10 PM John D. Ament <jo...@apache.org> wrote:
> I agree, but then why does Shrinkwrap put the files there?
>
>
> On Thu, Nov 30, 2017 at 1:07 PM Romain Manni-Bucau <rm...@gmail.com> wrote:
> WEB-INF/classes/META-INF yep, (classpath only)
>
> I think it is normal, we could support WEB-INF/microprofile.properties
> but META-INF in a war sounds weird no?
>
> Romain Manni-Bucau
> @rmannibucau | Blog | Old Blog | Github | LinkedIn
>
>
> 2017-11-30 19:05 GMT+01:00 John D. Ament <jo...@apache.org>:
> > I have the following deployment used in an Arquillian test:
> >
> > @Deployment
> > public static WebArchive createDeployment() {
> > String propertyName = SimpleGetApi.class.getName()+"/mp-rest/url";
> > String value = getStringURL();
> > return ShrinkWrap.create(WebArchive.class)
> > .addClass(SimpleGetApi.class)
> > .addAsManifestResource(new StringAsset(propertyName+"="+value),
> > "microprofile-config.properties")
> > .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
> > }
> >
> > When I use this, Geronimo Config says it can't find the property. When I
> > instead change to use a JAR file, it's loaded correctly.
> >
> > So is this file in the right location in the WAR?
> >
> > fa5a7db1-3692-4d52-b663-302c2a91241b.war:
> > /WEB-INF/
> > /WEB-INF/classes/
> > /WEB-INF/classes/org/
> > /WEB-INF/classes/org/eclipse/
> > /WEB-INF/classes/org/eclipse/microprofile/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
> > /META-INF/
> > /META-INF/microprofile-config.properties
> > /META-INF/beans.xml
> >
> > Or should GConfig be looking for it in WEB-INF/classes/META-INF?
> >
> > And the other half of my question, is this a GConfig issue or a MP Config
> > issue?
> >
> > John
>
Re: Reading microprofile-config.properties from a WAR file in an
Arquillian test
Posted by Romain Manni-Bucau <rm...@gmail.com>.
SW respect what you do bit agree it lack a classes metainf api shortcut.
Isnt an adpater bug once well placed?
Le 30 nov. 2017 19:16, "John D. Ament" <jo...@apache.org> a écrit :
And that doesn't work either for GConfig at least (granted, this is an
arquillian test against a WAR file on Weld, so I'm not sure if there's
classloader behavior at play here either). Do I just need to check to see
if I can getResource("META-INF/microprofile-config.properties") ?
94b1dd18-16f9-4945-b91a-47b49009a9a5.war:
/WEB-INF/
/WEB-INF/classes/
/WEB-INF/classes/org/
/WEB-INF/classes/org/eclipse/
/WEB-INF/classes/org/eclipse/microprofile/
/WEB-INF/classes/org/eclipse/microprofile/rest/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
interfaces/SimpleGetApi.class
/WEB-INF/classes/META-INF/
/WEB-INF/classes/META-INF/microprofile-config.properties
/WEB-INF/beans.xml
On Thu, Nov 30, 2017 at 1:10 PM John D. Ament <jo...@apache.org> wrote:
> I agree, but then why does Shrinkwrap put the files there?
>
>
> On Thu, Nov 30, 2017 at 1:07 PM Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
>> WEB-INF/classes/META-INF yep, (classpath only)
>>
>> I think it is normal, we could support WEB-INF/microprofile.properties
>> but META-INF in a war sounds weird no?
>>
>> Romain Manni-Bucau
>> @rmannibucau | Blog | Old Blog | Github | LinkedIn
>>
>>
>> 2017-11-30 19:05 GMT+01:00 John D. Ament <jo...@apache.org>:
>> > I have the following deployment used in an Arquillian test:
>> >
>> > @Deployment
>> > public static WebArchive createDeployment() {
>> > String propertyName = SimpleGetApi.class.getName()+"
>> /mp-rest/url";
>> > String value = getStringURL();
>> > return ShrinkWrap.create(WebArchive.class)
>> > .addClass(SimpleGetApi.class)
>> > .addAsManifestResource(new StringAsset(propertyName+"="+
>> value),
>> > "microprofile-config.properties")
>> > .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
>> > }
>> >
>> > When I use this, Geronimo Config says it can't find the property. When
>> I
>> > instead change to use a JAR file, it's loaded correctly.
>> >
>> > So is this file in the right location in the WAR?
>> >
>> > fa5a7db1-3692-4d52-b663-302c2a91241b.war:
>> > /WEB-INF/
>> > /WEB-INF/classes/
>> > /WEB-INF/classes/org/
>> > /WEB-INF/classes/org/eclipse/
>> > /WEB-INF/classes/org/eclipse/microprofile/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
>> interfaces/SimpleGetApi.class
>> > /META-INF/
>> > /META-INF/microprofile-config.properties
>> > /META-INF/beans.xml
>> >
>> > Or should GConfig be looking for it in WEB-INF/classes/META-INF?
>> >
>> > And the other half of my question, is this a GConfig issue or a MP
>> Config
>> > issue?
>> >
>> > John
>>
>
Re: Reading microprofile-config.properties from a WAR file in an
Arquillian test
Posted by Mark Struberg <st...@yahoo.de>.
Did you try it out with OWB? Because we really added special ClassLoader logic to emulate real WAR files some time ago.
Prior to that change we just served the @Deployment as ScannerService feed. And of course this did not affect ClassLoader#getResources() which did not find anything.
Maybe weld still doesn't handle this?
LieGrue,
strub
> Am 30.11.2017 um 19:16 schrieb John D. Ament <jo...@apache.org>:
>
> And that doesn't work either for GConfig at least (granted, this is an arquillian test against a WAR file on Weld, so I'm not sure if there's classloader behavior at play here either). Do I just need to check to see if I can getResource("META-INF/microprofile-config.properties") ?
>
> 94b1dd18-16f9-4945-b91a-47b49009a9a5.war:
> /WEB-INF/
> /WEB-INF/classes/
> /WEB-INF/classes/org/
> /WEB-INF/classes/org/eclipse/
> /WEB-INF/classes/org/eclipse/microprofile/
> /WEB-INF/classes/org/eclipse/microprofile/rest/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
> /WEB-INF/classes/META-INF/
> /WEB-INF/classes/META-INF/microprofile-config.properties
> /WEB-INF/beans.xml
>
> On Thu, Nov 30, 2017 at 1:10 PM John D. Ament <jo...@apache.org> wrote:
> I agree, but then why does Shrinkwrap put the files there?
>
>
> On Thu, Nov 30, 2017 at 1:07 PM Romain Manni-Bucau <rm...@gmail.com> wrote:
> WEB-INF/classes/META-INF yep, (classpath only)
>
> I think it is normal, we could support WEB-INF/microprofile.properties
> but META-INF in a war sounds weird no?
>
> Romain Manni-Bucau
> @rmannibucau | Blog | Old Blog | Github | LinkedIn
>
>
> 2017-11-30 19:05 GMT+01:00 John D. Ament <jo...@apache.org>:
> > I have the following deployment used in an Arquillian test:
> >
> > @Deployment
> > public static WebArchive createDeployment() {
> > String propertyName = SimpleGetApi.class.getName()+"/mp-rest/url";
> > String value = getStringURL();
> > return ShrinkWrap.create(WebArchive.class)
> > .addClass(SimpleGetApi.class)
> > .addAsManifestResource(new StringAsset(propertyName+"="+value),
> > "microprofile-config.properties")
> > .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
> > }
> >
> > When I use this, Geronimo Config says it can't find the property. When I
> > instead change to use a JAR file, it's loaded correctly.
> >
> > So is this file in the right location in the WAR?
> >
> > fa5a7db1-3692-4d52-b663-302c2a91241b.war:
> > /WEB-INF/
> > /WEB-INF/classes/
> > /WEB-INF/classes/org/
> > /WEB-INF/classes/org/eclipse/
> > /WEB-INF/classes/org/eclipse/microprofile/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
> > /META-INF/
> > /META-INF/microprofile-config.properties
> > /META-INF/beans.xml
> >
> > Or should GConfig be looking for it in WEB-INF/classes/META-INF?
> >
> > And the other half of my question, is this a GConfig issue or a MP Config
> > issue?
> >
> > John
Re: Reading microprofile-config.properties from a WAR file in an
Arquillian test
Posted by "John D. Ament" <jo...@apache.org>.
And that doesn't work either for GConfig at least (granted, this is an
arquillian test against a WAR file on Weld, so I'm not sure if there's
classloader behavior at play here either). Do I just need to check to see
if I can getResource("META-INF/microprofile-config.properties") ?
94b1dd18-16f9-4945-b91a-47b49009a9a5.war:
/WEB-INF/
/WEB-INF/classes/
/WEB-INF/classes/org/
/WEB-INF/classes/org/eclipse/
/WEB-INF/classes/org/eclipse/microprofile/
/WEB-INF/classes/org/eclipse/microprofile/rest/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
/WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
/WEB-INF/classes/META-INF/
/WEB-INF/classes/META-INF/microprofile-config.properties
/WEB-INF/beans.xml
On Thu, Nov 30, 2017 at 1:10 PM John D. Ament <jo...@apache.org> wrote:
> I agree, but then why does Shrinkwrap put the files there?
>
>
> On Thu, Nov 30, 2017 at 1:07 PM Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
>> WEB-INF/classes/META-INF yep, (classpath only)
>>
>> I think it is normal, we could support WEB-INF/microprofile.properties
>> but META-INF in a war sounds weird no?
>>
>> Romain Manni-Bucau
>> @rmannibucau | Blog | Old Blog | Github | LinkedIn
>>
>>
>> 2017-11-30 19:05 GMT+01:00 John D. Ament <jo...@apache.org>:
>> > I have the following deployment used in an Arquillian test:
>> >
>> > @Deployment
>> > public static WebArchive createDeployment() {
>> > String propertyName =
>> SimpleGetApi.class.getName()+"/mp-rest/url";
>> > String value = getStringURL();
>> > return ShrinkWrap.create(WebArchive.class)
>> > .addClass(SimpleGetApi.class)
>> > .addAsManifestResource(new
>> StringAsset(propertyName+"="+value),
>> > "microprofile-config.properties")
>> > .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
>> > }
>> >
>> > When I use this, Geronimo Config says it can't find the property. When
>> I
>> > instead change to use a JAR file, it's loaded correctly.
>> >
>> > So is this file in the right location in the WAR?
>> >
>> > fa5a7db1-3692-4d52-b663-302c2a91241b.war:
>> > /WEB-INF/
>> > /WEB-INF/classes/
>> > /WEB-INF/classes/org/
>> > /WEB-INF/classes/org/eclipse/
>> > /WEB-INF/classes/org/eclipse/microprofile/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
>> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
>> >
>> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
>> > /META-INF/
>> > /META-INF/microprofile-config.properties
>> > /META-INF/beans.xml
>> >
>> > Or should GConfig be looking for it in WEB-INF/classes/META-INF?
>> >
>> > And the other half of my question, is this a GConfig issue or a MP
>> Config
>> > issue?
>> >
>> > John
>>
>
Re: Reading microprofile-config.properties from a WAR file in an
Arquillian test
Posted by "John D. Ament" <jo...@apache.org>.
I agree, but then why does Shrinkwrap put the files there?
On Thu, Nov 30, 2017 at 1:07 PM Romain Manni-Bucau <rm...@gmail.com>
wrote:
> WEB-INF/classes/META-INF yep, (classpath only)
>
> I think it is normal, we could support WEB-INF/microprofile.properties
> but META-INF in a war sounds weird no?
>
> Romain Manni-Bucau
> @rmannibucau | Blog | Old Blog | Github | LinkedIn
>
>
> 2017-11-30 19:05 GMT+01:00 John D. Ament <jo...@apache.org>:
> > I have the following deployment used in an Arquillian test:
> >
> > @Deployment
> > public static WebArchive createDeployment() {
> > String propertyName =
> SimpleGetApi.class.getName()+"/mp-rest/url";
> > String value = getStringURL();
> > return ShrinkWrap.create(WebArchive.class)
> > .addClass(SimpleGetApi.class)
> > .addAsManifestResource(new
> StringAsset(propertyName+"="+value),
> > "microprofile-config.properties")
> > .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
> > }
> >
> > When I use this, Geronimo Config says it can't find the property. When I
> > instead change to use a JAR file, it's loaded correctly.
> >
> > So is this file in the right location in the WAR?
> >
> > fa5a7db1-3692-4d52-b663-302c2a91241b.war:
> > /WEB-INF/
> > /WEB-INF/classes/
> > /WEB-INF/classes/org/
> > /WEB-INF/classes/org/eclipse/
> > /WEB-INF/classes/org/eclipse/microprofile/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
> > /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
> >
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
> > /META-INF/
> > /META-INF/microprofile-config.properties
> > /META-INF/beans.xml
> >
> > Or should GConfig be looking for it in WEB-INF/classes/META-INF?
> >
> > And the other half of my question, is this a GConfig issue or a MP Config
> > issue?
> >
> > John
>
Re: Reading microprofile-config.properties from a WAR file in an
Arquillian test
Posted by Romain Manni-Bucau <rm...@gmail.com>.
WEB-INF/classes/META-INF yep, (classpath only)
I think it is normal, we could support WEB-INF/microprofile.properties
but META-INF in a war sounds weird no?
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-30 19:05 GMT+01:00 John D. Ament <jo...@apache.org>:
> I have the following deployment used in an Arquillian test:
>
> @Deployment
> public static WebArchive createDeployment() {
> String propertyName = SimpleGetApi.class.getName()+"/mp-rest/url";
> String value = getStringURL();
> return ShrinkWrap.create(WebArchive.class)
> .addClass(SimpleGetApi.class)
> .addAsManifestResource(new StringAsset(propertyName+"="+value),
> "microprofile-config.properties")
> .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
> }
>
> When I use this, Geronimo Config says it can't find the property. When I
> instead change to use a JAR file, it's loaded correctly.
>
> So is this file in the right location in the WAR?
>
> fa5a7db1-3692-4d52-b663-302c2a91241b.war:
> /WEB-INF/
> /WEB-INF/classes/
> /WEB-INF/classes/org/
> /WEB-INF/classes/org/eclipse/
> /WEB-INF/classes/org/eclipse/microprofile/
> /WEB-INF/classes/org/eclipse/microprofile/rest/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/
> /WEB-INF/classes/org/eclipse/microprofile/rest/client/tck/interfaces/SimpleGetApi.class
> /META-INF/
> /META-INF/microprofile-config.properties
> /META-INF/beans.xml
>
> Or should GConfig be looking for it in WEB-INF/classes/META-INF?
>
> And the other half of my question, is this a GConfig issue or a MP Config
> issue?
>
> John