Add test for shading netty-tcnative. (#8157)

Motivation:

d67d639f5f added a test for shading the native transport of netty. We should also test that shading netty-tcnative is possible.

Modifications:

Add test for shading netty-tcnative

Result:

More testing.
This commit is contained in:
Norman Maurer 2018-07-28 02:53:43 +08:00 committed by GitHub
parent fcb19cb589
commit f60d08fd32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 10 deletions

View File

@ -71,7 +71,8 @@
</os> </os>
</activation> </activation>
<properties> <properties>
<nativeLib>netty_transport_native_kqueue_${os.detected.arch}.jnilib</nativeLib> <nativeTransportLib>netty_transport_native_kqueue_${os.detected.arch}.jnilib</nativeTransportLib>
<nativeTcnativeLib>netty_tcnative.jnilib</nativeTcnativeLib>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -81,6 +82,20 @@
<classifier>${jni.classifier}</classifier> <classifier>${jni.classifier}</classifier>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Needed to test shading of netty-tcnative -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-handler</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${tcnative.artifactId}</artifactId>
<version>${tcnative.version}</version>
<classifier>${tcnative.classifier}</classifier>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -126,7 +141,8 @@
<include name="${jarName}" /> <include name="${jarName}" />
</fileset> </fileset>
</unzip> </unzip>
<move file="${classesShadedNativeDir}/lib${nativeLib}" tofile="${classesShadedNativeDir}/lib${shadingPrefix}_${nativeLib}" /> <move file="${classesShadedNativeDir}/lib${nativeTransportLib}" tofile="${classesShadedNativeDir}/lib${shadingPrefix}_${nativeTransportLib}" />
<move file="${classesShadedNativeDir}/lib${nativeTcnativeLib}" tofile="${classesShadedNativeDir}/lib${shadingPrefix}_${nativeTcnativeLib}" />
<jar destfile="${project.build.directory}/${jarName}" basedir="${classesShadedDir}" /> <jar destfile="${project.build.directory}/${jarName}" basedir="${classesShadedDir}" />
<delete dir="${classesShadedDir}" /> <delete dir="${classesShadedDir}" />
</target> </target>
@ -162,7 +178,8 @@
</os> </os>
</activation> </activation>
<properties> <properties>
<nativeLib>netty_transport_native_epoll_${os.detected.arch}.so</nativeLib> <nativeTransportLib>netty_transport_native_epoll_${os.detected.arch}.so</nativeTransportLib>
<nativeTcnativeLib>netty_tcnative.so</nativeTcnativeLib>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -172,6 +189,20 @@
<classifier>${jni.classifier}</classifier> <classifier>${jni.classifier}</classifier>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Needed to test shading of netty-tcnative -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-handler</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${tcnative.artifactId}</artifactId>
<version>${tcnative.version}</version>
<classifier>${tcnative.classifier}</classifier>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -217,7 +248,8 @@
<include name="${jarName}" /> <include name="${jarName}" />
</fileset> </fileset>
</unzip> </unzip>
<move file="${classesShadedNativeDir}/lib${nativeLib}" tofile="${classesShadedNativeDir}/lib${shadingPrefix}_${nativeLib}" /> <move file="${classesShadedNativeDir}/lib${nativeTransportLib}" tofile="${classesShadedNativeDir}/lib${shadingPrefix}_${nativeTransportLib}" />
<move file="${classesShadedNativeDir}/lib${nativeTcnativeLib}" tofile="${classesShadedNativeDir}/lib${shadingPrefix}_${nativeTcnativeLib}" />
<jar destfile="${project.build.directory}/${jarName}" basedir="${classesShadedDir}" /> <jar destfile="${project.build.directory}/${jarName}" basedir="${classesShadedDir}" />
<delete dir="${classesShadedDir}" /> <delete dir="${classesShadedDir}" />
</target> </target>

View File

@ -23,14 +23,19 @@ import java.lang.reflect.Method;
public class ShadingIT { public class ShadingIT {
@Test @Test
public void testShadingNativeLibs() throws Exception { public void testShadingNativeTransport() throws Exception {
testShading0(PlatformDependent.isOsx() ? "io.netty.channel.kqueue.KQueue" : "io.netty.channel.epoll.Epoll");
}
@Test
public void testShadingTcnative() throws Exception {
testShading0("io.netty.handler.ssl.OpenSsl");
}
private static void testShading0(String classname) throws Exception {
String shadingPrefix = System.getProperty("shadingPrefix"); String shadingPrefix = System.getProperty("shadingPrefix");
final Class<?> clazz = Class.forName(shadingPrefix + '.' + className()); final Class<?> clazz = Class.forName(shadingPrefix + '.' + classname);
Method method = clazz.getMethod("ensureAvailability"); Method method = clazz.getMethod("ensureAvailability");
method.invoke(null); method.invoke(null);
} }
private static String className() {
return PlatformDependent.isOsx() ? "io.netty.channel.kqueue.KQueue" : "io.netty.channel.epoll.Epoll";
}
} }