After a lot of study I got the annotations to work, and updated the wiki with 
what I found necessary.  (yes, @Before and @After work fine in superclasses :-)

Now I'm interested if anyone has a clue about (2) and (3) :-)

many thanks!
david jencks

On Mar 2, 2012, at 12:12 AM, Achim Nierbeck wrote:

> Hi David,
> 
> I'm not sure if the @Before and @After are called in the super class
> but I know they do work in the derived classes.
> You might take a look at the pax web integration tests at [1] for example.
> Maybe this gives you the needed hint :)
> 
> regards, Achim
> 
> [1] - 
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/itest/src/test/java/org/ops4j/pax/web/itest/HttpServiceIntegrationTest.java
> 
> 
> 2012/3/2 David Jencks <david_jen...@yahoo.com>:
>> Any ideas?  I'd particularly like to understand why the @Before and @After 
>> annotations don't work.  This is getting somewhat critical for me....
>> 
>> thanks
>> david jencks
>> 
>> On Feb 22, 2012, at 5:00 PM, David Jencks wrote:
>> 
>>> I've been trying to write a new integration test for felix scr using 
>>> pax-exam 2.4.0.RC1 and I'm having some problems.  I'm using
>>>      <artifactId>pax-exam-container-forked</artifactId>
>>> 
>>>      <groupId>org.eclipse</groupId>
>>>      <artifactId>osgi</artifactId>
>>>      <version>3.7.1.R37x_v20110808-1106</version>
>>> 
>>> 
>>> 
>>> 1. I haven't been able to get the junit @Before and @After annotations to 
>>> work. They are in my test class's superclass, but the @inject and 
>>> @Configuration annotations all work in the superclass.
>>> 
>>> 2.  I'm running the test using equinox and equinox appears to be starting 
>>> its internal log service, and felix ds (that I'm trying to test) is using 
>>> that one rather than pax-logging.  Any idea how to get ds to use 
>>> pax-logging instead of equinox's log service?
>>> 
>>> 3.  I have to stop the framework in my test to demonstrate the behavior I'm 
>>> interested in.  This seems to cause the test to fail when pax-exam tries to 
>>> stop the framework.  I get a stack trace like:
>>> 
>>>    <error message="BundleContext is no longer valid" 
>>> type="java.lang.IllegalStateException">java.lang.IllegalStateException: 
>>> BundleContext is no longer valid
>>>        at 
>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.checkValid(BundleContextImpl.java:931)
>>>        at 
>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.ungetService(BundleContextImpl.java:634)
>>>        at 
>>> org.osgi.util.tracker.ServiceTracker.removedService(ServiceTracker.java:495)
>>>        at 
>>> org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1006)
>>>        at 
>>> org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1)
>>>        at 
>>> org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:352)
>>>        at 
>>> org.osgi.util.tracker.ServiceTracker.close(ServiceTracker.java:412)
>>>        at 
>>> org.eclipse.osgi.framework.internal.core.ConsoleManager.stopConsole(ConsoleManager.java:209)
>>>        at 
>>> org.eclipse.osgi.framework.internal.core.EquinoxLauncher.stop(EquinoxLauncher.java:284)
>>>        at org.eclipse.osgi.launch.Equinox.stop(Equinox.java:266)
>>>        at 
>>> org.ops4j.pax.swissbox.framework.RemoteFrameworkImpl.stop(RemoteFrameworkImpl.java:91)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at 
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at 
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at 
>>> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303)
>>>        at sun.rmi.transport.Transport$1.run(Transport.java:159)
>>>        at java.security.AccessController.doPrivileged(Native Method)
>>>        at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
>>>        at 
>>> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
>>>        at 
>>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
>>>        at 
>>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
>>>        at 
>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>        at 
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>        at java.lang.Thread.run(Thread.java:680)
>>>        at 
>>> sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
>>>        at 
>>> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
>>>        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
>>>        at 
>>> java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
>>>        at 
>>> java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
>>>        at $Proxy12.stop(Unknown Source)
>>>        at 
>>> org.ops4j.pax.exam.forked.ForkedTestContainer.stop(ForkedTestContainer.java:179)
>>>        at 
>>> org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:77)
>>>        at 
>>> org.ops4j.pax.exam.junit.JUnit4TestRunner$3.evaluate(JUnit4TestRunner.java:304)
>>>        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
>>>        at 
>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
>>>        at 
>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
>>>        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
>>>        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
>>>        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
>>>        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
>>>        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
>>>        at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
>>>        at 
>>> org.ops4j.pax.exam.junit.JUnit4TestRunner.run(JUnit4TestRunner.java:93)
>>>        at 
>>> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
>>>        at 
>>> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
>>>        at 
>>> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at 
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at 
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at 
>>> org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
>>>        at $Proxy0.invoke(Unknown Source)
>>>        at 
>>> org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
>>>        at 
>>> org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
>>>        at 
>>> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
>>> 
>>> Is there any way to avoid this error such as by having pax-exam check if 
>>> the framework is already stopped before trying to stop it?
>>> 
>>> Many thanks for any hints!!
>>> 
>>> david jencks
>>> 
>>> 
>>> _______________________________________________
>>> general mailing list
>>> general@lists.ops4j.org
>>> http://lists.ops4j.org/mailman/listinfo/general
>> 
>> 
>> _______________________________________________
>> general mailing list
>> general@lists.ops4j.org
>> http://lists.ops4j.org/mailman/listinfo/general
> 
> 
> 
> -- 
> 
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
> Committer & Project Lead
> blog <http://notizblog.nierbeck.de/>
> 
> _______________________________________________
> general mailing list
> general@lists.ops4j.org
> http://lists.ops4j.org/mailman/listinfo/general


_______________________________________________
general mailing list
general@lists.ops4j.org
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to