2 * Copyright (c) 2014 <copyright holder> <email>
4 * For license details, see the LICENSE file in the root of this project.
8 #include "GSSExceptionTest.h"
9 #include "GSSException.h"
14 // Registers the fixture into the 'registry'
15 CPPUNIT_TEST_SUITE_REGISTRATION( GSSExceptionTest );
17 void GSSExceptionTest::setUp()
19 CppUnit::TestFixture::setUp();
22 void GSSExceptionTest::tearDown()
24 CppUnit::TestFixture::tearDown();
28 void GSSExceptionTest::testWithMessage()
31 throw GSSException("Test message");
32 } catch (GSSException e)
34 CPPUNIT_ASSERT_EQUAL_MESSAGE(
35 "GSSException message reporting is incorrect.",
36 std::string("Test message\n\
39 The routine completed successfully\n\
41 Minor status details: \n\
48 void GSSExceptionTest::testWithMessageAndMajor()
51 throw GSSException("Test message", 524288);
52 } catch (GSSException e)
54 CPPUNIT_ASSERT_EQUAL_MESSAGE(
55 "GSSException message reporting is incorrect.",
56 std::string("Test message\n\
59 No context has been established\n\
61 Minor status details: \n\
68 void GSSExceptionTest::testWithMessageAndMajorAndMinor()
70 OM_uint32 major, minor, context = 0;
71 gss_buffer_desc_struct buf;
74 major = gss_display_status(&minor, 2109382930, GSS_C_MECH_CODE, GSS_C_NO_OID, &context, &buf);
75 throw GSSException("Test message", major, minor);
76 } catch (GSSException e)
78 CPPUNIT_ASSERT_EQUAL_MESSAGE(
79 "GSSException message reporting is incorrect.",
80 std::string("Test message\n\
83 An invalid status code was supplied\n\
85 Minor status details: \n\
92 void GSSExceptionTest::testWithMessageAndMajorAndMinorAndMechanism()
95 OM_uint32 major, minor, context = 0;
96 gss_buffer_desc_struct buf;
99 major = gss_display_status(&minor, 2109382930, GSS_C_MECH_CODE, GSS_C_NO_OID, &context, &buf);
100 throw GSSException("Test message", major, minor, GSS_C_NO_OID);
101 } catch (GSSException e)
103 CPPUNIT_ASSERT_EQUAL_MESSAGE(
104 "GSSException message reporting is incorrect.",
105 std::string("Test message\n\
106 GSS Error message:\n\
108 An invalid status code was supplied\n\
110 Minor status details: \n\
111 Invalid argument\n"),
112 std::string(e.what())