openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1776967 - in /openwebbeans/meecrowave/trunk/meecrowave-core/src: main/java/org/apache/meecrowave/Meecrowave.java test/java/org/apache/meecrowave/NoConnectorTest.java
Date Mon, 02 Jan 2017 17:28:39 GMT
Author: rmannibucau
Date: Mon Jan  2 17:28:38 2017
New Revision: 1776967

URL: http://svn.apache.org/viewvc?rev=1776967&view=rev
Log:
OWB-1165 ensure we can run without any connector (=port opened)

Added:
    openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/NoConnectorTest.java
Modified:
    openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java

Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java?rev=1776967&r1=1776966&r2=1776967&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
Mon Jan  2 17:28:38 2017
@@ -177,9 +177,9 @@ public class Meecrowave implements AutoC
             throw new IllegalArgumentException("Already deployed: '" + meta.context + "'");
         }
         // always nice to see the deployment with something else than internals
-        new LogFacade(Meecrowave.class.getName())
-                .info("--------------- " + configuration.getActiveProtocol() + "://"
-                        + tomcat.getHost().getName() + ':' + configuration.getActivePort()
+ meta.context);
+        final String base = tomcat.getService().findConnectors().length > 0 ?
+                (configuration.getActiveProtocol() + "://" + tomcat.getHost().getName() +
':' + configuration.getActivePort()) : "";
+        new LogFacade(Meecrowave.class.getName()).info("--------------- " + base + meta.context);
 
 
         final File dir = ofNullable(meta.docBase).orElseGet(() -> {

Added: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/NoConnectorTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/NoConnectorTest.java?rev=1776967&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/NoConnectorTest.java
(added)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/NoConnectorTest.java
Mon Jan  2 17:28:38 2017
@@ -0,0 +1,63 @@
+/*
+ * 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.meecrowave;
+
+import org.junit.Test;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.CDI;
+import java.io.IOException;
+import java.net.Socket;
+import java.util.stream.IntStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class NoConnectorTest {
+    @Test
+    public void run() {
+        final Meecrowave.Builder config = new Meecrowave.Builder();
+        config.setSkipHttp(true);
+        try (final Meecrowave meecrowave = new Meecrowave(config.includePackages(NoConnectorTest.class.getName())).bake())
{
+            final BeanManager beanManager = CDI.current().getBeanManager();
+            assertEquals("yeah", SomeBean.class.cast(
+                    beanManager.getReference(
+                            beanManager.resolve(beanManager.getBeans(SomeBean.class)),
+                            SomeBean.class,
+                            beanManager.createCreationalContext(null)))
+                    .get());
+            IntStream.of(config.getHttpPort(), config.getHttpsPort()).forEach(port ->
{
+                try (final Socket socket = new Socket("localhost", port)) {
+                    fail("port " + config.getHttpsPort() + " is opened");
+                } catch (final IOException e) {
+                    // ok
+                }
+            });
+            assertEquals(0, meecrowave.getTomcat().getService().findConnectors().length);
+        }
+    }
+
+    @ApplicationScoped
+    public static class SomeBean {
+        String get() {
+            return "yeah";
+        }
+    }
+}



Mime
View raw message