mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-20 03:11:21 +00:00
added test cases for single file websites
This commit is contained in:
parent
22dc3e55df
commit
b48b6b9d42
@ -98,6 +98,45 @@ public class ArbitraryServiceTests extends Common {
|
|||||||
assertEquals(ValidationResult.MISSING_INDEX_FILE, service.validate(path));
|
assertEquals(ValidationResult.MISSING_INDEX_FILE, service.validate(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testValidateWebsiteWithIndexFile() throws IOException {
|
||||||
|
// Generate some random data
|
||||||
|
byte[] data = new byte[1024];
|
||||||
|
new Random().nextBytes(data);
|
||||||
|
|
||||||
|
// Write the data to several files in a temp path
|
||||||
|
Path path = Files.createTempDirectory("testValidateWebsiteWithoutIndexFile");
|
||||||
|
path.toFile().deleteOnExit();
|
||||||
|
Files.write(Paths.get(path.toString(), "index.html"), data, StandardOpenOption.CREATE);
|
||||||
|
Files.write(Paths.get(path.toString(), "data1.html"), data, StandardOpenOption.CREATE);
|
||||||
|
Files.write(Paths.get(path.toString(), "data2"), data, StandardOpenOption.CREATE);
|
||||||
|
Files.write(Paths.get(path.toString(), "data3"), data, StandardOpenOption.CREATE);
|
||||||
|
|
||||||
|
Service service = Service.WEBSITE;
|
||||||
|
assertTrue(service.isValidationRequired());
|
||||||
|
|
||||||
|
// There is no index file in the root
|
||||||
|
assertEquals(ValidationResult.OK, service.validate(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testValidateWebsiteWithIndexFileOnly() throws IOException {
|
||||||
|
// Generate some random data
|
||||||
|
byte[] data = new byte[1024];
|
||||||
|
new Random().nextBytes(data);
|
||||||
|
|
||||||
|
// Write the data to several files in a temp path
|
||||||
|
Path path = Files.createTempDirectory("testValidateWebsiteWithoutIndexFile");
|
||||||
|
path.toFile().deleteOnExit();
|
||||||
|
Files.write(Paths.get(path.toString(), "index.html"), data, StandardOpenOption.CREATE);
|
||||||
|
|
||||||
|
Service service = Service.WEBSITE;
|
||||||
|
assertTrue(service.isValidationRequired());
|
||||||
|
|
||||||
|
// There is no index file in the root
|
||||||
|
assertEquals(ValidationResult.OK, service.validate(path));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateWebsiteWithoutIndexFileInRoot() throws IOException {
|
public void testValidateWebsiteWithoutIndexFileInRoot() throws IOException {
|
||||||
// Generate some random data
|
// Generate some random data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user