@Before public void before() throws IOException, JDOMException { factory = fixture.getFactory(); fixture.initSystemData(); StringBuffer standardConfigXml = new StringBuffer(); standardConfigXml.append("<config name=\"MyContentType\" version=\"1.0\">"); standardConfigXml.append(" <form>"); standardConfigXml.append(" <title name=\"myTitle\"/>"); standardConfigXml.append(" <block name=\"TestBlock1\">"); standardConfigXml.append( " <input name=\"myTitle\" required=\"true\" type=\"text\">"); standardConfigXml.append(" <display>My title</display>"); standardConfigXml.append(" <xpath>contentdata/mytitle</xpath>"); standardConfigXml.append(" </input>"); standardConfigXml.append(" <input name=\"myBinaryfile\" type=\"uploadfile\">"); standardConfigXml.append(" <display>My binaryfile</display>"); standardConfigXml.append(" <xpath>contentdata/mybinaryfile</xpath>"); standardConfigXml.append(" </input>"); standardConfigXml.append(" </block>"); standardConfigXml.append(" </form>"); standardConfigXml.append("</config>"); standardConfig = XMLDocumentFactory.create(standardConfigXml.toString()).getAsJDOMDocument(); MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteAddr("127.0.0.1"); ServletRequestAccessor.setRequest(request); }
@Before public void before() { factory = fixture.getFactory(); fixture.initSystemData(); fixture.createAndStoreUserAndUserGroup( "testuser", "testuser fullname", UserType.NORMAL, "testuserstore"); ServletRequestAttributes servletRequestAttributes = new ServletRequestAttributes(httpServletRequest); RequestContextHolder.setRequestAttributes(servletRequestAttributes); httpServletRequest.setCharacterEncoding("UTF-8"); ServletRequestAccessor.setRequest(httpServletRequest); loginUserInAdmin(fixture.findUserByName("testuser").getKey()); loginUserInPortal(fixture.findUserByName("testuser").getKey()); imageController.setGroupDao(groupDao); imageController.setContentDao(contentDao); imageController.setSecurityService(securityService); imageController.setImageService(imageService); imageController.setDisableParamEncoding(true); previewService = Mockito.mock(PreviewService.class); Mockito.when(previewService.isInPreview()).thenReturn(false); Mockito.when(previewService.getPreviewContext()).thenReturn(PreviewContext.NO_PREVIEW); site1 = factory.createSite("MySite", new Date(), null, "en"); fixture.save(site1); MenuItemEntity firstPage = createPage("Firstpage", null, "MySite"); fixture.save(firstPage); site1.setFirstPage(firstPage); fixture.flushAndClearHibernateSesssion(); fixture.save( factory.createContentHandler( "Image content", ContentHandlerName.IMAGE.getHandlerClassShortName())); fixture.save( factory.createContentType( "ImageContentType", ContentHandlerName.IMAGE.getHandlerClassShortName())); fixture.save(factory.createUnit("ImageUnit")); fixture.save( factory.createCategory( "ImageCategory", "ImageContentType", "ImageUnit", "testuser", "testuser")); fixture.save( factory.createCategoryAccessForUser("ImageCategory", "testuser", "read, create, approve")); fixture.flushAndClearHibernateSesssion(); }
@Before public void before() throws IOException, JDOMException { factory = fixture.getFactory(); fixture.initSystemData(); MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteAddr("127.0.0.1"); ServletRequestAccessor.setRequest(request); createContentTypeXml(); saveNeededEntities(); UserEntity runningUser = fixture.findUserByName("testuser"); PortalSecurityHolder.setImpersonatedUser(runningUser.getKey()); createUpdateContent(); createUpdateContentWithBinary(); }
@Before public void setUp() { factory = fixture.getFactory(); // setup needed common data for each test fixture.initSystemData(); fixture.save( factory.createContentHandler( "Custom content", ContentHandlerName.CUSTOM.getHandlerClassShortName())); MockHttpServletRequest httpRequest = new MockHttpServletRequest("GET", "/"); ServletRequestAccessor.setRequest(httpRequest); dataSourceService = new DataSourceServiceImpl(); dataSourceService.setContentService(contentService); dataSourceService.setTimeService(new MockTimeService(new DateTime(2010, 7, 1, 12, 0, 0, 0))); dataSourceService.setUserDao(userDao); fixture.createAndStoreNormalUserWithUserGroup("content-creator", "Creator", "testuserstore"); fixture.createAndStoreNormalUserWithUserGroup("content-querier", "Querier", "testuserstore"); // setup content type ContentTypeConfigBuilder ctyconf = new ContentTypeConfigBuilder("MyContent", "title"); ctyconf.startBlock("MyContent"); ctyconf.addInput("title", "text", "contentdata/title", "Title", true); ctyconf.addRelatedContentInput( "myRelatedContent", "contentdata/myRelatedContent", "My related content", false, true); ctyconf.endBlock(); Document configAsXmlBytes = XMLDocumentFactory.create(ctyconf.toString()).getAsJDOMDocument(); fixture.save( factory.createContentType( "MyRelatedType", ContentHandlerName.CUSTOM.getHandlerClassShortName(), configAsXmlBytes)); fixture.save(factory.createUnit("MyUnit", "en")); fixture.save( factory.createCategory( "MyCategory", null, "MyRelatedType", "MyUnit", User.ANONYMOUS_UID, User.ANONYMOUS_UID, false)); fixture.save( factory.createCategory( "MyOtherCategory", null, "MyRelatedType", "MyUnit", User.ANONYMOUS_UID, User.ANONYMOUS_UID, false)); fixture.save( factory.createCategoryAccessForUser( "MyCategory", "content-creator", "read, create, approve, admin_browse")); fixture.save( factory.createCategoryAccessForUser("MyCategory", "content-querier", "read, admin_browse")); fixture.save( factory.createCategoryAccessForUser( "MyOtherCategory", "content-creator", "read, create, approve, admin_browse")); fixture.save( factory.createCategoryAccessForUser( "MyOtherCategory", "content-querier", "read, admin_browse")); fixture.flushAndClearHibernateSession(); fixture.flushIndexTransaction(); }
@Before public void before() throws IOException, JDOMException { factory = fixture.getFactory(); fixture.initSystemData(); StringBuffer configXml = new StringBuffer(); configXml.append("<config name=\"MyContentType\" version=\"1.0\">"); configXml.append(" <form>"); configXml.append(" <title name=\"myTitle\"/>"); configXml.append(" <block name=\"General\">"); configXml.append(" <input name=\"myTitle\" required=\"true\" type=\"text\">"); configXml.append(" <display>My title</display>"); configXml.append(" <xpath>contentdata/mytitle</xpath>"); configXml.append(" </input>"); configXml.append(" </block>"); configXml.append(" <block name=\"Related content\">"); configXml.append( " <input name=\"myMultipleRelatedContent\" type=\"relatedcontent\" multiple=\"true\">"); configXml.append(" <display>My related content</display>"); configXml.append(" <xpath>contentdata/myrelatedcontents</xpath>"); configXml.append(" </input>"); configXml.append( " <input name=\"mySoleRelatedContent\" type=\"relatedcontent\" multiple=\"false\">"); configXml.append(" <display>My sole related content</display>"); configXml.append(" <xpath>contentdata/mysolerelatedcontent</xpath>"); configXml.append(" <contenttype name=\"MyContentType\"/>"); configXml.append(" </input>"); configXml.append(" </block>"); configXml.append(" </form>"); configXml.append("</config>"); configEl = JDOMUtil.parseDocument(configXml.toString()).getRootElement(); config = XMLDocumentFactory.create(configXml.toString()).getAsJDOMDocument(); fixture.createAndStoreNormalUserWithUserGroup("testuser", "testuser fullname", "testuserstore"); hibernateTemplate.save( factory.createContentHandler( "Custom content", ContentHandlerName.CUSTOM.getHandlerClassShortName())); hibernateTemplate.save( factory.createContentType( "MyContentType", ContentHandlerName.CUSTOM.getHandlerClassShortName(), config)); hibernateTemplate.save(factory.createUnit("MyUnit")); hibernateTemplate.save( factory.createCategory( "MyCategory", null, "MyContentType", "MyUnit", "testuser", "testuser")); hibernateTemplate.save( factory.createCategoryAccess( "MyCategory", fixture.findUserByName("testuser"), "read, create, approve")); hibernateTemplate.flush(); hibernateTemplate.clear(); MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteAddr("127.0.0.1"); ServletRequestAccessor.setRequest(request); }