From d5a9f0e0e54d705f217231888388c8a5ad3c3ffa Mon Sep 17 00:00:00 2001 From: WalkerWatch Date: Wed, 9 Aug 2017 17:42:15 -0400 Subject: [PATCH] EOL Fix --- .../jsr356/DelayedStartClientTest.java | 222 +++++++++--------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DelayedStartClientTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DelayedStartClientTest.java index af004bf2b07..a62b1841a04 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DelayedStartClientTest.java +++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DelayedStartClientTest.java @@ -1,111 +1,111 @@ -// -// ======================================================================== -// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - -package org.eclipse.jetty.websocket.jsr356; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.hasItem; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Executor; - -import javax.websocket.ContainerProvider; -import javax.websocket.WebSocketContainer; - -import org.eclipse.jetty.util.component.ContainerLifeCycle; -import org.eclipse.jetty.util.component.LifeCycle; -import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.junit.After; -import org.junit.Test; - -public class DelayedStartClientTest -{ - WebSocketContainer container; - - @After - public void stopContainer() throws Exception - { - ((LifeCycle)container).stop(); - } - - @Test - public void testNoExtraHttpClientThreads() - { - container = ContainerProvider.getWebSocketContainer(); - assertThat("Container", container, notNullValue()); - - List threadNames = getThreadNames((ContainerLifeCycle)container); - assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketContainer@")))); - assertThat("Threads", threadNames, not(hasItem(containsString("HttpClient@")))); - } - - public static List getThreadNames(ContainerLifeCycle... containers) - { - List threadNames = new ArrayList<>(); - Set seen = new HashSet<>(); - for (ContainerLifeCycle container : containers) - { - if (container == null) - { - continue; - } - - findConfiguredThreadNames(seen, threadNames, container); - } - seen.clear(); - // System.out.println("Threads: " + threadNames.stream().collect(Collectors.joining(", ", "[", "]"))); - return threadNames; - } - - private static void findConfiguredThreadNames(Set seen, List threadNames, ContainerLifeCycle container) - { - if (seen.contains(container)) - { - // skip - return; - } - - seen.add(container); - - Collection executors = container.getBeans(Executor.class); - for (Executor executor : executors) - { - if (executor instanceof QueuedThreadPool) - { - QueuedThreadPool qtp = (QueuedThreadPool) executor; - threadNames.add(qtp.getName()); - } - else - { - System.err.println("### Executor: " + executor); - } - } - - for (ContainerLifeCycle child : container.getBeans(ContainerLifeCycle.class)) - { - findConfiguredThreadNames(seen, threadNames, child); - } - } -} +// +// ======================================================================== +// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.websocket.jsr356; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Executor; + +import javax.websocket.ContainerProvider; +import javax.websocket.WebSocketContainer; + +import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.util.component.LifeCycle; +import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.junit.After; +import org.junit.Test; + +public class DelayedStartClientTest +{ + WebSocketContainer container; + + @After + public void stopContainer() throws Exception + { + ((LifeCycle)container).stop(); + } + + @Test + public void testNoExtraHttpClientThreads() + { + container = ContainerProvider.getWebSocketContainer(); + assertThat("Container", container, notNullValue()); + + List threadNames = getThreadNames((ContainerLifeCycle)container); + assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketContainer@")))); + assertThat("Threads", threadNames, not(hasItem(containsString("HttpClient@")))); + } + + public static List getThreadNames(ContainerLifeCycle... containers) + { + List threadNames = new ArrayList<>(); + Set seen = new HashSet<>(); + for (ContainerLifeCycle container : containers) + { + if (container == null) + { + continue; + } + + findConfiguredThreadNames(seen, threadNames, container); + } + seen.clear(); + // System.out.println("Threads: " + threadNames.stream().collect(Collectors.joining(", ", "[", "]"))); + return threadNames; + } + + private static void findConfiguredThreadNames(Set seen, List threadNames, ContainerLifeCycle container) + { + if (seen.contains(container)) + { + // skip + return; + } + + seen.add(container); + + Collection executors = container.getBeans(Executor.class); + for (Executor executor : executors) + { + if (executor instanceof QueuedThreadPool) + { + QueuedThreadPool qtp = (QueuedThreadPool) executor; + threadNames.add(qtp.getName()); + } + else + { + System.err.println("### Executor: " + executor); + } + } + + for (ContainerLifeCycle child : container.getBeans(ContainerLifeCycle.class)) + { + findConfiguredThreadNames(seen, threadNames, child); + } + } +}