use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class VisibilityConstraintTest method setUp.
@Before
public void setUp() throws Exception {
vc = new VisibilityConstraint();
mutation = new Mutation("r");
ArrayByteSequence bs = new ArrayByteSequence("good".getBytes(UTF_8));
AuthorizationContainer ac = createNiceMock(AuthorizationContainer.class);
expect(ac.contains(bs)).andReturn(true);
replay(ac);
env = createMock(Environment.class);
expect(env.getAuthorizationsContainer()).andReturn(ac);
replay(env);
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class VisibilityEvaluatorTest method testUnescape.
@Test
public void testUnescape() {
assertEquals("a\"b", VisibilityEvaluator.unescape(new ArrayByteSequence("a\\\"b")).toString());
assertEquals("a\\b", VisibilityEvaluator.unescape(new ArrayByteSequence("a\\\\b")).toString());
assertEquals("a\\\"b", VisibilityEvaluator.unescape(new ArrayByteSequence("a\\\\\\\"b")).toString());
assertEquals("\\\"", VisibilityEvaluator.unescape(new ArrayByteSequence("\\\\\\\"")).toString());
assertEquals("a\\b\\c\\d", VisibilityEvaluator.unescape(new ArrayByteSequence("a\\\\b\\\\c\\\\d")).toString());
try {
VisibilityEvaluator.unescape(new ArrayByteSequence("a\\b"));
fail("Expected failure to unescape invalid escape sequence");
} catch (IllegalArgumentException e) {
}
try {
VisibilityEvaluator.unescape(new ArrayByteSequence("a\\b\\c"));
fail("Expected failure to unescape invalid escape sequence");
} catch (IllegalArgumentException e) {
}
try {
VisibilityEvaluator.unescape(new ArrayByteSequence("a\"b\\"));
fail("Expected failure to unescape invalid escape sequence");
} catch (IllegalArgumentException e) {
}
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class ColumnFamilySkippingIteratorTest method test3.
public void test3() throws Exception {
// construct test where ColumnFamilySkippingIterator might try to seek past the end of the user supplied range
TreeMap<Key, Value> tm1 = new TreeMap<>();
for (int r = 0; r < 3; r++) {
for (int cf = 4; cf < 1000; cf++) {
for (int cq = 0; cq < 1; cq++) {
put(tm1, r, cf, cq, 6, r * cf * cq);
}
}
}
CountingIterator ci = new CountingIterator(new SortedMapIterator(tm1));
ColumnFamilySkippingIterator cfi = new ColumnFamilySkippingIterator(ci);
HashSet<ByteSequence> colfams = new HashSet<>();
colfams.add(new ArrayByteSequence(String.format("%06d", 4)));
Range range = new Range(newKey(0, 4, 0, 6), true, newKey(0, 400, 0, 6), true);
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
colfams.add(new ArrayByteSequence(String.format("%06d", 500)));
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
range = new Range(newKey(0, 4, 0, 6), true, newKey(1, 400, 0, 6), true);
cfi.seek(range, colfams, true);
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertTrue(cfi.hasTop());
assertEquals(newKey(0, 500, 0, 6), cfi.getTopKey());
cfi.next();
assertTrue(cfi.hasTop());
assertEquals(newKey(1, 4, 0, 6), cfi.getTopKey());
cfi.next();
assertFalse(cfi.hasTop());
// System.out.println(ci.getCount());
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class ColumnFamilySkippingIteratorTest method test2.
public void test2() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
for (int r = 0; r < 10; r++) {
for (int cf = 0; cf < 1000; cf++) {
for (int cq = 0; cq < 3; cq++) {
put(tm1, r, cf, cq, 6, r * cf * cq);
}
}
}
HashSet<ByteSequence> allColfams = new HashSet<>();
for (int cf = 0; cf < 1000; cf++) {
allColfams.add(new ArrayByteSequence(String.format("%06d", cf)));
}
ColumnFamilySkippingIterator cfi = new ColumnFamilySkippingIterator(new SortedMapIterator(tm1));
HashSet<ByteSequence> colfams = new HashSet<>();
runTest(cfi, 30000, 0, allColfams, colfams);
colfams.add(new ArrayByteSequence(String.format("%06d", 60)));
runTest(cfi, 30000, 30, allColfams, colfams);
colfams.add(new ArrayByteSequence(String.format("%06d", 602)));
runTest(cfi, 30000, 60, allColfams, colfams);
colfams.add(new ArrayByteSequence(String.format("%06d", 0)));
runTest(cfi, 30000, 90, allColfams, colfams);
colfams.add(new ArrayByteSequence(String.format("%06d", 999)));
runTest(cfi, 30000, 120, allColfams, colfams);
colfams.remove(new ArrayByteSequence(String.format("%06d", 0)));
runTest(cfi, 30000, 90, allColfams, colfams);
colfams.add(new ArrayByteSequence(String.format("%06d", 1000)));
runTest(cfi, 30000, 90, allColfams, colfams);
colfams.remove(new ArrayByteSequence(String.format("%06d", 999)));
runTest(cfi, 30000, 60, allColfams, colfams);
colfams.add(new ArrayByteSequence(String.format("%06d", 61)));
runTest(cfi, 30000, 90, allColfams, colfams);
for (int i = 62; i < 100; i++) colfams.add(new ArrayByteSequence(String.format("%06d", i)));
runTest(cfi, 30000, 1230, allColfams, colfams);
}
Aggregations