You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ie...@apache.org on 2010/06/02 22:06:37 UTC
svn commit: r950746 - in /sling/trunk/launchpad/integration-tests/src/main:
java/org/apache/sling/launchpad/webapp/integrationtest/UploadFileTest.java
resources/integration-test/file-to-upload.txt
Author: ieb
Date: Wed Jun 2 20:06:37 2010
New Revision: 950746
URL: http://svn.apache.org/viewvc?rev=950746&view=rev
Log:
SLING-1495 Fixed issues with UploaderFileTest that was directly accessing the src folder.
Removed:
sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/file-to-upload.txt
Modified:
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/UploadFileTest.java
Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/UploadFileTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/UploadFileTest.java?rev=950746&r1=950745&r2=950746&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/UploadFileTest.java (original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/UploadFileTest.java Wed Jun 2 20:06:37 2010
@@ -16,19 +16,32 @@
*/
package org.apache.sling.launchpad.webapp.integrationtest;
-import java.io.File;
-import java.io.IOException;
-
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.sling.commons.testing.integration.HttpTestBase;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
/**
* Test uploading files using the Sling post servlet (SLING-168)
*/
public class UploadFileTest extends HttpTestBase {
- private static final String TEST_FILE = "src/test/resources/integration-test/file-to-upload.txt";
+
+ private static final String UPLOAD_CONTENT = "This file is used by UploadFileTest.java.\n" +
+ "\n" +
+ "It must contain http://www.apache.org/licenses/LICENSE-2.0 for tests.\n" +
+ "\n" +
+ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce semper ipsum et lorem. In hac habitasse \n" +
+ "platea dictumst. Donec dictum tincidunt purus. Aenean quis nunc. Aliquam rhoncus. Proin sed risus. \n" +
+ "Maecenas porta arcu in nisi. Pellentesque quis sapien quis lectus vehicula aliquet. Cras ornare elit \n" +
+ "eget massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed \n" +
+ "ut justo. Integer porttitor quam. Aliquam aliquet. Nulla interdum arcu vitae nibh. Morbi dapibus odio \n" +
+ "a sem. Integer dictum. Praesent vel eros nec ipsum venenatis malesuada. Vestibulum rutrum mi ac ligula. \n" +
+ "Ut nisl ligula, vehicula dignissim, accumsan quis, faucibus sed, sapien. Quisque purus tellus, euismod \n" +
+ "id, auctor quis, rutrum non, augue.\n";
public void testDistinctResource() throws IOException {
String folderPath = "/UploadFileTest_1_" + System.currentTimeMillis();
@@ -43,7 +56,7 @@ public class UploadFileTest extends Http
}
// upload local file
- File localFile = new File(TEST_FILE);
+ File localFile = getTestFile();
testClient.uploadToFileNode(urlOfNewNode, localFile, "./file", null);
// get and check URL of created file
@@ -69,6 +82,7 @@ public class UploadFileTest extends Http
}
+
public void testDistinctResourceWithType() throws IOException {
String folderPath = "/UploadFileTest_1_" + System.currentTimeMillis();
final String url = HTTP_BASE_URL + folderPath;
@@ -82,7 +96,7 @@ public class UploadFileTest extends Http
}
// upload local file
- File localFile = new File(TEST_FILE);
+ File localFile = getTestFile();
testClient.uploadToFileNode(urlOfNewNode, localFile, "./file", "nt:unstructured");
// get and check URL of created file
@@ -115,7 +129,7 @@ public class UploadFileTest extends Http
// upload local file
- File localFile = new File(TEST_FILE);
+ File localFile = getTestFile();
testClient.uploadToFileNode(url, localFile, "./file", null);
// get and check URL of created file
@@ -160,12 +174,12 @@ public class UploadFileTest extends Http
} catch(IOException ioe) {
fail("createNode failed: " + ioe);
}
-
// upload local file
+ File tempFile = getTestFile();
File [] localFiles = new File[] {
- new File(TEST_FILE),
- new File(TEST_FILE),
- new File(TEST_FILE)
+ tempFile,
+ tempFile,
+ tempFile
};
String [] fieldNames = new String [] {
"./file1.txt",
@@ -212,4 +226,19 @@ public class UploadFileTest extends Http
assertTrue("checking primary type", content_json.contains("\"jcr:primaryType\":\"nt:resource\""));
assertTrue("checking mime type", content_json.contains("\"jcr:mimeType\":\"text/plain\""));
}
+
+ /**
+ * @return
+ * @throws IOException
+ */
+ private File getTestFile() throws IOException {
+ File tempFile = new File("target/file-to-upload.txt");
+ if ( !tempFile.exists() || tempFile.length() == 0 ) {
+ FileWriter out = new FileWriter(tempFile);
+ out.write(UPLOAD_CONTENT); // we do rather than from a resource since surefire has fun with classloaders.
+ out.close();
+ }
+ return tempFile;
+ }
+
}
\ No newline at end of file