Author: dkatayev
Date: 2010-06-22 05:24:30 -0400 (Tue, 22 Jun 2010)
New Revision: 2677
Removed:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java
Log:
EXOJCR-774 If-Modified-Since management fixed
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java
===================================================================
---
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java 2010-06-22
09:23:36 UTC (rev 2676)
+++
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavConst.java 2010-06-22
09:24:30 UTC (rev 2677)
@@ -464,6 +464,11 @@
* Last modification date psttern.
*/
public static final String MODIFICATION = "EEE, dd MMM yyyy HH:mm:ss z";
+
+ /**
+ * If-Modified-Since date psttern.
+ */
+ public static final String IF_MODIFIED_SINCE_PATTERN = "EEE, d MMM yyyy
HH:mm:ss z";
}
/**
Deleted:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java
===================================================================
---
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java 2010-06-22
09:23:36 UTC (rev 2676)
+++
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCashing.java 2010-06-22
09:24:30 UTC (rev 2677)
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.webdav.ext;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MultivaluedMap;
-
-import org.exoplatform.common.http.HTTPStatus;
-import org.exoplatform.services.jcr.webdav.BaseStandaloneTest;
-import org.exoplatform.services.jcr.webdav.WebDavConstants.WebDAVMethods;
-import org.exoplatform.services.jcr.webdav.utils.TestUtils;
-import org.exoplatform.services.rest.ExtHttpHeaders;
-import org.exoplatform.services.rest.impl.ContainerResponse;
-import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
-
-/**
- * Created by The eXo Platform SAS Author : Dmytro Katayev
- * work.visor.ck(a)gmail.com Aug 13, 2008
- */
-public class TestCashing extends BaseStandaloneTest
-{
- private String path = TestUtils.getFileName();
-
- private String fileContent = TestUtils.getFileContent();
-
- private Node node;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- InputStream inputStream = new ByteArrayInputStream(fileContent.getBytes());
- node = TestUtils.addContent(session, path, inputStream, defaultFileNodeType,
"");
- }
-
- public void testIfModifiedSince() throws Exception
- {
- Node contentNode = node.getNode("jcr:content");
- Property lastModifiedProperty =
contentNode.getProperty("jcr:lastModified");
- String formatPattern = "EEE, dd MMM yyyy HH:mm:ss z";
- SimpleDateFormat dateFormat = new SimpleDateFormat(formatPattern, Locale.ENGLISH);
- dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
- String lastModified = dateFormat.format(lastModifiedProperty.getDate().getTime());
- MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.add(ExtHttpHeaders.IF_MODIFIED_SINCE, lastModified);
- ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path,
"", headers, null);
- assertEquals(HTTPStatus.NOT_MODIFIED, response.getStatus());
- }
-
- public void testCacheConf() throws Exception
- {
- ArrayList<CacheControlType> testValues = new
ArrayList<CacheControlType>();
- testValues.add(new CacheControlType("text/xml",
"max-age=1800"));
- testValues.add(new CacheControlType("text/pdf",
"max-age=777"));
- testValues.add(new CacheControlType("image/jpg",
"max-age=3600"));
- testValues.add(new CacheControlType("image/gif",
"max-age=555"));
- testValues.add(new CacheControlType("test/test", "no-cache"));
- testValues.add(new CacheControlType("*/*", "no-cache"));
-
- Node contentNode = node.getNode("jcr:content");
-
- for (CacheControlType cacheControlType : testValues)
- {
- contentNode.setProperty("jcr:mimeType",
cacheControlType.getContentType());
- contentNode.getSession().save();
- ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path,
"", null, null);
- String cacheControlHeader =
response.getHttpHeaders().get(HttpHeaders.CACHE_CONTROL).toString();
- cacheControlHeader = cacheControlHeader.substring(1, cacheControlHeader.length()
- 1);
- assertEquals(cacheControlHeader, cacheControlType.getCacheValue());
- }
- }
-
- @Override
- protected String getRepositoryName()
- {
- return null;
- }
-
-}