entityMock.expects(new AnyArgumentsMatcher()).method("getPortletWindowList").withNoArguments().will(new ReturnStub(windowList));
windowListMock.expects(new AnyArgumentsMatcher()).method("add").withAnyArguments().will(new VoidStub());
portletApplicationMock.expects(new AnyArgumentsMatcher()).method("getId").withNoArguments().will(new ReturnStub(new JetspeedLongObjectID(1)));
portletDefinitionMock.expects(new AnyArgumentsMatcher()).method("getPortletApplicationDefinition").withNoArguments().will(new ReturnStub(portletApplicationMock.proxy()));
entityMock.expects(new AnyArgumentsMatcher()).method("getPortletDefinition").withNoArguments().will(new ReturnStub(portletDefinitionMock.proxy()));
PortletWindowAccessor accessor = (PortletWindowAccessor) engine.getComponentManager().getComponent(PortletWindowAccessor.class);
accessor.createPortletWindow((PortletEntity)entityMock.proxy(), "111");
accessor.createPortletWindow((PortletEntity)entityMock.proxy(), "222");
accessor.createPortletWindow((PortletEntity)entityMock.proxy(), "333");
// register mocked PortletApplication in PortletFactory so the PortletWindowAccessor check for it won't break the tests
PortletFactory portletFactory = (PortletFactory)engine.getComponentManager().getComponent("portletFactory");
portletFactory.registerPortletApplication((PortletApplication)portletApplicationMock.proxy(),Thread.currentThread().getContextClassLoader());