You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by ad...@apache.org on 2010/05/26 20:34:49 UTC
svn commit: r948527 [27/38] - in /incubator/shiro:
branches/shiro-root-1.0.x/ branches/shiro-root-1.0.x/all/
branches/shiro-root-1.0.x/core/src/main/java/org/apache/shiro/
branches/shiro-root-1.0.x/core/src/main/java/org/apache/shiro/aop/
branches/shir...
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/HostUnauthorizedExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/HostUnauthorizedExceptionTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/HostUnauthorizedExceptionTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/HostUnauthorizedExceptionTest.java Wed May 26 18:34:28 2010
@@ -1,33 +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.
- */
-package org.apache.shiro.authz;
-
-import org.apache.shiro.ExceptionTest;
-
-
-/**
- * @author Les Hazlewood
- * @since Jun 10, 2008 4:04:38 PM
- */
-public class HostUnauthorizedExceptionTest extends ExceptionTest {
-
- protected Class getExceptionClass() {
- return HostUnauthorizedException.class;
- }
-}
+/*
+ * 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.shiro.authz;
+
+import org.apache.shiro.ExceptionTest;
+
+
+/**
+ * @author Les Hazlewood
+ * @since Jun 10, 2008 4:04:38 PM
+ */
+public class HostUnauthorizedExceptionTest extends ExceptionTest {
+
+ protected Class getExceptionClass() {
+ return HostUnauthorizedException.class;
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/HostUnauthorizedExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthenticatedExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthenticatedExceptionTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthenticatedExceptionTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthenticatedExceptionTest.java Wed May 26 18:34:28 2010
@@ -1,33 +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.
- */
-package org.apache.shiro.authz;
-
-import org.apache.shiro.ExceptionTest;
-
-
-/**
- * @author Les Hazlewood
- * @since Jun 10, 2008 4:06:15 PM
- */
-public class UnauthenticatedExceptionTest extends ExceptionTest {
-
- protected Class getExceptionClass() {
- return UnauthenticatedException.class;
- }
-}
+/*
+ * 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.shiro.authz;
+
+import org.apache.shiro.ExceptionTest;
+
+
+/**
+ * @author Les Hazlewood
+ * @since Jun 10, 2008 4:06:15 PM
+ */
+public class UnauthenticatedExceptionTest extends ExceptionTest {
+
+ protected Class getExceptionClass() {
+ return UnauthenticatedException.class;
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthenticatedExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthorizedExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthorizedExceptionTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthorizedExceptionTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthorizedExceptionTest.java Wed May 26 18:34:28 2010
@@ -1,33 +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.
- */
-package org.apache.shiro.authz;
-
-import org.apache.shiro.ExceptionTest;
-
-
-/**
- * @author Les Hazlewood
- * @since Jun 10, 2008 4:06:45 PM
- */
-public class UnauthorizedExceptionTest extends ExceptionTest {
-
- protected Class getExceptionClass() {
- return UnauthorizedException.class;
- }
-}
+/*
+ * 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.shiro.authz;
+
+import org.apache.shiro.ExceptionTest;
+
+
+/**
+ * @author Les Hazlewood
+ * @since Jun 10, 2008 4:06:45 PM
+ */
+public class UnauthorizedExceptionTest extends ExceptionTest {
+
+ protected Class getExceptionClass() {
+ return UnauthorizedException.class;
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/UnauthorizedExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/aop/PermissionAnnotationHandlerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/aop/RoleAnnotationHandlerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/permission/AllPermissionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorServiceTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorServiceTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorServiceTest.java Wed May 26 18:34:28 2010
@@ -1,75 +1,75 @@
-/*
- * 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.shiro.concurrent;
-
-import org.apache.shiro.subject.support.SubjectRunnable;
-import org.apache.shiro.test.SecurityManagerTestSupport;
-import org.junit.Test;
-
-import java.util.concurrent.*;
-
-import static org.easymock.EasyMock.*;
-
-/**
- * Test cases for the {@link SubjectAwareExecutorService} implementation.
- */
-public class SubjectAwareExecutorServiceTest extends SecurityManagerTestSupport {
-
- @SuppressWarnings({"unchecked"})
- @Test
- public void testSubmitRunnable() {
- ExecutorService mockExecutorService = createNiceMock(ExecutorService.class);
- expect(mockExecutorService.submit(isA(SubjectRunnable.class))).andReturn(new DummyFuture());
- replay(mockExecutorService);
-
- final SubjectAwareExecutorService executor = new SubjectAwareExecutorService(mockExecutorService);
-
- Runnable testRunnable = new Runnable() {
- public void run() {
- System.out.println("Hello World");
- }
- };
-
- executor.submit(testRunnable);
- verify(mockExecutorService);
- }
-
- private class DummyFuture<V> implements Future<V> {
-
- public boolean cancel(boolean b) {
- return false;
- }
-
- public boolean isCancelled() {
- return false;
- }
-
- public boolean isDone() {
- return true;
- }
-
- public V get() throws InterruptedException, ExecutionException {
- return null;
- }
-
- public V get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
- return null;
- }
- }
-}
+/*
+ * 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.shiro.concurrent;
+
+import org.apache.shiro.subject.support.SubjectRunnable;
+import org.apache.shiro.test.SecurityManagerTestSupport;
+import org.junit.Test;
+
+import java.util.concurrent.*;
+
+import static org.easymock.EasyMock.*;
+
+/**
+ * Test cases for the {@link SubjectAwareExecutorService} implementation.
+ */
+public class SubjectAwareExecutorServiceTest extends SecurityManagerTestSupport {
+
+ @SuppressWarnings({"unchecked"})
+ @Test
+ public void testSubmitRunnable() {
+ ExecutorService mockExecutorService = createNiceMock(ExecutorService.class);
+ expect(mockExecutorService.submit(isA(SubjectRunnable.class))).andReturn(new DummyFuture());
+ replay(mockExecutorService);
+
+ final SubjectAwareExecutorService executor = new SubjectAwareExecutorService(mockExecutorService);
+
+ Runnable testRunnable = new Runnable() {
+ public void run() {
+ System.out.println("Hello World");
+ }
+ };
+
+ executor.submit(testRunnable);
+ verify(mockExecutorService);
+ }
+
+ private class DummyFuture<V> implements Future<V> {
+
+ public boolean cancel(boolean b) {
+ return false;
+ }
+
+ public boolean isCancelled() {
+ return false;
+ }
+
+ public boolean isDone() {
+ return true;
+ }
+
+ public V get() throws InterruptedException, ExecutionException {
+ return null;
+ }
+
+ public V get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
+ return null;
+ }
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorServiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java Wed May 26 18:34:28 2010
@@ -1,55 +1,55 @@
-/*
- * 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.shiro.concurrent;
-
-import org.apache.shiro.subject.support.SubjectRunnable;
-import org.apache.shiro.test.SecurityManagerTestSupport;
-import org.junit.Test;
-
-import java.util.concurrent.Executor;
-
-import static org.easymock.EasyMock.*;
-
-/**
- * Test cases for the {@link SubjectAwareExecutor} implementation.
- *
- * @since 1.0
- */
-public class SubjectAwareExecutorTest extends SecurityManagerTestSupport {
-
- @Test
- public void testExecute() {
- Executor targetMockExecutor = createNiceMock(Executor.class);
- //* ensure the target Executor receives a SubjectRunnable instance that retains the subject identity:
- //(this is what verifies the test is valid):
- targetMockExecutor.execute(isA(SubjectRunnable.class));
- replay(targetMockExecutor);
-
- final SubjectAwareExecutor executor = new SubjectAwareExecutor(targetMockExecutor);
-
- Runnable work = new Runnable() {
- public void run() {
- System.out.println("Hello World");
- }
- };
- executor.execute(work);
-
- verify(targetMockExecutor);
- }
-}
+/*
+ * 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.shiro.concurrent;
+
+import org.apache.shiro.subject.support.SubjectRunnable;
+import org.apache.shiro.test.SecurityManagerTestSupport;
+import org.junit.Test;
+
+import java.util.concurrent.Executor;
+
+import static org.easymock.EasyMock.*;
+
+/**
+ * Test cases for the {@link SubjectAwareExecutor} implementation.
+ *
+ * @since 1.0
+ */
+public class SubjectAwareExecutorTest extends SecurityManagerTestSupport {
+
+ @Test
+ public void testExecute() {
+ Executor targetMockExecutor = createNiceMock(Executor.class);
+ //* ensure the target Executor receives a SubjectRunnable instance that retains the subject identity:
+ //(this is what verifies the test is valid):
+ targetMockExecutor.execute(isA(SubjectRunnable.class));
+ replay(targetMockExecutor);
+
+ final SubjectAwareExecutor executor = new SubjectAwareExecutor(targetMockExecutor);
+
+ Runnable work = new Runnable() {
+ public void run() {
+ System.out.println("Hello World");
+ }
+ };
+ executor.execute(work);
+
+ verify(targetMockExecutor);
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/concurrent/SubjectAwareExecutorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/CompositeBean.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/CompositeBean.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/CompositeBean.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/CompositeBean.java Wed May 26 18:34:28 2010
@@ -1,109 +1,109 @@
-/*
- * 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.shiro.config;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Les Hazlewood
- * @since Aug 5, 2008 10:17:37 AM
- */
-@SuppressWarnings({"UnusedDeclaration"})
-public class CompositeBean {
-
- private String stringProp;
- private boolean booleanProp;
- private int intProp;
- private SimpleBean simpleBean;
-
- private Set<SimpleBean> simpleBeanSet;
- private List<SimpleBean> simpleBeanList;
- private Collection<SimpleBean> simpleBeanCollection;
- private Map<String, SimpleBean> simpleBeanMap;
-
- public CompositeBean() {
- }
-
- public String getStringProp() {
- return stringProp;
- }
-
- public void setStringProp(String stringProp) {
- this.stringProp = stringProp;
- }
-
- public boolean isBooleanProp() {
- return booleanProp;
- }
-
- public void setBooleanProp(boolean booleanProp) {
- this.booleanProp = booleanProp;
- }
-
- public int getIntProp() {
- return intProp;
- }
-
- public void setIntProp(int intProp) {
- this.intProp = intProp;
- }
-
- public SimpleBean getSimpleBean() {
- return simpleBean;
- }
-
- public void setSimpleBean(SimpleBean simpleBean) {
- this.simpleBean = simpleBean;
- }
-
- public Set<SimpleBean> getSimpleBeanSet() {
- return simpleBeanSet;
- }
-
- public void setSimpleBeanSet(Set<SimpleBean> simpleBeanSet) {
- this.simpleBeanSet = simpleBeanSet;
- }
-
- public List<SimpleBean> getSimpleBeanList() {
- return simpleBeanList;
- }
-
- public void setSimpleBeanList(List<SimpleBean> simpleBeanList) {
- this.simpleBeanList = simpleBeanList;
- }
-
- public Collection<SimpleBean> getSimpleBeanCollection() {
- return simpleBeanCollection;
- }
-
- public void setSimpleBeanCollection(Collection<SimpleBean> simpleBeanCollection) {
- this.simpleBeanCollection = simpleBeanCollection;
- }
-
- public Map<String, SimpleBean> getSimpleBeanMap() {
- return simpleBeanMap;
- }
-
- public void setSimpleBeanMap(Map<String, SimpleBean> simpleBeanMap) {
- this.simpleBeanMap = simpleBeanMap;
- }
-}
+/*
+ * 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.shiro.config;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Les Hazlewood
+ * @since Aug 5, 2008 10:17:37 AM
+ */
+@SuppressWarnings({"UnusedDeclaration"})
+public class CompositeBean {
+
+ private String stringProp;
+ private boolean booleanProp;
+ private int intProp;
+ private SimpleBean simpleBean;
+
+ private Set<SimpleBean> simpleBeanSet;
+ private List<SimpleBean> simpleBeanList;
+ private Collection<SimpleBean> simpleBeanCollection;
+ private Map<String, SimpleBean> simpleBeanMap;
+
+ public CompositeBean() {
+ }
+
+ public String getStringProp() {
+ return stringProp;
+ }
+
+ public void setStringProp(String stringProp) {
+ this.stringProp = stringProp;
+ }
+
+ public boolean isBooleanProp() {
+ return booleanProp;
+ }
+
+ public void setBooleanProp(boolean booleanProp) {
+ this.booleanProp = booleanProp;
+ }
+
+ public int getIntProp() {
+ return intProp;
+ }
+
+ public void setIntProp(int intProp) {
+ this.intProp = intProp;
+ }
+
+ public SimpleBean getSimpleBean() {
+ return simpleBean;
+ }
+
+ public void setSimpleBean(SimpleBean simpleBean) {
+ this.simpleBean = simpleBean;
+ }
+
+ public Set<SimpleBean> getSimpleBeanSet() {
+ return simpleBeanSet;
+ }
+
+ public void setSimpleBeanSet(Set<SimpleBean> simpleBeanSet) {
+ this.simpleBeanSet = simpleBeanSet;
+ }
+
+ public List<SimpleBean> getSimpleBeanList() {
+ return simpleBeanList;
+ }
+
+ public void setSimpleBeanList(List<SimpleBean> simpleBeanList) {
+ this.simpleBeanList = simpleBeanList;
+ }
+
+ public Collection<SimpleBean> getSimpleBeanCollection() {
+ return simpleBeanCollection;
+ }
+
+ public void setSimpleBeanCollection(Collection<SimpleBean> simpleBeanCollection) {
+ this.simpleBeanCollection = simpleBeanCollection;
+ }
+
+ public Map<String, SimpleBean> getSimpleBeanMap() {
+ return simpleBeanMap;
+ }
+
+ public void setSimpleBeanMap(Map<String, SimpleBean> simpleBeanMap) {
+ this.simpleBeanMap = simpleBeanMap;
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/CompositeBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/HashMapCacheManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniSecurityManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniSecurityManagerFactoryTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniSecurityManagerFactoryTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniSecurityManagerFactoryTest.java Wed May 26 18:34:28 2010
@@ -1,209 +1,209 @@
-/*
- * 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.shiro.config;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authc.UsernamePasswordToken;
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.cache.MapCache;
-import org.apache.shiro.crypto.hash.Sha256Hash;
-import org.apache.shiro.mgt.DefaultSecurityManager;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.realm.Realm;
-import org.apache.shiro.realm.text.IniRealm;
-import org.apache.shiro.realm.text.PropertiesRealm;
-import org.apache.shiro.session.Session;
-import org.apache.shiro.session.mgt.AbstractSessionManager;
-import org.apache.shiro.session.mgt.DefaultSessionManager;
-import org.apache.shiro.session.mgt.eis.CachingSessionDAO;
-import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
-import org.apache.shiro.session.mgt.eis.SessionDAO;
-import org.apache.shiro.subject.Subject;
-import org.junit.Test;
-
-import java.util.Collection;
-
-import static junit.framework.Assert.*;
-
-/**
- * Unit tests for the {@link IniSecurityManagerFactory} implementation.
- *
- * @author The Apache Shiro Project (shiro-dev@incubator.apache.org)
- * @since 1.0
- */
-public class IniSecurityManagerFactoryTest {
-
- @Test
- public void testGetInstanceWithoutIni() {
- IniSecurityManagerFactory factory = new IniSecurityManagerFactory();
- SecurityManager sm = factory.getInstance();
- assertNotNull(sm);
- assertTrue(sm instanceof DefaultSecurityManager);
- }
-
- @Test
- public void testGetInstanceWithResourcePath() {
- String path = "classpath:org/apache/shiro/config/IniSecurityManagerFactoryTest.ini";
- IniSecurityManagerFactory factory = new IniSecurityManagerFactory(path);
- SecurityManager sm = factory.getInstance();
- assertNotNull(sm);
- assertTrue(sm instanceof DefaultSecurityManager);
- }
-
- @Test
- public void testGetInstanceWithEmptyIni() {
- Ini ini = new Ini();
- IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
- SecurityManager sm = factory.getInstance();
- assertNotNull(sm);
- assertTrue(sm instanceof DefaultSecurityManager);
- }
-
- @Test
- public void testGetInstanceWithSimpleIni() {
- Ini ini = new Ini();
- ini.setSectionProperty(IniSecurityManagerFactory.MAIN_SECTION_NAME,
- "securityManager.sessionManager.globalSessionTimeout", "5000");
- IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
- SecurityManager sm = factory.getInstance();
- assertNotNull(sm);
- assertTrue(sm instanceof DefaultSecurityManager);
- assertEquals(5000, ((AbstractSessionManager) ((DefaultSecurityManager) sm).getSessionManager()).getGlobalSessionTimeout());
- }
-
- @Test
- public void testGetInstanceWithConfiguredRealm() {
- Ini ini = new Ini();
- Ini.Section section = ini.addSection(IniSecurityManagerFactory.MAIN_SECTION_NAME);
- section.put("propsRealm", PropertiesRealm.class.getName());
- section.put("propsRealm.resourcePath",
- "classpath:org/apache/shiro/config/IniSecurityManagerFactoryTest.propsRealm.properties");
-
- IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
- SecurityManager sm = factory.getInstance();
- assertNotNull(sm);
- assertTrue(sm instanceof DefaultSecurityManager);
- Collection<Realm> realms = ((DefaultSecurityManager) sm).getRealms();
- assertEquals(1, realms.size());
- Realm realm = realms.iterator().next();
- assertTrue(realm instanceof PropertiesRealm);
- }
-
- @Test
- public void testGetInstanceWithAutomaticallyCreatedIniRealm() {
- Ini ini = new Ini();
- Ini.Section section = ini.addSection(IniRealm.USERS_SECTION_NAME);
- section.put("admin", "admin");
-
- IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
- SecurityManager sm = factory.getInstance();
- assertNotNull(sm);
- assertTrue(sm instanceof DefaultSecurityManager);
- Collection<Realm> realms = ((DefaultSecurityManager) sm).getRealms();
- assertEquals(1, realms.size());
- Realm realm = realms.iterator().next();
- assertTrue(realm instanceof IniRealm);
- assertTrue(((IniRealm) realm).accountExists("admin"));
- }
-
- /**
- * Test for issue <a href="https://issues.apache.org/jira/browse/SHIRO-125">SHIRO-125</a>.
- */
- @Test
- public void testImplicitIniRealmWithAdditionalRealmConfiguration() {
-
- Ini ini = new Ini();
-
- //The users section below should create an implicit 'iniRealm' instance in the
- //main configuration. So we should be able to set properties on it immediately
- //such as the Sha256 credentials matcher:
- Ini.Section main = ini.addSection("main");
- main.put("credentialsMatcher", "org.apache.shiro.authc.credential.Sha256CredentialsMatcher");
- main.put("iniRealm.credentialsMatcher", "$credentialsMatcher");
-
- //create a users section - user 'admin', with a Sha256-hashed 'admin' password (hex encoded):
- Ini.Section users = ini.addSection(IniRealm.USERS_SECTION_NAME);
- users.put("admin", new Sha256Hash("secret").toString());
-
- IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
- SecurityManager sm = factory.getInstance();
-
- //go ahead and try to log in with the admin user, ensuring the
- //iniRealm has a Sha256CredentialsMatcher enabled:
-
- //try to log-in:
- Subject subject = new Subject.Builder(sm).buildSubject();
- //ensure thread clean-up after the login method returns. Test cases only:
- subject.execute(new Runnable() {
- public void run() {
- //the plain-text 'secret' should be converted to an Sha256 hash first
- //by the CredentialsMatcher. This should return quietly if
- //this test case is valid:
- SecurityUtils.getSubject().login(new UsernamePasswordToken("admin", "secret"));
- }
- });
- assertTrue(subject.getPrincipal().equals("admin"));
- }
-
- /**
- * Test case for issue <a href="https://issues.apache.org/jira/browse/SHIRO-95">SHIRO-95</a>.
- */
- @Test
- public void testCacheManagerConfigOrderOfOperations() {
-
- Ini ini = new Ini();
- Ini.Section main = ini.addSection(IniSecurityManagerFactory.MAIN_SECTION_NAME);
- //create a non-default CacheManager:
- main.put("cacheManager", "org.apache.shiro.config.HashMapCacheManager");
-
- //now add a session DAO after the cache manager has been set - this is what tests the user-reported issue
- main.put("sessionDAO", "org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO");
- main.put("securityManager.sessionManager.sessionDAO", "$sessionDAO");
-
- //add the cache manager after the sessionDAO has been set:
- main.put("securityManager.cacheManager", "$cacheManager");
-
- //add a test user:
- ini.setSectionProperty(IniRealm.USERS_SECTION_NAME, "admin", "admin");
-
- IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
- SecurityManager sm = factory.getInstance();
-
- //try to log-in:
- Subject subject = new Subject.Builder(sm).buildSubject();
- subject.login(new UsernamePasswordToken("admin", "admin"));
- Session session = subject.getSession();
- session.setAttribute("hello", "world");
- //session should have been started, and a cache is in use. Assert that the SessionDAO is still using
- //the cache instances provided by our custom CacheManager and not the Default MemoryConstrainedCacheManager
-
- SessionDAO sessionDAO = ((DefaultSessionManager) ((DefaultSecurityManager) sm).getSessionManager()).getSessionDAO();
- assertTrue(sessionDAO instanceof EnterpriseCacheSessionDAO);
- CachingSessionDAO cachingSessionDAO = (CachingSessionDAO) sessionDAO;
- Cache activeSessionsCache = cachingSessionDAO.getActiveSessionsCache();
- assertTrue(activeSessionsCache instanceof MapCache);
- MapCache mapCache = (MapCache) activeSessionsCache;
-
- //this is the line that verifies Caches created by our specific CacheManager are not overwritten by the
- //default cache manager's caches:
- assertTrue(mapCache instanceof HashMapCacheManager.HashMapCache);
- }
-
-
-}
+/*
+ * 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.shiro.config;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.authc.UsernamePasswordToken;
+import org.apache.shiro.cache.Cache;
+import org.apache.shiro.cache.MapCache;
+import org.apache.shiro.crypto.hash.Sha256Hash;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.IniRealm;
+import org.apache.shiro.realm.text.PropertiesRealm;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.session.mgt.AbstractSessionManager;
+import org.apache.shiro.session.mgt.DefaultSessionManager;
+import org.apache.shiro.session.mgt.eis.CachingSessionDAO;
+import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
+import org.apache.shiro.session.mgt.eis.SessionDAO;
+import org.apache.shiro.subject.Subject;
+import org.junit.Test;
+
+import java.util.Collection;
+
+import static junit.framework.Assert.*;
+
+/**
+ * Unit tests for the {@link IniSecurityManagerFactory} implementation.
+ *
+ * @author The Apache Shiro Project (shiro-dev@incubator.apache.org)
+ * @since 1.0
+ */
+public class IniSecurityManagerFactoryTest {
+
+ @Test
+ public void testGetInstanceWithoutIni() {
+ IniSecurityManagerFactory factory = new IniSecurityManagerFactory();
+ SecurityManager sm = factory.getInstance();
+ assertNotNull(sm);
+ assertTrue(sm instanceof DefaultSecurityManager);
+ }
+
+ @Test
+ public void testGetInstanceWithResourcePath() {
+ String path = "classpath:org/apache/shiro/config/IniSecurityManagerFactoryTest.ini";
+ IniSecurityManagerFactory factory = new IniSecurityManagerFactory(path);
+ SecurityManager sm = factory.getInstance();
+ assertNotNull(sm);
+ assertTrue(sm instanceof DefaultSecurityManager);
+ }
+
+ @Test
+ public void testGetInstanceWithEmptyIni() {
+ Ini ini = new Ini();
+ IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
+ SecurityManager sm = factory.getInstance();
+ assertNotNull(sm);
+ assertTrue(sm instanceof DefaultSecurityManager);
+ }
+
+ @Test
+ public void testGetInstanceWithSimpleIni() {
+ Ini ini = new Ini();
+ ini.setSectionProperty(IniSecurityManagerFactory.MAIN_SECTION_NAME,
+ "securityManager.sessionManager.globalSessionTimeout", "5000");
+ IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
+ SecurityManager sm = factory.getInstance();
+ assertNotNull(sm);
+ assertTrue(sm instanceof DefaultSecurityManager);
+ assertEquals(5000, ((AbstractSessionManager) ((DefaultSecurityManager) sm).getSessionManager()).getGlobalSessionTimeout());
+ }
+
+ @Test
+ public void testGetInstanceWithConfiguredRealm() {
+ Ini ini = new Ini();
+ Ini.Section section = ini.addSection(IniSecurityManagerFactory.MAIN_SECTION_NAME);
+ section.put("propsRealm", PropertiesRealm.class.getName());
+ section.put("propsRealm.resourcePath",
+ "classpath:org/apache/shiro/config/IniSecurityManagerFactoryTest.propsRealm.properties");
+
+ IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
+ SecurityManager sm = factory.getInstance();
+ assertNotNull(sm);
+ assertTrue(sm instanceof DefaultSecurityManager);
+ Collection<Realm> realms = ((DefaultSecurityManager) sm).getRealms();
+ assertEquals(1, realms.size());
+ Realm realm = realms.iterator().next();
+ assertTrue(realm instanceof PropertiesRealm);
+ }
+
+ @Test
+ public void testGetInstanceWithAutomaticallyCreatedIniRealm() {
+ Ini ini = new Ini();
+ Ini.Section section = ini.addSection(IniRealm.USERS_SECTION_NAME);
+ section.put("admin", "admin");
+
+ IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
+ SecurityManager sm = factory.getInstance();
+ assertNotNull(sm);
+ assertTrue(sm instanceof DefaultSecurityManager);
+ Collection<Realm> realms = ((DefaultSecurityManager) sm).getRealms();
+ assertEquals(1, realms.size());
+ Realm realm = realms.iterator().next();
+ assertTrue(realm instanceof IniRealm);
+ assertTrue(((IniRealm) realm).accountExists("admin"));
+ }
+
+ /**
+ * Test for issue <a href="https://issues.apache.org/jira/browse/SHIRO-125">SHIRO-125</a>.
+ */
+ @Test
+ public void testImplicitIniRealmWithAdditionalRealmConfiguration() {
+
+ Ini ini = new Ini();
+
+ //The users section below should create an implicit 'iniRealm' instance in the
+ //main configuration. So we should be able to set properties on it immediately
+ //such as the Sha256 credentials matcher:
+ Ini.Section main = ini.addSection("main");
+ main.put("credentialsMatcher", "org.apache.shiro.authc.credential.Sha256CredentialsMatcher");
+ main.put("iniRealm.credentialsMatcher", "$credentialsMatcher");
+
+ //create a users section - user 'admin', with a Sha256-hashed 'admin' password (hex encoded):
+ Ini.Section users = ini.addSection(IniRealm.USERS_SECTION_NAME);
+ users.put("admin", new Sha256Hash("secret").toString());
+
+ IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
+ SecurityManager sm = factory.getInstance();
+
+ //go ahead and try to log in with the admin user, ensuring the
+ //iniRealm has a Sha256CredentialsMatcher enabled:
+
+ //try to log-in:
+ Subject subject = new Subject.Builder(sm).buildSubject();
+ //ensure thread clean-up after the login method returns. Test cases only:
+ subject.execute(new Runnable() {
+ public void run() {
+ //the plain-text 'secret' should be converted to an Sha256 hash first
+ //by the CredentialsMatcher. This should return quietly if
+ //this test case is valid:
+ SecurityUtils.getSubject().login(new UsernamePasswordToken("admin", "secret"));
+ }
+ });
+ assertTrue(subject.getPrincipal().equals("admin"));
+ }
+
+ /**
+ * Test case for issue <a href="https://issues.apache.org/jira/browse/SHIRO-95">SHIRO-95</a>.
+ */
+ @Test
+ public void testCacheManagerConfigOrderOfOperations() {
+
+ Ini ini = new Ini();
+ Ini.Section main = ini.addSection(IniSecurityManagerFactory.MAIN_SECTION_NAME);
+ //create a non-default CacheManager:
+ main.put("cacheManager", "org.apache.shiro.config.HashMapCacheManager");
+
+ //now add a session DAO after the cache manager has been set - this is what tests the user-reported issue
+ main.put("sessionDAO", "org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO");
+ main.put("securityManager.sessionManager.sessionDAO", "$sessionDAO");
+
+ //add the cache manager after the sessionDAO has been set:
+ main.put("securityManager.cacheManager", "$cacheManager");
+
+ //add a test user:
+ ini.setSectionProperty(IniRealm.USERS_SECTION_NAME, "admin", "admin");
+
+ IniSecurityManagerFactory factory = new IniSecurityManagerFactory(ini);
+ SecurityManager sm = factory.getInstance();
+
+ //try to log-in:
+ Subject subject = new Subject.Builder(sm).buildSubject();
+ subject.login(new UsernamePasswordToken("admin", "admin"));
+ Session session = subject.getSession();
+ session.setAttribute("hello", "world");
+ //session should have been started, and a cache is in use. Assert that the SessionDAO is still using
+ //the cache instances provided by our custom CacheManager and not the Default MemoryConstrainedCacheManager
+
+ SessionDAO sessionDAO = ((DefaultSessionManager) ((DefaultSecurityManager) sm).getSessionManager()).getSessionDAO();
+ assertTrue(sessionDAO instanceof EnterpriseCacheSessionDAO);
+ CachingSessionDAO cachingSessionDAO = (CachingSessionDAO) sessionDAO;
+ Cache activeSessionsCache = cachingSessionDAO.getActiveSessionsCache();
+ assertTrue(activeSessionsCache instanceof MapCache);
+ MapCache mapCache = (MapCache) activeSessionsCache;
+
+ //this is the line that verifies Caches created by our specific CacheManager are not overwritten by the
+ //default cache manager's caches:
+ assertTrue(mapCache instanceof HashMapCacheManager.HashMapCache);
+ }
+
+
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniSecurityManagerFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniTest.java Wed May 26 18:34:28 2010
@@ -1,90 +1,90 @@
-/*
- * 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.shiro.config;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-import java.util.Scanner;
-
-/**
- * Unit test for the {@link Ini} class.
- *
- * @since 1.0
- */
-public class IniTest {
-
- private static final String NL = "\n";
-
- @Test
- public void testNoSections() {
- String test =
- "prop1 = value1" + NL +
- "prop2 = value2";
-
- Ini ini = new Ini();
- ini.load(test);
-
- assertNotNull(ini.getSections());
- assertEquals(1, ini.getSections().size());
-
- Ini.Section section = ini.getSections().iterator().next();
- assertEquals(Ini.DEFAULT_SECTION_NAME, section.getName());
- assertFalse(section.isEmpty());
- assertEquals(2, section.size());
- assertEquals("value1", section.get("prop1"));
- assertEquals("value2", section.get("prop2"));
- }
-
- @Test
- public void testOneSection() {
- String sectionName = "main";
- String test = NL +
- "" + NL +
- " " + NL +
- " # comment1 " + NL +
- " ; comment 2" + NL +
- "[" + sectionName + "]" + NL +
- "prop1 = value1" + NL +
- " " + NL +
- "; comment " + NL +
- "prop2 value2" + NL +
- "prop3:value3" + NL +
- "prop4 : value 4" + NL +
- "prop5 some long \\" + NL +
- " value " + NL +
- "# comment.";
-
- Ini ini = new Ini();
- ini.load(new Scanner(test));
-
- assertNotNull(ini.getSections());
- assertEquals(1, ini.getSections().size());
- Ini.Section section = ini.getSection("main");
- assertNotNull(section);
- assertEquals(sectionName, section.getName());
- assertFalse(section.isEmpty());
- assertEquals(5, section.size());
- assertEquals("value1", section.get("prop1"));
- assertEquals("value2", section.get("prop2"));
- assertEquals("value3", section.get("prop3"));
- assertEquals("value 4", section.get("prop4"));
- assertEquals("some long value", section.get("prop5"));
- }
-}
+/*
+ * 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.shiro.config;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+import java.util.Scanner;
+
+/**
+ * Unit test for the {@link Ini} class.
+ *
+ * @since 1.0
+ */
+public class IniTest {
+
+ private static final String NL = "\n";
+
+ @Test
+ public void testNoSections() {
+ String test =
+ "prop1 = value1" + NL +
+ "prop2 = value2";
+
+ Ini ini = new Ini();
+ ini.load(test);
+
+ assertNotNull(ini.getSections());
+ assertEquals(1, ini.getSections().size());
+
+ Ini.Section section = ini.getSections().iterator().next();
+ assertEquals(Ini.DEFAULT_SECTION_NAME, section.getName());
+ assertFalse(section.isEmpty());
+ assertEquals(2, section.size());
+ assertEquals("value1", section.get("prop1"));
+ assertEquals("value2", section.get("prop2"));
+ }
+
+ @Test
+ public void testOneSection() {
+ String sectionName = "main";
+ String test = NL +
+ "" + NL +
+ " " + NL +
+ " # comment1 " + NL +
+ " ; comment 2" + NL +
+ "[" + sectionName + "]" + NL +
+ "prop1 = value1" + NL +
+ " " + NL +
+ "; comment " + NL +
+ "prop2 value2" + NL +
+ "prop3:value3" + NL +
+ "prop4 : value 4" + NL +
+ "prop5 some long \\" + NL +
+ " value " + NL +
+ "# comment.";
+
+ Ini ini = new Ini();
+ ini.load(new Scanner(test));
+
+ assertNotNull(ini.getSections());
+ assertEquals(1, ini.getSections().size());
+ Ini.Section section = ini.getSection("main");
+ assertNotNull(section);
+ assertEquals(sectionName, section.getName());
+ assertFalse(section.isEmpty());
+ assertEquals(5, section.size());
+ assertEquals("value1", section.get("prop1"));
+ assertEquals("value2", section.get("prop2"));
+ assertEquals("value3", section.get("prop3"));
+ assertEquals("value 4", section.get("prop4"));
+ assertEquals("some long value", section.get("prop5"));
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/IniTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/ReflectionBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/ReflectionBuilderTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/ReflectionBuilderTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/ReflectionBuilderTest.java Wed May 26 18:34:28 2010
@@ -1,244 +1,244 @@
-/*
- * 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.shiro.config;
-
-import org.apache.shiro.codec.Base64;
-import org.apache.shiro.codec.CodecSupport;
-import org.apache.shiro.codec.Hex;
-import org.apache.shiro.util.CollectionUtils;
-import org.junit.Test;
-
-import java.util.*;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Les Hazlewood
- * @since Aug 5, 2008 9:53:00 AM
- */
-public class ReflectionBuilderTest {
-
- @Test
- public void testSimpleConfig() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.stringProp", "blah");
- defs.put("compositeBean.booleanProp", "true");
- defs.put("compositeBean.intProp", "42");
-
- ReflectionBuilder builder = new ReflectionBuilder();
- Map beans = builder.buildObjects(defs);
-
- CompositeBean compositeBean = (CompositeBean) beans.get("compositeBean");
- assertNotNull(compositeBean);
- assertEquals(compositeBean.getStringProp(), "blah");
- assertTrue(compositeBean.isBooleanProp());
- assertEquals(compositeBean.getIntProp(), 42);
- }
-
- @Test
- public void testSimpleConfigWithDollarSignStringValue() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.stringProp", "\\$500");
-
- ReflectionBuilder builder = new ReflectionBuilder();
- Map beans = builder.buildObjects(defs);
-
- CompositeBean compositeBean = (CompositeBean) beans.get("compositeBean");
- assertEquals(compositeBean.getStringProp(), "$500");
- }
-
- @Test
- public void testObjectReferenceConfig() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean.intProp", "101");
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.stringProp", "blah");
- defs.put("compositeBean.simpleBean", "$simpleBean");
-
- ReflectionBuilder builder = new ReflectionBuilder();
- Map beans = builder.buildObjects(defs);
-
- CompositeBean compositeBean = (CompositeBean) beans.get("compositeBean");
- assertNotNull(compositeBean);
- assertEquals(compositeBean.getStringProp(), "blah");
- SimpleBean simpleBean = (SimpleBean) beans.get("simpleBean");
- assertNotNull(simpleBean);
- assertNotNull(compositeBean.getSimpleBean());
- assertEquals(simpleBean, compositeBean.getSimpleBean());
- assertEquals(simpleBean.getIntProp(), 101);
- }
-
- @Test(expected = ConfigurationException.class)
- public void testObjectReferenceConfigWithTypeMismatch() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.simpleBean", "simpleBean");
- ReflectionBuilder builder = new ReflectionBuilder();
- builder.buildObjects(defs);
- }
-
- @Test(expected = UnresolveableReferenceException.class)
- public void testObjectReferenceConfigWithInvalidReference() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.simpleBean", "$foo");
- ReflectionBuilder builder = new ReflectionBuilder();
- builder.buildObjects(defs);
- }
-
- @Test
- public void testSetProperty() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.simpleBeanSet", "$simpleBean1, $simpleBean2, $simpleBean2");
- ReflectionBuilder builder = new ReflectionBuilder();
- Map objects = builder.buildObjects(defs);
- assertFalse(CollectionUtils.isEmpty(objects));
- CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
- assertNotNull(cBean);
- Set<SimpleBean> simpleBeans = cBean.getSimpleBeanSet();
- assertNotNull(simpleBeans);
- assertEquals(2, simpleBeans.size());
- }
-
- @Test
- public void testListProperty() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.simpleBeanList", "$simpleBean1, $simpleBean2, $simpleBean2");
- ReflectionBuilder builder = new ReflectionBuilder();
- Map objects = builder.buildObjects(defs);
- assertFalse(CollectionUtils.isEmpty(objects));
- CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
- assertNotNull(cBean);
- List<SimpleBean> simpleBeans = cBean.getSimpleBeanList();
- assertNotNull(simpleBeans);
- assertEquals(3, simpleBeans.size());
- }
-
- @Test
- public void testCollectionProperty() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.simpleBeanCollection", "$simpleBean1, $simpleBean2, $simpleBean2");
- ReflectionBuilder builder = new ReflectionBuilder();
- Map objects = builder.buildObjects(defs);
- assertFalse(CollectionUtils.isEmpty(objects));
- CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
- assertNotNull(cBean);
- Collection<SimpleBean> simpleBeans = cBean.getSimpleBeanCollection();
- assertNotNull(simpleBeans);
- assertTrue(simpleBeans instanceof List);
- assertEquals(3, simpleBeans.size());
- }
-
- @Test
- public void testByteArrayHexProperty() {
- String source = "Hello, world.";
- byte[] bytes = CodecSupport.toBytes(source);
- String hex = Hex.encodeToString(bytes);
- String hexValue = "0x" + hex;
-
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean.byteArrayProp", hexValue);
- ReflectionBuilder builder = new ReflectionBuilder();
- Map objects = builder.buildObjects(defs);
- assertFalse(CollectionUtils.isEmpty(objects));
- SimpleBean bean = (SimpleBean) objects.get("simpleBean");
- assertNotNull(bean);
- byte[] beanBytes = bean.getByteArrayProp();
- assertNotNull(beanBytes);
- String reconstituted = CodecSupport.toString(beanBytes);
- assertEquals(source, reconstituted);
- }
-
- @Test
- public void testByteArrayBase64Property() {
- String source = "Hello, world.";
- byte[] bytes = CodecSupport.toBytes(source);
- String base64 = Base64.encodeToString(bytes);
-
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean.byteArrayProp", base64);
- ReflectionBuilder builder = new ReflectionBuilder();
- Map objects = builder.buildObjects(defs);
- SimpleBean bean = (SimpleBean) objects.get("simpleBean");
- byte[] beanBytes = bean.getByteArrayProp();
- assertNotNull(beanBytes);
- assertTrue(Arrays.equals(beanBytes, bytes));
- String reconstituted = CodecSupport.toString(beanBytes);
- assertEquals(reconstituted, source);
- }
-
- @Test
- public void testMapProperty() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.simpleBeanMap", "simpleBean1:$simpleBean1, simpleBean2:$simpleBean2");
- ReflectionBuilder builder = new ReflectionBuilder();
- Map objects = builder.buildObjects(defs);
- assertFalse(CollectionUtils.isEmpty(objects));
- CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
- assertNotNull(cBean);
- Map map = cBean.getSimpleBeanMap();
- assertNotNull(map);
- assertEquals(2, map.size());
- Object value = map.get("simpleBean1");
- assertTrue(value instanceof SimpleBean);
- value = map.get("simpleBean2");
- assertTrue(value instanceof SimpleBean);
- }
-
- @Test
- public void testNestedListProperty() {
- Map<String, String> defs = new LinkedHashMap<String, String>();
- defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
- defs.put("simpleBean3", "org.apache.shiro.config.SimpleBean");
- defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
- defs.put("compositeBean.simpleBean", "$simpleBean1");
- defs.put("compositeBean.simpleBean.simpleBeans", "$simpleBean2, $simpleBean3");
- ReflectionBuilder builder = new ReflectionBuilder();
- Map objects = builder.buildObjects(defs);
- assertFalse(CollectionUtils.isEmpty(objects));
- CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
- assertNotNull(cBean);
- SimpleBean nested = cBean.getSimpleBean();
- assertNotNull(nested);
- List<SimpleBean> children = nested.getSimpleBeans();
- assertNotNull(children);
- assertEquals(2, children.size());
- }
-
-}
+/*
+ * 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.shiro.config;
+
+import org.apache.shiro.codec.Base64;
+import org.apache.shiro.codec.CodecSupport;
+import org.apache.shiro.codec.Hex;
+import org.apache.shiro.util.CollectionUtils;
+import org.junit.Test;
+
+import java.util.*;
+
+import static org.junit.Assert.*;
+
+/**
+ * @author Les Hazlewood
+ * @since Aug 5, 2008 9:53:00 AM
+ */
+public class ReflectionBuilderTest {
+
+ @Test
+ public void testSimpleConfig() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.stringProp", "blah");
+ defs.put("compositeBean.booleanProp", "true");
+ defs.put("compositeBean.intProp", "42");
+
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map beans = builder.buildObjects(defs);
+
+ CompositeBean compositeBean = (CompositeBean) beans.get("compositeBean");
+ assertNotNull(compositeBean);
+ assertEquals(compositeBean.getStringProp(), "blah");
+ assertTrue(compositeBean.isBooleanProp());
+ assertEquals(compositeBean.getIntProp(), 42);
+ }
+
+ @Test
+ public void testSimpleConfigWithDollarSignStringValue() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.stringProp", "\\$500");
+
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map beans = builder.buildObjects(defs);
+
+ CompositeBean compositeBean = (CompositeBean) beans.get("compositeBean");
+ assertEquals(compositeBean.getStringProp(), "$500");
+ }
+
+ @Test
+ public void testObjectReferenceConfig() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean.intProp", "101");
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.stringProp", "blah");
+ defs.put("compositeBean.simpleBean", "$simpleBean");
+
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map beans = builder.buildObjects(defs);
+
+ CompositeBean compositeBean = (CompositeBean) beans.get("compositeBean");
+ assertNotNull(compositeBean);
+ assertEquals(compositeBean.getStringProp(), "blah");
+ SimpleBean simpleBean = (SimpleBean) beans.get("simpleBean");
+ assertNotNull(simpleBean);
+ assertNotNull(compositeBean.getSimpleBean());
+ assertEquals(simpleBean, compositeBean.getSimpleBean());
+ assertEquals(simpleBean.getIntProp(), 101);
+ }
+
+ @Test(expected = ConfigurationException.class)
+ public void testObjectReferenceConfigWithTypeMismatch() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.simpleBean", "simpleBean");
+ ReflectionBuilder builder = new ReflectionBuilder();
+ builder.buildObjects(defs);
+ }
+
+ @Test(expected = UnresolveableReferenceException.class)
+ public void testObjectReferenceConfigWithInvalidReference() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.simpleBean", "$foo");
+ ReflectionBuilder builder = new ReflectionBuilder();
+ builder.buildObjects(defs);
+ }
+
+ @Test
+ public void testSetProperty() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.simpleBeanSet", "$simpleBean1, $simpleBean2, $simpleBean2");
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map objects = builder.buildObjects(defs);
+ assertFalse(CollectionUtils.isEmpty(objects));
+ CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
+ assertNotNull(cBean);
+ Set<SimpleBean> simpleBeans = cBean.getSimpleBeanSet();
+ assertNotNull(simpleBeans);
+ assertEquals(2, simpleBeans.size());
+ }
+
+ @Test
+ public void testListProperty() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.simpleBeanList", "$simpleBean1, $simpleBean2, $simpleBean2");
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map objects = builder.buildObjects(defs);
+ assertFalse(CollectionUtils.isEmpty(objects));
+ CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
+ assertNotNull(cBean);
+ List<SimpleBean> simpleBeans = cBean.getSimpleBeanList();
+ assertNotNull(simpleBeans);
+ assertEquals(3, simpleBeans.size());
+ }
+
+ @Test
+ public void testCollectionProperty() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.simpleBeanCollection", "$simpleBean1, $simpleBean2, $simpleBean2");
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map objects = builder.buildObjects(defs);
+ assertFalse(CollectionUtils.isEmpty(objects));
+ CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
+ assertNotNull(cBean);
+ Collection<SimpleBean> simpleBeans = cBean.getSimpleBeanCollection();
+ assertNotNull(simpleBeans);
+ assertTrue(simpleBeans instanceof List);
+ assertEquals(3, simpleBeans.size());
+ }
+
+ @Test
+ public void testByteArrayHexProperty() {
+ String source = "Hello, world.";
+ byte[] bytes = CodecSupport.toBytes(source);
+ String hex = Hex.encodeToString(bytes);
+ String hexValue = "0x" + hex;
+
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean.byteArrayProp", hexValue);
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map objects = builder.buildObjects(defs);
+ assertFalse(CollectionUtils.isEmpty(objects));
+ SimpleBean bean = (SimpleBean) objects.get("simpleBean");
+ assertNotNull(bean);
+ byte[] beanBytes = bean.getByteArrayProp();
+ assertNotNull(beanBytes);
+ String reconstituted = CodecSupport.toString(beanBytes);
+ assertEquals(source, reconstituted);
+ }
+
+ @Test
+ public void testByteArrayBase64Property() {
+ String source = "Hello, world.";
+ byte[] bytes = CodecSupport.toBytes(source);
+ String base64 = Base64.encodeToString(bytes);
+
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean.byteArrayProp", base64);
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map objects = builder.buildObjects(defs);
+ SimpleBean bean = (SimpleBean) objects.get("simpleBean");
+ byte[] beanBytes = bean.getByteArrayProp();
+ assertNotNull(beanBytes);
+ assertTrue(Arrays.equals(beanBytes, bytes));
+ String reconstituted = CodecSupport.toString(beanBytes);
+ assertEquals(reconstituted, source);
+ }
+
+ @Test
+ public void testMapProperty() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.simpleBeanMap", "simpleBean1:$simpleBean1, simpleBean2:$simpleBean2");
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map objects = builder.buildObjects(defs);
+ assertFalse(CollectionUtils.isEmpty(objects));
+ CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
+ assertNotNull(cBean);
+ Map map = cBean.getSimpleBeanMap();
+ assertNotNull(map);
+ assertEquals(2, map.size());
+ Object value = map.get("simpleBean1");
+ assertTrue(value instanceof SimpleBean);
+ value = map.get("simpleBean2");
+ assertTrue(value instanceof SimpleBean);
+ }
+
+ @Test
+ public void testNestedListProperty() {
+ Map<String, String> defs = new LinkedHashMap<String, String>();
+ defs.put("simpleBean1", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean2", "org.apache.shiro.config.SimpleBean");
+ defs.put("simpleBean3", "org.apache.shiro.config.SimpleBean");
+ defs.put("compositeBean", "org.apache.shiro.config.CompositeBean");
+ defs.put("compositeBean.simpleBean", "$simpleBean1");
+ defs.put("compositeBean.simpleBean.simpleBeans", "$simpleBean2, $simpleBean3");
+ ReflectionBuilder builder = new ReflectionBuilder();
+ Map objects = builder.buildObjects(defs);
+ assertFalse(CollectionUtils.isEmpty(objects));
+ CompositeBean cBean = (CompositeBean) objects.get("compositeBean");
+ assertNotNull(cBean);
+ SimpleBean nested = cBean.getSimpleBean();
+ assertNotNull(nested);
+ List<SimpleBean> children = nested.getSimpleBeans();
+ assertNotNull(children);
+ assertEquals(2, children.size());
+ }
+
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/ReflectionBuilderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/SimpleBean.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/SimpleBean.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/SimpleBean.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/SimpleBean.java Wed May 26 18:34:28 2010
@@ -1,69 +1,69 @@
-/*
- * 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.shiro.config;
-
-import java.util.List;
-
-/**
- * @author Les Hazlewood
- * @since 1.0
- */
-public class SimpleBean {
-
- private String stringProp = null;
- private int intProp;
- private byte[] byteArrayProp = null;
-
- private List<SimpleBean> simpleBeans;
-
- public SimpleBean() {
- }
-
- public String getStringProp() {
- return stringProp;
- }
-
- public void setStringProp(String stringProp) {
- this.stringProp = stringProp;
- }
-
- public int getIntProp() {
- return intProp;
- }
-
- public void setIntProp(int intProp) {
- this.intProp = intProp;
- }
-
- public byte[] getByteArrayProp() {
- return byteArrayProp;
- }
-
- public void setByteArrayProp(byte[] byteArrayProp) {
- this.byteArrayProp = byteArrayProp;
- }
-
- public List<SimpleBean> getSimpleBeans() {
- return simpleBeans;
- }
-
- public void setSimpleBeans(List<SimpleBean> simpleBeans) {
- this.simpleBeans = simpleBeans;
- }
-}
+/*
+ * 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.shiro.config;
+
+import java.util.List;
+
+/**
+ * @author Les Hazlewood
+ * @since 1.0
+ */
+public class SimpleBean {
+
+ private String stringProp = null;
+ private int intProp;
+ private byte[] byteArrayProp = null;
+
+ private List<SimpleBean> simpleBeans;
+
+ public SimpleBean() {
+ }
+
+ public String getStringProp() {
+ return stringProp;
+ }
+
+ public void setStringProp(String stringProp) {
+ this.stringProp = stringProp;
+ }
+
+ public int getIntProp() {
+ return intProp;
+ }
+
+ public void setIntProp(int intProp) {
+ this.intProp = intProp;
+ }
+
+ public byte[] getByteArrayProp() {
+ return byteArrayProp;
+ }
+
+ public void setByteArrayProp(byte[] byteArrayProp) {
+ this.byteArrayProp = byteArrayProp;
+ }
+
+ public List<SimpleBean> getSimpleBeans() {
+ return simpleBeans;
+ }
+
+ public void setSimpleBeans(List<SimpleBean> simpleBeans) {
+ this.simpleBeans = simpleBeans;
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/config/SimpleBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/crypto/AesCipherServiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/crypto/BlowfishCipherServiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/io/SerializationExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/io/SerializationExceptionTest.java?rev=948527&r1=948526&r2=948527&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/io/SerializationExceptionTest.java (original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/io/SerializationExceptionTest.java Wed May 26 18:34:28 2010
@@ -1,32 +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.shiro.io;
-
-import org.apache.shiro.ExceptionTest;
-
-
-/**
- * @author Les Hazlewood
- */
-public class SerializationExceptionTest extends ExceptionTest {
-
- protected Class getExceptionClass() {
- return SerializationException.class;
- }
-}
+/*
+ * 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.shiro.io;
+
+import org.apache.shiro.ExceptionTest;
+
+
+/**
+ * @author Les Hazlewood
+ */
+public class SerializationExceptionTest extends ExceptionTest {
+
+ protected Class getExceptionClass() {
+ return SerializationException.class;
+ }
+}
Propchange: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/io/SerializationExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native