public void TestIdsIncludingNonAscii() { string id = "myAdderId" + '\u0765' + "1" + @"\uA"; string expectedMarshalledId = @"myAdderId\u07651\\uA"; Adder adder = m_testService.CreateNewWithUserID(id); string marshalUrl = RemotingServices.GetObjectUri(adder); Ior adderIor = new Ior(marshalUrl); IInternetIiopProfile prof = adderIor.FindInternetIiopProfile(); byte[] objectKey = prof.ObjectKey; ASCIIEncoding enc = new ASCIIEncoding(); string marshalUri = new String(enc.GetChars(objectKey)); Assert.AreEqual(expectedMarshalledId, marshalUri, "wrong user id"); // check if callable int arg1 = 1; int arg2 = 2; Assert.AreEqual(arg1 + arg2, adder.Add(arg1, arg2), "wrong adder result"); }
public void TestNonUsableProfileIncluded() { string iorString = "IOR:000000000000001b49444c3a636d6956322f5573657241636365737356323a312e3000020000000210ca1000000000650000000800000008646576312d73660033de6f8e0000004d000000020000000855736572504f41000000001043415355736572416363657373563200c3fbedfb0000000e007c4c51000000fd57aacdaf801a0000000e007c4c51000000fd57aacdaf80120000009400000000000000980001023100000008646576312d736600200b00020000004d000000020000000855736572504f41000000001043415355736572416363657373563200c3fbedfb0000000e007c4c51000000fd57aacdaf801a0000000e007c4c51000000fd57aacdaf8012000000140000000200000002000000140000000400000001000000230000000400000001000000000000000800000000cb0e0001"; Ior ior = new Ior(iorString); Assert.AreEqual("IDL:cmiV2/UserAccessV2:1.0", ior.TypID, "wrong RepositoryId"); IInternetIiopProfile iiopProf = ior.FindInternetIiopProfile(); Assert.NotNull(iiopProf, "iiop ior profile not found"); Assert.AreEqual("dev1-sf", iiopProf.HostName, "wrong hostname"); Assert.AreEqual(8203, iiopProf.Port, "wrong port"); Assert.AreEqual(1, iiopProf.Version.Major, "wrong major"); Assert.AreEqual(2, iiopProf.Version.Minor, "wrong minor"); Assert.AreEqual(2, ior.Profiles.Length, "wrong number of profiles"); }
public void TestObjectToString() { OrbServices orbServices = OrbServices.GetSingleton(); string id = "myAdderId2"; Adder adder = m_testService.CreateNewWithUserID(id); string iorString = orbServices.object_to_string(adder); Ior adderIor = new Ior(iorString); IInternetIiopProfile prof = adderIor.FindInternetIiopProfile(); Assert.AreEqual(8087, prof.Port); Assert.AreEqual(1, prof.Version.Major); Assert.AreEqual(2, prof.Version.Minor); byte[] oid = { 0x6d, 0x79, 0x41, 0x64, 0x64, 0x65, 0x72, 0x49, 0x64, 0x32 }; CheckIorKey(oid, prof.ObjectKey); string testServiceIorString = m_testService.GetIorStringForThisObject(); Ior testServiceIor = new Ior(testServiceIorString); IInternetIiopProfile profSvcIor = testServiceIor.FindInternetIiopProfile(); Assert.AreEqual(8087, profSvcIor.Port); Assert.AreEqual(1, profSvcIor.Version.Major); Assert.AreEqual(2, profSvcIor.Version.Minor); byte[] oidTestService = { 0x74, 0x65, 0x73, 0x74 }; CheckIorKey(oidTestService, profSvcIor.ObjectKey); }
public void TestSystemIdForMbr() { Adder adder = m_testService.CreateNewWithSystemID(); string marshalUrl = RemotingServices.GetObjectUri(adder); Ior adderIor = new Ior(marshalUrl); IInternetIiopProfile prof = adderIor.FindInternetIiopProfile(); byte[] objectKey = prof.ObjectKey; ASCIIEncoding enc = new ASCIIEncoding(); string marshalUri = new String(enc.GetChars(objectKey)); if (marshalUri.StartsWith("/")) { marshalUri = marshalUri.Substring(1); } Assert.IsTrue(marshalUri.IndexOf("/") > 0, "no appdomain-guid"); string guid_string = marshalUri.Substring(0, marshalUri.IndexOf("/")); guid_string = guid_string.Replace("_", "-"); try { Guid guid = new Guid(guid_string); } catch (Exception ex) { Assert.Fail("guid not in uri: " + ex); } // check if callable int arg1 = 1; int arg2 = 2; Assert.AreEqual(arg1 + arg2, adder.Add(arg1, arg2), "wrong adder result"); }
public void TestUserIdForMbr() { string id = "myAdderId"; Adder adder = m_testService.CreateNewWithUserID(id); string marshalUrl = RemotingServices.GetObjectUri(adder); Ior adderIor = new Ior(marshalUrl); IInternetIiopProfile prof = adderIor.FindInternetIiopProfile(); byte[] objectKey = prof.ObjectKey; ASCIIEncoding enc = new ASCIIEncoding(); string marshalUri = new String(enc.GetChars(objectKey)); Assert.AreEqual(id, marshalUri, "wrong user id"); // check if callable int arg1 = 1; int arg2 = 2; Assert.AreEqual(arg1 + arg2, adder.Add(arg1, arg2), "wrong adder result"); }
private void CheckIorForUrl(Ior iorForUrl, int expectedNumberOfComponents, bool shouldHaveCodeSetComponent) { Assert.AreEqual(1, iorForUrl.Profiles.Length, "number of profiles"); Assert.AreEqual(typeof(MarshalByRefObject), iorForUrl.Type, "type"); IIorProfile profile = iorForUrl.FindInternetIiopProfile(); Assert.NotNull(profile, "internet iiop profile"); Assert.AreEqual( new byte[] { 116, 101, 115, 116 }, profile.ObjectKey, "profile object key"); Assert.AreEqual(new GiopVersion(1, 2), profile.Version, "profile giop version"); if (shouldHaveCodeSetComponent) { Assert.AreEqual( expectedNumberOfComponents, profile.TaggedComponents.Count, "number of components"); Assert.IsTrue(profile.ContainsTaggedComponent( CodeSetService.SERVICE_ID), "code set component present"); CodeSetComponentData data = (CodeSetComponentData) profile.TaggedComponents.GetComponentData(CodeSetService.SERVICE_ID, m_codec, CodeSetComponentData.TypeCode); Assert.AreEqual( (int)CharSet.LATIN1, data.NativeCharSet, "code set component: native char set"); Assert.AreEqual( (int)WCharSet.UTF16, data.NativeWCharSet, "code set component: native char set"); } else { Assert.IsTrue( !profile.ContainsTaggedComponent( CodeSetService.SERVICE_ID), "code set component present"); } }
/// <summary> /// This method parses an url for the IIOP channel. /// It extracts the channel URI and the objectURI /// </summary> /// <param name="url">the url to parse</param> /// <param name="objectURI">the objectURI</param> /// <returns>the channel-Uri</returns> internal Uri ParseUrl(string url, out string objectUri, out GiopVersion version) { Uri uri = null; if (url.StartsWith("iiop")) { IiopLoc iiopLoc = new IiopLoc(url, m_codec, m_defaultAdditionalTaggedComponents); uri = iiopLoc.ParseUrl(out objectUri, out version); } else if (url.StartsWith("IOR")) { Ior ior = new Ior(url); IInternetIiopProfile profile = ior.FindInternetIiopProfile(); if (profile != null) { uri = new Uri("iiop" + profile.Version.Major + "." + profile.Version.Minor + Uri.SchemeDelimiter + profile.HostName + ":" + profile.Port); objectUri = IorUtil.GetObjectUriForObjectKey(profile.ObjectKey); version = profile.Version; } else { uri = null; objectUri = null; version = new GiopVersion(1, 0); } } else if (url.StartsWith("corbaloc")) { Corbaloc loc = new Corbaloc(url, m_codec, m_defaultAdditionalTaggedComponents); uri = loc.ParseUrl(out objectUri, out version); } else { // not possible uri = null; objectUri = null; version = new GiopVersion(1, 0); } return uri; }