You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2019/05/29 10:02:10 UTC

[tomee] 05/07: Adding test

This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch tomee-7.1.x
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 5a50e885cef581e12a4161a028f869aa86862fc2
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Tue May 28 13:02:09 2019 +0100

    Adding test
---
 .../core/security/BasicJaccProviderTest.java       | 44 ++++++++++++++++++----
 1 file changed, 36 insertions(+), 8 deletions(-)

diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/security/BasicJaccProviderTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/security/BasicJaccProviderTest.java
index c9d3ce6..2d9b387 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/security/BasicJaccProviderTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/security/BasicJaccProviderTest.java
@@ -16,27 +16,55 @@
  */
 package org.apache.openejb.core.security;
 
-import org.apache.openejb.core.security.jacc.BasicJaccProvider;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.testing.Classes;
 import org.apache.openejb.testing.ContainerProperties;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import static org.junit.Assert.assertTrue;
+import javax.ejb.EJB;
+import javax.ejb.Singleton;
+import java.security.Policy;
 
-@Classes
+
+@Classes(innerClassesAsBean = true)
 @RunWith(ApplicationComposer.class)
 @ContainerProperties(
         @ContainerProperties.Property(
-                name = "org.apache.openejb.core.security.JaccProvider",
-                value = "org.apache.openejb.core.security.AbstractSecurityServiceTest$MyJaacProv"))
+                name = "javax.security.jacc.policy.provider",
+                value = "org.apache.openejb.core.security.BasicJaccProviderTest.MyPolicy"))
 public class BasicJaccProviderTest {
+
+    @EJB
+    private SimpleSingleton myBean;
+
     @Test
-    public void run() {
-        assertTrue(MyJaacProv.class.isInstance(JaccProvider.get()));
+    public void run() throws Exception {
+        Assert.assertEquals("tset", myBean.reverse("test"));
     }
 
-    public static class MyJaacProv extends BasicJaccProvider {
+    public static class MyPolicy extends Policy {
+    }
+
+    @Singleton
+    public static class SimpleSingleton {
+        public String reverse(final String input) {
+            if (input == null) {
+                return null;
+            }
+
+            if (input.length() == 0) {
+                return "";
+            }
+
+            char[] chars = new char[input.length()];
+            for (int i = 0; i < input.length(); i++) {
+                chars[i] = input.charAt((input.length() - 1) - i);
+            }
+
+            return new String(chars);
+        }
     }
 }
+