Search in sources :

Example 11 with ServletEnvironment

use of org.xwiki.environment.internal.ServletEnvironment in project xwiki-platform by xwiki.

the class AbstractFilesystemAttachmentStoreTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    Utils.setComponentManager(this.getComponentManager());
    final ServletEnvironment environment = (ServletEnvironment) this.getComponentManager().getInstance(Environment.class);
    final ServletContext mockServletContext = this.getMockery().mock(ServletContext.class);
    environment.setServletContext(mockServletContext);
    this.getMockery().checking(new Expectations() {

        {
            allowing(mockServletContext).getAttribute("javax.servlet.context.tempdir");
            will(returnValue(new File(System.getProperty("java.io.tmpdir"))));
            allowing(mockServletContext).getResource("/WEB-INF/xwiki.properties");
            will(returnValue(null));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) ServletEnvironment(org.xwiki.environment.internal.ServletEnvironment) Environment(org.xwiki.environment.Environment) ServletContext(javax.servlet.ServletContext) ServletEnvironment(org.xwiki.environment.internal.ServletEnvironment) File(java.io.File) Before(org.junit.Before)

Aggregations

ServletEnvironment (org.xwiki.environment.internal.ServletEnvironment)11 ServletContext (javax.servlet.ServletContext)8 Environment (org.xwiki.environment.Environment)5 File (java.io.File)4 Test (org.junit.Test)4 XWikiContext (com.xpn.xwiki.XWikiContext)3 XWikiStubContextProvider (com.xpn.xwiki.util.XWikiStubContextProvider)3 ComponentManager (org.xwiki.component.manager.ComponentManager)3 Execution (org.xwiki.context.Execution)3 CoreConfiguration (com.xpn.xwiki.CoreConfiguration)2 Date (java.util.Date)2 Expectations (org.jmock.Expectations)2 Before (org.junit.Before)2 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)2 ExtendedURL (org.xwiki.url.ExtendedURL)2 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)2 XWiki (com.xpn.xwiki.XWiki)1 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 XWikiCfgConfigurationSource (com.xpn.xwiki.internal.XWikiCfgConfigurationSource)1