src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
TimeUtils { public static String getSpecifiedDate(long time) { return simpleDateFormat_1.format(new Date(time)); } static String getMM_SS(long time); static String getYHM(long time); static String getHistoryTime(long timeInLong); static String getHistoryTime1(long timeInLong); static String getLiveTime(long timeInLong... | @Test public void getSpecifiedDate() throws Exception { } |
TimeUtils { public static long startOfDay(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); return cal.getTimeInMillis(); } static String getMM_SS(long time); static String getYHM(long time); static... | @Test public void startOfDay() throws Exception { } |
TimeUtils { public static boolean isToday(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date(time)); Calendar calendar1 = Calendar.getInstance(); calendar1.setTime(new Date(System.currentTimeMillis())); return calendar.get(Calendar.YEAR) == calendar1.get(Calendar.YEAR) && calendar.get(Ca... | @Test public void isToday() throws Exception { } |
JConstant { public static String assembleUrl(String id, String packageName) { return String.format(Locale.getDefault(), VERSION_URL, id, packageName); } static String getAIText(int[] objects); static String getRoot(); static int getNetTypeRes(int net); static int getMessageIcon(int pid); static int getOnlineIcon(int p... | @Test public void testUrl() { String id = "VRJz6f"; String packageName = "hell"; System.out.println(assembleUrl(id, packageName)); } |
TimeUtils { public static String getSuperString(long time) { return getDateFormatSuper.get().format(new Date(time)); } static String getMM_SS(long time); static String getYHM(long time); static String getHistoryTime(long timeInLong); static String getHistoryTime1(long timeInLong); static String getLiveTime(long timeIn... | @Test public void getSuperString() throws Exception { } |
TimeUtils { public static String getHomeItemTime(Context context, long time) { if (time == 0) return ""; if (System.currentTimeMillis() - time <= 5 * 60 * 1000L) return context.getString(R.string.JUST_NOW); if (startOfDay(System.currentTimeMillis()) < time) return getSimpleDateFormatHHMM.get().format(new Date(time)); r... | @Test public void getHomeItemTime() throws Exception { } |
TimeUtils { public static String getMonthInYear(long time) { SimpleDateFormat format = (SimpleDateFormat) SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.FULL, SimpleDateFormat.FULL); format.applyPattern("MMMM"); return format.format(new Date(time)); } static String getMM_SS(long time); static String getYHM(long... | @Test public void getMonthInYear() throws Exception { } |
TimeUtils { public static String getBellRecordTime(long time) { Date today = new Date(); Date provide = new Date(time); SimpleDateFormat format = (SimpleDateFormat) SimpleDateFormat.getInstance(); if (today.getYear() > provide.getYear()) { format.applyPattern("yyyy.MM.dd"); return format.format(provide); } if (today.ge... | @Test public void getBellRecordTime() throws Exception { Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("EE", Locale.SIMPLIFIED_CHINESE); String asWeek = dateFormat.format(now); System.out.println(asWeek); System.out.println("星期缩写:"); for (Locale locale : JFGRules.CONST_LOCALE) { DateFormatSy... |
MiscUtils { public static List<JFGDPMsg> getCamDateVersionList(long startTime, int days) { ArrayList<JFGDPMsg> list = new ArrayList<>(); for (int i = 0; i < days; i++) { list.add(makeMsg(startTime - 24 * 3600 * 1000L * i, 222)); list.add(makeMsg(startTime - 24 * 3600 * 1000L * i, 505)); list.add(makeMsg(startTime - 24 ... | @Test public void getCamDateVersionList() throws Exception { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); List<JFGDPMsg> list = MiscUtils.getCamDateVersio... |
MiscUtils { public static int getSum(int num, int base) { float ret = (float) num / base; int count = num / base; if (ret > count) { return count + 1; } return 0; } static boolean isInRange(int start, int end, int dst); static boolean isBad(List<Integer> list, int level, int count); static int parseTime(String time); ... | @Test public void testUrl() { long time = 1499670801000l; SimpleDateFormat format = new SimpleDateFormat("yyyyMMDD HH:mm:ss", Locale.getDefault()); format.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); System.out.println(format.format(new Date(time))); format.setTimeZone(TimeZone.getTimeZone("GMT+0:00")); System.out.pr... |
MapSubscription implements Subscription { @Override public boolean isUnsubscribed() { return unsubscribed; } MapSubscription(); @Override boolean isUnsubscribed(); void add(final Subscription s, String tag); void remove(final String tag); void clear(); @Override void unsubscribe(); boolean hasSubscriptions(); boolean h... | @Test public void isUnsubscribed() throws Exception { } |
MapSubscription implements Subscription { public void add(final Subscription s, String tag) { remove(tag); if (!unsubscribed) { synchronized (this) { if (!unsubscribed) { if (subscriptions == null) { subscriptions = new HashMap<>(4); } subscriptions.put(tag, s); AppLogger.d("add to sub:" + tag); return; } } } s.unsubsc... | @Test public void add() throws Exception { MapSubscription mapSubscription = new MapSubscription(); mapSubscription.add(getTag(), "getTag"); mapSubscription.add(getTag(), "getTag"); Thread.sleep(50000); } |
MapSubscription implements Subscription { public void remove(final String tag) { if (!unsubscribed) { Subscription unsubscribe = null; synchronized (this) { if (unsubscribed || subscriptions == null) { return; } unsubscribe = subscriptions.remove(tag); } if (unsubscribe != null) { unsubscribe.unsubscribe(); } } } MapSu... | @Test public void remove() throws Exception { } |
MapSubscription implements Subscription { public void clear() { if (!unsubscribed) { Collection<Map.Entry<String, Subscription>> unsubscribe = null; synchronized (this) { if (unsubscribed || subscriptions == null) { return; } else { unsubscribe = subscriptions.entrySet(); subscriptions = null; } unsubscribeFromAll(unsu... | @Test public void clear() throws Exception { } |
MapSubscription implements Subscription { @Override public void unsubscribe() { if (!unsubscribed) { Collection<Map.Entry<String, Subscription>> unsubscribe = null; synchronized (this) { if (unsubscribed || subscriptions == null) { return; } unsubscribed = true; unsubscribe = subscriptions.entrySet(); subscriptions = n... | @Test public void unsubscribe() throws Exception { } |
MapSubscription implements Subscription { public boolean hasSubscriptions() { if (!unsubscribed) { synchronized (this) { return !unsubscribed && subscriptions != null && !subscriptions.isEmpty(); } } return false; } MapSubscription(); @Override boolean isUnsubscribed(); void add(final Subscription s, String tag); void ... | @Test public void hasSubscriptions() throws Exception { } |
DeviceBean implements Parcelable { @Override public int hashCode() { return uuid != null ? uuid.hashCode() : 0; } DeviceBean(); protected DeviceBean(Parcel in); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override int describeContents(); @Override void writeToParcel(Parc... | @Test public void testHashCode() { List<DeviceBean> beanList = new ArrayList<>(); for (int i = 0; i < 10; i++) { DeviceBean bean = new DeviceBean(); bean.alias = RandomUtils.getRandom(50) + ""; bean.uuid = i + ""; bean.uuid = i + ""; bean.sn = i + ""; beanList.add(bean); } for (int i = 8; i < 12; i++) { DeviceBean bean... |
RxTask { @CheckReturnValue @NonNull public static <R> Single<R> single(@NonNull final Callable<Task<R>> callable) { return Single.fromCallable(callable).flatMap(new Function<Task<R>, SingleSource<? extends R>>() { @Override public SingleSource<? extends R> apply(Task<R> task) throws Exception { return single(task); } }... | @Test public void testSingleSuccessful() { final String hello = "Hello, world!"; when(mockHelloTask.getResult()) .thenReturn(hello); when(mockHelloTask.isSuccessful()) .thenReturn(true); when(mockHelloTask.addOnCompleteListener(onComplete.capture())) .thenReturn(mockHelloTask); TestObserver<String> obs = TestObserver.c... |
RxTask { @CheckReturnValue @NonNull public static <R> Completable completes(@NonNull final Callable<Task<R>> callable) { return Single.fromCallable(callable).flatMapCompletable( new Function<Task<R>, Completable>() { @Override public Completable apply(Task<R> task) throws Exception { return completes(task); } }); } @C... | @Test public void testCompleteSuccessful() { final String hello = "Hello, world!"; when(mockHelloTask.getResult()) .thenReturn(hello); when(mockHelloTask.isSuccessful()) .thenReturn(true); when(mockHelloTask.addOnCompleteListener(onComplete.capture())) .thenReturn(mockHelloTask); TestObserver<String> obs = TestObserver... |
RxTask { @CheckReturnValue @NonNull public static <R> Maybe<R> maybe(@NonNull final Callable<Task<R>> callable) { return Single.fromCallable(callable).flatMapMaybe( new Function<Task<R>, MaybeSource<? extends R>>() { @Override public MaybeSource<? extends R> apply(Task<R> task) throws Exception { return maybe(task); } ... | @Test public void testMaybe() { final String hello = "Hello, world!"; when(mockHelloTask.getResult()) .thenReturn(hello); when(mockHelloTask.isSuccessful()) .thenReturn(true); when(mockHelloTask.addOnCompleteListener(onComplete.capture())) .thenReturn(mockHelloTask); TestObserver<String> obs = TestObserver.create(); Rx... |
SimpleMemoryManager { public int malloc(final int size) { return malloc_internal(size + 16) + 16; } SimpleMemoryManager(final int totalMemory); int freeMemory(); int allocated(); int malloc(final int size); void free(final int position); void GC(); void printDebug(final PrintStream ps); } | @Test public void testMalloc() { final SimpleMemoryManager mm = new SimpleMemoryManager(1000); final int ptr = mm.malloc(100); assertEquals(16, ptr); assertEquals(884, mm.freeMemory()); assertEquals(116, mm.allocated()); assertEquals(132, mm.malloc(200)); assertEquals(348, mm.malloc(300)); mm.printDebug(System.out); } |
Module { public MemorySection getMems() { return mems; } Module(final String label, final String sourcemapFileName); void writeTo(final TextWriter writer, final boolean enableDebug); TypesSection getTypes(); GlobalsIndex globalsIndex(); EventIndex eventIndex(); FunctionIndex functionIndex(); void writeTo(final BinaryWr... | @Test public void testWithExportedMemory() throws IOException { final StringWriter strWriter = new StringWriter(); final PrintWriter pw = new PrintWriter(strWriter); final Module module = new Module("mod", "mod.wasm.map"); final Memory memory = module.getMems().newMemory(10, 20); memory.exportAs("exported"); final Expo... |
Module { public ImportsSection getImports() { return imports; } Module(final String label, final String sourcemapFileName); void writeTo(final TextWriter writer, final boolean enableDebug); TypesSection getTypes(); GlobalsIndex globalsIndex(); EventIndex eventIndex(); FunctionIndex functionIndex(); void writeTo(final B... | @Test public void testFunctionImportBinary() throws IOException { final Module module = new Module("mod", "mod.wasm.map"); final Function function = module.getImports().importFunction(new ImportReference("mod","obj"),"label", PrimitiveType.i32); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final Strin... |
Module { public FunctionsSection getFunctions() { return functions; } Module(final String label, final String sourcemapFileName); void writeTo(final TextWriter writer, final boolean enableDebug); TypesSection getTypes(); GlobalsIndex globalsIndex(); EventIndex eventIndex(); FunctionIndex functionIndex(); void writeTo(f... | @Test public void testLocalAccess() throws IOException { final StringWriter strWriter = new StringWriter(); final PrintWriter pw = new PrintWriter(strWriter); final Module module = new Module("mod", "mod.wasm.map"); final FunctionsSection functionsContent = module.getFunctions(); final Param p1 = param("p1", PrimitiveT... |
SimpleMemoryManager { public void GC() { Chunk current = allocatedList; while (current != null) { final Chunk next = current.next; free_internal(current.position); current = next; } } SimpleMemoryManager(final int totalMemory); int freeMemory(); int allocated(); int malloc(final int size); void free(final int position)... | @Test public void testGC() { final SimpleMemoryManager mm = new SimpleMemoryManager(1000); final int a = mm.malloc(100); final int b = mm.malloc(200); final int c = mm.malloc(300); mm.GC(); mm.printDebug(System.out); assertEquals(1000, mm.freeMemory()); assertEquals(0, mm.allocated()); } |
VLQ { public static int[] decode(final String aData) { final List<Integer> theResult = new ArrayList<>(); int theShift = 0; int theValue = 0; for (int i=0;i<aData.length();i++) { int theInteger = CHARACTERS.indexOf(aData.charAt(i)); final int hasContinuationBit = theInteger & 32; theInteger &= 31; theValue += theIntege... | @Test public void testDecode() { final int[] theResult = VLQ.decode("IAAM"); Assert.assertEquals(4, theResult.length); Assert.assertEquals(4, theResult[0]); Assert.assertEquals(0, theResult[1]); Assert.assertEquals(0, theResult[2]); Assert.assertEquals(6, theResult[3]); } |
Partitioning { public List<Set<T>> partitions() { return partitions; } Partitioning(final Set<T> nodes, final Predicate<Edge<EdgeType, T>> edgeFilter); List<Set<T>> partitions(); } | @Test public void testEmptyGraph() { final Partitioning thePartitioning = new Partitioning(new HashSet(), t -> true); final List<Set<Node>> thePartitions = thePartitioning.partitions(); assertTrue(thePartitions.isEmpty()); }
@Test public void testSingleNodeGraph() { final Set<Node> theNodes = new HashSet<>(); final Nod... |
VLQ { public static String encode(final int[] aData) { final StringBuilder theResult = new StringBuilder(); for (int i = 0; i < aData.length; i += 1 ) { theResult.append(encodeInteger(aData[i])); } return theResult.toString(); } private VLQ(); static int[] decode(final String aData); static String encode(final int[] a... | @Test public void testEncode() { Assert.assertEquals("IAAM", VLQ.encode(new int[] {4,0,0,6})); } |
BytecodeLoader { public BytecodeClass loadByteCode(final BytecodeObjectTypeRef aTypeRef) throws IOException, ClassNotFoundException { return loadByteCode(aTypeRef, bytecodeReplacer); } BytecodeLoader(final ClassLoader aClassLoader); BytecodeSignatureParser getSignatureParser(); BytecodeClass loadByteCode(final Bytecode... | @Test public void testLoadInterface() throws IOException, ClassNotFoundException { BytecodeLoader theLoader = new BytecodeLoader(getClass().getClassLoader()); theLoader.loadByteCode(new BytecodeObjectTypeRef(SimpleInterface.class.getName())); } |
Stackifier { public void writeStructuredControlFlow(final StackifierStructuredControlFlowWriter writer) { flow.writeStructuredControlFlow(writer); } Stackifier(final ControlFlowGraph controlFlowGraph); void writeStructuredControlFlow(final StackifierStructuredControlFlowWriter writer); void printDebug(final PrintWriter... | @Test public void testOnlyOneNode() throws HeadToHeadControlFlowException { final Program p = new Program(DebugInformation.empty(), null); final ControlFlowGraph g = new ControlFlowGraph(p); final RegionNode startNode = g.createAt(BytecodeOpcodeAddress.START_AT_ZERO, RegionNode.BlockType.NORMAL); g.calculateReachabilit... |
Function extends Container implements Importable, Callable { @Override public void writeTo(final TextWriter textWriter, final Module aModule) throws IOException { textWriter.opening(); textWriter.write("func"); textWriter.space(); textWriter.writeLabel(label); textWriter.space(); functionType.writeRefTo(textWriter); te... | @Test public void testSimpleCase() throws IOException { final StringWriter strWriter = new StringWriter(); final PrintWriter pw = new PrintWriter(strWriter); final Module module = new Module("mod", "mod.wasm.map"); final FunctionsSection functionsContent = module.getFunctions(); final ExportableFunction function = func... |
StructuredControlFlow { public void printDebug(final PrintWriter pw) { pw.println("Original:"); printDebug(pw, false); for (final JumpArrow<T> arrow : knownJumpArrows) { pw.println(String.format(" %s %d -> %d", arrow.getEdgeType(), indexOf(arrow.getTail()), indexOf(arrow.getHead()))); } pw.println(); pw.println("Stacki... | @Test public void testHeadToHead() throws HeadToHeadControlFlowException { expectedException.expect(HeadToHeadControlFlowException.class); expectedException.expectMessage("{2,3} are head to head"); final StructuredControlFlowBuilder<Integer> builder = new StructuredControlFlowBuilder<>(Arrays.asList(0, 1, 2, 3)); build... |
AnnotationBasedExpiration implements BeanFactoryAware, CustomExpiry<K, V> { protected ExpirationAttributes getDefaultExpirationAttributes() { return this.defaultExpirationAttributes; } AnnotationBasedExpiration(); AnnotationBasedExpiration(ExpirationAttributes defaultExpirationAttributes); static AnnotationBasedExpira... | @Test public void constructUninitializedAnnotationBasedExpirationInstance() { AnnotationBasedExpiration expiration = new AnnotationBasedExpiration(); assertThat(expiration.getDefaultExpirationAttributes(), is(nullValue())); }
@Test public void constructInitializedAnnotationBasedExpirationInstance() { AnnotationBasedExp... |
PartitionedRegionFactoryBean extends PeerRegionFactoryBean<K, V> { @Override protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy == null) { dataPolicy = isPersistent() ? DataPolicy.PERSISTENT_PARTITION : DataPolicy.PARTITION; } else { Assert.is... | @Test public void testResolveDataPolicyWhenPersistentUnspecifiedAndPartitionDataPolicy() { RegionFactory mockRegionFactory = createMockRegionFactory(); factoryBean.resolveDataPolicy(mockRegionFactory, null, "PARTITION"); verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PARTITION)); }
@Test public void testResolveD... |
ReplicatedRegionFactoryBean extends PeerRegionFactoryBean<K, V> { @Override protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy == null) { dataPolicy = isPersistent() ? DataPolicy.PERSISTENT_REPLICATE : DataPolicy.REPLICATE; } else if (DataPoli... | @Test public void testResolveDataPolicyWithPersistentUnspecifiedAndDataPolicyUnspecified() { RegionFactory mockRegionFactory = createMockRegionFactory(); factoryBean.resolveDataPolicy(mockRegionFactory, null, (String) null); verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.REPLICATE)); }
@Test public void testReso... |
AnnotationBasedExpiration implements BeanFactoryAware, CustomExpiry<K, V> { protected Expiration getExpiration(Region.Entry<K, V> entry) { return getExpiration(entry.getValue()); } AnnotationBasedExpiration(); AnnotationBasedExpiration(ExpirationAttributes defaultExpirationAttributes); static AnnotationBasedExpiration... | @Test public void getExpirationWithNoGenericExpirationRegionEntry() { Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry"); when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutExpiration()); assertThat(noDefaultExpiration.getExpiration(mockRegionEntry), is(null... |
AnnotationBasedExpiration implements BeanFactoryAware, CustomExpiry<K, V> { protected IdleTimeoutExpiration getIdleTimeout(Region.Entry<K, V> entry) { return getIdleTimeout(entry.getValue()); } AnnotationBasedExpiration(); AnnotationBasedExpiration(ExpirationAttributes defaultExpirationAttributes); static AnnotationBa... | @Test public void getIdleTimeoutWithIdleTimeoutExpirationBasedRegionEntry() { Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry"); when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithIdleTimeoutExpiration()); assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry), isA(Idle... |
RegionShortcutConverter implements Converter<String, RegionShortcut> { protected static String toUpperCase(final String value) { return (value != null ? value.toUpperCase().trim() : String.valueOf(value)); } @Override RegionShortcut convert(final String source); } | @Test public void testToUpperCase() { assertEquals("TEST", RegionShortcutConverter.toUpperCase("test")); assertEquals("TEST", RegionShortcutConverter.toUpperCase(" Test ")); assertEquals("", RegionShortcutConverter.toUpperCase("")); assertEquals("", RegionShortcutConverter.toUpperCase(" ")); assertEquals("NULL", Region... |
RegionShortcutConverter implements Converter<String, RegionShortcut> { @Override public RegionShortcut convert(final String source) { return RegionShortcut.valueOf(toUpperCase(source)); } @Override RegionShortcut convert(final String source); } | @Test public void testConvert() { for (RegionShortcut shortcut : RegionShortcut.values()) { assertEquals(shortcut, converter.convert(shortcut.name())); } assertEquals(RegionShortcut.PARTITION_PROXY, converter.convert("Partition_Proxy")); assertEquals(RegionShortcut.REPLICATE_OVERFLOW, converter.convert("replicate_overf... |
ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> { @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public Class<? extends GemFireCache> getObjectType() { return Optional.ofNullable(getCache()).map(Object::getClass).orElse((Class) ClientCache.class); } @Over... | @Test public void getObjectTypeEqualsClientCacheClass() { assertThat(new ClientCacheFactoryBean().getObjectType()).isEqualTo(ClientCache.class); } |
ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> { @Override protected Object createFactory(Properties gemfireProperties) { return new ClientCacheFactory(gemfireProperties); } @Override void onApplicationEvent(ContextRefreshedEvent event); @Override @SuppressWarning... | @Test public void createClientCacheFactory() { Properties gemfireProperties = new Properties(); Object clientCacheFactoryReference = new ClientCacheFactoryBean().createFactory(gemfireProperties); assertThat(clientCacheFactoryReference).isInstanceOf(ClientCacheFactory.class); assertThat(gemfireProperties.isEmpty()).isTr... |
ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> { ClientCacheFactory configurePdx(ClientCacheFactory clientCacheFactory) { Optional.ofNullable(getPdxSerializer()).ifPresent(clientCacheFactory::setPdxSerializer); Optional.ofNullable(getPdxDiskStoreName()).filter(Stri... | @Test public void initializePdxWithAllPdxOptions() { ClientCacheFactoryBean clientCacheFactoryBean = new ClientCacheFactoryBean(); PdxSerializer mockPdxSerializer = mock(PdxSerializer.class); clientCacheFactoryBean.setPdxDiskStoreName("MockPdxDiskStoreName"); clientCacheFactoryBean.setPdxIgnoreUnreadFields(false); clie... |
ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> { @Override @SuppressWarnings("unchecked") protected <T extends GemFireCache> T createCache(Object factory) { return (T) ((ClientCacheFactory) factory).create(); } @Override void onApplicationEvent(ContextRefreshedEve... | @Test public void createCache() { ClientCache mockClientCache = mock(ClientCache.class); ClientCacheFactory mockClientCacheFactory = mock(ClientCacheFactory.class); when(mockClientCacheFactory.create()).thenReturn(mockClientCache); ClientCacheFactoryBean clientCacheFactoryBean = new ClientCacheFactoryBean(); assertThat... |
ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> { @Override public final Boolean getEnableAutoReconnect() { return Boolean.FALSE; } @Override void onApplicationEvent(ContextRefreshedEvent event); @Override @SuppressWarnings({ "rawtypes", "unchecked" }) Class<? exte... | @Test public void autoReconnectDisabled() { assertThat(new ClientCacheFactoryBean().getEnableAutoReconnect()).isFalse(); } |
ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> { @Override public final void setEnableAutoReconnect(Boolean enableAutoReconnect) { throw new UnsupportedOperationException("Auto-reconnect does not apply to clients"); } @Override void onApplicationEvent(ContextRefre... | @Test(expected = UnsupportedOperationException.class) public void autoReconnectEnabled() { new ClientCacheFactoryBean().setEnableAutoReconnect(true); } |
ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> { @Override public final Boolean getUseClusterConfiguration() { return Boolean.FALSE; } @Override void onApplicationEvent(ContextRefreshedEvent event); @Override @SuppressWarnings({ "rawtypes", "unchecked" }) Class<? ... | @Test public void clusterConfigurationNotUsed() { assertThat(new ClientCacheFactoryBean().getUseClusterConfiguration()).isFalse(); } |
ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> { @Override public final void setUseClusterConfiguration(Boolean useClusterConfiguration) { throw new UnsupportedOperationException("Cluster-based Configuration is not applicable for clients"); } @Override void onAppl... | @Test(expected = UnsupportedOperationException.class) public void usesClusterConfiguration() { new ClientCacheFactoryBean().setUseClusterConfiguration(true); } |
ClientRegionFactoryBean extends ConfigurableRegionFactoryBean<K, V> implements SmartLifecycleSupport, EvictingRegionFactoryBean, ExpiringRegionFactoryBean<K, V>, DisposableBean { protected ClientRegionFactory<K, V> createClientRegionFactory(ClientCache clientCache, ClientRegionShortcut clientRegionShortcut) { return cl... | @Test @SuppressWarnings("unchecked") public void createClientRegionFactoryFromClientCache() { ClientCache mockClientCache = mock(ClientCache.class); ClientRegionFactory mockClientRegionFactory = mock(ClientRegionFactory.class); when(mockClientCache.createClientRegionFactory(any(ClientRegionShortcut.class))) .thenReturn... |
ClientRegionFactoryBean extends ConfigurableRegionFactoryBean<K, V> implements SmartLifecycleSupport, EvictingRegionFactoryBean, ExpiringRegionFactoryBean<K, V>, DisposableBean { ClientRegionShortcut resolveClientRegionShortcut() { ClientRegionShortcut resolvedShortcut = this.shortcut; if (resolvedShortcut == null) { D... | @Test public void testResolveClientRegionShortcut() throws Exception { assertNull(TestUtils.readField("dataPolicy", factoryBean)); assertNull(TestUtils.readField("persistent", factoryBean)); assertNull(TestUtils.readField("shortcut", factoryBean)); assertEquals(ClientRegionShortcut.LOCAL, factoryBean.resolveClientRegio... |
ClientRegionFactoryBean extends ConfigurableRegionFactoryBean<K, V> implements SmartLifecycleSupport, EvictingRegionFactoryBean, ExpiringRegionFactoryBean<K, V>, DisposableBean { @Override public void destroy() throws Exception { Optional.ofNullable(getObject()).ifPresent(region -> { if (isClose() && RegionUtils.isClos... | @Test @SuppressWarnings("unchecked") public void destroyDoesNothingWhenClientRegionFactoryBeanCloseAndDestroyAreFalse() throws Exception { Region mockRegion = mock(Region.class, "MockRegion"); doReturn(mockRegion).when(factoryBean).getObject(); factoryBean.destroy(); verify(factoryBean, times(1)).getObject(); verify(mo... |
ListRegionsOnServerFunction implements Function { @Override @SuppressWarnings("unchecked") public void execute(FunctionContext functionContext) { List<String> regionNames = new ArrayList<>(); for (Region<?, ?> region : getCache().rootRegions()) { regionNames.add(region.getName()); } functionContext.getResultSender().la... | @Test @SuppressWarnings("unchecked") public void executeReturnsRootRegionNames() { final Cache mockCache = mock(Cache.class, "MockGemFireCache"); Region mockRegionOne = mock(Region.class, "MockGemFireRegionOne"); Region mockRegionTwo = mock(Region.class, "MockGemFireRegionTwo"); Region mockRegionThree = mock(Region.cla... |
AnnotationBasedExpiration implements BeanFactoryAware, CustomExpiry<K, V> { protected TimeToLiveExpiration getTimeToLive(Region.Entry<K, V> entry) { return getTimeToLive(entry.getValue()); } AnnotationBasedExpiration(); AnnotationBasedExpiration(ExpirationAttributes defaultExpirationAttributes); static AnnotationBased... | @Test public void getTimeToLiveWithTimeToLiveExpirationBasedRegionEntry() { Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry"); when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveExpiration()); assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry), isA(TimeToLi... |
ListRegionsOnServerFunction implements Function { @Override public String getId() { return this.getClass().getName(); } @Override @SuppressWarnings("unchecked") void execute(FunctionContext functionContext); @Override String getId(); @Override boolean hasResult(); @Override boolean isHA(); @Override boolean optimizeFo... | @Test public void getIdIsFullyQualifiedClassName() { assertThat(function.getId(), is(equalTo(ListRegionsOnServerFunction.class.getName()))); } |
ListRegionsOnServerFunction implements Function { @Override public boolean hasResult() { return true; } @Override @SuppressWarnings("unchecked") void execute(FunctionContext functionContext); @Override String getId(); @Override boolean hasResult(); @Override boolean isHA(); @Override boolean optimizeForWrite(); static... | @Test public void hasResultIsTrue() { assertThat(function.hasResult(), is(true)); } |
ClientRegionShortcutConverter implements Converter<String, ClientRegionShortcut> { protected static String toUpperCase(final String value) { return (value != null ? value.toUpperCase().trim() : String.valueOf(value)); } @Override ClientRegionShortcut convert(final String source); } | @Test public void testToUpperCase() { assertEquals("TEST", ClientRegionShortcutConverter.toUpperCase("test")); assertEquals("TEST", ClientRegionShortcutConverter.toUpperCase(" Test ")); assertEquals("", ClientRegionShortcutConverter.toUpperCase("")); assertEquals("", ClientRegionShortcutConverter.toUpperCase(" ")); ass... |
ClientRegionShortcutConverter implements Converter<String, ClientRegionShortcut> { @Override public ClientRegionShortcut convert(final String source) { return ClientRegionShortcut.valueOf(toUpperCase(source)); } @Override ClientRegionShortcut convert(final String source); } | @Test public void testConvert() { for (ClientRegionShortcut shortcut : ClientRegionShortcut.values()) { assertEquals(shortcut, converter.convert(shortcut.name())); } assertEquals(ClientRegionShortcut.PROXY, converter.convert("Proxy")); assertEquals(ClientRegionShortcut.CACHING_PROXY, converter.convert("caching_proxy"))... |
GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPostProcessor { @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (beanFactory instanceof ConfigurableBeanFactory) { this.beanFactory = (ConfigurableBeanFactory) beanFactory; } else { throw new TypeMismatchException(b... | @Test(expected = TypeMismatchException.class) public void setBeanFactoryToIncompatibleTypeThrowsBeansException() { new GemfireDataSourcePostProcessor().setBeanFactory(mock(BeanFactory.class)); }
@Test(expected = TypeMismatchException.class) public void setBeanFactoryToNullThrowsBeansException() { new GemfireDataSourceP... |
GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPostProcessor { boolean containsRegionInformation(Object results) { return results instanceof Object[] && ((Object[]) results).length > 0 && ((Object[]) results)[0] instanceof RegionInformation; } @Override void setBeanFactory(BeanFactory beanFactory); Op... | @Test public void containsRegionInformationIsTrue() { assertThat(new GemfireDataSourcePostProcessor() .containsRegionInformation(new Object[] { newRegionInformation(mockRegion("Example")) })) .isTrue(); }
@Test public void containsRegionInformationWithEmptyArrayIsFalse() { assertThat(new GemfireDataSourcePostProcessor(... |
GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPostProcessor { void createClientProxyRegions(ConfigurableBeanFactory beanFactory, ClientCache clientCache, Iterable<String> regionNames) { if (regionNames.iterator().hasNext()) { ClientRegionShortcut resolvedClientRegionShortcut = resolveClientRegionShort... | @Test @SuppressWarnings("unchecked") public void createClientProxyRegionsIsSuccessful() { ClientRegionFactory mockClientRegionFactory = mock(ClientRegionFactory.class); when(this.mockClientCache.createClientRegionFactory(eq(ClientRegionShortcut.PROXY))) .thenReturn(mockClientRegionFactory); Region mockRegionOne = mock(... |
FactoryDefaultsPoolAdapter extends PoolAdapter { @Override public List<InetSocketAddress> getLocators() { return Collections.emptyList(); } @Override int getFreeConnectionTimeout(); @Override long getIdleTimeout(); @Override int getLoadConditioningInterval(); @Override List<InetSocketAddress> getLocators(); @Override ... | @Test public void locatorsReturnsEmptyList() { assertThat(this.poolAdapter.getLocators()).isEqualTo(Collections.<InetSocketAddress>emptyList()); } |
FactoryDefaultsPoolAdapter extends PoolAdapter { @Override public String getName() { return DEFAULT_POOL_NAME; } @Override int getFreeConnectionTimeout(); @Override long getIdleTimeout(); @Override int getLoadConditioningInterval(); @Override List<InetSocketAddress> getLocators(); @Override int getMaxConnections(); @O... | @Test public void nameReturnsDefault() { assertThat(this.poolAdapter.getName()).isEqualTo(FactoryDefaultsPoolAdapter.DEFAULT_POOL_NAME); } |
FactoryDefaultsPoolAdapter extends PoolAdapter { @Override public List<InetSocketAddress> getOnlineLocators() { return Collections.emptyList(); } @Override int getFreeConnectionTimeout(); @Override long getIdleTimeout(); @Override int getLoadConditioningInterval(); @Override List<InetSocketAddress> getLocators(); @Ove... | @Test public void onlineLocatorsIsEmptyList() { assertThat(this.poolAdapter.getOnlineLocators()).isEqualTo(Collections.EMPTY_LIST); } |
FactoryDefaultsPoolAdapter extends PoolAdapter { @Override public QueryService getQueryService() { return null; } @Override int getFreeConnectionTimeout(); @Override long getIdleTimeout(); @Override int getLoadConditioningInterval(); @Override List<InetSocketAddress> getLocators(); @Override int getMaxConnections(); @... | @Test public void queryServiceIsNull() { assertThat(this.poolAdapter.getQueryService()).isNull(); } |
FactoryDefaultsPoolAdapter extends PoolAdapter { @Override public List<InetSocketAddress> getServers() { return Collections.singletonList(new InetSocketAddress(LOCALHOST, GemfireUtils.DEFAULT_CACHE_SERVER_PORT)); } @Override int getFreeConnectionTimeout(); @Override long getIdleTimeout(); @Override int getLoadConditio... | @Test public void serversReturnsLocalhostListeningOnDefaultCacheServerPort() { assertThat(this.poolAdapter.getServers()).isEqualTo(Collections.singletonList( newSocketAddress("localhost", DEFAULT_CACHE_SERVER_PORT))); } |
AnnotationBasedExpiration implements BeanFactoryAware, CustomExpiry<K, V> { private <T extends Annotation> T getAnnotation(Object obj, Class<T> annotationType) { return AnnotationUtils.getAnnotation(obj.getClass(), annotationType); } AnnotationBasedExpiration(); AnnotationBasedExpiration(ExpirationAttributes defaultEx... | @Test public void fromExpiration() { ExpirationMetaData expirationMetaData = ExpirationMetaData.from( RegionEntryValueWithGenericExpiration.class.getAnnotation(Expiration.class)); assertExpiration(expirationMetaData, 60, ExpirationActionType.INVALIDATE); }
@Test public void fromExpirationIdleTimeout() { ExpirationMetaD... |
FactoryDefaultsPoolAdapter extends PoolAdapter { public void destroy() { destroy(DEFAULT_KEEP_ALIVE); } @Override int getFreeConnectionTimeout(); @Override long getIdleTimeout(); @Override int getLoadConditioningInterval(); @Override List<InetSocketAddress> getLocators(); @Override int getMaxConnections(); @Override i... | @Test(expected = UnsupportedOperationException.class) public void destroyedIsUnsupported() { testPoolOperationIsUnsupported(() -> { this.poolAdapter.destroy(); return null; }); }
@Test(expected = UnsupportedOperationException.class) public void destroyedWithKeepAliveIsUnsupported() { testPoolOperationIsUnsupported(() -... |
DefaultableDelegatingPoolAdapter { protected Pool getDelegate() { return this.delegate; } protected DefaultableDelegatingPoolAdapter(Pool delegate); static DefaultableDelegatingPoolAdapter from(Pool delegate); DefaultableDelegatingPoolAdapter preferDefault(); DefaultableDelegatingPoolAdapter preferPool(); boolean isDe... | @Test public void fromMockPool() { assertThat(this.poolAdapter.getDelegate()).isSameAs(this.mockPool); } |
DefaultableDelegatingPoolAdapter { public static DefaultableDelegatingPoolAdapter from(Pool delegate) { return new DefaultableDelegatingPoolAdapter(delegate) {}; } protected DefaultableDelegatingPoolAdapter(Pool delegate); static DefaultableDelegatingPoolAdapter from(Pool delegate); DefaultableDelegatingPoolAdapter pr... | @Test(expected = IllegalArgumentException.class) public void fromNull() { try { DefaultableDelegatingPoolAdapter.from(null); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage("Pool delegate must not be null"); assertThat(expected).hasNoCause(); throw expected; } } |
LocalRegionFactoryBean extends PeerRegionFactoryBean<K, V> { @Override protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy == null || DataPolicy.NORMAL.equals(dataPolicy)) { DataPolicy resolvedDataPolicy = (isPersistent() ? DataPolicy.PERSISTEN... | @Test public void testResolveDataPolicyWhenPersistentUnspecifiedAndDataPolicyUnspecified() { RegionFactory mockRegionFactory = createMockRegionFactory(); factoryBean.resolveDataPolicy(mockRegionFactory, null, (String) null); verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.NORMAL)); }
@Test public void testResolve... |
BatchingResultSender { public void sendArrayResults(Object result) { Assert.isTrue(ObjectUtils.isArray(result), () -> String.format("Object must be an array; was [%s]", ObjectUtils.nullSafeClassName(result))); int arrayLength = Array.getLength(result); ResultSender<Object> resultSender = getResultSender(); if (doNotSen... | @SuppressWarnings("unchecked") @Test(expected = IllegalArgumentException.class) public void sendArrayResultsWithNonArrayThrowIllegalArgumentException() { try { new BatchingResultSender(20, mock(ResultSender.class)).sendArrayResults(new Object()); } catch (IllegalArgumentException expected) { assertThat(expected).hasMes... |
AbstractFunctionExecution { <T> T executeAndExtract() { Iterable<T> results = execute(); if (isEmpty(results)) { return null; } T result = results.iterator().next(); return throwOnExceptionOrReturn(result); } @SuppressWarnings("rawtypes") AbstractFunctionExecution(Function function, Object... arguments); AbstractFunc... | @Test public void executeAndExtractWithSingleResult() { List<String> results = Collections.singletonList("test"); AbstractFunctionExecution functionExecution = new AbstractFunctionExecution() { @Override protected Execution getExecution() { return mockExecution; } @SuppressWarnings("unchecked") @Override <T> Iterable<T... |
PdxFunctionArgumentResolver extends DefaultFunctionArgumentResolver { @Override public Object[] resolveFunctionArguments(final FunctionContext functionContext) { Object[] functionArguments = super.resolveFunctionArguments(functionContext); if (isPdxSerializerConfigured()) { int index = 0; for (Object functionArgument :... | @Test public void testResolveSimpleFunctionArguments() { functionArgumentResolver = new PdxFunctionArgumentResolver() { @Override public Method getFunctionAnnotatedMethod() { return getMethod(FunctionExecutions.class, "simpleMethod", Boolean.class, Character.class, Integer.class, Double.class, String.class); } }; Objec... |
ExpirationAttributesFactoryBean implements FactoryBean<ExpirationAttributes>, InitializingBean { @Override public boolean isSingleton() { return true; } @Override ExpirationAttributes getObject(); @Override Class<?> getObjectType(); @Override boolean isSingleton(); void setAction(final ExpirationAction action); Expira... | @Test public void testIsSingleton() { assertTrue(new ExpirationAttributesFactoryBean().isSingleton()); } |
CallableCacheLoaderAdapter implements Callable<V>, CacheLoader<K, V> { public void close() { getCacheLoader().close(); } CallableCacheLoaderAdapter(CacheLoader<K, V> delegate); CallableCacheLoaderAdapter(CacheLoader<K, V> delegate, K key, Region<K, V> region); CallableCacheLoaderAdapter(CacheLoader<K, V> delegate, K ... | @Test public void closeDelegatesToCacheLoaderClose() { new CallableCacheLoaderAdapter<>(mockCacheLoader).close(); verify(mockCacheLoader, times(1)).close(); } |
CallableCacheLoaderAdapter implements Callable<V>, CacheLoader<K, V> { public V load(LoaderHelper<K, V> loaderHelper) throws CacheLoaderException { return getCacheLoader().load(loaderHelper); } CallableCacheLoaderAdapter(CacheLoader<K, V> delegate); CallableCacheLoaderAdapter(CacheLoader<K, V> delegate, K key, Region<... | @Test public void loadDelegatesToCacheLoaderLoad() { CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<>(mockCacheLoader); when(mockCacheLoader.load(eq(mockLoaderHelper))).thenReturn("test"); assertThat(instance.load(mockLoaderHelper), is(equalTo("test"))); verify(mockCacheLoader, tim... |
DiskStoreFactoryBean extends AbstractFactoryBeanSupport<DiskStore> implements InitializingBean { protected void validateCompactionThreshold(Integer compactionThreshold) { Assert.isTrue(compactionThreshold == null || (compactionThreshold >= 0 && compactionThreshold <= 100), String.format("The DiskStore's (%1$s) compacti... | @Test public void testValidateCompactionThresholdWhenNull() { factoryBean.validateCompactionThreshold(null); }
@Test public void testValidateCompactionThresholdWhenValid() { factoryBean.validateCompactionThreshold(0); factoryBean.validateCompactionThreshold(50); factoryBean.validateCompactionThreshold(100); } |
DiskStoreFactoryBean extends AbstractFactoryBeanSupport<DiskStore> implements InitializingBean { public void setCompactionThreshold(Integer compactionThreshold) { validateCompactionThreshold(compactionThreshold); this.compactionThreshold = compactionThreshold; } @Override void afterPropertiesSet(); @Override DiskStore... | @Test public void testSetCompactionThreshold() { factoryBean.setCompactionThreshold(75); } |
DiskStoreFactoryBean extends AbstractFactoryBeanSupport<DiskStore> implements InitializingBean { @Override public void afterPropertiesSet() throws Exception { String diskStoreName = resolveDiskStoreName(); applyDiskStoreConfigurers(diskStoreName); GemFireCache cache = resolveCache(diskStoreName); DiskStoreFactory diskS... | @Test(expected = IllegalStateException.class) public void testAfterPropertiesSetWithNoCacheReference() throws Exception { try { factoryBean.afterPropertiesSet(); } catch (IllegalStateException expected) { assertEquals("Cache is required to create DiskStore [testDiskStore]", expected.getMessage()); throw expected; } } |
Regions implements Iterable<Region<?, ?>> { @SuppressWarnings("unchecked") public <T> Region<?, T> getRegion(Class<T> entityType) { Assert.notNull(entityType, "Entity type must not be null"); String regionName = Optional.ofNullable(this.mappingContext.getPersistentEntity(entityType)) .map(entity -> entity.getRegionName... | @Test public void getRegionByEntityTypeReturnsRegionForEntityRegionName() { GemfirePersistentEntity<User> mockPersistentEntity = mock(GemfirePersistentEntity.class); when(mockPersistentEntity.getRegionName()).thenReturn("Users"); when(mockMappingContext.getPersistentEntity(eq(User.class))).thenReturn(mockPersistentEnti... |
ExpirationAttributesFactoryBean implements FactoryBean<ExpirationAttributes>, InitializingBean { @Override public void afterPropertiesSet() throws Exception { expirationAttributes = new ExpirationAttributes(getTimeout(), getAction()); } @Override ExpirationAttributes getObject(); @Override Class<?> getObjectType(); @O... | @Test public void testAfterPropertiesSet() throws Exception { ExpirationAttributesFactoryBean expirationAttributesFactoryBean = new ExpirationAttributesFactoryBean(); assertNull(expirationAttributesFactoryBean.getObject()); assertEquals(ExpirationAttributes.class, expirationAttributesFactoryBean.getObjectType()); expir... |
DataPolicyConverter implements Converter<String, DataPolicy> { @Override public DataPolicy convert(String policyValue) { Policy policy = Policy.getValue(policyValue); return (policy == null ? null : policy.toDataPolicy()); } @Override DataPolicy convert(String policyValue); } | @Test public void convertDataPolicyStrings() { assertEquals(DataPolicy.EMPTY, converter.convert("empty")); assertEquals(DataPolicy.PARTITION, converter.convert("Partition")); assertEquals(DataPolicy.PERSISTENT_REPLICATE, converter.convert("PERSISTENT_REPLICATE")); assertNull(converter.convert("invalid")); assertNull(co... |
CacheServerFactoryBean extends AbstractFactoryBeanSupport<CacheServer> implements DisposableBean, InitializingBean, SmartLifecycle { @Override public CacheServer getObject() { return this.cacheServer; } @Override void afterPropertiesSet(); @Override CacheServer getObject(); @Override Class<?> getObjectType(); boolean ... | @Test public void testGetObjectUninitialized() { assertNull(new CacheServerFactoryBean().getObject()); } |
CacheServerFactoryBean extends AbstractFactoryBeanSupport<CacheServer> implements DisposableBean, InitializingBean, SmartLifecycle { @Override public Class<?> getObjectType() { return this.cacheServer != null ? this.cacheServer.getClass() : CacheServer.class; } @Override void afterPropertiesSet(); @Override CacheServe... | @Test public void testGetObjectType() { assertEquals(CacheServer.class, new CacheServerFactoryBean().getObjectType()); } |
CacheServerFactoryBean extends AbstractFactoryBeanSupport<CacheServer> implements DisposableBean, InitializingBean, SmartLifecycle { @Override public void afterPropertiesSet() throws IOException { applyCacheServerConfigurers(); Cache cache = resolveCache(); this.cacheServer = postProcess(configure(addCacheServer(cache)... | @Test @SuppressWarnings("deprecation") public void testAfterPropertiesSet() throws IOException { Cache mockCache = mock(Cache.class, "testAfterPropertiesSet.MockCache"); CacheServer mockCacheServer = mock(CacheServer.class, "testAfterPropertiesSet.MockCacheServer"); ClientSubscriptionConfig mockClientSubscriptionConfig... |
CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache> implements DisposableBean, InitializingBean, PersistenceExceptionTranslator, Phased { @Override public GemFireCache getObject() throws Exception { return Optional.<GemFireCache>ofNullable(getCache()).orElseGet(this::init); } @Override void afterProperti... | @Test public void getObjectCallsInit() throws Exception { AtomicBoolean initCalled = new AtomicBoolean(false); Cache mockCache = mock(Cache.class); CacheFactoryBean cacheFactoryBean = new CacheFactoryBean() { @Override Cache init() { initCalled.set(true); return mockCache; } }; assertThat(cacheFactoryBean.getObject(), ... |
ComposableSnapshotFilter implements SnapshotFilter<K, V> { @SuppressWarnings("unchecked") protected static <K, V> SnapshotFilter<K, V> compose(Operator operator, SnapshotFilter<K, V>... snapshotFilters) { SnapshotFilter<K, V> composedSnapshotFilter = null; for (SnapshotFilter<K, V> snapshotFilter : nullSafeArray(snapsh... | @Test public void composeSingle() { SnapshotFilter mockSnapshotFilter = mockSnapshotFilter(false); SnapshotFilter composedFilter = ComposableSnapshotFilter.compose(Operator.AND, mockSnapshotFilter); assertThat(composedFilter, is(sameInstance(mockSnapshotFilter))); }
@Test public void composeMultiple() throws Exception ... |
SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport<SnapshotServiceAdapter<K, V>> implements InitializingBean, DisposableBean, ApplicationListener<SnapshotApplicationEvent<K, V>> { static boolean nullSafeIsDirectory(File file) { return file != null && file.isDirectory(); } @Override @SuppressWarnings("unchec... | @Test public void nullSafeIsDirectoryWithDirectory() { assertThat(SnapshotServiceFactoryBean.nullSafeIsDirectory(new File(System.getProperty("user.dir"))), is(true)); }
@Test public void nullSafeIsDirectoryWithNonDirectories() { assertThat(SnapshotServiceFactoryBean.nullSafeIsDirectory(new File("path/to/non-existing/di... |
SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport<SnapshotServiceAdapter<K, V>> implements InitializingBean, DisposableBean, ApplicationListener<SnapshotApplicationEvent<K, V>> { static boolean nullSafeIsFile(File file) { return file != null && file.isFile(); } @Override @SuppressWarnings("unchecked") void... | @Test public void nullSafeIsFileWithFile() { assertThat(SnapshotServiceFactoryBean.nullSafeIsFile(FileSystemUtils.JAVA_EXE), is(FileSystemUtils.JAVA_EXE.isFile())); }
@Test public void nullSafeIsFileWithNonFiles() { assertThat(SnapshotServiceFactoryBean.nullSafeIsFile(new File("/path/to/non-existing/file.ext")), is(fal... |
SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport<SnapshotServiceAdapter<K, V>> implements InitializingBean, DisposableBean, ApplicationListener<SnapshotApplicationEvent<K, V>> { public void setCache(Cache cache) { this.cache = Optional.ofNullable(cache) .orElseThrow(() -> newIllegalArgumentException("The G... | @Test public void setCacheToNull() { exception.expect(IllegalArgumentException.class); exception.expectCause(is(nullValue(Throwable.class))); exception.expectMessage("The GemFire Cache must not be null"); factoryBean.setCache(null); } |
SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport<SnapshotServiceAdapter<K, V>> implements InitializingBean, DisposableBean, ApplicationListener<SnapshotApplicationEvent<K, V>> { protected Cache getCache() { return Optional.ofNullable(this.cache) .orElseThrow(() -> newIllegalStateException("The GemFire Cach... | @Test public void getCacheWhenUninitialized() { exception.expect(IllegalStateException.class); exception.expectCause(is(nullValue(Throwable.class))); exception.expectMessage("The GemFire Cache was not properly initialized"); factoryBean.getCache(); } |
SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport<SnapshotServiceAdapter<K, V>> implements InitializingBean, DisposableBean, ApplicationListener<SnapshotApplicationEvent<K, V>> { @Override public boolean isSingleton() { return true; } @Override @SuppressWarnings("unchecked") void afterPropertiesSet(); void... | @Test public void isSingletonIsTrue() { assertThat(factoryBean.isSingleton(), is(true)); } |
SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport<SnapshotServiceAdapter<K, V>> implements InitializingBean, DisposableBean, ApplicationListener<SnapshotApplicationEvent<K, V>> { protected SnapshotServiceAdapter<Object, Object> wrap(CacheSnapshotService cacheSnapshotService) { return new CacheSnapshotServic... | @Test public void wrapNullCacheSnapshotService() { exception.expect(IllegalArgumentException.class); exception.expectCause(is(nullValue(Throwable.class))); exception.expectMessage("The backing CacheSnapshotService must not be null"); factoryBean.wrap((CacheSnapshotService) null); }
@Test public void wrapNullRegionSnaps... |
CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache> implements DisposableBean, InitializingBean, PersistenceExceptionTranslator, Phased { @SuppressWarnings("deprecation") GemFireCache init() { ClassLoader currentThreadContextClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.curren... | @Test @SuppressWarnings("deprecation") public void init() throws Exception { BeanFactory mockBeanFactory = mock(BeanFactory.class); Cache mockCache = mock(Cache.class); CacheTransactionManager mockCacheTransactionManager = mock(CacheTransactionManager.class); DistributedMember mockDistributedMember = mock(DistributedMe... |
SnapshotApplicationEvent extends ApplicationEvent { public boolean matches(Region region) { return (region != null && matches(region.getFullPath())); } SnapshotApplicationEvent(Object source, SnapshotMetadata<K, V>... snapshotMetadata); SnapshotApplicationEvent(Object source, String regionPath, SnapshotMetadata<K, V>.... | @Test public void matchesNullRegionIsFalse() { assertThat(new TestSnapshotApplicationEvent(this).matches((Region) null), is(false)); }
@Test public void matchesNonMatchingRegionIsFalse() { Region mockRegion = mock(Region.class, "MockRegion"); when(mockRegion.getFullPath()).thenReturn("/Example"); assertThat(new TestSna... |
SpringServerLauncherCacheProvider implements ServerLauncherCacheProvider { @Override public Cache createCache(Properties gemfireProperties, ServerLauncher serverLauncher) { Cache cache = null; if (serverLauncher.isSpringXmlLocationSpecified()) { System.setProperty(gemfireName(), serverLauncher.getMemberName()); newSpri... | @Test public void createsCacheWhenSpringXmlLocationIsSpecified() { Cache mockCache = mock(Cache.class); ConfigurableApplicationContext mockApplicationContext = mock(ConfigurableApplicationContext.class); ServerLauncher mockServerLauncher = mock(ServerLauncher.class); SpringContextBootstrappingInitializer.applicationCon... |
ConnectionEndpointList extends AbstractList<ConnectionEndpoint> { public static ConnectionEndpointList parse(int defaultPort, String... hostsPorts) { List<ConnectionEndpoint> connectionEndpoints = new ArrayList<ConnectionEndpoint>( ArrayUtils.length(hostsPorts)); for (String hostPort : ArrayUtils.nullSafeArray(hostsPor... | @Test public void parse() { ConnectionEndpointList list = ConnectionEndpointList.parse(24842, "mercury[11235]", "venus", "[12480]", "[]", "jupiter[]", "saturn[1, 2-Hundred and 34.zero5]", "neptune[four]"); String[] expectedHostPorts = { "mercury[11235]", "venus[24842]", "localhost[12480]", "localhost[24842]", "jupiter[... |
ConnectionEndpointList extends AbstractList<ConnectionEndpoint> { @Override @SuppressWarnings("all") public ConnectionEndpoint[] toArray() { return connectionEndpoints.toArray(new ConnectionEndpoint[connectionEndpoints.size()]); } ConnectionEndpointList(); ConnectionEndpointList(ConnectionEndpoint... connectionEndpoin... | @Test public void toArrayFromEmptyList() { ConnectionEndpoint[] connectionEndpoints = new ConnectionEndpointList().toArray(); assertThat(connectionEndpoints, is(notNullValue())); assertThat(connectionEndpoints.length, is(equalTo(0))); } |
ConnectionEndpointList extends AbstractList<ConnectionEndpoint> { @Override public String toString() { return connectionEndpoints.toString(); } ConnectionEndpointList(); ConnectionEndpointList(ConnectionEndpoint... connectionEndpoints); ConnectionEndpointList(Iterable<ConnectionEndpoint> connectionEndpoints); static ... | @Test public void toStringFromEmptyList() { assertThat(new ConnectionEndpointList().toString(), is(equalTo("[]"))); } |
CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache> implements DisposableBean, InitializingBean, PersistenceExceptionTranslator, Phased { @SuppressWarnings("unchecked") protected <T extends GemFireCache> T resolveCache() { try { this.cacheResolutionMessagePrefix = "Found existing"; return (T) fetchCache()... | @Test public void resolveCacheCallsFetchCacheReturnsMock() { Cache mockCache = mock(Cache.class); CacheFactoryBean cacheFactoryBean = new CacheFactoryBean() { @Override @SuppressWarnings("unchecked ") protected <T extends GemFireCache> T fetchCache() { return (T) mockCache; } }; assertThat(cacheFactoryBean.resolveCache... |
SpringContextBootstrappingInitializer implements Declarable, ApplicationListener<ApplicationContextEvent> { public static synchronized ConfigurableApplicationContext getApplicationContext() { Assert.state(applicationContext != null, "A Spring ApplicationContext was not configured and initialized properly"); return appl... | @Test public void getInitializedApplicationContext() { ConfigurableApplicationContext mockApplicationContext = mock(ConfigurableApplicationContext.class, "testGetApplicationContext"); SpringContextBootstrappingInitializer.applicationContext = mockApplicationContext; assertThat(SpringContextBootstrappingInitializer.getA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.