Exemplo n.º 1
0
        public virtual void testSetJavaOjectSerialized()
        {
            var instance = runtimeService.StartProcessInstanceByKey("oneTaskProcess");

            var javaSerializable = new JavaSerializable("foo");


            var baos = new MemoryStream(Encoding.UTF8.GetBytes(javaSerializable.Property));
            // baos.WriteTo(javaSerializable);//ObjectOutputStream
            //  (new ObjectOutputStream(baos.GetBuffer(),FileMode.OpenOrCreate)).WriteObject(javaSerializable);
            var serializedObject = StringUtil.FromBytes(Base64.EncodeBase64(baos.GetBuffer()), processEngine);

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method:
            runtimeService.SetVariable(instance.Id, "simpleBean",
                                       ESS.FW.Bpm.Engine.Variable.Variables.SerializedObjectValue(serializedObject)
                                       .SerializationDataFormat(JAVA_DATA_FORMAT)
                                       // .objectTypeName(typeof(JavaSerializable).FullName).Create());
                                       .GetType()
                                       .Assembly);

            var value = (JavaSerializable)runtimeService.GetVariable(instance.Id, "simpleBean");

            Assert.AreEqual(javaSerializable, value);

            // validate typed value
            var typedValue = runtimeService.GetVariableTyped <IObjectValue>(instance.Id, "simpleBean");

            TypedValueAssert.AssertObjectValueDeserialized(typedValue, javaSerializable);
            //ObjectValueSerializedJava(typedValue, javaSerializable);
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            JavaSerializable other = (JavaSerializable)obj;

            if (string.ReferenceEquals(property, null))
            {
                if (!string.ReferenceEquals(other.property, null))
                {
                    return(false);
                }
            }
            else if (!property.Equals(other.property))
            {
                return(false);
            }
            return(true);
        }
        public virtual void Execute(IBaseDelegateExecution Execution)
        {
            JavaSerializable dataObject = (JavaSerializable)Execution.GetVariable("varName");

            Assert.NotNull(dataObject);
            Assert.AreEqual("foo", dataObject.Property);
        }
Exemplo n.º 4
0
        public virtual void testSerializationAsJava()
        {
            var instance = runtimeService.StartProcessInstanceByKey("oneTaskProcess");

            var javaSerializable = new JavaSerializable("foo");

            runtimeService.SetVariable(instance.Id, "simpleBean", ESS.FW.Bpm.Engine.Variable.Variables.ObjectValue(javaSerializable)
                                       .SerializationDataFormat(JAVA_DATA_FORMAT)
                                       .Create());

            // validate untyped value
            var value = (JavaSerializable)runtimeService.GetVariable(instance.Id, "simpleBean");

            Assert.AreEqual(javaSerializable, value);

            // validate typed value
            var typedValue = runtimeService.GetVariableTyped <IObjectValue>(instance.Id, "simpleBean");

            TypedValueAssert.AssertObjectValueDeserialized(typedValue, javaSerializable);
            TypedValueAssert.AssertObjectValueSerializedJava(typedValue, javaSerializable);
        }
Exemplo n.º 5
0
        public virtual void testSetUntypedNullForExistingVariable()
        {
            var instance = runtimeService.StartProcessInstanceByKey("oneTaskProcess");

            // initially the variable has a value
            var javaSerializable = new JavaSerializable("foo");

            runtimeService.SetVariable(instance.Id, "varName", ESS.FW.Bpm.Engine.Variable.Variables.ObjectValue(javaSerializable)
                                       .SerializationDataFormat(JAVA_DATA_FORMAT)
                                       .Create());

            // get value via untyped api
            Assert.AreEqual(javaSerializable, runtimeService.GetVariable(instance.Id, "varName"));

            // set the variable to null via untyped Api
            runtimeService.SetVariable(instance.Id, "varName", null);

            // variable is now untyped null
            var nullValue = runtimeService.GetVariableTyped <ITypedValue>(instance.Id, "varName");

            TypedValueAssert.AssertUntypedNullValue(nullValue);
        }
Exemplo n.º 6
0
        public virtual void testJavaObjectDeserializedInFirstCommand()
        {
            // this test makes sure that if a serialized value is set, it can be deserialized in the same command in which it is set.

            // given
            // a serialized Java Object
            var javaSerializable = new JavaSerializable("foo");
            var baos             = new MemoryStream();
            //(new ObjectOutputStream(baos)).WriteObject(javaSerializable);
            var serializedObject = StringUtil.FromBytes(Base64.EncodeBase64(baos.GetBuffer()), processEngine);

            // if
            // I start a process instance in which a Java Delegate reads the value in its deserialized form
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.GetName method:
            runtimeService.StartProcessInstanceByKey("oneTaskProcess", ESS.FW.Bpm.Engine.Variable.Variables.CreateVariables()
                                                     .PutValue("varName", ESS.FW.Bpm.Engine.Variable.Variables.SerializedObjectValue(serializedObject)
                                                               .SerializationDataFormat(JAVA_DATA_FORMAT)
                                                               //.objectTypeName(typeof(JavaSerializable).FullName).Create()));
                                                               .GetType()
                                                               .Assembly));
            // then
            // it does not Assert.Fail
        }