src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
TransformerUtils { @SuppressWarnings("unchecked") @Deprecated public static <I, O> Transformer<I, O> switchTransformer(final Predicate<? super I> predicate, final Transformer<? super I, ? extends O> trueTransformer, final Transformer<? super I, ? extends O> falseTransformer) { return SwitchTransformer.switchTransformer... | @Test @SuppressWarnings("unchecked") public void testSwitchTransformer() { final Transformer<String, String> a = TransformerUtils.constantTransformer("A"); final Transformer<String, String> b = TransformerUtils.constantTransformer("B"); final Transformer<String, String> c = TransformerUtils.constantTransformer("C"); as... |
TransformerUtils { @SuppressWarnings("unchecked") public static <I, O> Transformer<I, O> switchMapTransformer( final Map<I, Transformer<I, O>> objectsAndTransformers) { if (objectsAndTransformers == null) { throw new NullPointerException("The object and transformer map must not be null"); } final Transformer<? super I,... | @Test public void testSwitchMapTransformer() { final Transformer<String, String> a = TransformerUtils.constantTransformer("A"); final Transformer<String, String> b = TransformerUtils.constantTransformer("B"); final Transformer<String, String> c = TransformerUtils.constantTransformer("C"); Map<String, Transformer<String... |
TransformerUtils { public static <I, O> Transformer<I, O> invokerTransformer(final String methodName) { return InvokerTransformer.invokerTransformer(methodName, null, null); } private TransformerUtils(); static Transformer<I, O> exceptionTransformer(); static Transformer<I, O> nullTransformer(); static Transformer<T, ... | @Test public void testInvokerTransformer() { final List<Object> list = new ArrayList<Object>(); assertEquals(Integer.valueOf(0), TransformerUtils.invokerTransformer("size").transform(list)); list.add(new Object()); assertEquals(Integer.valueOf(1), TransformerUtils.invokerTransformer("size").transform(list)); assertEqua... |
LocalCacheHandler extends SimpleCacheHandler { public Map<String, Object> getBulk(Set<String> keys) { return getBulk(keys, null); } LocalCacheHandler(); LocalCacheHandler(Ticker ticker); Object get(String key); Map<String, Object> getBulk(Set<String> keys); @Override Object get(String key, Type type); @Override Map<St... | @Test public void testGetBulk() throws Exception { Ticker4Test t = new Ticker4Test(); LocalCacheHandler cache = new LocalCacheHandler(t); int seconds = 100; String key = "key"; String value = "value"; int seconds2 = 200; String key2 = "key2"; String value2 = "value2"; cache.set(key, value, seconds); cache.set(key2, val... |
TransformerUtils { public static <T> Transformer<T, String> stringValueTransformer() { return StringValueTransformer.stringValueTransformer(); } private TransformerUtils(); static Transformer<I, O> exceptionTransformer(); static Transformer<I, O> nullTransformer(); static Transformer<T, T> nopTransformer(); static Tra... | @Test public void testStringValueTransformer() { assertNotNull( "StringValueTransformer should NEVER return a null value.", TransformerUtils.stringValueTransformer().transform(null)); assertEquals( "StringValueTransformer should return \"null\" when given a null argument.", "null", TransformerUtils.stringValueTransform... |
TransformerUtils { public static <T> Transformer<Class<? extends T>, T> instantiateTransformer() { return InstantiateTransformer.instantiateTransformer(); } private TransformerUtils(); static Transformer<I, O> exceptionTransformer(); static Transformer<I, O> nullTransformer(); static Transformer<T, T> nopTransformer()... | @Test public void testInstantiateTransformerNull() { try { TransformerUtils.instantiateTransformer(null, new Object[] { "str" }); fail(); } catch (final IllegalArgumentException ex) {} try { TransformerUtils.instantiateTransformer(new Class[] {}, new Object[] { "str" }); fail(); } catch (final IllegalArgumentException ... |
PredicateUtils { public static <T> Predicate<T> exceptionPredicate() { return ExceptionPredicate.exceptionPredicate(); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nullPredicate(); static Predicate<T... | @Test public void testExceptionPredicate() { assertNotNull(PredicateUtils.exceptionPredicate()); assertSame(PredicateUtils.exceptionPredicate(), PredicateUtils.exceptionPredicate()); try { PredicateUtils.exceptionPredicate().evaluate(null); } catch (final FunctorException ex) { try { PredicateUtils.exceptionPredicate()... |
PredicateUtils { public static <T> Predicate<T> notNullPredicate() { return NotNullPredicate.notNullPredicate(); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nullPredicate(); static Predicate<T> notN... | @Test public void testIsNotNullPredicate() { assertNotNull(PredicateUtils.notNullPredicate()); assertSame(PredicateUtils.notNullPredicate(), PredicateUtils.notNullPredicate()); assertEquals(false, PredicateUtils.notNullPredicate().evaluate(null)); assertEquals(true, PredicateUtils.notNullPredicate().evaluate(cObject));... |
PredicateUtils { public static <T> Predicate<T> identityPredicate(final T value) { return IdentityPredicate.identityPredicate(value); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nullPredicate(); sta... | @Test public void testIdentityPredicate() { assertSame(nullPredicate(), PredicateUtils.identityPredicate(null)); assertNotNull(PredicateUtils.identityPredicate(Integer.valueOf(6))); assertEquals(false, PredicateUtils.identityPredicate(Integer.valueOf(6)).evaluate(null)); assertEquals(false, PredicateUtils.<Object>ident... |
PredicateUtils { public static <T> Predicate<T> truePredicate() { return TruePredicate.truePredicate(); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nullPredicate(); static Predicate<T> notNullPredic... | @Test public void testTruePredicate() { assertNotNull(TruePredicate.truePredicate()); assertSame(TruePredicate.truePredicate(), TruePredicate.truePredicate()); assertEquals(true, TruePredicate.truePredicate().evaluate(null)); assertEquals(true, TruePredicate.truePredicate().evaluate(cObject)); assertEquals(true, TruePr... |
PredicateUtils { public static <T> Predicate<T> falsePredicate() { return FalsePredicate.falsePredicate(); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nullPredicate(); static Predicate<T> notNullPre... | @Test public void testFalsePredicate() { assertNotNull(FalsePredicate.falsePredicate()); assertSame(FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()); assertEquals(false, FalsePredicate.falsePredicate().evaluate(null)); assertEquals(false, FalsePredicate.falsePredicate().evaluate(cObject)); assertEquals... |
PredicateUtils { public static <T> Predicate<T> notPredicate(final Predicate<? super T> predicate) { return NotPredicate.notPredicate(predicate); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nullPred... | @Test public void testNotPredicate() { assertNotNull(PredicateUtils.notPredicate(TruePredicate.truePredicate())); assertEquals(false, PredicateUtils.notPredicate(TruePredicate.truePredicate()).evaluate(null)); assertEquals(false, PredicateUtils.notPredicate(TruePredicate.truePredicate()).evaluate(cObject)); assertEqual... |
LocalCacheHandler extends SimpleCacheHandler { @Override public void delete(String key) { cache.remove(key); } LocalCacheHandler(); LocalCacheHandler(Ticker ticker); Object get(String key); Map<String, Object> getBulk(Set<String> keys); @Override Object get(String key, Type type); @Override Map<String, Object> getBulk... | @Test public void testDelete() throws Exception { Ticker4Test t = new Ticker4Test(); LocalCacheHandler cache = new LocalCacheHandler(t); int seconds = 100; String key = "key"; String value = "value"; cache.set(key, value, seconds); assertThat((String) cache.get(key), equalTo(value)); cache.delete(key); assertThat(cache... |
PredicateUtils { public static <T> Predicate<T> andPredicate(final Predicate<? super T> predicate1, final Predicate<? super T> predicate2) { return AndPredicate.andPredicate(predicate1, predicate2); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predic... | @Test public void testAndPredicate() { assertEquals(true, PredicateUtils.andPredicate(TruePredicate.truePredicate(), TruePredicate.truePredicate()).evaluate(null)); assertEquals(false, PredicateUtils.andPredicate(TruePredicate.truePredicate(), FalsePredicate.falsePredicate()).evaluate(null)); assertEquals(false, Predic... |
PredicateUtils { public static <T> Predicate<T> allPredicate(final Predicate<? super T>... predicates) { return AllPredicate.allPredicate(predicates); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nul... | @SuppressWarnings("unchecked") @Test public void testAllPredicate() { assertTrue(AllPredicate.allPredicate(new Predicate[] {}), null); assertEquals(true, AllPredicate.allPredicate(new Predicate[] { TruePredicate.truePredicate(), TruePredicate.truePredicate(), TruePredicate.truePredicate()}).evaluate(null)); assertEqual... |
LocalCacheHandler extends SimpleCacheHandler { @Override public void add(String key, Object value, int exptimeSeconds) { long now = ticker.read(); Entry entry = new Entry(value, now + TimeUnit.SECONDS.toNanos(exptimeSeconds)); cache.putIfAbsent(key, entry); } LocalCacheHandler(); LocalCacheHandler(Ticker ticker); Obje... | @Test public void testAdd() throws Exception { Ticker4Test t = new Ticker4Test(); LocalCacheHandler cache = new LocalCacheHandler(t); int seconds = 100; String key = "key"; String value = "value"; int seconds2 = 200; String key2 = "key2"; String value2 = "value2"; cache.set(key, value, seconds); cache.add(key, value2, ... |
PredicateUtils { public static <T> Predicate<T> orPredicate(final Predicate<? super T> predicate1, final Predicate<? super T> predicate2) { return OrPredicate.orPredicate(predicate1, predicate2); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate... | @Test public void testOrPredicate() { assertEquals(true, PredicateUtils.orPredicate(TruePredicate.truePredicate(), TruePredicate.truePredicate()).evaluate(null)); assertEquals(true, PredicateUtils.orPredicate(TruePredicate.truePredicate(), FalsePredicate.falsePredicate()).evaluate(null)); assertEquals(true, PredicateUt... |
PredicateUtils { public static <T> Predicate<T> anyPredicate(final Predicate<? super T>... predicates) { return AnyPredicate.anyPredicate(predicates); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nul... | @SuppressWarnings("unchecked") @Test public void testAnyPredicate() { assertFalse(PredicateUtils.anyPredicate(new Predicate[] {}), null); assertEquals(true, PredicateUtils.anyPredicate(new Predicate[] { TruePredicate.truePredicate(), TruePredicate.truePredicate(), TruePredicate.truePredicate()}).evaluate(null)); assert... |
PredicateUtils { public static <T> Predicate<T> eitherPredicate(final Predicate<? super T> predicate1, final Predicate<? super T> predicate2) { @SuppressWarnings("unchecked") final Predicate<T> onePredicate = PredicateUtils.onePredicate(predicate1, predicate2); return onePredicate; } private PredicateUtils(); static P... | @Test public void testEitherPredicate() { assertEquals(false, PredicateUtils.eitherPredicate(TruePredicate.truePredicate(), TruePredicate.truePredicate()).evaluate(null)); assertEquals(true, PredicateUtils.eitherPredicate(TruePredicate.truePredicate(), FalsePredicate.falsePredicate()).evaluate(null)); assertEquals(true... |
CacheableQueryOperator extends QueryOperator { @Override public Object execute(Object[] values, InvocationStat stat) { InvocationContext context = invocationContextFactory.newInvocationContext(values); return driver.isUseMultipleKeys() ? multipleKeysCache(context, rowMapper.getMappedClass(), driver.getOnlyCacheByClass(... | @Test public void testQuerySingleKeyHit() throws Exception { TypeToken<Integer> pt = TypeToken.of(Integer.class); TypeToken<User> rt = TypeToken.of(User.class); String srcSql = "select * from user where id=:1"; AbstractOperator operator = getOperator(pt, rt, srcSql, new CacheHandlerAdapter() { @Override public Object g... |
PredicateUtils { public static <T> Predicate<T> onePredicate(final Predicate<? super T>... predicates) { return OnePredicate.onePredicate(predicates); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nul... | @SuppressWarnings("unchecked") @Test public void testOnePredicate() { assertFalse(PredicateUtils.onePredicate((Predicate<Object>[]) new Predicate[] {}), null); assertEquals(false, PredicateUtils.onePredicate(new Predicate[] { TruePredicate.truePredicate(), TruePredicate.truePredicate(), TruePredicate.truePredicate()}).... |
PredicateUtils { public static <T> Predicate<T> neitherPredicate(final Predicate<? super T> predicate1, final Predicate<? super T> predicate2) { @SuppressWarnings("unchecked") final Predicate<T> nonePredicate = PredicateUtils.nonePredicate(predicate1, predicate2); return nonePredicate; } private PredicateUtils(); stat... | @Test public void testNeitherPredicate() { assertEquals(false, PredicateUtils.neitherPredicate(TruePredicate.truePredicate(), TruePredicate.truePredicate()).evaluate(null)); assertEquals(false, PredicateUtils.neitherPredicate(TruePredicate.truePredicate(), FalsePredicate.falsePredicate()).evaluate(null)); assertEquals(... |
DynamicTokens { public static <E> TypeToken<Collection<E>> collectionToken(TypeToken<E> entityToken) { return new TypeToken<Collection<E>>() {} .where(new TypeParameter<E>() {}, entityToken); } static TypeToken<Collection<E>> collectionToken(TypeToken<E> entityToken); static TypeToken<List<E>> listToken(TypeToken<E> e... | @Test public void testCollectionToken() throws Exception { TypeToken<Collection<String>> token = DynamicTokens.collectionToken(TypeToken.of(String.class)); Type expectedType = DynamicTokensTest.class.getMethod("func").getGenericReturnType(); assertThat(token.getType(), equalTo(expectedType)); } |
PredicateUtils { public static <T> Predicate<T> nonePredicate(final Predicate<? super T>... predicates) { return NonePredicate.nonePredicate(predicates); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> ... | @SuppressWarnings("unchecked") @Test public void testNonePredicate() { assertTrue(PredicateUtils.nonePredicate(new Predicate[] {}), null); assertEquals(false, PredicateUtils.nonePredicate(new Predicate[] { TruePredicate.truePredicate(), TruePredicate.truePredicate(), TruePredicate.truePredicate() }).evaluate(null)); as... |
PredicateUtils { public static Predicate<Object> instanceofPredicate(final Class<?> type) { return InstanceofPredicate.instanceOfPredicate(type); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nullPred... | @Test public void testInstanceOfPredicate() { assertNotNull(PredicateUtils.instanceofPredicate(String.class)); assertEquals(false, PredicateUtils.instanceofPredicate(String.class).evaluate(null)); assertEquals(false, PredicateUtils.instanceofPredicate(String.class).evaluate(cObject)); assertEquals(true, PredicateUtils.... |
PredicateUtils { public static <T> Predicate<T> uniquePredicate() { return UniquePredicate.uniquePredicate(); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static Predicate<T> nullPredicate(); static Predicate<T> notNull... | @Test public void testUniquePredicate() { final Predicate<Object> p = PredicateUtils.uniquePredicate(); assertEquals(true, p.evaluate(new Object())); assertEquals(true, p.evaluate(new Object())); assertEquals(true, p.evaluate(new Object())); assertEquals(true, p.evaluate(cString)); assertEquals(false, p.evaluate(cStrin... |
PredicateUtils { public static <T> Predicate<T> asPredicate(final Transformer<? super T, Boolean> transformer) { return TransformerPredicate.transformerPredicate(transformer); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate()... | @Test public void testAsPredicateTransformer() { assertEquals(false, PredicateUtils.asPredicate(TransformerUtils.<Boolean>nopTransformer()).evaluate(false)); assertEquals(true, PredicateUtils.asPredicate(TransformerUtils.<Boolean>nopTransformer()).evaluate(true)); }
@Test(expected=NullPointerException.class) public voi... |
PredicateUtils { public static <T> Predicate<T> invokerPredicate(final String methodName) { return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName)); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredica... | @Test public void testInvokerPredicate() { final List<Object> list = new ArrayList<Object>(); assertEquals(true, PredicateUtils.invokerPredicate("isEmpty").evaluate(list)); list.add(new Object()); assertEquals(false, PredicateUtils.invokerPredicate("isEmpty").evaluate(list)); }
@Test(expected=NullPointerException.class... |
PredicateUtils { public static <T> Predicate<T> nullIsExceptionPredicate(final Predicate<? super T> predicate){ return NullIsExceptionPredicate.nullIsExceptionPredicate(predicate); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredic... | @Test(expected=FunctorException.class) public void testNullIsExceptionPredicate() { assertEquals(true, PredicateUtils.nullIsExceptionPredicate(TruePredicate.truePredicate()).evaluate(new Object())); PredicateUtils.nullIsExceptionPredicate(TruePredicate.truePredicate()).evaluate(null); }
@Test(expected=NullPointerExcept... |
PredicateUtils { public static <T> Predicate<T> nullIsTruePredicate(final Predicate<? super T> predicate){ return NullIsTruePredicate.nullIsTruePredicate(predicate); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); static P... | @Test public void testNullIsTruePredicate() { assertEquals(true, PredicateUtils.nullIsTruePredicate(TruePredicate.truePredicate()).evaluate(null)); assertEquals(true, PredicateUtils.nullIsTruePredicate(TruePredicate.truePredicate()).evaluate(new Object())); assertEquals(false, PredicateUtils.nullIsTruePredicate(FalsePr... |
PredicateUtils { public static <T> Predicate<T> nullIsFalsePredicate(final Predicate<? super T> predicate){ return NullIsFalsePredicate.nullIsFalsePredicate(predicate); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Predicate<T> truePredicate(); static Predicate<T> falsePredicate(); stati... | @Test public void testNullIsFalsePredicate() { assertEquals(false, PredicateUtils.nullIsFalsePredicate(TruePredicate.truePredicate()).evaluate(null)); assertEquals(true, PredicateUtils.nullIsFalsePredicate(TruePredicate.truePredicate()).evaluate(new Object())); assertEquals(false, PredicateUtils.nullIsFalsePredicate(Fa... |
PredicateUtils { public static <T> Predicate<T> transformedPredicate( final Transformer<? super T, ? extends T> transformer, final Predicate<? super T> predicate) { return TransformedPredicate.transformedPredicate(transformer, predicate); } private PredicateUtils(); static Predicate<T> exceptionPredicate(); static Pre... | @Test public void testTransformedPredicate() { assertEquals(true, PredicateUtils.transformedPredicate( TransformerUtils.nopTransformer(), TruePredicate.truePredicate()).evaluate(new Object())); final Map<Object, Object> map = new HashMap<Object, Object>(); map.put(Boolean.TRUE, "Hello"); final Transformer<Object, Objec... |
ComparatorPredicate implements Predicate<T>, Serializable { public static <T> Predicate<T> comparatorPredicate(final T object, final Comparator<T> comparator) { return comparatorPredicate(object, comparator, Criterion.EQUAL); } ComparatorPredicate(final T object, final Comparator<T> comparator, final Criterion criterio... | @Test public void compareEquals() { final Integer value = Integer.valueOf(10); final Predicate<Integer> p = comparatorPredicate(value, new TestComparator<Integer>()); assertFalse(p, Integer.valueOf(value.intValue() - 1)); assertTrue(p, Integer.valueOf(value.intValue())); assertFalse(p, Integer.valueOf(value.intValue() ... |
NullPredicate implements Predicate<T>, Serializable { @SuppressWarnings("unchecked") public static <T> Predicate<T> nullPredicate() { return (Predicate<T>) INSTANCE; } private NullPredicate(); @SuppressWarnings("unchecked") static Predicate<T> nullPredicate(); boolean evaluate(final T object); @SuppressWarnings("rawty... | @Test public void testNullPredicate() { assertSame(NullPredicate.nullPredicate(), NullPredicate.nullPredicate()); assertTrue(nullPredicate(), null); }
@Test public void ensurePredicateCanBeTypedWithoutWarning() throws Exception { final Predicate<String> predicate = NullPredicate.nullPredicate(); assertFalse(predicate, ... |
CatchAndRethrowClosure implements Closure<E> { public void execute(final E input) { try { executeAndThrow(input); } catch (final RuntimeException ex) { throw ex; } catch (final Throwable t) { throw new FunctorException(t); } } void execute(final E input); } | @Test public void testThrowingClosure() { Closure<Integer> closure = generateNoExceptionClosure(); try { closure.execute(Integer.valueOf(0)); } catch (final FunctorException ex) { Assert.fail(); } catch (final RuntimeException ex) { Assert.fail(); } closure = generateIOExceptionClosure(); try { closure.execute(Integer.... |
EqualPredicate implements Predicate<T>, Serializable { public static <T> Predicate<T> equalPredicate(final T object) { if (object == null) { return NullPredicate.nullPredicate(); } return new EqualPredicate<T>(object); } EqualPredicate(final T object); EqualPredicate(final T object, final Equator<T> equator); static P... | @Test public void testNullArgumentEqualsNullPredicate() throws Exception { assertSame(nullPredicate(), equalPredicate(null)); }
@Test public void objectFactoryUsesEqualsForTest() throws Exception { final Predicate<EqualsTestObject> predicate = equalPredicate(FALSE_OBJECT); assertFalse(predicate, FALSE_OBJECT); assertTr... |
AllPredicate extends AbstractQuantifierPredicate<T> { public boolean evaluate(final T object) { for (final Predicate<? super T> iPredicate : iPredicates) { if (!iPredicate.evaluate(object)) { return false; } } return true; } AllPredicate(final Predicate<? super T>... predicates); static Predicate<T> allPredicate(final ... | @SuppressWarnings({"unchecked"}) @Test public void emptyArrayToGetInstance() { assertTrue("empty array not true", getPredicateInstance(new Predicate[] {}).evaluate(null)); }
@Test public void emptyCollectionToGetInstance() { final Predicate<Integer> allPredicate = getPredicateInstance( Collections.<Predicate<Integer>>e... |
CacheableBatchUpdateOperator extends BatchUpdateOperator { @Override public Object execute(Object[] values, InvocationStat stat) { Iterables iterables = getIterables(values); if (iterables.isEmpty()) { return transformer.transform(new int[]{}); } Set<String> keys = new HashSet<String>(iterables.size() * 2); Map<DataSou... | @Test public void testBatchUpdate() throws Exception { TypeToken<List<User>> pt = new TypeToken<List<User>>() { }; TypeToken<int[]> rt = TypeToken.of(int[].class); String srcSql = "update user set name=:1.name where id=:1.id"; AbstractOperator operator = getOperator(pt, rt, srcSql, new CacheHandlerAdapter() { @Override... |
FluentIterable implements Iterable<E> { public FluentIterable<E> collate(final Iterable<? extends E> other) { return of(IterableUtils.collatedIterable(iterable, other)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static Fluen... | @Test public void collate() { List<Integer> result = FluentIterable.of(iterableOdd).collate(iterableEven).toList(); List<Integer> combinedList = new ArrayList<Integer>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); Collections.sort(combinedList); assertEquals(c... |
FluentIterable implements Iterable<E> { public FluentIterable<E> filter(final Predicate<? super E> predicate) { return of(IterableUtils.filteredIterable(iterable, predicate)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static... | @Test public void filter() { Predicate<Integer> smallerThan3 = new Predicate<Integer>() { @Override public boolean evaluate(Integer object) { return object.intValue() < 3; } }; List<Integer> result = FluentIterable.of(iterableA).filter(smallerThan3).toList(); assertEquals(3, result.size()); assertEquals(Arrays.asList(1... |
FluentIterable implements Iterable<E> { public void forEach(final Closure<? super E> closure) { IterableUtils.forEach(iterable, closure); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleto... | @Test public void forEach() { final AtomicInteger sum = new AtomicInteger(0); Closure<Integer> closure = new Closure<Integer>() { @Override public void execute(Integer input) { sum.addAndGet(input); } }; FluentIterable.of(iterableA).forEach(closure); int expectedSum = 0; for (Integer i : iterableA) { expectedSum += i; ... |
FluentIterable implements Iterable<E> { public FluentIterable<E> limit(final long maxSize) { return of(IterableUtils.boundedIterable(iterable, maxSize)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(... | @Test public void limit() { List<Integer> result = FluentIterable.of(iterableA).limit(3).toList(); assertEquals(3, result.size()); assertEquals(Arrays.asList(1, 2, 2), result); result = FluentIterable.of(iterableA).limit(100).toList(); List<Integer> expected = IterableUtils.toList(iterableA); assertEquals(expected.size... |
FluentIterable implements Iterable<E> { public FluentIterable<E> reverse() { return of(IterableUtils.reversedIterable(iterable)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); stat... | @Test public void reverse() { List<Integer> result = FluentIterable.of(iterableA).reverse().toList(); List<Integer> expected = IterableUtils.toList(iterableA); Collections.reverse(expected); assertEquals(expected, result); result = FluentIterable.of(emptyIterable).reverse().toList(); assertEquals(0, result.size()); } |
FluentIterable implements Iterable<E> { public FluentIterable<E> skip(final long elementsToSkip) { return of(IterableUtils.skippingIterable(iterable, elementsToSkip)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentI... | @Test public void skip() { List<Integer> result = FluentIterable.of(iterableA).skip(4).toList(); assertEquals(6, result.size()); assertEquals(Arrays.asList(3, 3, 4, 4, 4, 4), result); result = FluentIterable.of(iterableA).skip(100).toList(); assertEquals(0, result.size()); result = FluentIterable.of(iterableA).skip(0).... |
FluentIterable implements Iterable<E> { public <O> FluentIterable<O> transform(final Transformer<? super E, ? extends O> transformer) { return of(IterableUtils.transformedIterable(iterable, transformer)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static Flue... | @Test public void transform() { Transformer<Integer, Integer> squared = new Transformer<Integer, Integer>() { @Override public Integer transform(Integer object) { return object * object; } }; List<Integer> result = FluentIterable.of(iterableA).transform(squared).toList(); assertEquals(10, result.size()); assertEquals(A... |
FluentIterable implements Iterable<E> { public FluentIterable<E> unique() { return of(IterableUtils.uniqueIterable(iterable)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); static ... | @Test public void unique() { List<Integer> result = FluentIterable.of(iterableA).unique().toList(); assertEquals(4, result.size()); assertEquals(Arrays.asList(1, 2, 3, 4), result); result = FluentIterable.of(emptyIterable).unique().toList(); assertEquals(0, result.size()); } |
CacheableUpdateOperator extends UpdateOperator { @Override public Object execute(Object[] values, InvocationStat stat) { InvocationContext context = invocationContextFactory.newInvocationContext(values); Object r = execute(context, stat); if (driver.isUseMultipleKeys()) { Set<String> keys = driver.getCacheKeys(context)... | @Test public void testUpdate() throws Exception { TypeToken<User> pt = TypeToken.of(User.class); TypeToken<Integer> rt = TypeToken.of(int.class); String srcSql = "update user set name=:1.name where id=:1.id"; AbstractOperator operator = getOperator(pt, rt, srcSql, new CacheHandlerAdapter() { @Override public void delet... |
FluentIterable implements Iterable<E> { public FluentIterable<E> unmodifiable() { return of(IterableUtils.unmodifiableIterable(iterable)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singlet... | @Test public void unmodifiable() { FluentIterable<Integer> iterable1 = FluentIterable.of(iterableA).unmodifiable(); Iterator<Integer> it = iterable1.iterator(); assertEquals(1, it.next().intValue()); try { it.remove(); fail("expecting UnsupportedOperationException"); } catch (UnsupportedOperationException ise) { } Flue... |
FluentIterable implements Iterable<E> { public FluentIterable<E> zip(final Iterable<? extends E> other) { return of(IterableUtils.zippingIterable(iterable, other)); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIter... | @SuppressWarnings("unchecked") @Test public void zip() { List<Integer> result = FluentIterable.of(iterableOdd).zip(iterableEven).toList(); List<Integer> combinedList = new ArrayList<Integer>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); Collections.sort(combin... |
FluentIterable implements Iterable<E> { public Enumeration<E> asEnumeration() { return IteratorUtils.asEnumeration(iterator()); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); static... | @Test public void asEnumeration() { Enumeration<Long> enumeration = FluentIterable.of(iterableB).asEnumeration(); List<Long> result = EnumerationUtils.toList(enumeration); assertEquals(iterableB, result); enumeration = FluentIterable.<Long>empty().asEnumeration(); assertFalse(enumeration.hasMoreElements()); } |
FluentIterable implements Iterable<E> { public boolean allMatch(final Predicate<? super E> predicate) { return IterableUtils.matchesAll(iterable, predicate); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T>... | @Test public void allMatch() { assertTrue(FluentIterable.of(iterableEven).allMatch(EVEN)); assertFalse(FluentIterable.of(iterableOdd).allMatch(EVEN)); assertFalse(FluentIterable.of(iterableA).allMatch(EVEN)); try { FluentIterable.of(iterableEven).allMatch(null); fail("expecting NullPointerException"); } catch (NullPoin... |
FluentIterable implements Iterable<E> { public boolean anyMatch(final Predicate<? super E> predicate) { return IterableUtils.matchesAny(iterable, predicate); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T>... | @Test public void anyMatch() { assertTrue(FluentIterable.of(iterableEven).anyMatch(EVEN)); assertFalse(FluentIterable.of(iterableOdd).anyMatch(EVEN)); assertTrue(FluentIterable.of(iterableA).anyMatch(EVEN)); try { FluentIterable.of(iterableEven).anyMatch(null); fail("expecting NullPointerException"); } catch (NullPoint... |
FluentIterable implements Iterable<E> { public boolean isEmpty() { return IterableUtils.isEmpty(iterable); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); static FluentIterable<T> of... | @Test public void isEmpty() { assertTrue(FluentIterable.of(emptyIterable).isEmpty()); assertFalse(FluentIterable.of(iterableOdd).isEmpty()); } |
FluentIterable implements Iterable<E> { public int size() { return IterableUtils.size(iterable); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); static FluentIterable<T> of(final T..... | @Test public void size() { try { FluentIterable.of((Iterable<?>) null).size(); fail("expecting NullPointerException"); } catch (NullPointerException npe) { } assertEquals(0, FluentIterable.of(emptyIterable).size()); assertEquals(IterableUtils.toList(iterableOdd).size(), FluentIterable.of(iterableOdd).size()); } |
FluentIterable implements Iterable<E> { public FluentIterable<E> eval() { return of(toList()); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); static FluentIterable<T> of(final T... ... | @Test public void eval() { List<Integer> listNumbers = new ArrayList<Integer>(); listNumbers.addAll(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); FluentIterable<Integer> iterable = FluentIterable.of(listNumbers).filter(EVEN); FluentIterable<Integer> materialized = iterable.eval(); listNumbers.addAll(Arrays.asList(11, ... |
FluentIterable implements Iterable<E> { public boolean contains(final Object object) { return IterableUtils.contains(iterable, object); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton)... | @Test public void contains() { assertTrue(FluentIterable.of(iterableEven).contains(2)); assertFalse(FluentIterable.of(iterableEven).contains(1)); assertFalse(FluentIterable.of(iterableEven).contains(null)); assertTrue(FluentIterable.of(iterableEven).append((Integer) null).contains(null)); } |
FluentIterable implements Iterable<E> { public void copyInto(final Collection<? super E> collection) { if (collection == null) { throw new NullPointerException("Collection must not be null"); } CollectionUtils.addAll(collection, iterable); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @Suppre... | @Test public void copyInto() { List<Integer> result = new ArrayList<Integer>(); FluentIterable.of(iterableA).copyInto(result); List<Integer> expected = IterableUtils.toList(iterableA); assertEquals(expected.size(), result.size()); assertEquals(expected, result); result = new ArrayList<Integer>(); result.add(10); result... |
FluentIterable implements Iterable<E> { @Override public Iterator<E> iterator() { return iterable.iterator(); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); static FluentIterable<T>... | @Test public void iterator() { Iterator<Integer> iterator = FluentIterable.of(iterableA).iterator(); assertTrue(iterator.hasNext()); iterator = FluentIterable.<Integer>empty().iterator(); assertFalse(iterator.hasNext()); } |
FluentIterable implements Iterable<E> { public E get(final int position) { return IterableUtils.get(iterable, position); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); static Fluent... | @Test public void get() { assertEquals(2, FluentIterable.of(iterableEven).get(0).intValue()); try { FluentIterable.of(iterableEven).get(-1); fail("expecting IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException ioe) { } try { FluentIterable.of(iterableEven).get(IterableUtils.size(iterableEven)); fail("expecti... |
FluentIterable implements Iterable<E> { public E[] toArray(final Class<E> arrayClass) { return IteratorUtils.toArray(iterator(), arrayClass); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T sing... | @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void toArray() { Long[] arr = new Long[] {1L, 2L, 3L, 4L, 5L}; Long[] result = FluentIterable.of(arr).toArray(Long.class); assertNotNull(result); assertArrayEquals(arr, result); try { FluentIterable.of(arr).toArray((Class) String.class); } catch (ArrayStoreExc... |
FluentIterable implements Iterable<E> { @Override public String toString() { return IterableUtils.toString(iterable); } FluentIterable(); private FluentIterable(final Iterable<E> iterable); @SuppressWarnings("unchecked") static FluentIterable<T> empty(); static FluentIterable<T> of(final T singleton); static FluentIte... | @Test public void testToString() { String result = FluentIterable.of(iterableA).toString(); assertEquals(iterableA.toString(), result); result = FluentIterable.empty().toString(); assertEquals("[]", result); } |
Charsets { public static Charset toCharset(final Charset charset) { return charset == null ? Charset.defaultCharset() : charset; } static Charset toCharset(final Charset charset); static Charset toCharset(final String charset); @Deprecated
static final Charset ISO_8859_1; @Deprecated
static final Charset US_AS... | @Test public void testToCharset() { Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset((String) null)); Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset((Charset) null)); Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset(Charset.defaultCharset())); Assert.assertEquals(Charse... |
StringEncoderComparator implements Comparator { @Override public int compare(final Object o1, final Object o2) { int compareCode = 0; try { @SuppressWarnings("unchecked") final Comparable<Comparable<?>> s1 = (Comparable<Comparable<?>>) this.stringEncoder.encode(o1); final Comparable<?> s2 = (Comparable<?>) this.stringE... | @Test public void testComparatorWithSoundex() throws Exception { final StringEncoderComparator sCompare = new StringEncoderComparator( new Soundex() ); assertTrue( "O'Brien and O'Brian didn't come out with " + "the same Soundex, something must be wrong here", 0 == sCompare.compare( "O'Brien", "O'Brian" ) ); }
@Test pub... |
UnixCrypt { public static String crypt(final byte[] original) { return crypt(original, null); } static String crypt(final byte[] original); static String crypt(final byte[] original, String salt); static String crypt(final String original); static String crypt(final String original, final String salt); } | @Test public void testUnixCryptStrings() { assertEquals("xxWAum7tHdIUw", Crypt.crypt("secret", "xx")); assertEquals("12UFlHxel6uMM", Crypt.crypt("", "12")); assertEquals("12FJgqDtVOg7Q", Crypt.crypt("secret", "12")); assertEquals("12FJgqDtVOg7Q", Crypt.crypt("secret", "12345678")); }
@Test public void testUnixCryptByte... |
TransactionTemplate { public static void execute( Mango mango, String dataSourceFactoryName, TransactionIsolationLevel level, TransactionAction action) throws TransactionException { execute(TransactionFactory.newTransaction(mango, dataSourceFactoryName, level), action); } static void execute(
Mango mango, String... | @Test public void testCommit() throws Exception { final Account x = new Account(1, 1000); final Account y = new Account(2, 1000); final Account z = new Account(3, 1000); dao.insert(x); dao.insert(y); dao.insert(z); TransactionTemplate.execute(mango, AbstractDataSourceFactory.DEFULT_NAME, new TransactionAction() { @Over... |
B64 { static void b64from24bit(final byte b2, final byte b1, final byte b0, final int outLen, final StringBuilder buffer) { int w = ((b2 << 16) & 0x00ffffff) | ((b1 << 8) & 0x00ffff) | (b0 & 0xff); int n = outLen; while (n-- > 0) { buffer.append(B64T.charAt(w & 0x3f)); w >>= 6; } } } | @Test public void testB64from24bit() { final StringBuilder buffer = new StringBuilder(""); B64.b64from24bit((byte) 8, (byte) 16, (byte) 64, 2, buffer); B64.b64from24bit((byte) 7, (byte) 77, (byte) 120, 4, buffer); assertEquals("./spo/", buffer.toString()); } |
DigestUtils { public static MessageDigest getDigest(final String algorithm) { try { return MessageDigest.getInstance(algorithm); } catch (final NoSuchAlgorithmException e) { throw new IllegalArgumentException(e); } } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static Me... | @Test(expected=IllegalArgumentException.class) public void testInternalNoSuchAlgorithmException() { DigestUtils.getDigest("Bogus Bogus"); } |
DigestUtils { public static String md2Hex(final byte[] data) { return Hex.encodeHexString(md2(data)); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); static ... | @Test public void testMd2Hex() throws IOException { assertEquals("8350e5a3e24c153df2275c9f80692773", DigestUtils.md2Hex("")); assertEquals("32ec01ec4a6dac72c0ab96fb34c0b5d1", DigestUtils.md2Hex("a")); assertEquals("da853b0d3f88d99b30283a69e6ded6bb", DigestUtils.md2Hex("abc")); assertEquals("ab4f496bfb2a530b219ff33031fe... |
DigestUtils { public static byte[] md2(final byte[] data) { return getMd2Digest().digest(data); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); static Messag... | @Test public void testMd2Length() { String hashMe = "this is some string that is longer than 16 characters"; byte[] hash = DigestUtils.md2(getBytesUtf8(hashMe)); assertEquals(16, hash.length); hashMe = "length < 16"; hash = DigestUtils.md2(getBytesUtf8(hashMe)); assertEquals(16, hash.length); } |
DigestUtils { public static String md5Hex(final byte[] data) { return Hex.encodeHexString(md5(data)); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); static ... | @Test public void testMd5Hex() throws IOException { assertEquals("d41d8cd98f00b204e9800998ecf8427e", DigestUtils.md5Hex("")); assertEquals("0cc175b9c0f1b6a831c399e269772661", DigestUtils.md5Hex("a")); assertEquals("900150983cd24fb0d6963f7d28e17f72", DigestUtils.md5Hex("abc")); assertEquals("f96b697d7cb7938d525a2f31aaf1... |
DigestUtils { public static byte[] md5(final byte[] data) { return getMd5Digest().digest(data); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); static Messag... | @Test public void testMd5Length() { String hashMe = "this is some string that is longer than 16 characters"; byte[] hash = DigestUtils.md5(getBytesUtf8(hashMe)); assertEquals(16, hash.length); hashMe = "length < 16"; hash = DigestUtils.md5(getBytesUtf8(hashMe)); assertEquals(16, hash.length); } |
DigestUtils { public static String sha1Hex(final byte[] data) { return Hex.encodeHexString(sha1(data)); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); stati... | @Test public void testSha1Hex() throws IOException { assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.sha1Hex("abc")); assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.sha1Hex(getBytesUtf8("abc"))); assertEquals( "84983e441c3bd26ebaae4aa1f95129e5e54670f1", DigestUtils.sha1Hex("ab... |
DigestUtils { public static byte[] sha256(final byte[] data) { return getSha256Digest().digest(data); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); static ... | @Test public void testSha256() throws IOException { assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex("abc")); assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex(getBytesUtf8("abc"))); assertEquals("248d6a61d20638b8... |
DigestUtils { public static byte[] sha384(final byte[] data) { return getSha384Digest().digest(data); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); static ... | @Test public void testSha384() throws IOException { assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" + "8086072ba1e7cc2358baeca134c825a7", DigestUtils.sha384Hex("abc")); assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" + "8086072ba1e7cc2358baeca134c825a7", D... |
DigestUtils { public static byte[] sha512(final byte[] data) { return getSha512Digest().digest(data); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); static ... | @Test public void testSha512() throws IOException { assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", DigestUtils.sha512Hex("abc")); assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + "2192... |
DigestUtils { @Deprecated public static String shaHex(final byte[] data) { return sha1Hex(data); } static MessageDigest getDigest(final String algorithm); static MessageDigest getMd2Digest(); static MessageDigest getMd5Digest(); static MessageDigest getSha1Digest(); static MessageDigest getSha256Digest(); static Messa... | @SuppressWarnings("deprecation") @Test public void testShaHex() throws IOException { assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.shaHex("abc")); assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.shaHex(getBytesUtf8("abc"))); assertEquals( "84983e441c3bd26ebaae4aa1f95129e5e546... |
HmacUtils { public static Mac getHmacMd5(final byte[] key) { return getInitializedMac(HmacAlgorithms.HMAC_MD5, key); } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); static Mac getHmacSha256(final byte[] key); static Mac getHmacSha384(final byte[] key); static Mac getHmacSha512(fina... | @Test(expected = IllegalArgumentException.class) public void testEmptyKey() { HmacUtils.getHmacMd5(new byte[] {}); }
@Test(expected = IllegalArgumentException.class) public void testNullKey() { HmacUtils.getHmacMd5(null); } |
HmacUtils { public static String hmacMd5Hex(final byte[] key, final byte[] valueToDigest) { return Hex.encodeHexString(hmacMd5(key, valueToDigest)); } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); static Mac getHmacSha256(final byte[] key); static Mac getHmacSha384(final byte[] key... | @Test public void testHmacMd5Hex() throws IOException { assertEquals("80070713463e7749b90c2dc24911e275", HmacUtils.hmacMd5Hex(STANDARD_KEY_STRING, "The quick brown fox jumps over the lazy dog")); assertEquals("750c783e6ab0b503eaa86e310a5db738", HmacUtils.hmacMd5Hex("Jefe", "what do ya want for nothing?")); assertEquals... |
HmacUtils { public static String hmacSha1Hex(final byte[] key, final byte[] valueToDigest) { return Hex.encodeHexString(hmacSha1(key, valueToDigest)); } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); static Mac getHmacSha256(final byte[] key); static Mac getHmacSha384(final byte[] k... | @Test public void testHmacSha1Hex() throws IOException { assertEquals(STANDARD_SHA1_RESULT_STRING, HmacUtils.hmacSha1Hex(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); assertEquals("f42bb0eeb018ebbd4597ae7213711ec60760843f", HmacUtils.hmacSha1Hex(STANDARD_KEY_STRING, "")); assertEquals("effcdf6ae5eb2fa2d27416d5f184df9c... |
HmacUtils { public static Mac getInitializedMac(final HmacAlgorithms algorithm, final byte[] key) { return getInitializedMac(algorithm.toString(), key); } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); static Mac getHmacSha256(final byte[] key); static Mac getHmacSha384(final byte[]... | @Test(expected = IllegalArgumentException.class) public void testInitializedMacNullAlgo() throws IOException { HmacUtils.getInitializedMac((String) null, STANDARD_KEY_BYTES); }
@Test(expected = IllegalArgumentException.class) public void testInitializedMacNullKey() throws IOException { HmacUtils.getInitializedMac(HmacA... |
HmacUtils { public static byte[] hmacMd5(final byte[] key, final byte[] valueToDigest) { try { return getHmacMd5(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { throw new IllegalArgumentException(e); } } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); static Ma... | @Test(expected = IllegalArgumentException.class) public void testMd5HMacFail() throws IOException { HmacUtils.hmacMd5((byte[]) null, STANDARD_PHRASE_BYTES); } |
HmacUtils { public static byte[] hmacSha1(final byte[] key, final byte[] valueToDigest) { try { return getHmacSha1(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { throw new IllegalArgumentException(e); } } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); static ... | @Test(expected = IllegalArgumentException.class) public void testSha1HMacFail() throws IOException { HmacUtils.hmacSha1((byte[]) null, STANDARD_PHRASE_BYTES); } |
HmacUtils { public static byte[] hmacSha256(final byte[] key, final byte[] valueToDigest) { try { return getHmacSha256(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { throw new IllegalArgumentException(e); } } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); sta... | @Test(expected = IllegalArgumentException.class) public void testSha256HMacFail() throws IOException { HmacUtils.hmacSha256((byte[]) null, STANDARD_PHRASE_BYTES); } |
HmacUtils { public static byte[] hmacSha384(final byte[] key, final byte[] valueToDigest) { try { return getHmacSha384(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { throw new IllegalArgumentException(e); } } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); sta... | @Test(expected = IllegalArgumentException.class) public void testSha384HMacFail() throws IOException { HmacUtils.hmacSha384((byte[]) null, STANDARD_PHRASE_BYTES); } |
HmacUtils { public static byte[] hmacSha512(final byte[] key, final byte[] valueToDigest) { try { return getHmacSha512(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { throw new IllegalArgumentException(e); } } static Mac getHmacMd5(final byte[] key); static Mac getHmacSha1(final byte[] key); sta... | @Test(expected = IllegalArgumentException.class) public void testSha512HMacFail() throws IOException { HmacUtils.hmacSha512((byte[]) null, STANDARD_PHRASE_BYTES); } |
MethodNameParser { public static MethodNameInfo parse(String str) { OrderUnit ou = parseOrderUnit(str); if (ou != null) { str = str.substring(0, str.length() - ou.getOrderStrSize()); } List<OpUnit> opUnits = new ArrayList<OpUnit>(); List<String> logics = new ArrayList<String>(); Pattern p = Pattern.compile(LOGIC_REGEX)... | @Test public void parse() throws Exception { MethodNameInfo info = MethodNameParser.parse("EmailAddressAndLastnameLessThanOrIdOrderByUserIdDesc"); assertThat(info.getLogics(), equalTo(Arrays.asList("and", "or"))); OrderUnit ou = info.getOrderUnit(); assertThat(ou.getOrderType(), equalTo(OrderType.DESC)); assertThat(ou.... |
DynamicTokens { public static <E> TypeToken<List<E>> listToken(TypeToken<E> entityToken) { return new TypeToken<List<E>>() {} .where(new TypeParameter<E>() {}, entityToken); } static TypeToken<Collection<E>> collectionToken(TypeToken<E> entityToken); static TypeToken<List<E>> listToken(TypeToken<E> entityToken); } | @Test public void testListToken() throws Exception { TypeToken<List<String>> token = DynamicTokens.listToken(TypeToken.of(String.class)); Type expectedType = DynamicTokensTest.class.getMethod("func2").getGenericReturnType(); assertThat(token.getType(), equalTo(expectedType)); } |
Crypt { public static String crypt(final byte[] keyBytes) { return crypt(keyBytes, null); } static String crypt(final byte[] keyBytes); static String crypt(final byte[] keyBytes, final String salt); static String crypt(final String key); static String crypt(final String key, final String salt); } | @Test public void testCrypt() { assertNotNull(new Crypt()); }
@Test public void testDefaultCryptVariant() { assertTrue(Crypt.crypt("secret").startsWith("$6$")); assertTrue(Crypt.crypt("secret", null).startsWith("$6$")); }
@Test public void testCryptWithBytes() { final byte[] keyBytes = new byte[] { 'b', 'y', 't', 'e' }... |
Md5Crypt { public static String md5Crypt(final byte[] keyBytes) { return md5Crypt(keyBytes, MD5_PREFIX + B64.getRandomSalt(8)); } static String apr1Crypt(final byte[] keyBytes); static String apr1Crypt(final byte[] keyBytes, String salt); static String apr1Crypt(final String keyBytes); static String apr1Crypt(final St... | @Test public void testMd5CryptExplicitCall() { assertTrue(Md5Crypt.md5Crypt("secret".getBytes()).matches("^\\$1\\$[a-zA-Z0-9./]{0,8}\\$.{1,}$")); assertTrue(Md5Crypt.md5Crypt("secret".getBytes(), null).matches("^\\$1\\$[a-zA-Z0-9./]{0,8}\\$.{1,}$")); }
@Test(expected = NullPointerException.class) public void testMd5Cry... |
StringUtils { public static byte[] getBytesIso8859_1(final String string) { return getBytes(string, Charsets.ISO_8859_1); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final String string, final String char... | @Test public void testGetBytesIso8859_1() throws UnsupportedEncodingException { final String charsetName = "ISO-8859-1"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesIso8859_1(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(... |
StringUtils { public static byte[] getBytesUsAscii(final String string) { return getBytes(string, Charsets.US_ASCII); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final String string, final String charsetN... | @Test public void testGetBytesUsAscii() throws UnsupportedEncodingException { final String charsetName = "US-ASCII"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUsAscii(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expect... |
StringUtils { public static byte[] getBytesUtf16(final String string) { return getBytes(string, Charsets.UTF_16); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final String string, final String charsetName)... | @Test public void testGetBytesUtf16() throws UnsupportedEncodingException { final String charsetName = "UTF-16"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUtf16(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, ac... |
MethodNameParser { @Nullable static OrderUnit parseOrderUnit(String str) { Pattern p = Pattern.compile(ORDER_BY_REGEX); Matcher m = p.matcher(str); if (m.find()) { String tailStr = Strings.firstLetterToLowerCase(str.substring(m.end() - 1)); int size = ORDER_BY.length() + tailStr.length(); String property; OrderType ord... | @Test public void parseOrderUnit() throws Exception { OrderUnit ou = MethodNameParser.parseOrderUnit("AgeAndNameOrderByIdDesc"); assertThat(ou.getProperty(), equalTo("id")); assertThat(ou.getOrderType(), equalTo(OrderType.DESC)); assertThat(ou.getOrderStrSize(), equalTo("OrderByIdDesc".length())); ou = MethodNameParser... |
StringUtils { public static byte[] getBytesUtf16Be(final String string) { return getBytes(string, Charsets.UTF_16BE); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final String string, final String charsetN... | @Test public void testGetBytesUtf16Be() throws UnsupportedEncodingException { final String charsetName = "UTF-16BE"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUtf16Be(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expect... |
StringUtils { public static byte[] getBytesUtf16Le(final String string) { return getBytes(string, Charsets.UTF_16LE); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final String string, final String charsetN... | @Test public void testGetBytesUtf16Le() throws UnsupportedEncodingException { final String charsetName = "UTF-16LE"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUtf16Le(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expect... |
StringUtils { public static byte[] getBytesUtf8(final String string) { return getBytes(string, Charsets.UTF_8); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final String string, final String charsetName); ... | @Test public void testGetBytesUtf8() throws UnsupportedEncodingException { final String charsetName = "UTF-8"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUtf8(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, actua... |
StringUtils { public static byte[] getBytesUnchecked(final String string, final String charsetName) { if (string == null) { return null; } try { return string.getBytes(charsetName); } catch (final UnsupportedEncodingException e) { throw StringUtils.newIllegalStateException(charsetName, e); } } static boolean equals(fi... | @Test public void testGetBytesUncheckedBadName() { try { StringUtils.getBytesUnchecked(STRING_FIXTURE, "UNKNOWN"); Assert.fail("Expected " + IllegalStateException.class.getName()); } catch (final IllegalStateException e) { } }
@Test public void testGetBytesUncheckedNullInput() { Assert.assertNull(StringUtils.getBytesUn... |
StringUtils { private static String newString(final byte[] bytes, final Charset charset) { return bytes == null ? null : new String(bytes, charset); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final Strin... | @Test public void testNewStringBadEnc() { try { StringUtils.newString(BYTES_FIXTURE, "UNKNOWN"); Assert.fail("Expected " + IllegalStateException.class.getName()); } catch (final IllegalStateException e) { } }
@Test public void testNewStringNullInput() { Assert.assertNull(StringUtils.newString(null, "UNKNOWN")); } |
StringUtils { public static String newStringIso8859_1(final byte[] bytes) { return new String(bytes, Charsets.ISO_8859_1); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final String string, final String cha... | @Test public void testNewStringIso8859_1() throws UnsupportedEncodingException { final String charsetName = "ISO-8859-1"; testNewString(charsetName); final String expected = new String(BYTES_FIXTURE, charsetName); final String actual = StringUtils.newStringIso8859_1(BYTES_FIXTURE); Assert.assertEquals(expected, actual)... |
StringUtils { public static String newStringUsAscii(final byte[] bytes) { return new String(bytes, Charsets.US_ASCII); } static boolean equals(final CharSequence cs1, final CharSequence cs2); static byte[] getBytesIso8859_1(final String string); static byte[] getBytesUnchecked(final String string, final String charset... | @Test public void testNewStringUsAscii() throws UnsupportedEncodingException { final String charsetName = "US-ASCII"; testNewString(charsetName); final String expected = new String(BYTES_FIXTURE, charsetName); final String actual = StringUtils.newStringUsAscii(BYTES_FIXTURE); Assert.assertEquals(expected, actual); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.