You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Milan Tomic <to...@yahoo.com> on 2014/09/08 10:09:46 UTC

PaxExam

Hello,

Is this a right place to ask questions about PaxExam with Karaf usage?

I have this:

<blueprint ...>
  <bean id="AppProfile" class="myPackage.impl.AppProfileImpl" />
  <service ref="AppProfile" interface="myPackage.api.AppProfile" />
</blueprint>

and this:

@Configuration
    public Option[] config() {
        MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf")
                .version("3.0.1").type("tar.gz");
        MavenUrlReference karafStandardRepo = maven().groupId("org.apache.karaf.features").artifactId("standard")
                .classifier("features").type("xml").version("3.0.1");
        return new Option[] {
                karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new File("target/exam"))
                        .useDeployFolder(false),
                keepRuntimeFolder(),
                KarafDistributionOption.features(karafStandardRepo, "scr"),
                CoreOptions.mavenBundle().groupId("css").artifactId("commonTemp").version("0.0.1-SNAPSHOT").start(),
                CoreOptions.mavenBundle().groupId("myGroupId")
                        .artifactId("myArtifactId1").version("0.0.1-SNAPSHOT").start(),
                CoreOptions.mavenBundle().groupId("myGroupId")
                        .artifactId("myArtifactId2").version("0.0.1-SNAPSHOT").start(),
        };
    }

but:

BundleContext bc = b.getBundleContext();
ServiceTracker st = new ServiceTracker(bc, AppProfile.class.getName(), null);
st.open();
Object service = st.waitForService(90 * 1000);

returns service == null

Is there anything else I should do? Should I somehow add blueprint support in PaxExam configuration (config() function?), because it seems that AppProfile service is not registered? 

Thank you in advance,
Milan

Re: PaxExam

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Milan,

you can execute command in the Karaf console.

Take a look in the KarafTestSupport in itest:

https://git-wip-us.apache.org/repos/asf?p=karaf.git;a=blob_plain;f=itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java;hb=karaf-3.0.x

You will see the executeCommand() method to execute commands in the 
console. You can extend the KarafTestSupport directly in your itest.

On the other hand, using the bundleContext, you can check the bundles 
installed pro grammatically (the same for service).

Regards
JB

On 09/08/2014 10:41 AM, Milan Tomic wrote:
> Hi JB,
>
> Thank you very much for a quick reply.
>
> How can I do that? When I run PaxExam, I don't have access to Karaf
> console? I see PaxExam/Karaf output in Eclipse console but it is not
> real console where I can execute Karaf commands.
>
> Best regards,
> Milan
>
>
> On Monday, September 8, 2014 10:22 AM, Jean-Baptiste Onofré
> <jb...@nanthrax.net> wrote:
>
>
> Hi,
>
> Did you check that your bundle is correctly installed, resolved, and
> started ?
>
> Regards
> JB
>
> On 09/08/2014 10:09 AM, Milan Tomic wrote:
>  > Hello,
>  >
>  > Is this a right place to ask questions about PaxExam with Karaf usage?
>  >
>  > I have this:
>  >
>  > <blueprint ...>
>  >    <bean id="AppProfile" class="myPackage.impl.AppProfileImpl" />
>  >    <service ref="AppProfile" interface="myPackage.api.AppProfile" />
>  > </blueprint>
>  >
>  > and this:
>  >
>  > @Configuration
>  >      public Option[] config() {
>  >          MavenArtifactUrlReference karafUrl =
>  > maven().groupId("org.apache.karaf").artifactId("apache-karaf")
>  > .version("3.0.1").type("tar.gz");
>  >          MavenUrlReference karafStandardRepo =
>  > maven().groupId("org.apache.karaf.features").artifactId("standard")
>  >                  .classifier("features").type("xml").version("3.0.1");
>  >          return new Option[] {
>  >
>  >
> karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new
>  > File("target/exam"))
>  >                          .useDeployFolder(false),
>  > keepRuntimeFolder(),
>  >                  KarafDistributionOption.features(karafStandardRepo,
> "scr"),
>  >
>  >
> CoreOptions.mavenBundle().groupId("css").artifactId("commonTemp").version("0.0.1-SNAPSHOT").start(),
>  >                  CoreOptions.mavenBundle().groupId("myGroupId")
>  >
>  > .artifactId("myArtifactId1").version("0.0.1-SNAPSHOT").start(),
>  >                  CoreOptions.mavenBundle().groupId("myGroupId")
>  >
>  > .artifactId("myArtifactId2").version("0.0.1-SNAPSHOT").start(),
>  >          };
>  >      }
>  >
>  > but:
>  >
>  > BundleContext bc = b.getBundleContext();
>  > ServiceTracker st = new ServiceTracker(bc, AppProfile.class.getName(),
>  > null);
>  > st.open();
>  > Object service = st.waitForService(90 * 1000);
>  >
>  > returns service == null
>  >
>  > Is there anything else I should do? Should I somehow add blueprint
>  > support in PaxExam configuration (config() function?), because it seems
>  > that AppProfile service is not registered?
>  >
>  > Thank you in advance,
>  > Milan
>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net <http://blog.nanthrax.net/>
> Talend - http://www.talend.com <http://www.talend.com/>
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: PaxExam

