You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2019/10/25 03:07:15 UTC

[GitHub] [skywalking] dmsolr commented on a change in pull request #3698: [test/plugin] immigrate undertow scenario

dmsolr commented on a change in pull request #3698: [test/plugin]  immigrate  undertow scenario
URL: https://github.com/apache/skywalking/pull/3698#discussion_r338869548
 
 

 ##########
 File path: test/plugin/scenarios/undertow-routing-scenario/src/main/java/org/apache/skywalking/amp/testcase/undertow/Application.java
 ##########
 @@ -0,0 +1,74 @@
+/*
+ * 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.skywalking.amp.testcase.undertow;
+
+import io.undertow.Undertow;
+import io.undertow.server.HttpHandler;
+import io.undertow.server.RoutingHandler;
+import io.undertow.util.Headers;
+import io.undertow.util.Methods;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+
+public class Application {
+
+    private static final String TEMPLATE = "/undertow-routing-scenario/case/{context}";
+
+    private static final String CASE_URL = "/undertow-routing-scenario/case/undertow";
+
+    public static void main(String[] args) throws InterruptedException {
+        HttpHandler httpHandler = exchange -> {
+            if (CASE_URL.equals(exchange.getRequestPath())) {
+                visit("http://localhost:8080/undertow-routing-scenario/case/undertow1");
+            }
+            exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
+            exchange.getResponseSender().send("Success");
+        };
+        RoutingHandler handler = new RoutingHandler();
+        handler.add(Methods.GET, TEMPLATE, httpHandler);
+        handler.add(Methods.HEAD, TEMPLATE, httpHandler);
+        Undertow server = Undertow.builder()
+            .addHttpListener(8080, "127.0.0.1")
+            .setHandler(handler).build();
+        Runtime.getRuntime().addShutdownHook(new Thread(server::stop));
+        // Waiting for service register, please do not delete.
+        Thread.sleep(5000);
 
 Review comment:
   Here is waiting for Agent Register done. Do you have any other suggestions about this, @wu-sheng @kezhenxu94 .

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services