Author: mturk Date: Wed May 13 09:54:19 2009 New Revision: 774269 URL: http://svn.apache.org/viewvc?rev=774269&view=rev Log: Add OpenSSL stub class and SUPPORTED field
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/OpenSSL.java (with props) Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/OpenSSL.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/OpenSSL.java?rev=774269&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/OpenSSL.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/OpenSSL.java Wed May 13 09:54:19 2009 @@ -0,0 +1,41 @@ +/* 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.commons.runtime.net; + +/** + * OpenSSL module + */ +public final class OpenSSL +{ + private static native boolean has0(); + + private OpenSSL() + { + // No instance. + } + + /** + * True if the OpenSSL module is compiled in and supported. + * <p> + * If the <em>Apache Commons Runtime</em> + * has compiled in {...@code OpenSSL} support the value of this + * field is {...@code true}. + * </p> + */ + public static final boolean SUPPORTED = has0(); + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/OpenSSL.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=774269&r1=774268&r2=774269&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java (original) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Wed May 13 09:54:19 2009 @@ -23,6 +23,8 @@ import junit.framework.*; import org.apache.commons.runtime.io.Status; +import org.apache.commons.runtime.net.OpenSSL; + /** * Native Test. * The native methods are compiled only when @@ -84,11 +86,14 @@ throws Exception { System.loadLibrary("acr"); - System.loadLibrary("acrssl"); for (int i = 0; i < longStrSize; i++) { longChar[i] = (char)('A' + (i % 20)); } longString = new String(longChar); + if (OpenSSL.SUPPORTED) { + // Load the ssl library if compiled in + System.loadLibrary("acrssl"); + } } public void testExInt() @@ -567,8 +572,10 @@ public void testModuleSSL() throws Throwable { - String s = test100("OpenSSL"); - assertEquals("Name", "OpenSSL", s); + if (OpenSSL.SUPPORTED) { + String s = test100("OpenSSL"); + assertEquals("Name", "OpenSSL", s); + } } }