aboutsummaryrefslogtreecommitdiffstats
path: root/lib/orber/test/lname_SUITE.erl
diff options
context:
space:
mode:
authorNiclas Eklund <[email protected]>2010-09-20 13:25:26 +0200
committerBjörn Gustavsson <[email protected]>2010-09-21 15:35:34 +0200
commit5ddf44bb91540fd88e604f077d71482c40185cd8 (patch)
treea9fb6b22a3428444f684848accb1c5181bd32d70 /lib/orber/test/lname_SUITE.erl
parentcedcfd6364a9ee2f36ea09b5995613375d7ab9ae (diff)
downloadotp-5ddf44bb91540fd88e604f077d71482c40185cd8.tar.gz
otp-5ddf44bb91540fd88e604f077d71482c40185cd8.tar.bz2
otp-5ddf44bb91540fd88e604f077d71482c40185cd8.zip
Add test suites for (most) CORBA applications
Diffstat (limited to 'lib/orber/test/lname_SUITE.erl')
-rw-r--r--lib/orber/test/lname_SUITE.erl198
1 files changed, 198 insertions, 0 deletions
diff --git a/lib/orber/test/lname_SUITE.erl b/lib/orber/test/lname_SUITE.erl
new file mode 100644
index 0000000000..d1f0e7cf0e
--- /dev/null
+++ b/lib/orber/test/lname_SUITE.erl
@@ -0,0 +1,198 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+%%-----------------------------------------------------------------
+%%
+%% Description:
+%% Test suite for the Names Library module
+%%
+%%-----------------------------------------------------------------
+-module(lname_SUITE).
+
+-include("test_server.hrl").
+-include_lib("orber/COSS/CosNaming/CosNaming.hrl").
+-include_lib("orber/COSS/CosNaming/lname.hrl").
+
+-define(default_timeout, ?t:minutes(3)).
+
+%%-----------------------------------------------------------------
+%% External exports
+%%-----------------------------------------------------------------
+-export([all/1]).
+
+%%-----------------------------------------------------------------
+%% Internal exports
+%%-----------------------------------------------------------------
+-export([]).
+-compile(export_all).
+
+%%-----------------------------------------------------------------
+%% Func: all/1
+%% Args:
+%% Returns:
+%%-----------------------------------------------------------------
+all(doc) -> ["Description", "more description"];
+all(suite) ->
+ [lname_component, lname].
+
+%%-----------------------------------------------------------------
+%% Init and cleanup functions.
+%%-----------------------------------------------------------------
+
+init_per_testcase(_Case, Config) ->
+ ?line Dog=test_server:timetrap(?default_timeout),
+ [{watchdog, Dog}|Config].
+
+
+fin_per_testcase(_Case, Config) ->
+ Dog = ?config(watchdog, Config),
+ test_server:timetrap_cancel(Dog),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: name component handling tests
+%% Description:
+%%-----------------------------------------------------------------
+lname_component(doc) -> ["Description", "more description"];
+lname_component(suite) -> [];
+lname_component(_) ->
+ create_test(),
+ get_tests(),
+ set_tests().
+
+create_test() ->
+ ?line #'CosNaming_NameComponent'{} = lname_component:create(),
+ ok.
+
+get_tests() ->
+ NC = #'CosNaming_NameComponent'{id="first", kind="apple"},
+ NC1 = #'CosNaming_NameComponent'{id="", kind="apple"},
+ NC2 = #'CosNaming_NameComponent'{id="first", kind=""},
+ ?line "first" = lname_component:get_id(NC),
+ ?line "apple" = lname_component:get_kind(NC),
+ ?line {'EXCEPTION', #'LNameComponent_NotSet'{}} =
+ (catch lname_component:get_id(NC1)),
+ ?line {'EXCEPTION', #'LNameComponent_NotSet'{}} =
+ (catch lname_component:get_kind(NC2)),
+ ok.
+
+set_tests() ->
+ NC = #'CosNaming_NameComponent'{id="first", kind="apple"},
+ ?line #'CosNaming_NameComponent'{id="second", kind="apple"} =
+ lname_component:set_id(NC, "second"),
+ ?line #'CosNaming_NameComponent'{id="first", kind="pear"} =
+ lname_component:set_kind(NC, "pear"),
+ ok.
+
+%%-----------------------------------------------------------------
+%% Test Case: name handling tests
+%% Description:
+%%-----------------------------------------------------------------
+lname(doc) -> ["Description", "more description"];
+lname(suite) -> [];
+lname(_) ->
+ Name = [#'CosNaming_NameComponent'{id="first", kind="apple"},
+ #'CosNaming_NameComponent'{id="last", kind="peach"},
+ #'CosNaming_NameComponent'{id="and", kind="plum"},
+ #'CosNaming_NameComponent'{id="always", kind="orange"}],
+ insert_tests(Name),
+ get_tests(Name),
+ delete_tests(Name),
+ comparision_tests(Name),
+ convertion_tests(Name).
+
+insert_tests(Name) ->
+ NC = #'CosNaming_NameComponent'{id="new", kind="pear"},
+ ?line [NC, #'CosNaming_NameComponent'{id="first", kind="apple"},
+ #'CosNaming_NameComponent'{id="last", kind="peach"},
+ #'CosNaming_NameComponent'{id="and", kind="plum"},
+ #'CosNaming_NameComponent'{id="always", kind="orange"}] =
+ lname:insert_component(Name, 1, NC),
+ ?line [#'CosNaming_NameComponent'{id="first", kind="apple"},
+ #'CosNaming_NameComponent'{id="last", kind="peach"},
+ #'CosNaming_NameComponent'{id="and", kind="plum"},
+ #'CosNaming_NameComponent'{id="always", kind="orange"}, NC] =
+ lname:insert_component(Name, 5, NC),
+ ?line [#'CosNaming_NameComponent'{id="first", kind="apple"},
+ #'CosNaming_NameComponent'{id="last", kind="peach"},
+ #'CosNaming_NameComponent'{id="and", kind="plum"}, NC,
+ #'CosNaming_NameComponent'{id="always", kind="orange"}] =
+ lname:insert_component(Name, 4, NC),
+ ?line [#'CosNaming_NameComponent'{id="first", kind="apple"},
+ #'CosNaming_NameComponent'{id="last", kind="peach"}, NC,
+ #'CosNaming_NameComponent'{id="and", kind="plum"},
+ #'CosNaming_NameComponent'{id="always", kind="orange"}] =
+ lname:insert_component(Name, 3, NC),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:insert_component(Name, 6, NC)),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:insert_component(Name, 0, NC)),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:insert_component(Name, -2, NC)),
+ ok.
+
+get_tests(Name) ->
+ ?line #'CosNaming_NameComponent'{id="first", kind="apple"} =
+ lname:get_component(Name, 1),
+ ?line #'CosNaming_NameComponent'{id="always", kind="orange"} =
+ lname:get_component(Name, 4),
+ ?line #'CosNaming_NameComponent'{id="and", kind="plum"} =
+ lname:get_component(Name, 3),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:get_component(Name, 5)),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:get_component(Name, 0)),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:get_component(Name, -2)),
+ ok.
+
+delete_tests(Name) ->
+ ?line [#'CosNaming_NameComponent'{id="last", kind="peach"},
+ #'CosNaming_NameComponent'{id="and", kind="plum"},
+ #'CosNaming_NameComponent'{id="always", kind="orange"}] =
+ lname:delete_component(Name, 1),
+ ?line [#'CosNaming_NameComponent'{id="first", kind="apple"},
+ #'CosNaming_NameComponent'{id="last", kind="peach"},
+ #'CosNaming_NameComponent'{id="and", kind="plum"}] =
+ lname:delete_component(Name, 4),
+ ?line [#'CosNaming_NameComponent'{id="first", kind="apple"},
+ #'CosNaming_NameComponent'{id="last", kind="peach"},
+ #'CosNaming_NameComponent'{id="always", kind="orange"}] =
+ lname:delete_component(Name, 3),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:delete_component(Name, 6)),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:delete_component(Name, 0)),
+ ?line {'EXCEPTION', #'LName_NoComponent'{}} =
+ (catch lname:delete_component(Name, -2)),
+ ok.
+
+comparision_tests(Name) ->
+ ?line true = lname:equal(Name, Name),
+ ?line false = lname:equal(Name, lname:delete_component(Name, 2)),
+ ?line true = lname:less_than(lname:delete_component(Name, 2), Name),
+ ?line false = lname:less_than(Name, Name),
+ ?line false = lname:less_than(Name, lname:delete_component(Name, 2)),
+ ok.
+
+convertion_tests(Name) ->
+ ?line Name = lname:from_idl_form(Name),
+ ?line Name = lname:to_idl_form(Name),
+ ok.