src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
RepositoryFactory { public <T> ObjectRepository<T> getRepository(NitriteConfig nitriteConfig, Class<T> type) { return getRepository(nitriteConfig, type, null); } RepositoryFactory(CollectionFactory collectionFactory); ObjectRepository<T> getRepository(NitriteConfig nitriteConfig, Class<T> type); @SuppressWarnings("unch... | @Test(expected = ValidationException.class) public void testNullType() { RepositoryFactory factory = new RepositoryFactory(new CollectionFactory(new LockService())); db = TestUtil.createDb(); factory.getRepository(db.getConfig(), null, "dummy"); }
@Test public void testNullCollection() { RepositoryFactory factory = new... |
InMemoryStore extends AbstractNitriteStore<InMemoryConfig> { @Override public boolean isClosed() { return closed; } InMemoryStore(); @Override void openOrCreate(); @Override boolean isClosed(); @Override boolean hasUnsavedChanges(); @Override boolean isReadOnly(); @Override void commit(); @Override void close(); @Overr... | @Test public void testConstructor() { assertFalse((new InMemoryStore()).isClosed()); } |
InMemoryStore extends AbstractNitriteStore<InMemoryConfig> { @Override public boolean hasUnsavedChanges() { return false; } InMemoryStore(); @Override void openOrCreate(); @Override boolean isClosed(); @Override boolean hasUnsavedChanges(); @Override boolean isReadOnly(); @Override void commit(); @Override void close()... | @Test public void testHasUnsavedChanges() { assertFalse((new InMemoryStore()).hasUnsavedChanges()); } |
InMemoryStore extends AbstractNitriteStore<InMemoryConfig> { @Override public boolean isReadOnly() { return false; } InMemoryStore(); @Override void openOrCreate(); @Override boolean isClosed(); @Override boolean hasUnsavedChanges(); @Override boolean isReadOnly(); @Override void commit(); @Override void close(); @Over... | @Test public void testIsReadOnly() { assertFalse((new InMemoryStore()).isReadOnly()); } |
RocksDBModule implements StoreModule { public NitriteStore<?> getStore() { RocksDBStore store = new RocksDBStore(); store.setStoreConfig(storeConfig); return store; } RocksDBModule(String path); @Override Set<NitritePlugin> plugins(); static RocksDBModuleBuilder withConfig(); NitriteStore<?> getStore(); } | @Test public void testConstructor() { assertTrue((new RocksDBModule("path")).getStore() instanceof RocksDBStore); } |
InMemoryStore extends AbstractNitriteStore<InMemoryConfig> { @Override public void close() { closed = true; alert(StoreEvents.Closed); } InMemoryStore(); @Override void openOrCreate(); @Override boolean isClosed(); @Override boolean hasUnsavedChanges(); @Override boolean isReadOnly(); @Override void commit(); @Override... | @Test public void testClose() { InMemoryStore inMemoryStore = new InMemoryStore(); inMemoryStore.close(); assertTrue(inMemoryStore.isClosed()); } |
InMemoryStore extends AbstractNitriteStore<InMemoryConfig> { @Override public boolean hasMap(String mapName) { return nitriteMapRegistry.containsKey(mapName) || nitriteRTreeMapRegistry.containsKey(mapName); } InMemoryStore(); @Override void openOrCreate(); @Override boolean isClosed(); @Override boolean hasUnsavedChang... | @Test public void testHasMap() { assertFalse((new InMemoryStore()).hasMap("mapName")); } |
InMemoryStore extends AbstractNitriteStore<InMemoryConfig> { @Override @SuppressWarnings("unchecked") public <Key, Value> NitriteMap<Key, Value> openMap(String mapName, Class<?> keyType, Class<?> valueType) { if (nitriteMapRegistry.containsKey(mapName)) { return (InMemoryMap<Key, Value>) nitriteMapRegistry.get(mapName)... | @Test public void testOpenMap() { Class<?> keyType = Object.class; Class<?> valueType = Object.class; NitriteMap<Object, Object> actualOpenMapResult = (new InMemoryStore()).openMap("mapName", keyType, valueType); assertEquals("mapName", actualOpenMapResult.getName()); assertEquals(0L, actualOpenMapResult.size()); asser... |
InMemoryStore extends AbstractNitriteStore<InMemoryConfig> { @Override @SuppressWarnings("unchecked") public <Key extends BoundingBox, Value> NitriteRTree<Key, Value> openRTree(String rTreeName, Class<?> keyType, Class<?> valueType) { if (nitriteRTreeMapRegistry.containsKey(rTreeName)) { return (InMemoryRTree<Key, Valu... | @Test public void testOpenRTree() { Class<?> keyType = Object.class; Class<?> valueType = Object.class; assertEquals(0L, (new InMemoryStore()).openRTree("rTreeName", keyType, valueType).size()); } |
InMemoryStore extends AbstractNitriteStore<InMemoryConfig> { @Override public String getStoreVersion() { return "InMemory/" + NITRITE_VERSION; } InMemoryStore(); @Override void openOrCreate(); @Override boolean isClosed(); @Override boolean hasUnsavedChanges(); @Override boolean isReadOnly(); @Override void commit(); @... | @Test public void testGetStoreVersion() { String actualStoreVersion = (new InMemoryStore()).getStoreVersion(); assertEquals(String.join("", "InMemory/", NITRITE_VERSION), actualStoreVersion); } |
InMemoryRTree implements NitriteRTree<Key, Value> { @Override public long size() { return backingMap.size(); } InMemoryRTree(); @Override void add(Key key, NitriteId nitriteId); @Override void remove(Key key, NitriteId nitriteId); @Override RecordStream<NitriteId> findIntersectingKeys(Key key); @Override RecordStream<N... | @Test public void testConstructor() { assertEquals(0L, (new InMemoryRTree<>()).size()); }
@Test public void testSize() { assertEquals(0L, (new InMemoryRTree<>()).size()); } |
InMemoryConfig implements StoreConfig { @Override public final String filePath() { return null; } InMemoryConfig(); @Override final String filePath(); @Override Boolean isReadOnly(); @Override void addStoreEventListener(StoreEventListener listener); } | @Test public void testFilePath() { assertNull((new InMemoryConfig()).filePath()); } |
InMemoryConfig implements StoreConfig { @Override public Boolean isReadOnly() { return false; } InMemoryConfig(); @Override final String filePath(); @Override Boolean isReadOnly(); @Override void addStoreEventListener(StoreEventListener listener); } | @Test public void testIsReadOnly() { assertFalse((new InMemoryConfig()).isReadOnly()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public boolean containsKey(Key key) { if (key == null) { return nullEntryMap.containsKey(NullEntry.getInstance()); } return backingMap.containsKey(key); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Overrid... | @Test public void testContainsKey() { InMemoryMap<Object, Object> inMemoryMap = new InMemoryMap<Object, Object>(null, null); inMemoryMap.put(null, "value"); assertFalse(inMemoryMap.containsKey("key")); }
@Test public void testContainsKey2() { assertFalse((new InMemoryMap<Object, Object>("mapName", null)).containsKey("k... |
RocksDBConfig implements StoreConfig { @Override public final boolean isInMemory() { return false; } RocksDBConfig(); @Override void addStoreEventListener(StoreEventListener listener); @Override final boolean isInMemory(); @Override final Boolean isReadOnly(); } | @Test public void testConstructor() { RocksDBConfig actualRocksDBConfig = new RocksDBConfig(); assertFalse(actualRocksDBConfig.isInMemory()); assertNull(actualRocksDBConfig.options()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public Value get(Key key) { if (key == null) { return nullEntryMap.get(NullEntry.getInstance()); } return backingMap.get(key); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Override Value get(Key key); @Ove... | @Test public void testGet() { assertNull((new InMemoryMap<Object, Object>("mapName", null)).get("key")); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public RecordStream<Value> values() { return RecordStream.fromCombined(backingMap.values(), nullEntryMap.values()); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Override Value get(Key key); @Override Nitri... | @Test public void testValues() { assertTrue((new InMemoryMap<Object, Object>("mapName", null)).values().isEmpty()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public Value remove(Key key) { Value value; if (key == null) { value = nullEntryMap.remove(NullEntry.getInstance()); } else { value = backingMap.remove(key); } updateLastModifiedTime(); return value; } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @... | @Test public void testRemove() { InMemoryMap<Object, Object> inMemoryMap = new InMemoryMap<Object, Object>("", null); assertNull(inMemoryMap.remove("key")); assertEquals(0L, inMemoryMap.size()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public RecordStream<Key> keySet() { return RecordStream.fromIterable(() -> new Iterator<Key>() { final Iterator<Key> keyIterator = backingMap.keySet().iterator(); final Iterator<NullEntry> nullEntryIterator = nullEntryMap.keySet().iterator(); @Override public bo... | @Test public void testKeySet() { assertTrue((new InMemoryMap<Object, Object>("mapName", null)).keySet().isEmpty()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public void put(Key key, Value value) { notNull(value, "value cannot be null"); if (key == null) { nullEntryMap.put(NullEntry.getInstance(), value); } else { Map.Entry<Key, Value> firstEntry = backingMap.firstEntry(); if (firstEntry != null) { if (!firstEntry.ge... | @Test public void testPut() { InMemoryMap<Object, Object> inMemoryMap = new InMemoryMap<Object, Object>(null, null); inMemoryMap.put(null, "value"); assertEquals(1L, inMemoryMap.size()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public long size() { return backingMap.size() + nullEntryMap.size(); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Override Value get(Key key); @Override NitriteStore<?> getStore(); @Override void clear(); ... | @Test public void testSize() { assertEquals(0L, (new InMemoryMap<Object, Object>("mapName", null)).size()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public Value putIfAbsent(Key key, Value value) { notNull(value, "value cannot be null"); Value v = get(key); if (v == null) { put(key, value); } updateLastModifiedTime(); return v; } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean co... | @Test public void testPutIfAbsent() { InMemoryMap<Object, Object> inMemoryMap = new InMemoryMap<Object, Object>(null, null); assertNull(inMemoryMap.putIfAbsent(null, "value")); assertEquals(1L, inMemoryMap.size()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public RecordStream<Pair<Key, Value>> entries() { return RecordStream.fromIterable(() -> new Iterator<Pair<Key, Value>>() { private final Iterator<Map.Entry<Key, Value>> entryIterator = backingMap.entrySet().iterator(); private final Iterator<Map.Entry<NullEntry... | @Test public void testEntries() { assertTrue((new InMemoryMap<Object, Object>("mapName", null)).entries().isEmpty()); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public Key higherKey(Key key) { if (key == null) { return null; } return backingMap.higherKey(key); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Override Value get(Key key); @Override NitriteStore<?> getSt... | @Test public void testHigherKey() { assertNull((new InMemoryMap<Object, Object>("mapName", null)).higherKey("key")); assertNull((new InMemoryMap<Object, Object>("mapName", null)).higherKey(null)); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public Key ceilingKey(Key key) { if (key == null) { return null; } return backingMap.ceilingKey(key); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Override Value get(Key key); @Override NitriteStore<?> get... | @Test public void testCeilingKey() { assertNull((new InMemoryMap<Object, Object>("mapName", null)).ceilingKey("key")); assertNull((new InMemoryMap<Object, Object>("mapName", null)).ceilingKey(null)); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public Key lowerKey(Key key) { if (key == null) { return null; } return backingMap.lowerKey(key); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Override Value get(Key key); @Override NitriteStore<?> getStor... | @Test public void testLowerKey() { InMemoryMap<Object, Object> inMemoryMap = new InMemoryMap<Object, Object>(null, null); inMemoryMap.put("key", "value"); assertNull(inMemoryMap.lowerKey("key")); }
@Test public void testLowerKey2() { assertNull((new InMemoryMap<Object, Object>("mapName", null)).lowerKey(null)); }
@Test... |
InMemoryMap implements NitriteMap<Key, Value> { @Override public Key floorKey(Key key) { if (key == null) { return null; } return backingMap.floorKey(key); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Override Value get(Key key); @Override NitriteStore<?> getStor... | @Test public void testFloorKey() { assertNull((new InMemoryMap<Object, Object>("mapName", null)).floorKey("key")); assertNull((new InMemoryMap<Object, Object>("mapName", null)).floorKey(null)); } |
InMemoryMap implements NitriteMap<Key, Value> { @Override public boolean isEmpty() { return backingMap.isEmpty() && nullEntryMap.isEmpty(); } InMemoryMap(String mapName, NitriteStore<?> nitriteStore); @Override boolean containsKey(Key key); @Override Value get(Key key); @Override NitriteStore<?> getStore(); @Override v... | @Test public void testIsEmpty() { assertTrue((new InMemoryMap<Object, Object>("mapName", null)).isEmpty()); } |
DatabaseMetaData { public Document getInfo() { return Document.createDocument() .put("createTime", createTime) .put("storeVersion", storeVersion) .put("nitriteVersion", nitriteVersion) .put("schemaVersion", schemaVersion); } DatabaseMetaData(Document document); Document getInfo(); } | @Test public void testGetInfo() { DatabaseMetaData databaseMetaData = new DatabaseMetaData(); databaseMetaData.setNitriteVersion("1.0.2"); assertEquals(4, databaseMetaData.getInfo().size()); }
@Test public void testGetInfo2() { assertEquals(4, (new DatabaseMetaData()).getInfo().size()); } |
StringUtils { public static boolean isNullOrEmpty(String value) { return value == null || "".equalsIgnoreCase(value); } private StringUtils(); static boolean isNullOrEmpty(String value); static boolean isNullOrEmpty(CharSequence value); static String join(String separator, String[] strings); static StringTokenizer str... | @Test public void testIsNullOrEmpty() { assertTrue(isNullOrEmpty(null)); assertTrue(isNullOrEmpty("")); assertFalse(isNullOrEmpty("a")); } |
ValidationUtils { public static void notEmpty(String value, String message) { if (isNullOrEmpty(value)) { throw new ValidationException(message); } } private ValidationUtils(); static void notEmpty(String value, String message); static void notEmpty(CharSequence value, String message); static void notEmpty(Collection<... | @Test public void testNotEmpty() { boolean exception = false; try { notEmpty("", "empty string"); } catch (ValidationException e) { exception = true; assertEquals(e.getMessage(), "empty string"); } finally { assertTrue(exception); } }
@Test public void testCharSequenceNotEmpty() { CharSequence cs = ""; boolean invalid ... |
ValidationUtils { public static void notNull(Object value, String message) { if (value == null) { throw new ValidationException(message); } } private ValidationUtils(); static void notEmpty(String value, String message); static void notEmpty(CharSequence value, String message); static void notEmpty(Collection<?> value... | @Test public void testNotNull() { boolean exception = false; String a = null; try { notNull(a, "null string"); } catch (ValidationException e) { exception = true; assertEquals(e.getMessage(), "null string"); } finally { assertTrue(exception); } } |
Comparables { @SuppressWarnings({"rawtypes", "unchecked"}) public static int compare(Comparable first, Comparable second) { if (first instanceof Number && second instanceof Number) { Number number1 = (Number) first; Number number2 = (Number) second; int result = Numbers.compare(number1, number2); if (!first.getClass().... | @Test public void testCompare() { MutableByte first = new MutableByte(); assertEquals(0, Comparables.compare(first, new MutableByte())); }
@Test public void testCompare2() { ClassKey first = new ClassKey(Object.class); assertEquals(0, Comparables.compare(first, new ClassKey(Object.class))); }
@Test public void testComp... |
Iterables { public static <T> T firstOrNull(Iterable<T> iterable) { if (iterable == null) return null; Iterator<T> iterator = iterable.iterator(); if (iterator.hasNext()) { return iterator.next(); } return null; } private Iterables(); static T firstOrNull(Iterable<T> iterable); static List<T> toList(Iterable<T> iterab... | @Test public void testFirstOrNull() { assertNull(Iterables.firstOrNull(new ArrayList<>())); }
@Test public void testFirstOrNull2() { ArrayList<Object> objectList = new ArrayList<>(); objectList.add(null); assertNull(Iterables.firstOrNull(objectList)); }
@Test public void testFirstOrDefault() { assertNull(firstOrNull(ne... |
Iterables { public static <T> List<T> toList(Iterable<T> iterable) { if (iterable instanceof List) return (List<T>) iterable; List<T> list = new ArrayList<>(); for (T item : iterable) { list.add(item); } return Collections.unmodifiableList(list); } private Iterables(); static T firstOrNull(Iterable<T> iterable); stati... | @Test public void testToList() { ArrayList<Object> objectList = new ArrayList<Object>(); List<Object> actualToListResult = Iterables.toList(objectList); assertSame(objectList, actualToListResult); assertEquals(0, actualToListResult.size()); } |
NitriteBuilder { public NitriteBuilder loadModule(NitriteModule module) { this.nitriteConfig.loadModule(module); return this; } NitriteBuilder(); NitriteBuilder fieldSeparator(String separator); NitriteBuilder loadModule(NitriteModule module); NitriteBuilder addMigrations(Migration... migrations); NitriteBuilder schema... | @Test public void testNitriteMapper() { NitriteBuilder builder = Nitrite.builder(); builder.loadModule(module(new CustomNitriteMapper())); NitriteConfig config = builder.getNitriteConfig(); assertNotNull(config.nitriteMapper()); } |
Iterables { public static <T> Set<T> toSet(Iterable<T> iterable) { if (iterable instanceof Set) return (Set<T>) iterable; Set<T> set = new LinkedHashSet<>(); for (T item : iterable) { set.add(item); } return Collections.unmodifiableSet(set); } private Iterables(); static T firstOrNull(Iterable<T> iterable); static Lis... | @Test public void testToSet() { ArrayList<Object> objectList = new ArrayList<>(); objectList.add("foo"); assertEquals(1, Iterables.toSet(objectList).size()); } |
Iterables { @SuppressWarnings("unchecked") public static <T> T[] toArray(Iterable<T> iterable, Class<T> type) { T[] dummy = (T[]) Array.newInstance(type, 0); if (iterable instanceof Collection) { return ((Collection<T>) iterable).toArray(dummy); } else { List<T> list = new ArrayList<>(); for (T item : iterable) { list.... | @Test public void testToArray() { final List<String> list = new ArrayList<String>() {{ add("a"); add("b"); }}; assertArrayEquals(toArray(new ArrayList<String>() {{ add("a"); add("b"); }}), new String[]{"a", "b"}); assertArrayEquals(toArray(list), new String[]{"a", "b"}); }
@Test public void testToArray2() { Class type ... |
Iterables { public static <T> boolean arrayContains(T[] array, T element) { for (T item : array) { if (item.equals(element)) return true; } return false; } private Iterables(); static T firstOrNull(Iterable<T> iterable); static List<T> toList(Iterable<T> iterable); static Set<T> toSet(Iterable<T> iterable); @SuppressW... | @Test public void testArrayContains() { assertTrue(Iterables.arrayContains(new Object[]{"element"}, "element")); assertFalse(Iterables.arrayContains(new Object[]{"array"}, "element")); } |
Iterables { @SafeVarargs public static <T> List<T> listOf(T... items) { if (items != null) { return Arrays.asList(items); } return Collections.emptyList(); } private Iterables(); static T firstOrNull(Iterable<T> iterable); static List<T> toList(Iterable<T> iterable); static Set<T> toSet(Iterable<T> iterable); @Suppres... | @Test public void testListOf() { assertEquals(1, Iterables.<Object>listOf("items").size()); assertEquals(0, Iterables.listOf( null).size()); } |
Iterables { public static long size(Iterable<?> iterable) { if (iterable instanceof Collection) { return ((Collection<?>) iterable).size(); } long count = 0; for (Object ignored : iterable) { count++; } return count; } private Iterables(); static T firstOrNull(Iterable<T> iterable); static List<T> toList(Iterable<T> i... | @Test public void testSize() { assertEquals(0L, Iterables.size(new ArrayList<>())); } |
ObjectUtils { public static <T> String findRepositoryName(Class<T> type, String key) { return findRepositoryName(getEntityName(type), key); } private ObjectUtils(); static String getEntityName(Class<T> type); static String findRepositoryName(Class<T> type, String key); static String findRepositoryName(String entityNam... | @Test public void testFindRepositoryName() { assertEquals("entityName", ObjectUtils.findRepositoryName("entityName", "")); assertEquals("entityName+key", ObjectUtils.findRepositoryName("entityName", "key")); assertEquals("java.lang.Object+key", ObjectUtils.findRepositoryName(Object.class, "key")); assertEquals("java.la... |
ST2084 implements TransferCharacteristics { @Override public double fromLinear(double l) { if (l <= 0.0) return 0.0; double ln = pow(l, N); double a = C1 + C2 * ln; double b = 1 + C3 * ln; return pow(a / b, M); } protected ST2084(); ST2084(int code, String name); @Override int code(); @Override String toString(); @Ov... | @Test public void checkFromLinear() { assertEquals(0.0, PQ.fromLinear(-MAX_VALUE)); assertEquals(0.0, PQ.fromLinear(-1.0)); assertEquals(0.0, PQ.fromLinear(0.0), 1e-6); assertEquals(1.0, PQ.fromLinear(1.0)); assertEquals(1.99, PQ.fromLinear(MAX_VALUE), 1e-2); } |
RbspWriter { public void u1(boolean flag) { int pos = buf.checkWrite(1); int index = getByteIndex(pos); int shift = getByteShift(pos); if (flag) { buf.bytes[index] |= (0x80 >> shift); } else { buf.bytes[index] &= ~(0x80 >> shift); } } RbspWriter(NalBuffer buf); RbspWriter(byte[] rbsp); byte[] bytes(); boolean isByteAl... | @Test public void testWriteU1() { NalBuffer buf = new NalBuffer(); RbspWriter writer = new RbspWriter(buf); range(0, 2).flatMap(i -> IntStream.of(0, 1, 0, 0, 1, 1, 0, 1)) .forEach(b -> writer.u1(b != 0)); assertEquals(16, buf.pos); range(0, 2).forEach(i -> assertEquals(0b01001101, buf.bytes[i])); } |
RbspWriter { public void u3(int value) { writeInt(3, value); } RbspWriter(NalBuffer buf); RbspWriter(byte[] rbsp); byte[] bytes(); boolean isByteAligned(); static int countUEbits(int ue); void ue(int ue); void se(int se); static int se2ue(int se); void writeBytes(byte[] bytes); void writeTrailingBits(byte[] bytes); vo... | @Test public void testWriteU3() { NalBuffer buf = new NalBuffer(); RbspWriter writer = new RbspWriter(buf); writer.u3(0b010); writer.u3(0b011); writer.u3(0b010); writer.u3(0b100); writer.u3(0b110); writer.u3(0b101); writer.u3(0b001); writer.u3(0b101); assertEquals(24, buf.pos); range(0, 3).forEach(i -> assertEquals(0b0... |
RbspWriter { public void u20(int value) { writeInt(20, value); } RbspWriter(NalBuffer buf); RbspWriter(byte[] rbsp); byte[] bytes(); boolean isByteAligned(); static int countUEbits(int ue); void ue(int ue); void se(int se); static int se2ue(int se); void writeBytes(byte[] bytes); void writeTrailingBits(byte[] bytes); ... | @Test public void testWriteU20() { NalBuffer buf = new NalBuffer(); RbspWriter writer = new RbspWriter(buf); writer.u20(0b01001101010011010100); writer.u20(0b11010100110101001101); assertEquals(40, buf.pos); range(0, 5).forEach(i -> assertEquals(0b01001101, buf.bytes[i])); } |
RbspWriter { public void writeULong(int bits, long value) { assert (bits < 64); writeLong(bits, value); } RbspWriter(NalBuffer buf); RbspWriter(byte[] rbsp); byte[] bytes(); boolean isByteAligned(); static int countUEbits(int ue); void ue(int ue); void se(int se); static int se2ue(int se); void writeBytes(byte[] bytes... | @Test public void testWriteULong() { NalBuffer buf = new NalBuffer(); RbspWriter writer = new RbspWriter(buf); writer.writeULong(44, 0b01001101010011010100110101001101010011010100L); writer.writeULong(36, 0b110101001101010011010100110101001101L); assertEquals(80, buf.pos); range(0, 10).forEach(i -> assertEquals(0b01001... |
RbspWriter { public void ue(int ue) { int leadingZeroBits = leadingUEbits(ue); u(leadingZeroBits + 1, 1); u(leadingZeroBits, ue + 1 - (1 << leadingZeroBits)); } RbspWriter(NalBuffer buf); RbspWriter(byte[] rbsp); byte[] bytes(); boolean isByteAligned(); static int countUEbits(int ue); void ue(int ue); void se(int se);... | @Test public void testUE() { assertEquals(0, se2ue(0)); assertEquals(1, se2ue(1)); assertEquals(2, se2ue(-1)); assertEquals(3, se2ue(2)); assertEquals(4, se2ue(-2)); assertEquals(5, se2ue(3)); assertEquals(6, se2ue(-3)); } |
ArrayMath { public static String toHexString(byte[] bytes) { return toHexString(bytes, 0, bytes.length); } private ArrayMath(); static double[] add(double[] in, double[] out, int mul); static int[] multiply(int[] in, int[] out, int mul); static double[] multiply(double[] in, double[] out, double mul); static double[] ... | @Test public void testToHexString() { assertEquals("", toHexString(bytes())); assertEquals("C5", toHexString(bytes(0xC5))); assertEquals("FEDCBA9876543210", toHexString(bytes( 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10))); } |
ArrayMath { public static int fromHexChar(char ch) { if ('0' <= ch && ch <= '9') return ch - '0'; if ('A' <= ch && ch <= 'F') return ch - 'A' + 10; return -1; } private ArrayMath(); static double[] add(double[] in, double[] out, int mul); static int[] multiply(int[] in, int[] out, int mul); static double[] multiply(do... | @Test public void testFromHexChar() { assertEquals(0, fromHexChar('0')); assertEquals(5, fromHexChar('5')); assertEquals(9, fromHexChar('9')); assertEquals(0xA, fromHexChar('A')); assertEquals(0xD, fromHexChar('D')); assertEquals(0xF, fromHexChar('F')); assertEquals(-1, fromHexChar('_')); } |
ArrayMath { public static byte[] fromHexString(String chars) { var out = new ByteArrayOutputStream(chars.length() / 2); for (int i = 0; i < chars.length();) { int msb = fromHexChar(chars.charAt(i++)); if (msb < 0) { continue; } int lsb = fromHexChar(chars.charAt(i++)); if (lsb < 0) throw new IllegalArgumentException( "... | @Test public void testFromHexString() { assertArrayEquals(bytes(0xC5, 0xC5), fromHexString("C5C5")); assertArrayEquals(bytes(0xC5, 0xC5), fromHexString("_C5_C5_")); assertThrows(IllegalArgumentException.class, () -> fromHexString("C_")); assertThrows(IllegalArgumentException.class, () -> fromHexString("C_5")); assertTh... |
Matrix3x3 { public Matrix3x3 invert() { double[][] v = values; double d00 = v[1][1] * v[2][2] - v[1][2] * v[2][1]; double d01 = v[1][2] * v[2][0] - v[1][0] * v[2][2]; double d02 = v[1][0] * v[2][1] - v[1][1] * v[2][0]; double d = v[0][0] * d00 + v[0][1] * d01 + v[0][2] * d02; return new Matrix3x3( d00 / d, (v[0][2] * v... | @Test public void invert() { var a = new Matrix3x3( 1.0, 2.0, 3.0, 2.0, 5.0, 3.0, 1.0, 0.0, 8.0); var b = a.invert(); var expected = new Matrix3x3( -40.0, 16.0, 9.0, 13.0, -5.0, -3.0, 5.0, -2.0, -1.0); assertArrayEquals(expected.values[0], b.values[0], MIN_VALUE); assertArrayEquals(expected.values[1], b.values[1], MIN_... |
Matrix3x3 { public Matrix3x3 multiply(double multiplier) { double[][] m = new double[3][]; for (int row = 0; row < 3; row++) { double[] dstRow = m[row] = new double[3]; double[] srcRow = values[row]; for (int col = 0; col < 3; col++) { dstRow[col] = srcRow[col] * multiplier; } } return new Matrix3x3(m); } private Matr... | @Test public void multiply() { var a = new Matrix3x3( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); var b = a.multiply(a); var expected = new Matrix3x3( 30.0, 36.0, 42.0, 66.0, 81.0, 96.0, 102.0, 126.0, 150.0); assertArrayEquals(expected.values[0], b.values[0]); assertArrayEquals(expected.values[1], b.values[1]); asser... |
ST2084 implements TransferCharacteristics { @Override public double toLinear(double v) { if (v <= 0.0) return 0.0; double vm = pow(v, 1.0 / M); double a = vm - C1; if (a <= 0.0) return 0.0; double b = C2 - C3 * vm; return b <= 0.0 ? POSITIVE_INFINITY : pow(a / b, 1.0 / N); } protected ST2084(); ST2084(int code, Strin... | @Test public void checkToLinear() { assertEquals(0.0, PQ.toLinear(-MAX_VALUE)); assertEquals(0.0, PQ.toLinear(-1.0)); assertEquals(0.0, PQ.toLinear(0.0)); assertEquals(92.24570899406527 / L_MAX, PQ.toLinear(0.5), 1e-14); assertEquals(1.0, PQ.toLinear(1.0)); assertEquals(7e17, PQ.toLinear(1.99), 2e16); assertEquals(POSI... |
RbspReader { public boolean u1() { int pos = buf.checkRead(1); int index = getByteIndex(pos); int shift = getByteShift(pos); return (buf.bytes[index] & (0x80 >> shift)) != 0; } RbspReader(NalBuffer buf); RbspReader(byte[] rbsp, int offset, int length); int available(); boolean isByteAligned(); int ue(); int se(); stat... | @Test public void uFlag() { var in = reader(0b01001101, 0b01001101); for (int i = 0; i < 2; i++) { assertEquals(false, in.u1()); assertEquals(true, in.u1()); assertEquals(false, in.u1()); assertEquals(false, in.u1()); assertEquals(true, in.u1()); assertEquals(true, in.u1()); assertEquals(false, in.u1()); assertEquals(t... |
RbspReader { public byte u3() { return readUByte(3); } RbspReader(NalBuffer buf); RbspReader(byte[] rbsp, int offset, int length); int available(); boolean isByteAligned(); int ue(); int se(); static int ue2se(int ue); byte[] readBytes(int size); byte[] readTrailingBits(); boolean u1(); byte u2(); byte u3(); byte u4()... | @Test public void uByte() { var in = reader(0b01001101, 0b01001101, 0b01001101); assertEquals(0b010, in.u3()); assertEquals(0b011, in.u3()); assertEquals(0b010, in.u3()); assertEquals(0b100, in.u3()); assertEquals(0b110, in.u3()); assertEquals(0b101, in.u3()); assertEquals(0b001, in.u3()); assertEquals(0b101, in.u3());... |
RbspReader { public byte i3() { return readByte(3); } RbspReader(NalBuffer buf); RbspReader(byte[] rbsp, int offset, int length); int available(); boolean isByteAligned(); int ue(); int se(); static int ue2se(int ue); byte[] readBytes(int size); byte[] readTrailingBits(); boolean u1(); byte u2(); byte u3(); byte u4();... | @Test public void iByte() { var in = reader(0b01001101, 0b01001101, 0b01001101); assertEquals((byte) 0b00000_010, in.i3()); assertEquals((byte) 0b00000_011, in.i3()); assertEquals((byte) 0b00000_010, in.i3()); assertEquals((byte) 0b11111_100, in.i3()); assertEquals((byte) 0b11111_110, in.i3()); assertEquals((byte) 0b11... |
RbspReader { public int u20() { return readUInt(20); } RbspReader(NalBuffer buf); RbspReader(byte[] rbsp, int offset, int length); int available(); boolean isByteAligned(); int ue(); int se(); static int ue2se(int ue); byte[] readBytes(int size); byte[] readTrailingBits(); boolean u1(); byte u2(); byte u3(); byte u4()... | @Test public void uInt() { var in = reader(0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101); assertEquals(0b01001101010011010100, in.u20()); assertEquals(0b11010100110101001101, in.u20()); } |
RbspReader { public int i20() { return readInt(20); } RbspReader(NalBuffer buf); RbspReader(byte[] rbsp, int offset, int length); int available(); boolean isByteAligned(); int ue(); int se(); static int ue2se(int ue); byte[] readBytes(int size); byte[] readTrailingBits(); boolean u1(); byte u2(); byte u3(); byte u4();... | @Test public void iInt() { var in = reader(0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101); assertEquals(0b000000000000_01001101010011010100, in.i20()); assertEquals(0b111111111111_11010100110101001101, in.i20()); } |
RbspReader { public long readULong(int bits) { assert (bits < 64); return readLong(bits, false); } RbspReader(NalBuffer buf); RbspReader(byte[] rbsp, int offset, int length); int available(); boolean isByteAligned(); int ue(); int se(); static int ue2se(int ue); byte[] readBytes(int size); byte[] readTrailingBits(); b... | @Test public void uLong() { var in = reader(0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101); assertEquals(0b01001101010011010100110101001101010011010100L, in.readULong(44)); assertEquals(0b110101001101010011010100110101001101L, in.readULong(36)); } |
RbspReader { public long readLong(int bits) { assert (bits <= 64); return readLong(bits, true); } RbspReader(NalBuffer buf); RbspReader(byte[] rbsp, int offset, int length); int available(); boolean isByteAligned(); int ue(); int se(); static int ue2se(int ue); byte[] readBytes(int size); byte[] readTrailingBits(); bo... | @Test public void iLong() { var in = reader(0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101, 0b01001101); assertEquals( 0b00000000000000000000_01001101010011010100110101001101010011010100L, in.readLong(44)); assertEquals( 0b1111111111111111111111111111_11010100... |
RbspReader { public int se() { return ue2se(ue()); } RbspReader(NalBuffer buf); RbspReader(byte[] rbsp, int offset, int length); int available(); boolean isByteAligned(); int ue(); int se(); static int ue2se(int ue); byte[] readBytes(int size); byte[] readTrailingBits(); boolean u1(); byte u2(); byte u3(); byte u4(); ... | @Test public void testSE() { assertEquals(0, ue2se(0)); assertEquals(1, ue2se(1)); assertEquals(-1, ue2se(2)); assertEquals(2, ue2se(3)); assertEquals(-2, ue2se(4)); assertEquals(3, ue2se(5)); assertEquals(-3, ue2se(6)); } |
TensorflowProcessorProperties { @NotNull public Resource getModelLocation() { return modelLocation; } @NotNull String getOutputName(); void setOutputName(String outputName); @NotNull Resource getModelLocation(); void setModelLocation(Resource modelLocation); int getOutputIndex(); void setOutputIndex(int outputIndex); ... | @Test public void modelLocationCanBeCustomized() { EnvironmentTestUtils.addEnvironment(context, "tensorflow.modelLocation:/remote"); context.register(Conf.class); context.refresh(); TensorflowProcessorProperties properties = context.getBean(TensorflowProcessorProperties.class); assertThat(properties.getModelLocation(),... |
TensorflowProcessorProperties { @NotNull public String getOutputName() { return outputName; } @NotNull String getOutputName(); void setOutputName(String outputName); @NotNull Resource getModelLocation(); void setModelLocation(Resource modelLocation); int getOutputIndex(); void setOutputIndex(int outputIndex); boolean ... | @Test public void outputNameCanBeCustomized() { EnvironmentTestUtils.addEnvironment(context, "tensorflow.outputName:output1"); context.register(Conf.class); context.refresh(); TensorflowProcessorProperties properties = context.getBean(TensorflowProcessorProperties.class); assertThat(properties.getOutputName(), equalTo(... |
TensorflowProcessorProperties { public int getOutputIndex() { return outputIndex; } @NotNull String getOutputName(); void setOutputName(String outputName); @NotNull Resource getModelLocation(); void setModelLocation(Resource modelLocation); int getOutputIndex(); void setOutputIndex(int outputIndex); boolean isSaveOutp... | @Test public void outputIndexCanBeCustomized() { EnvironmentTestUtils.addEnvironment(context, "tensorflow.outputIndex:666"); context.register(Conf.class); context.refresh(); TensorflowProcessorProperties properties = context.getBean(TensorflowProcessorProperties.class); assertThat(properties.getOutputIndex(), equalTo(6... |
TensorflowProcessorProperties { public boolean isSaveOutputInHeader() { return saveOutputInHeader; } @NotNull String getOutputName(); void setOutputName(String outputName); @NotNull Resource getModelLocation(); void setModelLocation(Resource modelLocation); int getOutputIndex(); void setOutputIndex(int outputIndex); b... | @Test public void saveOutputInHeaderCanBeCustomized() { EnvironmentTestUtils.addEnvironment(context, "tensorflow.saveOutputInHeader:false"); context.register(Conf.class); context.refresh(); TensorflowProcessorProperties properties = context.getBean(TensorflowProcessorProperties.class); assertFalse(properties.isSaveOutp... |
LabelImageProcessorProperties { @NotNull public Resource getLabelsLocation() { return labelsLocation; } @NotNull Resource getLabelsLocation(); void setLabelsLocation(Resource labelsLocation); int getAlternativesLength(); void setAlternativesLength(int alternativesLength); } | @Test public void labelsLocationCanBeCustomized() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "inception.labelsLocation:/remote"); context.register(Conf.class); context.refresh(); LabelImageProcessorProperties properties = context... |
LabelImageProcessorProperties { public int getAlternativesLength() { return alternativesLength; } @NotNull Resource getLabelsLocation(); void setLabelsLocation(Resource labelsLocation); int getAlternativesLength(); void setAlternativesLength(int alternativesLength); } | @Test public void alternativesLengthCanBeCustomized() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "inception.labelsLocation:/remote"); EnvironmentTestUtils.addEnvironment(context, "inception.alternativesLength:5"); context.registe... |
TwitterSentimentProcessorProperties { @NotNull public Resource getVocabularyLocation() { return vocabularyLocation; } @NotNull Resource getVocabularyLocation(); void setVocabularyLocation(Resource vocabularyLocation); } | @Test public void vocabularyLocationCanBeCustomized() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "inception.vocabularyLocation:/remote"); context.register(Conf.class); context.refresh(); TwitterSentimentProcessorProperties proper... |
HttpReporterMetricsExporter extends ReporterMetricsExporter { @Override public void close() { if (server != null) server.stop(); } @Override void start(ReporterMetrics metrics); @Override void close(); } | @Test public void jsonFormat() throws IOException { ReporterMetricsExporter exporter = new HttpReporterMetricsExporter(); ReporterMetrics metrics = InMemoryReporterMetrics.instance(exporter); Request request = new Request.Builder() .url("http: .build(); Response response = client.newCall(request).execute(); assertEqual... |
QueueManager { AbstractSizeBoundedQueue getOrCreate(MessageKey key) { AbstractSizeBoundedQueue queue = keyToQueue.get(key); if (queue == null) { queue = queueFactory.newQueue(pendingMaxMessages, overflowStrategy, key); AbstractSizeBoundedQueue prev = keyToQueue.putIfAbsent(key, queue); if (prev == null) { timer.newTime... | @Test public void getAfterCreate() { AbstractSizeBoundedQueue q = manager.getOrCreate(testKey()); assertEquals(q, manager.getOrCreate(testKey())); }
@Test public void keepAlive() throws InterruptedException { MessageKey key = testKey(); AbstractSizeBoundedQueue q = manager.getOrCreate(key); TimeUnit.MILLISECONDS.sleep(... |
AsyncSenderAdaptor implements AsyncSender<R> { @Override public CompositeFuture send(final List<MessagePromise<R>> promises) { logger.debug("Sending {} messages.", promises.size()); final List<M> messages = extractMessages(promises); executor.execute(new Runnable() { @Override public void run() { try { List<R> result =... | @Test public void sendingSuccess() throws InterruptedException { FakeSender sender = new FakeSender(); CountDownLatch countDown = new CountDownLatch(1); adaptor = new AsyncSenderAdaptor<>(sender, 1); CompositeFuture future = adaptor.send( Arrays.asList(newPromise(0), newPromise(1), newPromise(2))); future.addListener(f... |
AsyncSenderAdaptor implements AsyncSender<R> { @Override public void close() throws IOException { synchronized (AsyncSenderAdaptor.class) { if (executorHolder != null && executorHolder.close()) { executorHolder = null; } } delegate.close(); } AsyncSenderAdaptor(Sender<M, R> delegate, int sharedSenderThreads); @Override... | @Test public void refCount() throws IOException { FakeSender sender = new FakeSender(); adaptor = new AsyncSenderAdaptor<>(sender, 1); assertEquals(1, AsyncSenderAdaptor.executorHolder.refCount()); AsyncSenderAdaptor adaptor2 = new AsyncSenderAdaptor<>(sender, 1); assertEquals(2, AsyncSenderAdaptor.executorHolder.refCo... |
BatchJdbcTemplate { public MessageFuture<Integer> update(String sql) throws DataAccessException { return reporter.report(Sql.builder().sql(sql).build()); } @VisibleForTesting BatchJdbcTemplate(JdbcTemplate delegate, final Reporter<Sql, Integer> reporter); @SuppressWarnings("unchecked") BatchJdbcTemplate(JdbcTemplate ... | @Test public void updateFailed() throws InterruptedException { SenderProxy sender = new SenderProxy(new JdbcTemplateSender(underlying)); RuntimeException ex = new RuntimeException(); sender.onMessages(messages -> { throw ex; }); reporter = AsyncReporter.builder(sender).messageTimeout(10, TimeUnit.MILLISECONDS).build();... |
FlushSynchronizer { boolean offer(AbstractSizeBoundedQueue q) { if (q.ready) { return false; } q.ready = true; boolean result = queue.offer(q); if (blocker.tryLock()) { try { if (blocker.hasWaiters(notEmpty)) { notEmpty.signalAll(); } } finally { blocker.unlock(); } } return result; } } | @Test public void oneQueueShouldNotBeOfferedTwice() { BlockingSizeBoundedQueue q = new BlockingSizeBoundedQueue(1, Strategy.DropTail); assertTrue(synchronizer.offer(q)); assertFalse(synchronizer.offer(q)); } |
FlushSynchronizer { AbstractSizeBoundedQueue poll(long timeoutNanos) { boolean wasInterrupted = false; AbstractSizeBoundedQueue first; blocker.lock(); try { while ((first = queue.poll()) == null) { if (timeoutNanos <= 0L) return null; try { timeoutNanos = notEmpty.awaitNanos(timeoutNanos); } catch (InterruptedException... | @Test public void returnNullIfExceedsTimeout() throws InterruptedException { CountDownLatch countDown = new CountDownLatch(1); new Thread(() -> { assertNull(synchronizer.poll(TimeUnit.MILLISECONDS.toNanos(50))); countDown.countDown(); }).start(); assertFalse(countDown.await(40, TimeUnit.MILLISECONDS)); assertTrue(count... |
AbstractSizeBoundedQueue { abstract void offer(MessagePromise<?> promise); AbstractSizeBoundedQueue(int maxSize, MessageKey key); } | @Test public void offer_failsWhenFull_size() { AtomicBoolean success = new AtomicBoolean(true); for (int i = 0; i < queue.maxSize; i++) { queue.offer(newPromise(i)); assertTrue(success.get()); } MessagePromise<Integer> shouldFail = newPromise(0); shouldFail.addListener(future -> success.set(false)); queue.offer(shouldF... |
FileEntryFactory { @SuppressWarnings("unchecked") List<Substitutable> getFileElements(FileEntry fileEntry) { String pathEntries[] = fileEntry.getName().split(","); List<Substitutable> substituables = null; List<File> retrievedFiles = null; for(String pathEntry : pathEntries) { String isRegex = fileEntry.getRegex(); if(... | @Test public void testGetFileFromDir() { FileEntry fileEntry = new FileEntry(); fileEntry.setName(_classFile.getParentFile().getAbsolutePath()); List<Substitutable> substitutables = _factory.getFileElements(fileEntry); Assert.assertTrue(!substitutables.isEmpty()); boolean fileFound = false; for (Substitutable substitut... |
UnixUser { public String getUserName() { return userName; } UnixUser(String userName, Passwd pwd); UnixUser(String userName); protected UnixUser(String userName, String gecos, String dir, String shell, int uid, int gid, Set<String> groups); String getUserName(); int getUID(); int getGID(); String getGecos(); String g... | @Test public void testGetUserName() { Assert.assertEquals("root", user.getUserName()); } |
UnixUser { public String getDir() { return dir; } UnixUser(String userName, Passwd pwd); UnixUser(String userName); protected UnixUser(String userName, String gecos, String dir, String shell, int uid, int gid, Set<String> groups); String getUserName(); int getUID(); int getGID(); String getGecos(); String getDir(); S... | @Test public void testGetDir() { Assert.assertNotNull(user.getDir()); } |
UnixUser { public int getUID() { return uid; } UnixUser(String userName, Passwd pwd); UnixUser(String userName); protected UnixUser(String userName, String gecos, String dir, String shell, int uid, int gid, Set<String> groups); String getUserName(); int getUID(); int getGID(); String getGecos(); String getDir(); Stri... | @Test public void testGetUID() { Assert.assertEquals(0, user.getUID()); } |
TransactionServicesImpl implements TransactionServices { public boolean isTransactionActive() { try { int curStatus = transactionManager.getStatus(); if ( curStatus == STATUS_ACTIVE || curStatus == STATUS_MARKED_ROLLBACK || curStatus == STATUS_PREPARED || curStatus == STATUS_UNKNOWN || curStatus == STATUS_PREPARING || ... | @Test public void testisTransactionActive() throws Exception { EasyMockSupport mockSupport = new EasyMockSupport(); ServiceLocator serviceLocator = mockSupport.createMock( ServiceLocator.class ); JavaEETransactionManager transactionManager = mockSupport.createMock( JavaEETransactionManager.class ); doTestIsTransactionA... |
WeldContextListener implements ServletContextListener { public void contextInitialized(ServletContextEvent servletContextEvent) { if (null != beanManager) { JspApplicationContext jspAppContext = getJspApplicationContext(servletContextEvent); jspAppContext.addELResolver(beanManager.getELResolver()); try { Class weldClas... | @Test public void testcontextInitialized() throws Exception { EasyMockSupport mockSupport = new EasyMockSupport(); ELResolver elResolver = mockSupport.createMock(ELResolver.class); ExpressionFactory expressionFactory = mockSupport.createMock(ExpressionFactory.class); StandardContext servletContext = new StandardContext... |
TransactionScopedContextImpl implements Context { @Override public boolean isActive() { try { getTransactionSynchronizationRegistry(); return true; } catch (ContextNotActiveException ignore) { } return false; } TransactionScopedContextImpl(); ConcurrentHashMap<TransactionSynchronizationRegistry, Set<TransactionScopedBe... | @Test public void testisActive() throws Exception { TransactionSynchronizationRegistry transactionSynchronizationRegistry = mockSupport.createMock(TransactionSynchronizationRegistry.class); expect( initialContext.lookup(TRANSACTION_SYNCHRONIZATION_REGISTRY_JNDI_NAME)).andThrow( new NamingException() ); mockSupport.repl... |
RestfulController { @GetMapping public String getDataWithCache() { Long startTime = System.currentTimeMillis(); long timestamp = this.cacheDao.getDataWithCache() ; Long endTime = System.currentTimeMillis(); System.out.println("耗时: " + (endTime - startTime)); return timestamp+""; } @GetMapping String getDataWithCache()... | @Test public void getDataWithCache() throws Exception { for (int i = 0; i < 10; i++) { mockMvc.perform(MockMvcRequestBuilders.get("/api/concurrenmapcache/cache")) .andDo(MockMvcResultHandlers.print()) .andExpect(MockMvcResultMatchers.status().isOk()) .andReturn().getResponse().getContentAsString(); } } |
RestfulController { @PostMapping public void save() { this.cacheDao.save(); } @GetMapping String getDataWithCache(); @PostMapping void save(); @DeleteMapping void delete(); } | @Test public void save() throws Exception { } |
RestfulController { @DeleteMapping public void delete() { this.cacheDao.delete(); } @GetMapping String getDataWithCache(); @PostMapping void save(); @DeleteMapping void delete(); } | @Test public void delete() throws Exception { } |
ELConfig { public void outputResource(){ System.out.println(normalValue); System.out.println(osName); System.out.println(randomNumber); System.out.println(elConfig); System.out.println(testUrl); System.out.println(authorName); try { System.out.println(IOUtils.toString(elConfig.getInputStream())); } catch (IOException e... | @Test public void testELConfig(){ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ELConfig.class) ; ELConfig elConfig = context.getBean(ELConfig.class) ; elConfig.outputResource(); context.close(); } |
AnnotationServiceImpl { @SuppressWarnings("unused") public void outputStream(){ System.out.println("用组合注解获得bean。。。"); } @SuppressWarnings("unused") void outputStream(); } | @Test public void testAnnotation(){ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringWebApplication.class) ; AnnotationServiceImpl annotationServiceImpl = context.getBean(AnnotationServiceImpl.class) ; annotationServiceImpl.outputStream(); context.close(); } |
AwareServiceImpl implements BeanNameAware,ResourceLoaderAware { public void outputResult(){ System.out.println("beanName:"+beanName); Resource resource = loader.getResource("classpath:config/elconfig.properties") ; try { System.out.println("ResourceLoader加载的资源文件:"+ IOUtils.toString(resource.getInputStream())); } catch ... | @Test public void testAwareService(){ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringWebApplication.class) ; AwareServiceImpl awareService = context.getBean(AwareServiceImpl.class) ; awareService.outputResult(); context.close(); } |
JavaDomUtils { public static String calculateTypeName(CompilationUnit compilationUnit, FullyQualifiedJavaType fqjt) { if (fqjt.getTypeArguments().size() > 0) { return calculateParameterizedTypeName(compilationUnit, fqjt); } if(compilationUnit == null || typeDoesNotRequireImport(fqjt) || typeIsInSamePackage(compilationU... | @Test public void testGenericTypeNothingImported() { Interface interfaze = new Interface(new FullyQualifiedJavaType("com.foo.UserMapper")); FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType("java.util.Map<java.math.BigDecimal, java.util.List<com.beeant.dto.User>>"); assertEquals("java.util.Map<java.math.BigDecim... |
JavaBeansUtil { public static String getSetterMethodName(String property) { StringBuilder sb = new StringBuilder(); sb.append(property); if (Character.isLowerCase(sb.charAt(0))) { if (sb.length() == 1 || !Character.isUpperCase(sb.charAt(1))) { sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); } } sb.insert(0, "set"... | @Test public void testGetSetterMethodName() { assertEquals("seteMail", getSetterMethodName("eMail")); assertEquals("setFirstName", getSetterMethodName("firstName")); assertEquals("setURL", getSetterMethodName("URL")); assertEquals("setXAxis", getSetterMethodName("XAxis")); assertEquals("setA", getSetterMethodName("a"))... |
StringUtility { public static String composeFullyQualifiedTableName(String catalog, String schema, String tableName, char separator) { StringBuilder sb = new StringBuilder(); if (stringHasValue(catalog)) { sb.append(catalog); sb.append(separator); } if (stringHasValue(schema)) { sb.append(schema); sb.append(separator);... | @Test public void testNoCatalog() { String answer = StringUtility.composeFullyQualifiedTableName(null, "schema", "table", '.'); assertEquals("schema.table", answer); }
@Test public void testNoSchema() { String answer = StringUtility.composeFullyQualifiedTableName("catalog", null, "table", '.'); assertEquals("catalog..t... |
JavaBeansUtil { public static String getValidPropertyName(String inputString) { String answer; if (inputString == null) { answer = null; } else if (inputString.length() < 2) { answer = inputString.toLowerCase(Locale.US); } else { if (Character.isUpperCase(inputString.charAt(0)) && !Character.isUpperCase(inputString.cha... | @Test public void testGetValidPropertyName() { assertEquals("eMail", getValidPropertyName("eMail")); assertEquals("firstName", getValidPropertyName("firstName")); assertEquals("URL", getValidPropertyName("URL")); assertEquals("XAxis", getValidPropertyName("XAxis")); assertEquals("a", getValidPropertyName("a")); assertE... |
JavaBeansUtil { public static String getGetterMethodName(String property, FullyQualifiedJavaType fullyQualifiedJavaType) { StringBuilder sb = new StringBuilder(); sb.append(property); if (Character.isLowerCase(sb.charAt(0))) { if (sb.length() == 1 || !Character.isUpperCase(sb.charAt(1))) { sb.setCharAt(0, Character.toU... | @Test public void testGetGetterMethodName() { assertEquals("geteMail", getGetterMethodName("eMail", FullyQualifiedJavaType.getStringInstance())); assertEquals("getFirstName", getGetterMethodName("firstName", FullyQualifiedJavaType.getStringInstance())); assertEquals("getURL", getGetterMethodName("URL", FullyQualifiedJa... |
PageNumberView extends TextView implements PageIndicators.PageObserver,
PageIndicators.PageCountObserver { @Override public void onPageChanged(@NonNull PageIndicators indicators, @IntRange(from = 0) int page) { if (this.page != page) { this.page = page; updateText(); } } PageNumberView(Context context); PageNu... | @Test public void onPageChanged() { PageIndicators indicators = new PageIndicators(getApplicationContext()); pageNumberView.setTemplate("%d-%d"); pageNumberView.onPageCountChanged(indicators, 3); pageNumberView.onPageChanged(indicators, 1); pageNumberView.onPageChanged(indicators, 2); assertThat(pageNumberView.getText(... |
SpaceDrawable extends Drawable { @Override public int getOpacity() { return PixelFormat.TRANSPARENT; } SpaceDrawable(int spacing); @Override int getIntrinsicWidth(); @Override int getIntrinsicHeight(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override void setColorFilter(ColorFi... | @Test public void getOpacity() { assertThat(drawable.getOpacity(), is(PixelFormat.TRANSPARENT)); } |
PageIndicators extends FrameLayout { @Override @CallSuper public void onViewAdded(View child) { if (child instanceof Observer) { observers.registerObserver((Observer) child); } } PageIndicators(Context context); PageIndicators(Context context, AttributeSet attrs); PageIndicators(Context context, AttributeSet attrs, i... | @Test public void onViewAdded() { indicators.onViewAdded(pageObserverView); assertThat(indicators.observers.pageObservers, hasItem(pageObserverView)); assertThat(indicators.observers.pageCountObservers, hasItem(pageObserverView)); assertThat(indicators.observers.pageStateObservers, hasItem(pageObserverView)); assertTha... |
PageIndicators extends FrameLayout { @Override @CallSuper public void onViewRemoved(View child) { if (child instanceof Observer) { observers.unregisterObserver((Observer) child); } } PageIndicators(Context context); PageIndicators(Context context, AttributeSet attrs); PageIndicators(Context context, AttributeSet attr... | @Test public void onViewRemoved() { indicators.registerObserver(pageObserverView); indicators.onViewRemoved(pageObserverView); assertThat(indicators.observers.pageObservers, empty()); assertThat(indicators.observers.pageCountObservers, empty()); assertThat(indicators.observers.pageStateObservers, empty()); assertThat(i... |
PageIndicators extends FrameLayout { @CallSuper public void setViewPager(@Nullable ViewPager viewPager) { addedAsDecor = false; if (this.viewPager != viewPager) { if (this.viewPager != null) { unbindViewPager(this.viewPager); } this.viewPager = viewPager; setupPageCount(observers); if (viewPager != null) { bindViewPage... | @Test public void setViewPager() { indicators.registerObserver(pageObserverView); TestViewPager oldViewPager = new TestViewPager(getApplicationContext()); TestViewPager newViewPager = new TestViewPager(getApplicationContext()); indicators.setViewPager(oldViewPager); indicators.setViewPager(newViewPager); assertThat(ind... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.