You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/02/17 14:52:14 UTC

svn commit: r508760 - /myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java

Author: cagatay
Date: Sat Feb 17 05:52:14 2007
New Revision: 508760

URL: http://svn.apache.org/viewvc?view=rev&rev=508760
Log:
Add test for SecurityContext

Added:
    myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java   (with props)

Added: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java?view=auto&rev=508760
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java Sat Feb 17 05:52:14 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.myfaces.custom.security;
+
+import java.security.Principal;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+/**
+ * @author cagatay (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class SecurityContextPropertyResolverTest extends AbstractJsfTestCase{
+
+	protected SecurityContextPropertyResolver resolver;
+	
+	public SecurityContextPropertyResolverTest(String testName) {
+		super(testName);
+	}
+	
+	public void setUp() throws Exception{
+		super.setUp();
+		resolver = new SecurityContextPropertyResolver(null);
+	}
+	
+	public void tearDown() throws Exception{
+		super.tearDown();
+		resolver = null;
+	}
+	
+	public static Test suite() {
+		return new TestSuite(SecurityContextPropertyResolverTest.class);
+	}
+	
+	//#{securityContext.remoteUser}
+	public void testRemoteUser() {
+		request.setUserPrincipal(new TestPrincipalImpl("Ronaldinho"));
+		
+		SecurityContext securityContext = new SecurityContextImpl();
+		String user = (String) resolver.getValue(securityContext, "remoteUser");
+		assertEquals("Ronaldinho", user);
+	}
+	
+	public static class TestPrincipalImpl implements Principal {
+
+		private String _name;
+
+		public TestPrincipalImpl() {
+			// NoOp
+		}
+
+		public TestPrincipalImpl(String name) {
+			this._name = name;
+		}
+
+		public String getName() {
+			return _name;
+		}
+	}
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision