[jboss-cvs] JBossAS SVN: r63196 - in trunk/ejb3/src/test/org/jboss/ejb3/test: ejbthree973 and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 24 06:57:30 EDT 2007
Author: wolfc
Date: 2007-05-24 06:57:30 -0400 (Thu, 24 May 2007)
New Revision: 63196
Added:
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmI.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmIBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/unit/AnonymousCallerPrincipalTestCase.java
Log:
EJBTHREE-973: unit test
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmI.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmI.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmI.java 2007-05-24 10:57:30 UTC (rev 63196)
@@ -0,0 +1,33 @@
+/*
+ * 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.ejbthree973;
+
+/**
+ * Report the caller principal.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface WhoAmI
+{
+ String getCallerPrincipal();
+}
\ No newline at end of file
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmI.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmIBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmIBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmIBean.java 2007-05-24 10:57:30 UTC (rev 63196)
@@ -0,0 +1,52 @@
+/*
+ * 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.ejbthree973;
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+
+import org.jboss.annotation.security.SecurityDomain;
+
+/**
+ * Report the caller principal.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(WhoAmI.class)
+ at SecurityDomain(value="", unauthenticatedPrincipal="anonymous")
+public class WhoAmIBean implements WhoAmI
+{
+ @Resource
+ private SessionContext ctx;
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.test.ejbthree973.WhoAmI#getCallerPrincipal()
+ */
+ public String getCallerPrincipal()
+ {
+ return ctx.getCallerPrincipal().getName();
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/WhoAmIBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/unit/AnonymousCallerPrincipalTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/unit/AnonymousCallerPrincipalTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/unit/AnonymousCallerPrincipalTestCase.java 2007-05-24 10:57:30 UTC (rev 63196)
@@ -0,0 +1,61 @@
+/*
+ * 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.ejbthree973.unit;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree973.WhoAmI;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test to see if we can get a caller principal without running in
+ * a security domain.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class AnonymousCallerPrincipalTestCase extends JBossTestCase
+{
+
+ public AnonymousCallerPrincipalTestCase(String name)
+ {
+ super(name);
+ }
+
+ private WhoAmI lookupBean() throws Exception
+ {
+ return (WhoAmI) getInitialContext().lookup("WhoAmIBean/remote");
+ }
+
+ public void testPrincipal() throws Exception
+ {
+ WhoAmI bean = lookupBean();
+ String actual = bean.getCallerPrincipal();
+ // "anonymous" is defined in the @SecurityDomain on WhoAmIBean
+ assertEquals("anonymous", actual);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(AnonymousCallerPrincipalTestCase.class, "ejbthree973.jar");
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree973/unit/AnonymousCallerPrincipalTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list