servlet: remove usage of deprecated stuff
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/9fe61e6b Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/9fe61e6b Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/9fe61e6b Branch: refs/heads/develop Commit: 9fe61e6b788c380745242e1c7055a7179af2f3ab Parents: d767264 Author: Paul Merlin <[email protected]> Authored: Sat Dec 17 22:10:03 2016 +0100 Committer: Paul Merlin <[email protected]> Committed: Sat Dec 17 22:10:03 2016 +0100 ---------------------------------------------------------------------- .../polygene/library/http/Dispatchers.java | 51 -------------------- .../apache/polygene/library/http/Servlets.java | 19 -------- .../polygene/library/servlet/ServletTest.java | 21 ++++---- 3 files changed, 12 insertions(+), 79 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/9fe61e6b/libraries/http/src/main/java/org/apache/polygene/library/http/Dispatchers.java ---------------------------------------------------------------------- diff --git a/libraries/http/src/main/java/org/apache/polygene/library/http/Dispatchers.java b/libraries/http/src/main/java/org/apache/polygene/library/http/Dispatchers.java deleted file mode 100644 index 462c527..0000000 --- a/libraries/http/src/main/java/org/apache/polygene/library/http/Dispatchers.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.polygene.library.http; - -import java.io.Serializable; -import java.util.EnumSet; -import java.util.Iterator; - -public class Dispatchers - implements Iterable<Dispatchers.Dispatcher>, Serializable -{ - public enum Dispatcher - { - FORWARD, REQUEST - } - - private final EnumSet<Dispatcher> dispatchers; - - private Dispatchers( EnumSet<Dispatcher> dispatchers ) - { - this.dispatchers = dispatchers; - } - - @Override - public Iterator<Dispatcher> iterator() - { - return dispatchers.iterator(); - } - - public static Dispatchers dispatchers( Dispatcher first, Dispatcher... rest ) - { - return new Dispatchers( EnumSet.of( first, rest ) ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/9fe61e6b/libraries/http/src/main/java/org/apache/polygene/library/http/Servlets.java ---------------------------------------------------------------------- diff --git a/libraries/http/src/main/java/org/apache/polygene/library/http/Servlets.java b/libraries/http/src/main/java/org/apache/polygene/library/http/Servlets.java index 44a870e..d04d914 100644 --- a/libraries/http/src/main/java/org/apache/polygene/library/http/Servlets.java +++ b/libraries/http/src/main/java/org/apache/polygene/library/http/Servlets.java @@ -31,7 +31,6 @@ import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.http.ConstraintInfo.Constraint; import org.apache.polygene.library.http.ConstraintInfo.HttpMethod; -import org.apache.polygene.library.http.Dispatchers.Dispatcher; import static org.apache.polygene.api.common.Visibility.layer; @@ -237,24 +236,6 @@ public final class Servlets return this; } - @Deprecated - public FilterAssembler on( Dispatcher first, Dispatcher... rest ) - { - EnumSet<DispatcherType> dispatch = EnumSet.noneOf( DispatcherType.class ); - for ( Dispatcher each : Dispatchers.dispatchers( first, rest ) ) { - switch ( each ) { - case FORWARD: - dispatch.add( DispatcherType.FORWARD ); - break; - case REQUEST: - dispatch.add( DispatcherType.REQUEST ); - break; - } - } - dispatchers = dispatch; - return this; - } - public FilterAssembler withInitParams( Map<String, String> initParams ) { this.initParams = initParams; http://git-wip-us.apache.org/repos/asf/zest-java/blob/9fe61e6b/libraries/servlet/src/test/java/org/apache/polygene/library/servlet/ServletTest.java ---------------------------------------------------------------------- diff --git a/libraries/servlet/src/test/java/org/apache/polygene/library/servlet/ServletTest.java b/libraries/servlet/src/test/java/org/apache/polygene/library/servlet/ServletTest.java index d0755e7..e16e24f 100644 --- a/libraries/servlet/src/test/java/org/apache/polygene/library/servlet/ServletTest.java +++ b/libraries/servlet/src/test/java/org/apache/polygene/library/servlet/ServletTest.java @@ -23,20 +23,20 @@ import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.BasicResponseHandler; -import org.apache.http.impl.client.DefaultHttpClient; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.junit.Assert; -import org.junit.Test; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.apache.polygene.bootstrap.ApplicationAssembly; import org.apache.polygene.bootstrap.ApplicationAssemblyFactory; import org.apache.polygene.bootstrap.AssemblyException; import org.apache.polygene.bootstrap.ModuleAssembly; import org.apache.polygene.library.servlet.lifecycle.AbstractPolygeneServletBootstrap; import org.apache.polygene.test.util.FreePortFinder; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.junit.Assert; +import org.junit.Test; public class ServletTest { @@ -100,9 +100,12 @@ public class ServletTest server.setHandler( context ); server.start(); - HttpClient client = new DefaultHttpClient(); - String result = client.execute( new HttpGet( "http://127.0.0.1:" + port + "/" ), new BasicResponseHandler() ); - Assert.assertEquals( APP_NAME, result.trim() ); + try( CloseableHttpClient client = HttpClientBuilder.create().build() ) + { + String result = client.execute( new HttpGet( "http://127.0.0.1:" + port + "/" ), + new BasicResponseHandler() ); + Assert.assertEquals( APP_NAME, result.trim() ); + } } finally { server.stop();
