summaryrefslogtreecommitdiff
path: root/swift/test/Ice/servantLocator/TestI.swift
blob: 8008ac660d3058e1100241babfc903ae96117669 (plain)
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
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

import Foundation
import Ice
import TestCommon

class TestI: TestIntf {
    func requestFailedException(current _: Current) throws {}

    func unknownUserException(current _: Current) throws {}

    func unknownLocalException(current _: Current) throws {}

    func unknownException(current _: Current) throws {}

    func localException(current _: Current) throws {}

    func userException(current _: Current) throws {}

    func unknownExceptionWithServantException(current: Current) throws {
        throw ObjectNotExistException(id: current.id,
                                      facet: current.facet,
                                      operation: current.operation)
    }

    func impossibleException(throw t: Bool, current _: Current) throws -> String {
        if t {
            throw TestImpossibleException()
        }
        //
        // Return a value so we can be sure that the stream position
        // is reset correctly if finished() throws.
        //
        return "Hello"
    }

    func intfUserException(throw t: Bool, current _: Current) throws -> String {
        if t {
            throw TestIntfUserException()
        }
        //
        // Return a value so we can be sure that the stream position
        // is reset correctly if finished() throws.
        //
        return "Hello"
    }

    func asyncResponse(current _: Current) throws {
        //
        // Only relevant for AMD.
        //
    }

    func asyncException(current _: Current) throws {
        //
        // Only relevant for AMD.
        //
    }

    func shutdown(current: Current) throws {
        current.adapter!.deactivate()
    }
}

class TestActivationI: TestActivation {
    var _helper: TestHelper

    init(_ helper: TestHelper) {
        _helper = helper
    }

    func activateServantLocator(activate: Bool, current: Current) throws {
        if activate {
            try current.adapter!.addServantLocator(locator: ServantLocatorI("", _helper), category: "")
            try current.adapter!.addServantLocator(locator: ServantLocatorI("category", _helper), category: "category")
        } else {
            var locator = try current.adapter!.removeServantLocator("")
            locator.deactivate("")
            locator = try current.adapter!.removeServantLocator("category")
            locator.deactivate("category")
        }
    }
}