Search in sources :

Example 21 with Environment

use of org.xwiki.environment.Environment 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

Environment (org.xwiki.environment.Environment)21 File (java.io.File)15 Test (org.junit.Test)10 ServletEnvironment (org.xwiki.environment.internal.ServletEnvironment)6 Before (org.junit.Before)5 ComponentManager (org.xwiki.component.manager.ComponentManager)5 ServletContext (javax.servlet.ServletContext)4 Attachment (com.xpn.xwiki.api.Attachment)3 CoreConfiguration (com.xpn.xwiki.CoreConfiguration)2 XWikiContext (com.xpn.xwiki.XWikiContext)2 XWikiStubContextProvider (com.xpn.xwiki.util.XWikiStubContextProvider)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 MimeBodyPart (javax.mail.internet.MimeBodyPart)2 MimeMessage (javax.mail.internet.MimeMessage)2 Expectations (org.jmock.Expectations)2 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)2 WikiReference (org.xwiki.model.reference.WikiReference)2 XWiki (com.xpn.xwiki.XWiki)1