summaryrefslogtreecommitdiff
path: root/python/test/Ice/properties/Client.py
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2015-03-21 15:35:40 -0230
committerMatthew Newhook <matthew@zeroc.com>2015-03-21 15:35:40 -0230
commit630a37d2fe66f24518299e705f958b571803c522 (patch)
tree969723791bdc4d73bb099c19d45554d0ca241ad9 /python/test/Ice/properties/Client.py
parentFix some README.md markdown formatting (diff)
downloadice-630a37d2fe66f24518299e705f958b571803c522.tar.bz2
ice-630a37d2fe66f24518299e705f958b571803c522.tar.xz
ice-630a37d2fe66f24518299e705f958b571803c522.zip
py -> python
rb -> ruby objc -> objective-c cs -> csharp
Diffstat (limited to 'python/test/Ice/properties/Client.py')
-rw-r--r--python/test/Ice/properties/Client.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/python/test/Ice/properties/Client.py b/python/test/Ice/properties/Client.py
new file mode 100644
index 00000000000..e771da6903e
--- /dev/null
+++ b/python/test/Ice/properties/Client.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+
+import os, sys, traceback
+import Ice
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class Client(Ice.Application):
+ def run(self, args):
+ properties = self.communicator().getProperties()
+ test(properties.getProperty("Ice.Trace.Network") == "1")
+ test(properties.getProperty("Ice.Trace.Protocol") == "1")
+ test(properties.getProperty("Config.Path") == "./config/中国_client.config")
+ test(properties.getProperty("Ice.ProgramName") == "PropertiesClient")
+ test(self.appName() == properties.getProperty("Ice.ProgramName"))
+
+
+sys.stdout.write("testing load properties from UTF-8 path... ")
+sys.stdout.flush()
+properties = Ice.createProperties()
+properties.load("./config/中国_client.config")
+test(properties.getProperty("Ice.Trace.Network") == "1")
+test(properties.getProperty("Ice.Trace.Protocol") == "1")
+test(properties.getProperty("Config.Path") == "./config/中国_client.config")
+test(properties.getProperty("Ice.ProgramName") == "PropertiesClient")
+print("ok")
+sys.stdout.write("testing load properties from UTF-8 path using Ice::Application... ")
+sys.stdout.flush()
+c = Client()
+c.main(sys.argv, "./config/中国_client.config")
+print("ok")
+
+sys.stdout.write("testing using Ice.Config with multiple config files... ")
+sys.stdout.flush()
+properties = Ice.createProperties(["--Ice.Config=config/config.1, config/config.2, config/config.3"])
+test(properties.getProperty("Config1") == "Config1")
+test(properties.getProperty("Config2") == "Config2")
+test(properties.getProperty("Config3") == "Config3")
+print("ok")
+
+sys.stdout.write("testing configuration file escapes... ")
+sys.stdout.flush()
+properties = Ice.createProperties(["--Ice.Config=config/escapes.cfg"])
+
+props = { "Foo\tBar":"3",
+ "Foo\\tBar":"4",
+ "Escape\\ Space":"2",
+ "Prop1":"1",
+ "Prop2":"2",
+ "Prop3":"3",
+ "My Prop1":"1",
+ "My Prop2":"2",
+ "My.Prop1":"a property",
+ "My.Prop2":"a property",
+ "My.Prop3":" a property ",
+ "My.Prop4":" a property ",
+ "My.Prop5":"a \\ property",
+ "foo=bar":"1",
+ "foo#bar":"2",
+ "foo bar":"3",
+ "A":"1",
+ "B":"2 3 4",
+ "C":"5=#6",
+ "AServer":"\\\\server\\dir",
+ "BServer":"\\server\\dir"};
+
+for k in props.keys():
+ test(properties.getProperty(k) == props[k])
+
+print("ok")
+
+sys.exit(0)