[jboss-cvs] JBossAS SVN: r64502 - in branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer: unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 8 06:03:47 EDT 2007
Author: wolfc
Date: 2007-08-08 06:03:47 -0400 (Wed, 08 Aug 2007)
New Revision: 64502
Added:
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/SecuredTimerTesterBean.java
Modified:
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java
Log:
EJBTHREE-1027: unit test
Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/SecuredTimerTesterBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/SecuredTimerTesterBean.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/SecuredTimerTesterBean.java 2007-08-08 10:03:47 UTC (rev 64502)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.timer;
+
+import javax.annotation.security.PermitAll;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+
+import org.jboss.annotation.security.SecurityDomain;
+import org.jboss.logging.Logger;
+
+/**
+ * NOTE: We use a security domain without an unauthenticatedIdentity set.
+ *
+ * @author carlo
+ *
+ */
+ at Stateless
+ at Remote(TimerTester.class)
+ at SecurityDomain("other")
+public class SecuredTimerTesterBean extends BaseTimerTesterBean
+{
+ private static final Logger log = Logger.getLogger(SecuredTimerTesterBean.class);
+
+ @Timeout
+ @PermitAll
+ public void timeoutHandler(Timer timer)
+ {
+ // We should never get here, because we don't have a principal (unauthenticatedIdentity is not set)
+ log.info("EJB TIMEOUT!!!!");
+ log.info("caller principal = " + ctx.getCallerPrincipal());
+ timerCalled = true;
+ //timer.cancel();
+ }
+}
Property changes on: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/SecuredTimerTesterBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java 2007-08-08 09:58:27 UTC (rev 64501)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java 2007-08-08 10:03:47 UTC (rev 64502)
@@ -28,6 +28,8 @@
import org.jboss.ejb3.test.timer.TimerTester;
import org.jboss.ejb3.test.timer.LifecycleRemote;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
import org.jboss.test.JBossTestCase;
import junit.framework.Test;
@@ -78,6 +80,39 @@
assertTrue(test.isTimerCalled());
}
+ // EJBTHREE-1027
+ public void testSecurity() throws Exception
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
+ SecurityAssociation.setCredential("password".toCharArray());
+
+ TimerTester test = (TimerTester) getInitialContext().lookup("SecuredTimerTesterBean/remote");
+ test.startTimer(5000);
+ test.accessTimer();
+ Thread.sleep(6000);
+ assertFalse(test.isTimerCalled());
+ test.startTimerViaEJBContext(5000);
+ test.accessTimer();
+ Thread.sleep(6000);
+ assertFalse(test.isTimerCalled());
+ }
+
+ // EJBTHREE-1027
+ public void testSecurityWithPersistence() throws Exception
+ {
+ TimerTester test = (TimerTester) getInitialContext().lookup("SecuredTimerTesterBean/remote");
+ long when = System.currentTimeMillis() + 5000;
+ test.setTimer(new Date(when));
+
+ redeploy("timer-test.jar");
+
+ test = (TimerTester) getInitialContext().lookup("SecuredTimerTesterBean/remote");
+ long wait = 1000 + (when - System.currentTimeMillis());
+ if(wait > 0)
+ Thread.sleep(wait);
+ assertFalse(test.isTimerCalled());
+ }
+
public void testService() throws Exception
{
TimerTester test = (TimerTester) getInitialContext().lookup("TimerTesterService/remote");
@@ -91,7 +126,7 @@
assertTrue(test.isTimerCalled());
}
- public void atestSimple() throws Exception
+ public void testSimple() throws Exception
{
TimerTester test = (TimerTester) this.getInitialContext().lookup("TimerTesterBean/remote");
test.startTimer(5000);
More information about the jboss-cvs-commits
mailing list