[
https://issues.apache.org/jira/browse/CALCITE-2284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16460054#comment-16460054
]
ASF GitHub Bot commented on CALCITE-2284:
-----------------------------------------
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/calcite-avatica/pull/46#discussion_r185313655
--- Diff:
server/src/test/java/org/apache/calcite/avatica/server/HttpServerCustomizerTest.java
---
@@ -0,0 +1,73 @@
+/*
+ * 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.calcite.avatica.server;
+
+import org.apache.calcite.avatica.Meta;
+import org.apache.calcite.avatica.remote.Driver;
+import org.apache.calcite.avatica.remote.LocalService;
+import org.apache.calcite.avatica.remote.Service;
+
+import org.eclipse.jetty.server.Server;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+/**
+ * HTTP server customizer tests
+ */
+public class HttpServerCustomizerTest {
+
+ private static HttpServer server;
+ private static Meta mockMeta;
+
+ private static ServerCustomizer mockCustomizer1;
+ private static ServerCustomizer mockCustomizer2;
+
+ @BeforeClass public static void startServer() {
+ mockCustomizer1 = mock(ServerCustomizer.class);
+ mockCustomizer2 = mock(ServerCustomizer.class);
+ mockMeta = mock(Meta.class);
+ Service service = new LocalService(mockMeta);
+ server = new HttpServer.Builder()
+ .withHandler(service, Driver.Serialization.PROTOBUF)
+ .withServerCustomizers(Arrays.asList(mockCustomizer1,
mockCustomizer2))
+ .withPort(0)
+ .build();
+ server.start();
+ }
+
+ @AfterClass public static void stopServer() {
+ if (null != server) {
+ server.stop();
+ }
+ }
+
+ @Test public void serverCustomizersInvoked() {
+ verify(mockCustomizer2, times(1)).customize(any(Server.class));
--- End diff --
nit: `times(1)` is unnecessary, I think.
Nice test addition though!!
> Allow Jetty Server to be customized before startup
> --------------------------------------------------
>
> Key: CALCITE-2284
> URL: https://issues.apache.org/jira/browse/CALCITE-2284
> Project: Calcite
> Issue Type: Improvement
> Components: avatica
> Affects Versions: 1.11.0
> Reporter: Alex Araujo
> Priority: Critical
> Attachments: CALCITE-2284.patch
>
>
> Avatica server options currently allow users to enable TLS with file based
> key stores. In order to support additional options (in memory keystores,
> dynamically loaded keys/certificates, etc.) Avatica should provide a callback
> to customize the embedded Jetty server before starting it up.
>
> This would be similar to how Spring Boot allows developers to customize the
> embedded server.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)