File: Association.cpp

package info (click to toggle)
odil 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: cpp: 55,982; python: 3,947; javascript: 460; xml: 182; makefile: 99; sh: 36
file content (117 lines) | stat: -rw-r--r-- 3,263 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#define BOOST_TEST_MODULE Association
#include <boost/test/unit_test.hpp>

#include <ostream>

#include "odil/Association.h"
#include "odil/Exception.h"
#include "odil/registry.h"

#include "../PeerFixtureBase.h"

BOOST_AUTO_TEST_CASE(DefaultConstructor)
{
    odil::Association association;
    BOOST_CHECK_EQUAL(association.get_peer_host(), "");
    BOOST_CHECK_EQUAL(association.get_peer_port(), 104);
    BOOST_CHECK(
        association.get_parameters() ==
            odil::AssociationParameters()
    );

    BOOST_CHECK(!association.is_associated());
}

BOOST_AUTO_TEST_CASE(CopyConstructor)
{
    odil::Association association;
    association.set_peer_host("pacs.example.com");
    association.set_peer_port(11112);
    association.update_parameters()
        .set_called_ae_title("remote")
        .set_user_identity_to_username_and_password("foo", "bar");

    odil::Association const other(association);

    BOOST_CHECK_EQUAL(other.get_peer_host(), association.get_peer_host());
    BOOST_CHECK_EQUAL(other.get_peer_port(), association.get_peer_port());
    BOOST_CHECK(
        association.get_parameters() ==
            other.get_parameters()
    );
}

BOOST_AUTO_TEST_CASE(Assignment)
{
    odil::Association association;
    association.set_peer_host("pacs.example.com");
    association.set_peer_port(11112);
    association.update_parameters()
        .set_called_ae_title("remote")
        .set_user_identity_to_username_and_password("foo", "bar");

    odil::Association other;
    other = association;

    BOOST_CHECK_EQUAL(other.get_peer_host(), association.get_peer_host());
    BOOST_CHECK_EQUAL(other.get_peer_port(), association.get_peer_port());
    BOOST_CHECK(
        association.get_parameters() ==
            other.get_parameters()
    );
}

BOOST_AUTO_TEST_CASE(PeerHostName)
{
    odil::Association association;
    association.set_peer_host("pacs.example.com");
    BOOST_CHECK_EQUAL(association.get_peer_host(), "pacs.example.com");
}

BOOST_AUTO_TEST_CASE(PeerPort)
{
    odil::Association association;
    association.set_peer_port(11112);
    BOOST_CHECK_EQUAL(association.get_peer_port(), 11112);
}

BOOST_AUTO_TEST_CASE(AssociationParameters)
{
    odil::Association association;

    odil::AssociationParameters parameters;
    parameters.set_calling_ae_title("foo");
    association.set_parameters(parameters);

    BOOST_REQUIRE(association.get_parameters() == parameters);
}

BOOST_AUTO_TEST_CASE(Associate)
{
    PeerFixtureBase fixture({
        {
            1, odil::registry::Verification,
            { odil::registry::ImplicitVRLittleEndian }, 
            odil::AssociationParameters::PresentationContext::Role::SCU
        }
    });
    BOOST_CHECK_THROW(
        fixture.association.set_peer_host("foo"), odil::Exception);
    BOOST_CHECK_THROW(
        fixture.association.set_peer_port(1234), odil::Exception);
    BOOST_CHECK_THROW(
        fixture.association.update_parameters().set_maximum_length(123),
        odil::Exception);
}

BOOST_AUTO_TEST_CASE(Release)
{
    odil::Association association;
    BOOST_CHECK_THROW(association.release(), odil::Exception);
}

BOOST_AUTO_TEST_CASE(Abort)
{
    odil::Association association;
    BOOST_CHECK_THROW(association.abort(2, 4), odil::Exception);
}