You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2016/07/21 14:01:30 UTC

tomee git commit: TOMEE-1881 respecting init param activated in ServerServlet

Repository: tomee
Updated Branches:
  refs/heads/master 9cce91cf1 -> 14e895bd2


TOMEE-1881 respecting init param activated in ServerServlet


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/14e895bd
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/14e895bd
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/14e895bd

Branch: refs/heads/master
Commit: 14e895bd2fc684c5658469713f86f45383bfe688
Parents: 9cce91c
Author: Romain manni-Bucau <rm...@gmail.com>
Authored: Thu Jul 21 16:01:16 2016 +0200
Committer: Romain manni-Bucau <rm...@gmail.com>
Committed: Thu Jul 21 16:01:16 2016 +0200

----------------------------------------------------------------------
 .../openejb/server/httpd/ServerServlet.java     |  4 +-
 .../openejb/server/httpd/ServerServletTest.java | 68 ++++++++++++++++++++
 2 files changed, 71 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/14e895bd/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServerServlet.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServerServlet.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServerServlet.java
index 9f8f0da..9f424b6 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServerServlet.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/ServerServlet.java
@@ -41,7 +41,9 @@ public class ServerServlet extends HttpServlet {
         ejbServer = SystemInstance.get().getComponent(EjbServer.class);
         final String activatedStr = config.getInitParameter(ACTIVATED_INIT_PARAM);
         if (activatedStr != null) {
-            activated = Boolean.getBoolean(ACTIVATED_INIT_PARAM);
+            activated = Boolean.parseBoolean(activatedStr);
+        } else {
+            activated = Boolean.getBoolean(getClass().getName() + '.' + ACTIVATED_INIT_PARAM);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/14e895bd/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServerServletTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServerServletTest.java b/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServerServletTest.java
new file mode 100644
index 0000000..bf20e49
--- /dev/null
+++ b/server/openejb-http/src/test/java/org/apache/openejb/server/httpd/ServerServletTest.java
@@ -0,0 +1,68 @@
+/**
+ *
+ * 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.openejb.server.httpd;
+
+import org.apache.openejb.util.reflection.Reflections;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import java.util.Enumeration;
+
+import static java.util.Arrays.asList;
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Parameterized.class)
+public class ServerServletTest {
+    @Parameterized.Parameters
+    public static Iterable<Boolean> values() {
+        return asList(true, false);
+    }
+
+    @Parameterized.Parameter
+    public Boolean activated;
+
+    @Test
+    public void activated() {
+        final ServerServlet serverServlet = new ServerServlet();
+        serverServlet.init(new ServletConfig() {
+            @Override
+            public String getServletName() {
+                return null;
+            }
+
+            @Override
+            public ServletContext getServletContext() {
+                return null;
+            }
+
+            @Override
+            public String getInitParameter(final String name) {
+                return "activated".equals(name) ? Boolean.toString(activated) : null;
+            }
+
+            @Override
+            public Enumeration<String> getInitParameterNames() {
+                return null;
+            }
+        });
+        assertEquals(activated == null || activated, Reflections.get(serverServlet, "activated"));
+    }
+}