Hi! I now added a really simple test which shows the problems with OWB-351.
Please be aware that this will currently break the build! But since this is a blocker, we should get rid of those problems really soon. Thus, the more pain the more quickly we will fix it ;) If you like to build OWB, you have to comment out the @Test from SessionContextTest#testInstanceCreation() LieGrue, strub --- strub...@apache.org <strub...@apache.org> schrieb am Mo, 12.4.2010: > Von: strub...@apache.org <strub...@apache.org> > Betreff: svn commit: r933198 - in > /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session: > common/AppScopedBean.java common/PersonalDataBean.java > tests/SessionContextTest.java > An: comm...@openwebbeans.apache.org > Datum: Montag, 12. April, 2010 13:44 Uhr > Author: struberg > Date: Mon Apr 12 11:44:22 2010 > New Revision: 933198 > > URL: http://svn.apache.org/viewvc?rev=933198&view=rev > Log: > OWB-351 this simple test shows the problems with our > CreationalContexts > > The test takes an @ApplicationScoped bean which got a proxy > for a > @SessionScoped bean injected, and verifies that we get > different @SessionScoped > contextual instances for different sessions. > > Attention: this currently breaks the build, but this is a > real blocker! > > Added: > > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java > Modified: > > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java > > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java > > Added: > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java > URL: > http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java?rev=933198&view=auto > ============================================================================== > --- > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java > (added) > +++ > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/AppScopedBean.java > Mon Apr 12 11:44:22 2010 > @@ -0,0 +1,32 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under > one > + * or more contributor license agreements. See the NOTICE > file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this > file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in > compliance > + * with the License. You may obtain a copy of the License > at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in > writing, > + * software distributed under the License is distributed > on an > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > + * KIND, either express or implied. See the License for > the > + * specific language governing permissions and > limitations > + * under the License. > + */ > +package > org.apache.webbeans.newtests.contexts.session.common; > + > +import javax.enterprise.context.ApplicationScoped; > +import javax.inject.Inject; > + > +...@applicationscoped > +public class AppScopedBean { > + > + private @Inject PersonalDataBean pdb; > + > + public PersonalDataBean getPdb() { > + return pdb; > + } > +} > > Modified: > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java > URL: > http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java?rev=933198&r1=933197&r2=933198&view=diff > ============================================================================== > --- > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java > (original) > +++ > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java > Mon Apr 12 11:44:22 2010 > @@ -1,15 +1,20 @@ > /* > - * Licensed to the Apache Software Foundation (ASF) under > one or more > - * contributor license agreements. See the NOTICE file > distributed with this > - * work for additional information regarding copyright > ownership. The ASF > - * licenses this file to You under the Apache License, > Version 2.0 (the > - * "License"); you may not use this file except in > compliance with the License. > - * You may obtain a copy of the License at > - * http://www.apache.org/licenses/LICENSE-2.0 Unless > required by applicable law > - * or agreed to in writing, software distributed under the > License is > - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR > CONDITIONS OF ANY > - * KIND, either express or implied. See the License for > the specific language > - * governing permissions and limitations under the > License. > + * Licensed to the Apache Software Foundation (ASF) under > one > + * or more contributor license agreements. See the NOTICE > file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this > file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in > compliance > + * with the License. You may obtain a copy of the License > at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in > writing, > + * software distributed under the License is distributed > on an > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > + * KIND, either express or implied. See the License for > the > + * specific language governing permissions and > limitations > + * under the License. > */ > package > org.apache.webbeans.newtests.contexts.session.common; > > @@ -52,4 +57,9 @@ public class PersonalDataBean implements > { > PRE_DESTROY = true; > } > + > + public PersonalDataBean getInstance() > + { > + return this; > + } > } > > Modified: > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java > URL: > http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java?rev=933198&r1=933197&r2=933198&view=diff > ============================================================================== > --- > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java > (original) > +++ > openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java > Mon Apr 12 11:44:22 2010 > @@ -1,26 +1,33 @@ > /* > - * Licensed to the Apache Software Foundation (ASF) under > one or more > - * contributor license agreements. See the NOTICE file > distributed with this > - * work for additional information regarding copyright > ownership. The ASF > - * licenses this file to You under the Apache License, > Version 2.0 (the > - * "License"); you may not use this file except in > compliance with the License. > - * You may obtain a copy of the License at > - * http://www.apache.org/licenses/LICENSE-2.0 Unless > required by applicable law > - * or agreed to in writing, software distributed under the > License is > - * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR > CONDITIONS OF ANY > - * KIND, either express or implied. See the License for > the specific language > - * governing permissions and limitations under the > License. > + * Licensed to the Apache Software Foundation (ASF) under > one > + * or more contributor license agreements. See the NOTICE > file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this > file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in > compliance > + * with the License. You may obtain a copy of the License > at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in > writing, > + * software distributed under the License is distributed > on an > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > + * KIND, either express or implied. See the License for > the > + * specific language governing permissions and > limitations > + * under the License. > */ > package > org.apache.webbeans.newtests.contexts.session.tests; > > import java.util.ArrayList; > import java.util.Collection; > > +import javax.enterprise.context.SessionScoped; > import javax.enterprise.inject.spi.Bean; > > import junit.framework.Assert; > > import org.apache.webbeans.newtests.AbstractUnitTest; > +import > org.apache.webbeans.newtests.contexts.session.common.AppScopedBean; > import > org.apache.webbeans.newtests.contexts.session.common.PersonalDataBean; > import org.junit.Test; > > @@ -54,4 +61,28 @@ public class SessionContextTest extends > > > Assert.assertTrue(PersonalDataBean.PRE_DESTROY); > } > > + @Test > + public void testInstanceCreation() > + { > + > Collection<Class<?>> classes = new > ArrayList<Class<?>>(); > + > classes.add(PersonalDataBean.class); > + > classes.add(AppScopedBean.class); > + > + startContainer(classes); > + > + AppScopedBean appBeanInstance > = getInstance(AppScopedBean.class); > + > Assert.assertNotNull(appBeanInstance); > + PersonalDataBean pdb1 = > appBeanInstance.getPdb().getInstance(); > + Assert.assertNotNull(pdb1); > + > + // now we reset the session > Context so we should get a new contextual instance. > + > getLifecycle().getContextService().endContext(SessionScoped.class, > null); > + > getLifecycle().getContextService().startContext(SessionScoped.class, > null); > + > + PersonalDataBean pdb2 = > appBeanInstance.getPdb().getInstance(); > + Assert.assertNotNull(pdb2); > + > + // pdb1 and pdb2 are in > different sessions, so they must not be the same instance! > + Assert.assertTrue(pdb1 != > pdb2); > + } > } > > > __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com