use of org.apache.nifi.controller.repository.claim.ContentClaim in project nifi by apache.
the class TestFileSystemRepository method testClaimantCounts.
@Test
public void testClaimantCounts() throws IOException {
final ContentClaim claim = repository.create(true);
assertNotNull(claim);
assertEquals(1, repository.getClaimantCount(claim));
assertEquals(2, repository.incrementClaimaintCount(claim));
assertEquals(3, repository.incrementClaimaintCount(claim));
assertEquals(4, repository.incrementClaimaintCount(claim));
assertEquals(5, repository.incrementClaimaintCount(claim));
repository.decrementClaimantCount(claim);
assertEquals(4, repository.getClaimantCount(claim));
repository.decrementClaimantCount(claim);
assertEquals(3, repository.getClaimantCount(claim));
repository.decrementClaimantCount(claim);
assertEquals(2, repository.getClaimantCount(claim));
repository.decrementClaimantCount(claim);
assertEquals(1, repository.getClaimantCount(claim));
repository.decrementClaimantCount(claim);
assertEquals(0, repository.getClaimantCount(claim));
repository.remove(claim);
}
use of org.apache.nifi.controller.repository.claim.ContentClaim in project nifi by apache.
the class TestFileSystemRepository method testResourceClaimNotReusedAfterRestart.
@Test
public void testResourceClaimNotReusedAfterRestart() throws IOException, InterruptedException {
final ContentClaim claim1 = repository.create(false);
try (final OutputStream out = repository.write(claim1)) {
}
repository.shutdown();
Thread.sleep(1000L);
repository = new FileSystemRepository(nifiProperties);
repository.initialize(new StandardResourceClaimManager());
repository.purge();
final ContentClaim claim2 = repository.create(false);
assertNotSame(claim1.getResourceClaim(), claim2.getResourceClaim());
}
use of org.apache.nifi.controller.repository.claim.ContentClaim in project nifi by apache.
the class TestFileSystemRepository method testReadWithContent.
@Test
public void testReadWithContent() throws IOException {
final ContentClaim claim = repository.create(true);
final Path path = getPath(claim);
Files.createDirectories(path.getParent());
final byte[] data = "The quick brown fox jumps over the lazy dog".getBytes();
try (final OutputStream out = Files.newOutputStream(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE)) {
out.write(data);
}
try (final InputStream inStream = repository.read(claim)) {
assertNotNull(inStream);
final byte[] dataRead = readFully(inStream, data.length);
assertTrue(Arrays.equals(data, dataRead));
}
}
use of org.apache.nifi.controller.repository.claim.ContentClaim in project nifi by apache.
the class TestFileSystemRepository method testSize.
@Test
public void testSize() throws IOException {
final ContentClaim claim = repository.create(true);
final Path path = getPath(claim);
Files.createDirectories(path.getParent());
final byte[] data = "The quick brown fox jumps over the lazy dog".getBytes();
try (final OutputStream out = Files.newOutputStream(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE)) {
out.write(data);
}
assertEquals(data.length, repository.size(claim));
}
use of org.apache.nifi.controller.repository.claim.ContentClaim in project nifi by apache.
the class TestFileSystemRepository method testCreateContentClaim.
@Test
public void testCreateContentClaim() throws IOException {
// value passed to #create is irrelevant because the FileSystemRepository does not currently support loss tolerance.
final ContentClaim claim = repository.create(true);
assertNotNull(claim);
assertEquals(1, repository.getClaimantCount(claim));
}
Aggregations