openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r831026 - in /incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test: component/intercept/webbeans/CallBusinessInConstructorBean.java unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
Date Thu, 29 Oct 2009 16:56:01 GMT
Author: gerdogdu
Date: Thu Oct 29 16:56:00 2009
New Revision: 831026

URL: http://svn.apache.org/viewvc?rev=831026&view=rev
Log:
Testing calling business method from constructor.

Added:
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/intercept/webbeans/CallBusinessInConstructorBean.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
  (with props)

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/intercept/webbeans/CallBusinessInConstructorBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/intercept/webbeans/CallBusinessInConstructorBean.java?rev=831026&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/intercept/webbeans/CallBusinessInConstructorBean.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/intercept/webbeans/CallBusinessInConstructorBean.java
Thu Oct 29 16:56:00 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.test.component.intercept.webbeans;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+import org.apache.webbeans.test.component.intercept.webbeans.bindings.Secure;
+
+@Named
+@RequestScoped
+public class CallBusinessInConstructorBean
+{
+    public CallBusinessInConstructorBean()
+    {
+        shuffle();
+    }
+    
+    @Secure
+    public void shuffle()
+    {
+        
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/intercept/webbeans/CallBusinessInConstructorBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java?rev=831026&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
Thu Oct 29 16:56:00 2009
@@ -0,0 +1,87 @@
+/*
+ * 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.test.unittests.intercept.webbeans;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.spi.Bean;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.context.RequestContext;
+import org.apache.webbeans.test.component.intercept.webbeans.CallBusinessInConstructorBean;
+import org.apache.webbeans.test.component.intercept.webbeans.SecureInterceptor;
+import org.apache.webbeans.test.servlet.TestContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CallingBusinessInConstructorTest extends TestContext
+{
+    public CallingBusinessInConstructorTest()
+    {
+        super(CallingBusinessInConstructorTest.class.getName());
+    }
+    
+    @Before
+    public void init()
+    {
+        super.init();
+        
+        SecureInterceptor.CALL = false;
+        initializeInterceptorType(SecureInterceptor.class);
+    }
+    
+    @After
+    public void after()
+    {
+        SecureInterceptor.CALL = false;
+    }
+    
+    @Test
+    public void testCallBusinessInConstructor()
+    {
+        ContextFactory.initRequestContext(null);
+        
+        clear();        
+        
+        defineSimpleWebBeanInterceptor(SecureInterceptor.class);
+        Bean<CallBusinessInConstructorBean> bean = defineSimpleWebBean(CallBusinessInConstructorBean.class);
+        CallBusinessInConstructorBean instance = (CallBusinessInConstructorBean) getInstanceByName("callBusinessInConstructorBean");
+        
+        Assert.assertNotNull(instance);
+        
+        Assert.assertTrue(SecureInterceptor.CALL);
+        
+        ContextFactory.destroyRequestContext(null);
+        
+        SecureInterceptor.CALL = false;
+        
+        ContextFactory.initRequestContext(null);
+        
+        RequestContext ctx = (RequestContext) ContextFactory.getStandardContext(RequestScoped.class);
+                
+        Assert.assertNull(ctx.get(bean));
+                
+        instance = (CallBusinessInConstructorBean) getInstanceByName("callBusinessInConstructorBean");
+        
+        Assert.assertNotNull(instance);
+        
+        Assert.assertTrue(!SecureInterceptor.CALL);
+        
+        ContextFactory.destroyRequestContext(null);
+        
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message