mirror of
https://github.com/Qortal/qortal.git
synced 2025-02-12 10:15:49 +00:00
Removed QORTAL_METADATA service tests.
This commit is contained in:
parent
4043ae1928
commit
0628847d14
@ -101,78 +101,4 @@ public class ArbitraryServiceTests extends Common {
|
||||
assertEquals(ValidationResult.MISSING_INDEX_FILE, service.validate(path));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidQortalMetadata() throws IOException {
|
||||
// Metadata is to describe an arbitrary resource (title, description, tags, etc)
|
||||
String dataString = "{\"title\":\"Test Title\", \"description\":\"Test description\", \"tags\":[\"test\"]}";
|
||||
|
||||
// Write to temp path
|
||||
Path path = Files.createTempFile("testValidQortalMetadata", null);
|
||||
path.toFile().deleteOnExit();
|
||||
Files.write(path, dataString.getBytes(), StandardOpenOption.CREATE);
|
||||
|
||||
Service service = Service.QORTAL_METADATA;
|
||||
assertTrue(service.isValidationRequired());
|
||||
assertEquals(ValidationResult.OK, service.validate(path));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQortalMetadataMissingKeys() throws IOException {
|
||||
// Metadata is to describe an arbitrary resource (title, description, tags, etc)
|
||||
String dataString = "{\"description\":\"Test description\", \"tags\":[\"test\"]}";
|
||||
|
||||
// Write to temp path
|
||||
Path path = Files.createTempFile("testQortalMetadataMissingKeys", null);
|
||||
path.toFile().deleteOnExit();
|
||||
Files.write(path, dataString.getBytes(), StandardOpenOption.CREATE);
|
||||
|
||||
Service service = Service.QORTAL_METADATA;
|
||||
assertTrue(service.isValidationRequired());
|
||||
assertEquals(ValidationResult.MISSING_KEYS, service.validate(path));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQortalMetadataTooLarge() throws IOException {
|
||||
// Metadata is to describe an arbitrary resource (title, description, tags, etc)
|
||||
String dataString = "{\"title\":\"Test Title\", \"description\":\"Test description\", \"tags\":[\"test\"]}";
|
||||
|
||||
// Generate some large data to go along with it
|
||||
int largeDataSize = 11*1024; // Larger than allowed 10kiB
|
||||
byte[] largeData = new byte[largeDataSize];
|
||||
new Random().nextBytes(largeData);
|
||||
|
||||
// Write to temp path
|
||||
Path path = Files.createTempDirectory("testQortalMetadataTooLarge");
|
||||
path.toFile().deleteOnExit();
|
||||
Files.write(Paths.get(path.toString(), "data"), dataString.getBytes(), StandardOpenOption.CREATE);
|
||||
Files.write(Paths.get(path.toString(), "large_data"), largeData, StandardOpenOption.CREATE);
|
||||
|
||||
Service service = Service.QORTAL_METADATA;
|
||||
assertTrue(service.isValidationRequired());
|
||||
assertEquals(ValidationResult.EXCEEDS_SIZE_LIMIT, service.validate(path));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleFileMetadata() throws IOException {
|
||||
// Metadata is to describe an arbitrary resource (title, description, tags, etc)
|
||||
String dataString = "{\"title\":\"Test Title\", \"description\":\"Test description\", \"tags\":[\"test\"]}";
|
||||
|
||||
// Generate some large data to go along with it
|
||||
int otherDataSize = 1024; // Smaller than 10kiB limit
|
||||
byte[] otherData = new byte[otherDataSize];
|
||||
new Random().nextBytes(otherData);
|
||||
|
||||
// Write to temp path
|
||||
Path path = Files.createTempDirectory("testMultipleFileMetadata");
|
||||
path.toFile().deleteOnExit();
|
||||
Files.write(Paths.get(path.toString(), "data"), dataString.getBytes(), StandardOpenOption.CREATE);
|
||||
Files.write(Paths.get(path.toString(), "other_data"), otherData, StandardOpenOption.CREATE);
|
||||
|
||||
Service service = Service.QORTAL_METADATA;
|
||||
assertTrue(service.isValidationRequired());
|
||||
|
||||
// There are multiple files, so we don't know which one to parse as JSON
|
||||
assertEquals(ValidationResult.MISSING_KEYS, service.validate(path));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user