Example #1
0
        public void TestDeployImports()
        {
            var module = MakeModule("com.testit", "create schema S1 as SupportBean", "@Name('A') select SupportStaticMethodLib.PlusOne(IntPrimitive) as val from S1");

            module.Imports.Add(typeof(SupportBean).FullName);
            module.Imports.Add(typeof(SupportStaticMethodLib).Namespace);
            Assert.IsFalse(_deploymentAdmin.IsDeployed("com.testit"));
            _deploymentAdmin.Deploy(module, null);
            Assert.IsTrue(_deploymentAdmin.IsDeployed("com.testit"));
            _epService.EPAdministrator.GetStatement("A").Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 4));
            Assert.AreEqual(5, _listener.AssertOneGetNewAndReset().Get("val"));
        }
Example #2
0
        public void TestOrder()
        {
            Module          moduleA = null;
            Module          moduleB = null;
            Module          moduleC = null;
            Module          moduleD = null;
            Module          moduleE = null;
            DeploymentOrder order   = null;

            // Tree of 4 deep
            moduleA = GetModule("A");
            moduleB = GetModule("B", "A");
            moduleC = GetModule("C", "A", "B", "D");
            moduleD = GetModule("D", "A", "B");
            order   = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleC, moduleD, moduleB, moduleA }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleA, moduleB, moduleD, moduleC }, order);

            // Zero items
            order = _deploymentAdmin.GetDeploymentOrder(new Module[] {}, new DeploymentOrderOptions());
            AssertOrder(new Module[] {}, order);

            // 1 item
            moduleA = GetModule("A");
            order   = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleA }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleA }, order);

            // 2 item
            moduleA = GetModule("A", "B");
            moduleB = GetModule("B");
            order   = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleB, moduleA }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleB, moduleA }, order);

            // 3 item
            moduleB = GetModule("B");
            moduleC = GetModule("C", "B");
            moduleD = GetModule("D");
            order   = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleB, moduleC, moduleD }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleB, moduleC, moduleD }, order);
            order = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleD, moduleC, moduleB }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleB, moduleD, moduleC }, order);

            // 2 trees of 2 deep
            moduleA = GetModule("A", "B");
            moduleB = GetModule("B");
            moduleC = GetModule("C", "D");
            moduleD = GetModule("D");
            order   = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleC, moduleB, moduleA, moduleD }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleB, moduleD, moduleC, moduleA }, order);

            // Tree of 5 deep
            moduleA = GetModule("A", "C");
            moduleB = GetModule("B");
            moduleC = GetModule("C", "B");
            moduleD = GetModule("D", "C", "E");
            moduleE = GetModule("E");
            order   = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleA, moduleB, moduleC, moduleD, moduleE }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleB, moduleC, moduleE, moduleA, moduleD }, order);
            order = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleB, moduleE, moduleC, moduleA, moduleD }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleB, moduleE, moduleC, moduleA, moduleD }, order);
            order = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleA, moduleD, moduleE, moduleC, moduleB }, new DeploymentOrderOptions());
            AssertOrder(new Module[] { moduleB, moduleE, moduleC, moduleA, moduleD }, order);

            // Tree with null names
            moduleA = GetModule(null, "C", "A", "B", "D");
            moduleB = GetModule(null, "C");
            moduleC = GetModule("A");
            moduleD = GetModule("B", "A", "C");
            moduleE = GetModule("C");
            DeploymentOrderOptions options = new DeploymentOrderOptions();

            options.IsCheckUses = false;
            order = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleA, moduleB, moduleC, moduleD, moduleE }, options);
            AssertOrder(new Module[] { moduleC, moduleE, moduleD, moduleA, moduleB }, order);
            Assert.IsFalse(_deploymentAdmin.IsDeployed("C"));

            // Tree with duplicate names
            moduleA = GetModule("A", "C");
            moduleB = GetModule("B", "C");
            moduleC = GetModule("A", "B");
            moduleD = GetModule("D", "A");
            moduleE = GetModule("C");
            order   = _deploymentAdmin.GetDeploymentOrder(new Module[] { moduleA, moduleB, moduleC, moduleD, moduleE }, options);
            AssertOrder(new Module[] { moduleE, moduleB, moduleA, moduleC, moduleD }, order);
        }