Ejemplo n.º 1
0
        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");
            }
        }
Ejemplo n.º 2
0
        public void TestOverrideCodeSetsWhenAlreadySet()
        {
            TaggedComponent defaultComponent =
                CodeSetService.CreateDefaultCodesetComponent(m_codec);
            CodeSetComponentData codeSetData = (CodeSetComponentData)
                                               m_codec.decode_value(defaultComponent.component_data,
                                                                    CodeSetComponentData.TypeCode);

            Assert.IsTrue(Enum.IsDefined(typeof(CharSet), codeSetData.NativeCharSet));
            Assert.IsTrue(Enum.IsDefined(typeof(WCharSet), codeSetData.NativeWCharSet));

            IOrbServices orbServices = OrbServices.GetSingleton();

            try
            {
                orbServices.OverrideDefaultCharSets(CharSet.UTF8, WCharSet.UTF16);
                Assert.Fail("expected bad_inv_order exception");
            }
            catch (BAD_INV_ORDER)
            {
                // expected, because already set
            }
        }
Ejemplo n.º 3
0
        public void TestAddTaggedComponent()
        {
            CodeSetComponentData codeSetCompVal =
                new CodeSetComponentData((int)CharSet.LATIN1,
                                         new int[] { (int)CharSet.LATIN1 },
                                         (int)WCharSet.UTF16,
                                         new int[] { (int)WCharSet.UTF16 });
            TaggedComponent codeSetComponent =
                new TaggedComponent(TAG_CODE_SETS.ConstVal,
                                    m_codec.encode_value(codeSetCompVal));

            m_profile.AddTaggedComponent(codeSetComponent);
            Assert.AreEqual(1, m_profile.TaggedComponents.Count, "tagged components one entry");
            Assert.IsTrue(m_profile.ContainsTaggedComponent(TAG_CODE_SETS.ConstVal), "not found code set component");
            CodeSetComponentData retrieved =
                (CodeSetComponentData)m_profile.TaggedComponents.GetComponentData(TAG_CODE_SETS.ConstVal,
                                                                                  m_codec,
                                                                                  CodeSetComponentData.TypeCode);

            Assert.NotNull(retrieved, "not found code set component");
            Assert.AreEqual(codeSetCompVal.NativeCharSet, retrieved.NativeCharSet, "char set");
            Assert.AreEqual(codeSetCompVal.NativeWCharSet, retrieved.NativeWCharSet, "wchar set");
        }