@Test
    public void testJoinWindowWithSameWindow() throws InterruptedException {
        log.info("Test join window with the same window");

        SiddhiManager siddhiManager = new SiddhiManager();
        String streams = "" +
                "define stream cseEventStream (symbol string, price float, volume int); " +
                "define window cseEventWindow (symbol string, price float, volume int) length(2); ";
        String query = "" +
                "@info(name = 'query0') " +
                "from cseEventStream " +
                "insert into " +
                "cseEventWindow; " +
                "" +
                "@info(name = 'query1') " +
                "from cseEventWindow as a " +
                "join cseEventWindow as b " +
                "on a.symbol== b.symbol " +
                "select a.symbol as symbol, a.price as priceA, b.price as priceB " +
                "insert all events into outputStream ;";

        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
        try {
            siddhiAppRuntime.addCallback("query1", new QueryCallback() {
                @Override
                public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timestamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        inEventCount += inEvents.length;
                    }
                    if (removeEvents != null) {
                        removeEventCount += removeEvents.length;
                    }
                    eventArrived = true;
                }
            });

            InputHandler cseEventStreamHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
            siddhiAppRuntime.start();
            cseEventStreamHandler.send(new Object[]{"IBM", 75.6f, 100});    // Match with itself
            cseEventStreamHandler.send(new Object[]{"WSO2", 57.6f, 100});   // Match with itself
            // When the next event enters, the expired {"IBM", 75.6f, 100} will come out and joined
            // with the window which contains [{"WSO2", 57.6f, 100}, {"IBM", 59.6f, 100}] and latter the
            // current event {"IBM", 59.6f, 100} will match with the window.
            cseEventStreamHandler.send(new Object[]{"IBM", 59.6f, 100});
            Thread.sleep(1000);
            AssertJUnit.assertEquals(3, inEventCount);
            AssertJUnit.assertEquals(1, removeEventCount);
            AssertJUnit.assertTrue(eventArrived);
        } finally {
            siddhiAppRuntime.shutdown();
        }
    }
Behaviour of traditional Window and Window are different in join  with themselves.
Traditional Windows joins always maintain two windows and the event is passed to them one after
the other. Therefore, when left window receives a current event right window will bbe empty and
if an event is expired from left window it can join with right window since it will not expire at the same
time. Since Window maintains only one instance, when an event arrives to the window it will
be compared to the internal event chunk, where the current event will match with itself.
When an event expires, it will be immediately removed from the internal event chunk so that,
when joined with the window, the expired event will not match with itself.

@throws InterruptedException throw exception if interrupted the input handler sender.
modules/siddhi-core/src/test/java/io/siddhi/core/window/CustomJoinWindowTestCase.java