Posted by Milan Tomic <to...@yahoo.com>.
Hi JB,

Thank you very much for a quick reply.

How can I do that? When I run PaxExam, I don't have access to Karaf console? I see PaxExam/Karaf output in Eclipse console but it is not real console where I can execute Karaf commands.


Best regards,
Milan



On Monday, September 8, 2014 10:22 AM, Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
 


Hi,

Did you check that your bundle is correctly installed, resolved, and 
started ?

Regards
JB


On 09/08/2014 10:09 AM, Milan Tomic wrote:
> Hello,
>
> Is this a right place to ask questions about PaxExam with Karaf usage?
>
> I have this:
>
> <blueprint ...>
>    <bean id="AppProfile" class="myPackage.impl.AppProfileImpl" />
>    <service ref="AppProfile" interface="myPackage.api.AppProfile" />
> </blueprint>
>
> and this:
>
> @Configuration
>      public Option[] config() {
>          MavenArtifactUrlReference karafUrl =
> maven().groupId("org.apache.karaf").artifactId("apache-karaf")
> .version("3.0.1").type("tar.gz");
>          MavenUrlReference karafStandardRepo =
> maven().groupId("org.apache.karaf.features").artifactId("standard")
>                  .classifier("features").type("xml").version("3.0.1");
>          return new Option[] {
>
> karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new
> File("target/exam"))
>                          .useDeployFolder(false),
> keepRuntimeFolder(),
>                  KarafDistributionOption.features(karafStandardRepo, "scr"),
>
> CoreOptions.mavenBundle().groupId("css").artifactId("commonTemp").version("0.0.1-SNAPSHOT").start(),
>                  CoreOptions.mavenBundle().groupId("myGroupId")
>
> .artifactId("myArtifactId1").version("0.0.1-SNAPSHOT").start(),
>                  CoreOptions.mavenBundle().groupId("myGroupId")
>
> .artifactId("myArtifactId2").version("0.0.1-SNAPSHOT").start(),
>          };
>      }
>
> but:
>
> BundleContext bc = b.getBundleContext();
> ServiceTracker st = new ServiceTracker(bc, AppProfile.class.getName(),
> null);
> st.open();
> Object service = st.waitForService(90 * 1000);
>
> returns service == null
>
> Is there anything else I should do? Should I somehow add blueprint
> support in PaxExam configuration (config() function?), because it seems
> that AppProfile service is not registered?
>
> Thank you in advance,
> Milan

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: PaxExam

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

Did you check that your bundle is correctly installed, resolved, and 
started ?

Regards
JB

On 09/08/2014 10:09 AM, Milan Tomic wrote:
> Hello,
>
> Is this a right place to ask questions about PaxExam with Karaf usage?
>
> I have this:
>
> <blueprint ...>
>    <bean id="AppProfile" class="myPackage.impl.AppProfileImpl" />
>    <service ref="AppProfile" interface="myPackage.api.AppProfile" />
> </blueprint>
>
> and this:
>
> @Configuration
>      public Option[] config() {
>          MavenArtifactUrlReference karafUrl =
> maven().groupId("org.apache.karaf").artifactId("apache-karaf")
> .version("3.0.1").type("tar.gz");
>          MavenUrlReference karafStandardRepo =
> maven().groupId("org.apache.karaf.features").artifactId("standard")
>                  .classifier("features").type("xml").version("3.0.1");
>          return new Option[] {
>
> karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new
> File("target/exam"))
>                          .useDeployFolder(false),
> keepRuntimeFolder(),
>                  KarafDistributionOption.features(karafStandardRepo, "scr"),
>
> CoreOptions.mavenBundle().groupId("css").artifactId("commonTemp").version("0.0.1-SNAPSHOT").start(),
>                  CoreOptions.mavenBundle().groupId("myGroupId")
>
> .artifactId("myArtifactId1").version("0.0.1-SNAPSHOT").start(),
>                  CoreOptions.mavenBundle().groupId("myGroupId")
>
> .artifactId("myArtifactId2").version("0.0.1-SNAPSHOT").start(),
>          };
>      }
>
> but:
>
> BundleContext bc = b.getBundleContext();
> ServiceTracker st = new ServiceTracker(bc, AppProfile.class.getName(),
> null);
> st.open();
> Object service = st.waitForService(90 * 1000);
>
> returns service == null
>
> Is there anything else I should do? Should I somehow add blueprint
> support in PaxExam configuration (config() function?), because it seems
> that AppProfile service is not registered?
>
> Thank you in advance,
> Milan

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com