diff --git a/build.xml b/build.xml index 9c94e61..1abc47d 100644 --- a/build.xml +++ b/build.xml @@ -142,7 +142,7 @@ - + diff --git a/src/test/com/wolfssl/WolfSSLContextTest.java b/src/test/com/wolfssl/WolfSSLContextTest.java new file mode 100644 index 0000000..be53cd8 --- /dev/null +++ b/src/test/com/wolfssl/WolfSSLContextTest.java @@ -0,0 +1,81 @@ +/* WolfSSLTest.java + * + * Copyright (C) 2006-2014 wolfSSL Inc. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +package com.wolfssl; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static org.junit.Assert.*; + +import com.wolfssl.WolfSSL; + +public class WolfSSLContextTest { + + @Test + public void testWolfSSLContext() throws WolfSSLException { + + WolfSSL lib = null; + + try { + lib = new WolfSSL(); + } catch (WolfSSLException e) { + fail("failed to create WolfSSL object"); + } + + System.out.println("WolfSSLContext Class"); + + test_WolfSSLContext_new(lib.SSLv23_ServerMethod()); + + } + + public void test_WolfSSLContext_new(long method) { + + if (method != 0) + { + System.out.print("\tWolfSSLContext()"); + WolfSSLContext wc = null; + + /* test failure case */ + try { + + wc = new WolfSSLContext(0); + + } catch (WolfSSLException e) { + + /* now test success case */ + try { + wc = new WolfSSLContext(method); + } catch (WolfSSLException we) { + System.out.println("\t... failed"); + fail("failed to create WolfSSLContext object"); + } + + System.out.println("\t... passed"); + return; + } + + System.out.println("\t... failed"); + fail("failure case improperly succeeded, WolfSSLContext()"); + } + } +} + diff --git a/src/test/com/wolfssl/WolfSSLSessionTest.java b/src/test/com/wolfssl/WolfSSLSessionTest.java new file mode 100644 index 0000000..f0a8bea --- /dev/null +++ b/src/test/com/wolfssl/WolfSSLSessionTest.java @@ -0,0 +1,66 @@ +/* WolfSSLTest.java + * + * Copyright (C) 2006-2014 wolfSSL Inc. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +package com.wolfssl; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static org.junit.Assert.*; + +import com.wolfssl.WolfSSL; + +public class WolfSSLSessionTest { + + @Test + public void testWolfSSLSession() throws WolfSSLException { + + WolfSSL lib = null; + + try { + lib = new WolfSSL(); + } catch (WolfSSLException e) { + fail("failed to create WolfSSL object"); + } + + System.out.println("WolfSSLSession Class"); + + test_WolfSSL_new(lib); + + } + + public void test_WolfSSL_new(WolfSSL lib) { + + try { + System.out.print("\tWolfSSL()"); + lib = new WolfSSL(); + } catch (UnsatisfiedLinkError ule) { + System.out.println("\t\t... failed"); + fail("failed to load native JNI library"); + } catch (WolfSSLException we) { + System.out.println("\t\t... failed"); + fail("failed to create WolfSSL object"); + } + + System.out.println("\t\t... passed"); + } +} + diff --git a/src/test/com/wolfssl/WolfSSLTest.java b/src/test/com/wolfssl/WolfSSLTest.java index 73eade0..dc01941 100644 --- a/src/test/com/wolfssl/WolfSSLTest.java +++ b/src/test/com/wolfssl/WolfSSLTest.java @@ -22,25 +22,42 @@ package com.wolfssl; import org.junit.Test; -import junit.framework.TestCase; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static org.junit.Assert.*; import com.wolfssl.WolfSSL; -public class WolfSSLTest extends TestCase { +public class WolfSSLTest { + @BeforeClass + public static void loadLibrary() { + try { + WolfSSL.loadLibrary(); + } catch (UnsatisfiedLinkError ule) { + fail("failed to load native JNI library"); + } + } + + @Test public void testWolfSSL() throws WolfSSLException { WolfSSL lib = null; try { - WolfSSL.loadLibrary(); lib = new WolfSSL(); - } catch (UnsatisfiedLinkError ule) { - fail("failed to load native JNI library"); } catch (WolfSSLException e) { fail("failed to create WolfSSL object"); } + System.out.println("WolfSSL Class"); + + test_WolfSSL_Method_Allocators(lib); + + } + + public void test_WolfSSL_Method_Allocators(WolfSSL lib) { tstMethod(lib.SSLv3_ServerMethod(), "SSLv3_ServerMethod()"); tstMethod(lib.SSLv3_ClientMethod(), "SSLv3_ClientMethod()"); tstMethod(lib.TLSv1_ServerMethod(), "TLSv1_ServerMethod()"); diff --git a/src/test/com/wolfssl/WolfSSLTestSuite.java b/src/test/com/wolfssl/WolfSSLTestSuite.java new file mode 100644 index 0000000..7bf8f36 --- /dev/null +++ b/src/test/com/wolfssl/WolfSSLTestSuite.java @@ -0,0 +1,39 @@ +/* WolfSSLTest.java + * + * Copyright (C) 2006-2014 wolfSSL Inc. + * + * This file is part of CyaSSL. + * + * CyaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * CyaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +package com.wolfssl; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ + WolfSSLTest.class, + WolfSSLSessionTest.class, + WolfSSLContextTest.class +}) + +public class WolfSSLTestSuite { + /* this class remains empty, + * only used as a holder for the above + * annotations */ +} +