You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/01/31 20:14:35 UTC

svn commit: r1781163 - in /tomcat/trunk/test/org/apache/tomcat/jni: AbstractJniTest.java TestFile.java TestSocketServer.java TestSocketServerAnyLocalAddress.java

Author: markt
Date: Tue Jan 31 20:14:34 2017
New Revision: 1781163

URL: http://svn.apache.org/viewvc?rev=1781163&view=rev
Log:
Fix CI failure
Use abstract base class to configure the tc-native library and ensure tests only run when it is available.

Added:
    tomcat/trunk/test/org/apache/tomcat/jni/AbstractJniTest.java   (with props)
Modified:
    tomcat/trunk/test/org/apache/tomcat/jni/TestFile.java
    tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServer.java
    tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java

Added: tomcat/trunk/test/org/apache/tomcat/jni/AbstractJniTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/jni/AbstractJniTest.java?rev=1781163&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/jni/AbstractJniTest.java (added)
+++ tomcat/trunk/test/org/apache/tomcat/jni/AbstractJniTest.java Tue Jan 31 20:14:34 2017
@@ -0,0 +1,46 @@
+/*
+ *  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.tomcat.jni;
+
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+
+public abstract class AbstractJniTest {
+
+    private boolean nativeLibraryPresent = false;
+
+    @Before
+    public void initBase() throws Exception {
+        try {
+            Library.initialize(null);
+            nativeLibraryPresent = true;
+        } catch (LibraryNotFoundError lnfe) {
+            nativeLibraryPresent = false;
+        }
+        Assume.assumeTrue("APR Library not found", nativeLibraryPresent);
+    }
+
+
+    @After
+    public void destroyBase() {
+        if (nativeLibraryPresent) {
+            Library.terminate();
+        }
+    }
+
+}

Propchange: tomcat/trunk/test/org/apache/tomcat/jni/AbstractJniTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/test/org/apache/tomcat/jni/TestFile.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/jni/TestFile.java?rev=1781163&r1=1781162&r2=1781163&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/jni/TestFile.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/jni/TestFile.java Tue Jan 31 20:14:34 2017
@@ -20,7 +20,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 
-public class TestFile {
+public class TestFile extends AbstractJniTest {
 
     @Test
     public void testInfoGet() throws Exception {

Modified: tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServer.java?rev=1781163&r1=1781162&r2=1781163&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServer.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServer.java Tue Jan 31 20:14:34 2017
@@ -21,18 +21,16 @@ import java.util.concurrent.CountDownLat
 
 import org.junit.After;
 import org.junit.Assert;
-import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
 
 /**
  * Tests for server-side sockets.
  */
-public class TestSocketServer {
+public class TestSocketServer extends AbstractJniTest {
 
     private static final String HOST = "localhost";
 
-    private boolean nativeLibraryPresent = false;
     private int port = 0;
     private long serverSocket = 0;
     private long clientSocket = 0;
@@ -40,14 +38,6 @@ public class TestSocketServer {
 
     @Before
     public void init() throws Exception {
-        try {
-            Library.initialize(null);
-            nativeLibraryPresent = true;
-        } catch (LibraryNotFoundError lnfe) {
-            nativeLibraryPresent = false;
-        }
-        Assume.assumeTrue("APR Library not found", nativeLibraryPresent);
-
         long serverPool = Pool.create(0);
         long inetAddress = Address.info(HOST, Socket.APR_INET,
                                         0, 0, serverPool);
@@ -78,9 +68,6 @@ public class TestSocketServer {
             Socket.close(serverSocket);
             Socket.destroy(serverSocket);
         }
-        if (nativeLibraryPresent) {
-            Library.terminate();
-        }
     }
 
 

Modified: tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java?rev=1781163&r1=1781162&r2=1781163&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java Tue Jan 31 20:14:34 2017
@@ -25,30 +25,20 @@ import java.util.Enumeration;
 
 import org.junit.After;
 import org.junit.Assert;
-import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
 
 /**
  * Tests for server-side sockets using any local address (0.0.0.0 or ::).
  */
-public class TestSocketServerAnyLocalAddress {
+public class TestSocketServerAnyLocalAddress extends AbstractJniTest {
 
-    private boolean nativeLibraryPresent = false;
     private long serverSocket = 0;
     private long clientSocket = 0;
 
 
     @Before
     public void init() throws Exception {
-        try {
-            Library.initialize(null);
-            nativeLibraryPresent = true;
-        } catch (LibraryNotFoundError lnfe) {
-            nativeLibraryPresent = false;
-        }
-        Assume.assumeTrue("APR Library not found", nativeLibraryPresent);
-
         long serverPool = Pool.create(0);
         long inetAddress = Address.info(null, Socket.APR_UNSPEC,
                                         0, 0, serverPool);
@@ -76,9 +66,6 @@ public class TestSocketServerAnyLocalAdd
             Socket.close(serverSocket);
             Socket.destroy(serverSocket);
         }
-        if (nativeLibraryPresent) {
-            Library.terminate();
-        }
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org