You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2016/09/05 01:46:17 UTC
[1/2] zest-java git commit: Upgrade Gradle to 3.0
Repository: zest-java
Updated Branches:
refs/heads/develop 6e63400ea -> 8fd9d5ac0
Upgrade Gradle to 3.0
Starting from 3.0 the daemon is enabled by default.
See the release notes: https://docs.gradle.org/3.0/release-notes
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/954f5a49
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/954f5a49
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/954f5a49
Branch: refs/heads/develop
Commit: 954f5a499bc5666804b82c5eec9bbbfdea7a448e
Parents: 6e63400
Author: Paul Merlin <pa...@apache.org>
Authored: Sun Sep 4 18:31:45 2016 -0700
Committer: Paul Merlin <pa...@apache.org>
Committed: Sun Sep 4 18:31:45 2016 -0700
----------------------------------------------------------------------
gradle/wrapper/gradle-wrapper.jar | Bin 51348 -> 52980 bytes
gradle/wrapper/gradle-wrapper.properties | 2 +-
gradlew | 52 +++++++++++++-------------
gradlew.bat | 8 ++--
4 files changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/954f5a49/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 0087cd3..dbc7430 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
http://git-wip-us.apache.org/repos/asf/zest-java/blob/954f5a49/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3cde5b0..7153f30 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -23,4 +23,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
http://git-wip-us.apache.org/repos/asf/zest-java/blob/954f5a49/gradlew
----------------------------------------------------------------------
diff --git a/gradlew b/gradlew
index 91a7e26..27309d9 100755
--- a/gradlew
+++ b/gradlew
@@ -6,12 +6,30 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
http://git-wip-us.apache.org/repos/asf/zest-java/blob/954f5a49/gradlew.bat
----------------------------------------------------------------------
diff --git a/gradlew.bat b/gradlew.bat
index aec9973..f6d5974 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,7 +46,7 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
[2/2] zest-java git commit: ZEST-175 Only run HTTP library vhost
tests on Java < 9
Posted by pa...@apache.org.
ZEST-175 Only run HTTP library vhost tests on Java < 9
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/8fd9d5ac
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/8fd9d5ac
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/8fd9d5ac
Branch: refs/heads/develop
Commit: 8fd9d5ac0e300926003e5cd27d863d6045758f91
Parents: 954f5a4
Author: Paul Merlin <pa...@apache.org>
Authored: Sun Sep 4 18:45:36 2016 -0700
Committer: Paul Merlin <pa...@apache.org>
Committed: Sun Sep 4 18:45:36 2016 -0700
----------------------------------------------------------------------
libraries/http/build.gradle | 37 +++++-
.../zest/library/http/JettyTestSuite.java | 1 -
.../http/VirtualHostJettyServiceTest.java | 88 -------------
.../zest/library/http/dns/LocalManagedDns.java | 125 -------------------
.../http/dns/LocalManagedDnsDescriptor.java | 48 -------
...un.net.spi.nameservice.NameServiceDescriptor | 36 ------
.../http/VirtualHostJettyServiceTest.java | 90 +++++++++++++
.../zest/library/http/dns/LocalManagedDns.java | 125 +++++++++++++++++++
.../http/dns/LocalManagedDnsDescriptor.java | 48 +++++++
...un.net.spi.nameservice.NameServiceDescriptor | 17 +++
.../http/src/vhost-test/resources/logback.xml | 37 ++++++
11 files changed, 348 insertions(+), 304 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/build.gradle
----------------------------------------------------------------------
diff --git a/libraries/http/build.gradle b/libraries/http/build.gradle
index d7e3cdc..c049c65 100644
--- a/libraries/http/build.gradle
+++ b/libraries/http/build.gradle
@@ -22,11 +22,6 @@ description = "Apache Zest\u2122 Http Library provides embedded Jetty for Apache Ze
jar { manifest { name = "Apache Zest\u2122 Library - Http" }}
-test {
- systemProperties 'networkaddress.cache.ttl': '0'
- systemProperties 'sun.net.spi.nameservice.provider.1': 'dns,LocalManagedDns'
-}
-
dependencies {
compile( project( ":org.apache.zest.core:org.apache.zest.core.api" ) )
@@ -38,9 +33,39 @@ dependencies {
testCompile( project( ":org.apache.zest.core:org.apache.zest.core.testsupport" ) )
testCompile( libraries.http_client )
- testCompile( libraries.dnsjava )
testRuntime( project( ":org.apache.zest.core:org.apache.zest.core.runtime" ) )
testRuntime( libraries.logback )
}
+
+// Do not run vhost tests on Java >= 9 because they use internal JDK apis
+if(JavaVersion.current() < JavaVersion.VERSION_1_9) {
+ sourceSets {
+ vhostTest {
+ java {
+ compileClasspath += main.output + test.output
+ runtimeClasspath += main.output + test.output
+ srcDir file('src/vhost-test/java')
+ }
+ resources {
+ srcDir file('src/vhost-test/resources')
+ }
+ }
+ }
+ configurations {
+ vhostTestCompile.extendsFrom testCompile
+ vhostTestRuntime.extendsFrom testRuntime
+ }
+ dependencies {
+ vhostTestCompile( libraries.dnsjava )
+ }
+ task vhostTest(type: Test) {
+ testClassesDir = sourceSets.vhostTest.output.classesDir
+ classpath = sourceSets.vhostTest.runtimeClasspath
+ systemProperties 'networkaddress.cache.ttl': '0'
+ systemProperties 'sun.net.spi.nameservice.provider.1': 'dns,LocalManagedDns'
+ }
+ check.dependsOn vhostTest
+ vhostTest.mustRunAfter test
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/test/java/org/apache/zest/library/http/JettyTestSuite.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/test/java/org/apache/zest/library/http/JettyTestSuite.java b/libraries/http/src/test/java/org/apache/zest/library/http/JettyTestSuite.java
index e96e402..5d59563 100644
--- a/libraries/http/src/test/java/org/apache/zest/library/http/JettyTestSuite.java
+++ b/libraries/http/src/test/java/org/apache/zest/library/http/JettyTestSuite.java
@@ -24,7 +24,6 @@ import org.junit.runners.Suite;
@RunWith( Suite.class )
@Suite.SuiteClasses( {
- VirtualHostJettyServiceTest.class,
JettyServiceTest.class,
JettyJMXStatisticsTest.class,
SecureJettyServiceTest.class,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/test/java/org/apache/zest/library/http/VirtualHostJettyServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/test/java/org/apache/zest/library/http/VirtualHostJettyServiceTest.java b/libraries/http/src/test/java/org/apache/zest/library/http/VirtualHostJettyServiceTest.java
deleted file mode 100644
index 87b869d..0000000
--- a/libraries/http/src/test/java/org/apache/zest/library/http/VirtualHostJettyServiceTest.java
+++ /dev/null
@@ -1,88 +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.zest.library.http;
-
-import java.io.IOException;
-import org.apache.http.client.methods.HttpGet;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.library.http.dns.LocalManagedDns;
-import org.apache.zest.test.EntityTestAssembler;
-
-import static org.junit.Assert.assertEquals;
-import static org.apache.zest.library.http.Servlets.addServlets;
-import static org.apache.zest.library.http.Servlets.serve;
-import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
-
-public class VirtualHostJettyServiceTest
- extends AbstractJettyTest
-{
- private static final String HOST1 = "host1.http.library.zest";
- private static final String HOST2 = "host2.http.library.zest";
-
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- ModuleAssembly configModule = module;
- new EntityTestAssembler().assemble( configModule );
- new JettyServiceAssembler().withConfig( configModule, Visibility.layer ).assemble( module );
-
- SecureJettyConfiguration config = configModule.forMixin( SecureJettyConfiguration.class ).declareDefaults();
- config.hostName().set( "127.0.0.1" );
- config.port().set( HTTP_PORT );
- config.virtualHosts().set( HOST1 + "," + HOST2 );
-
- addServlets( serve( "/hello" ).with( HelloWorldServletService.class ) ).to( module );
- }
-
- @BeforeClass
- public static void beforeVirtualHostsClass()
- {
- assumeNoIbmJdk();
- LocalManagedDns.putName( HOST1, "127.0.0.1" );
- LocalManagedDns.putName( HOST2, "127.0.0.1" );
- }
-
- @AfterClass
- public static void afterVirtualHostsClass()
- {
- LocalManagedDns.removeName( HOST1 );
- LocalManagedDns.removeName( HOST2 );
- }
-
- @Test
- public void test()
- throws IOException
- {
- // Available on HOST1 and HOST2
- String output = defaultHttpClient.execute( new HttpGet( "http://" + HOST1 + ":8041/hello" ),
- stringResponseHandler );
- assertEquals( "Hello World", output );
-
- output = defaultHttpClient.execute( new HttpGet( "http://" + HOST2 + ":8041/hello" ),
- stringResponseHandler );
- assertEquals( "Hello World", output );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/test/java/org/apache/zest/library/http/dns/LocalManagedDns.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/test/java/org/apache/zest/library/http/dns/LocalManagedDns.java b/libraries/http/src/test/java/org/apache/zest/library/http/dns/LocalManagedDns.java
deleted file mode 100644
index 68b208d..0000000
--- a/libraries/http/src/test/java/org/apache/zest/library/http/dns/LocalManagedDns.java
+++ /dev/null
@@ -1,125 +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.zest.library.http.dns;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.xbill.DNS.spi.DNSJavaNameServiceDescriptor;
-import sun.net.spi.nameservice.NameService;
-
-public class LocalManagedDns
- implements NameService
-{
-
- private static final NameService DEFAULT_DNS = new DNSJavaNameServiceDescriptor().createNameService();
- private static final Map<String, String> NAMES = new ConcurrentHashMap<String, String>();
-
- public static void clearNames()
- {
- NAMES.clear();
- }
-
- public static String putName( String name, String ip )
- {
- return NAMES.put( name, ip );
- }
-
- public static String removeName( String name )
- {
- return NAMES.remove( name );
- }
-
- public String getHostByAddr( byte[] bytes )
- throws UnknownHostException
- {
- return DEFAULT_DNS.getHostByAddr( bytes );
- }
-
- public InetAddress[] lookupAllHostAddr( String name )
- throws UnknownHostException
- {
- String log = "[CDNS] Lookup request";
- String ip = NAMES.get( name );
- InetAddress[] result = new InetAddress[ 0 ];
- if ( ip != null && ip.length() > 0 ) {
- log += " on managed name (" + name + ")";
- byte[] ipBytes = ipStringToBytes( ip );
- result = new InetAddress[]{ Inet4Address.getByAddress( ipBytes ) };
- } else {
- log += " on non-managed name (" + name + ")";
- result = DEFAULT_DNS.lookupAllHostAddr( name );
- }
- return result;
- }
-
- private static byte[] ipStringToBytes( String ipString )
- {
- if ( ipString == null || ipString.length() == 0 ) {
- return null;
- }
-
- int inetAddrSize = 4;
- int octets;
- char ch;
- byte[] dst = new byte[ inetAddrSize ];
- char[] srcb = ipString.toCharArray();
- boolean saw_digit = false;
-
- octets = 0;
- int i = 0;
- int cur = 0;
- while ( i < srcb.length ) {
- ch = srcb[i++];
- if ( Character.isDigit( ch ) ) {
- int sum = dst[cur] * 10 + ( Character.digit( ch, 10 ) & 0xff );
-
- if ( sum > 255 ) {
- return null;
- }
-
- dst[cur] = ( byte ) ( sum & 0xff );
- if ( !saw_digit ) {
- if ( ++octets > inetAddrSize ) {
- return null;
- }
- saw_digit = true;
- }
- } else if ( ch == '.' && saw_digit ) {
- if ( octets == inetAddrSize ) {
- return null;
- }
- cur++;
- dst[cur] = 0;
- saw_digit = false;
- } else {
- return null;
- }
- }
-
- if ( octets < inetAddrSize ) {
- return null;
- }
- return dst;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/test/java/org/apache/zest/library/http/dns/LocalManagedDnsDescriptor.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/test/java/org/apache/zest/library/http/dns/LocalManagedDnsDescriptor.java b/libraries/http/src/test/java/org/apache/zest/library/http/dns/LocalManagedDnsDescriptor.java
deleted file mode 100644
index a2ae722..0000000
--- a/libraries/http/src/test/java/org/apache/zest/library/http/dns/LocalManagedDnsDescriptor.java
+++ /dev/null
@@ -1,48 +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.zest.library.http.dns;
-
-import sun.net.spi.nameservice.NameService;
-import sun.net.spi.nameservice.NameServiceDescriptor;
-
-public class LocalManagedDnsDescriptor
- implements NameServiceDescriptor
-{
-
- public static final String PROVIDER_NAME = "LocalManagedDns";
- private static final NameService nameService = new LocalManagedDns();
-
- public NameService createNameService()
- throws Exception
- {
- return nameService;
- }
-
- public String getProviderName()
- {
- return PROVIDER_NAME;
- }
-
- public String getType()
- {
- return "dns";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/test/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor
----------------------------------------------------------------------
diff --git a/libraries/http/src/test/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor b/libraries/http/src/test/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor
deleted file mode 100644
index a8a8434..0000000
--- a/libraries/http/src/test/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor
+++ /dev/null
@@ -1,36 +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.
-#
-#
-#
-
-# 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.
-
-org.apache.zest.library.http.dns.LocalManagedDnsDescriptor
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/vhost-test/java/org/apache/zest/library/http/VirtualHostJettyServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/vhost-test/java/org/apache/zest/library/http/VirtualHostJettyServiceTest.java b/libraries/http/src/vhost-test/java/org/apache/zest/library/http/VirtualHostJettyServiceTest.java
new file mode 100644
index 0000000..1bf526c
--- /dev/null
+++ b/libraries/http/src/vhost-test/java/org/apache/zest/library/http/VirtualHostJettyServiceTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.zest.library.http;
+
+import java.io.IOException;
+import org.apache.http.client.methods.HttpGet;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.library.http.dns.LocalManagedDns;
+import org.apache.zest.test.EntityTestAssembler;
+
+import static org.junit.Assert.assertEquals;
+import static org.apache.zest.library.http.Servlets.addServlets;
+import static org.apache.zest.library.http.Servlets.serve;
+import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
+
+// TODO Compilation fails with Java 9
+// TODO Move this to a separate source set that's enabled only when Java < 9
+public class VirtualHostJettyServiceTest
+ extends AbstractJettyTest
+{
+ private static final String HOST1 = "host1.http.library.zest";
+ private static final String HOST2 = "host2.http.library.zest";
+
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ ModuleAssembly configModule = module;
+ new EntityTestAssembler().assemble( configModule );
+ new JettyServiceAssembler().withConfig( configModule, Visibility.layer ).assemble( module );
+
+ SecureJettyConfiguration config = configModule.forMixin( SecureJettyConfiguration.class ).declareDefaults();
+ config.hostName().set( "127.0.0.1" );
+ config.port().set( HTTP_PORT );
+ config.virtualHosts().set( HOST1 + "," + HOST2 );
+
+ addServlets( serve( "/hello" ).with( HelloWorldServletService.class ) ).to( module );
+ }
+
+ @BeforeClass
+ public static void beforeVirtualHostsClass()
+ {
+ assumeNoIbmJdk();
+ LocalManagedDns.putName( HOST1, "127.0.0.1" );
+ LocalManagedDns.putName( HOST2, "127.0.0.1" );
+ }
+
+ @AfterClass
+ public static void afterVirtualHostsClass()
+ {
+ LocalManagedDns.removeName( HOST1 );
+ LocalManagedDns.removeName( HOST2 );
+ }
+
+ @Test
+ public void test()
+ throws IOException
+ {
+ // Available on HOST1 and HOST2
+ String output = defaultHttpClient.execute( new HttpGet( "http://" + HOST1 + ":8041/hello" ),
+ stringResponseHandler );
+ assertEquals( "Hello World", output );
+
+ output = defaultHttpClient.execute( new HttpGet( "http://" + HOST2 + ":8041/hello" ),
+ stringResponseHandler );
+ assertEquals( "Hello World", output );
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/vhost-test/java/org/apache/zest/library/http/dns/LocalManagedDns.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/vhost-test/java/org/apache/zest/library/http/dns/LocalManagedDns.java b/libraries/http/src/vhost-test/java/org/apache/zest/library/http/dns/LocalManagedDns.java
new file mode 100644
index 0000000..68b208d
--- /dev/null
+++ b/libraries/http/src/vhost-test/java/org/apache/zest/library/http/dns/LocalManagedDns.java
@@ -0,0 +1,125 @@
+/*
+ * 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.zest.library.http.dns;
+
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.xbill.DNS.spi.DNSJavaNameServiceDescriptor;
+import sun.net.spi.nameservice.NameService;
+
+public class LocalManagedDns
+ implements NameService
+{
+
+ private static final NameService DEFAULT_DNS = new DNSJavaNameServiceDescriptor().createNameService();
+ private static final Map<String, String> NAMES = new ConcurrentHashMap<String, String>();
+
+ public static void clearNames()
+ {
+ NAMES.clear();
+ }
+
+ public static String putName( String name, String ip )
+ {
+ return NAMES.put( name, ip );
+ }
+
+ public static String removeName( String name )
+ {
+ return NAMES.remove( name );
+ }
+
+ public String getHostByAddr( byte[] bytes )
+ throws UnknownHostException
+ {
+ return DEFAULT_DNS.getHostByAddr( bytes );
+ }
+
+ public InetAddress[] lookupAllHostAddr( String name )
+ throws UnknownHostException
+ {
+ String log = "[CDNS] Lookup request";
+ String ip = NAMES.get( name );
+ InetAddress[] result = new InetAddress[ 0 ];
+ if ( ip != null && ip.length() > 0 ) {
+ log += " on managed name (" + name + ")";
+ byte[] ipBytes = ipStringToBytes( ip );
+ result = new InetAddress[]{ Inet4Address.getByAddress( ipBytes ) };
+ } else {
+ log += " on non-managed name (" + name + ")";
+ result = DEFAULT_DNS.lookupAllHostAddr( name );
+ }
+ return result;
+ }
+
+ private static byte[] ipStringToBytes( String ipString )
+ {
+ if ( ipString == null || ipString.length() == 0 ) {
+ return null;
+ }
+
+ int inetAddrSize = 4;
+ int octets;
+ char ch;
+ byte[] dst = new byte[ inetAddrSize ];
+ char[] srcb = ipString.toCharArray();
+ boolean saw_digit = false;
+
+ octets = 0;
+ int i = 0;
+ int cur = 0;
+ while ( i < srcb.length ) {
+ ch = srcb[i++];
+ if ( Character.isDigit( ch ) ) {
+ int sum = dst[cur] * 10 + ( Character.digit( ch, 10 ) & 0xff );
+
+ if ( sum > 255 ) {
+ return null;
+ }
+
+ dst[cur] = ( byte ) ( sum & 0xff );
+ if ( !saw_digit ) {
+ if ( ++octets > inetAddrSize ) {
+ return null;
+ }
+ saw_digit = true;
+ }
+ } else if ( ch == '.' && saw_digit ) {
+ if ( octets == inetAddrSize ) {
+ return null;
+ }
+ cur++;
+ dst[cur] = 0;
+ saw_digit = false;
+ } else {
+ return null;
+ }
+ }
+
+ if ( octets < inetAddrSize ) {
+ return null;
+ }
+ return dst;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/vhost-test/java/org/apache/zest/library/http/dns/LocalManagedDnsDescriptor.java
----------------------------------------------------------------------
diff --git a/libraries/http/src/vhost-test/java/org/apache/zest/library/http/dns/LocalManagedDnsDescriptor.java b/libraries/http/src/vhost-test/java/org/apache/zest/library/http/dns/LocalManagedDnsDescriptor.java
new file mode 100644
index 0000000..a2ae722
--- /dev/null
+++ b/libraries/http/src/vhost-test/java/org/apache/zest/library/http/dns/LocalManagedDnsDescriptor.java
@@ -0,0 +1,48 @@
+/*
+ * 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.zest.library.http.dns;
+
+import sun.net.spi.nameservice.NameService;
+import sun.net.spi.nameservice.NameServiceDescriptor;
+
+public class LocalManagedDnsDescriptor
+ implements NameServiceDescriptor
+{
+
+ public static final String PROVIDER_NAME = "LocalManagedDns";
+ private static final NameService nameService = new LocalManagedDns();
+
+ public NameService createNameService()
+ throws Exception
+ {
+ return nameService;
+ }
+
+ public String getProviderName()
+ {
+ return PROVIDER_NAME;
+ }
+
+ public String getType()
+ {
+ return "dns";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/vhost-test/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor
----------------------------------------------------------------------
diff --git a/libraries/http/src/vhost-test/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor b/libraries/http/src/vhost-test/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor
new file mode 100644
index 0000000..723c58d
--- /dev/null
+++ b/libraries/http/src/vhost-test/resources/META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor
@@ -0,0 +1,17 @@
+# 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.
+
+org.apache.zest.library.http.dns.LocalManagedDnsDescriptor
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8fd9d5ac/libraries/http/src/vhost-test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/libraries/http/src/vhost-test/resources/logback.xml b/libraries/http/src/vhost-test/resources/logback.xml
new file mode 100644
index 0000000..c390645
--- /dev/null
+++ b/libraries/http/src/vhost-test/resources/logback.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ ~
+ -->
+<configuration>
+
+ <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>[ZEST] @%-20thread %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="stdout" />
+ </root>
+
+ <logger name="org.apache.zest.library.http" level="trace"/>
+ <logger name="org.eclipse.jetty" level="info"/>
+ <logger name="org.jetty" level="info"/>
+
+</configuration>