src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
GridFile extends File { @Override public void deleteOnExit() { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chunkSize, G... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testDeleteOnExit() { fs.getFile("nonsuch.txt").deleteOnExit(); } |
GridFile extends File { @Override public boolean renameTo(File dest) { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chun... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testRenameTo(){ fs.getFile("file.txt").renameTo(null); } |
GridFile extends File { @Override public String getCanonicalPath() throws IOException { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metada... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testGetCanonicalPath() throws IOException { fs.getFile("nonsuch.txt").getCanonicalPath(); } |
GridFile extends File { @Override public File getCanonicalFile() throws IOException { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadata... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testGetCanonicalFile() throws IOException { fs.getFile("nonsuch.txt").getCanonicalFile(); } |
GridFile extends File { @Override public URL toURL() throws MalformedURLException { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCa... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testToURL() throws MalformedURLException { fs.getFile("nonsuch.txt").toURL(); } |
GridFile extends File { @Override public URI toURI() { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chunkSize, GridFiles... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testToURI() { fs.getFile("nonsuch.txt").toURI(); } |
GridFile extends File { @Override public boolean setReadOnly() { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chunkSize,... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testSetReadOnly() { fs.getFile("nonsuch.txt").setReadOnly(); } |
GridFile extends File { @Override public boolean setWritable(boolean writable, boolean ownerOnly) { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Meta... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testSetWritable() { fs.getFile("nonsuch.txt").setWritable(true); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testSetWritable2() { fs.getFile("nonsuch.txt").setWritable(true, true); } |
GridFile extends File { @Override public boolean setReadable(boolean readable, boolean ownerOnly) { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Meta... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testSetReadable() { fs.getFile("nonsuch.txt").setReadable(true); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testSetReadable2() { fs.getFile("nonsuch.txt").setReadable(true, true); } |
GridFile extends File { @Override public boolean setExecutable(boolean executable, boolean ownerOnly) { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, ... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testSetExecutable() { fs.getFile("nonsuch.txt").setExecutable(true); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testSetExecutable2() { fs.getFile("nonsuch.txt").setExecutable(true, true); } |
GridFile extends File { @Override public long getTotalSpace() { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chunkSize, ... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testGetTotalSpace() { fs.getFile("nonsuch.txt").getTotalSpace(); } |
GridFile extends File { @Override public long getFreeSpace() { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chunkSize, G... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testGetFreeSpace() { fs.getFile("nonsuch.txt").getFreeSpace(); } |
GridFile extends File { @Override public long getUsableSpace() { throw new UnsupportedOperationException("Not implemented"); } GridFile(String pathname, Cache<String, Metadata> metadataCache, int chunkSize, GridFilesystem fs); GridFile(String parent, String child, Cache<String, Metadata> metadataCache, int chunkSize,... | @Test(expectedExceptions = UnsupportedOperationException.class) public void testGetUsableSpace() { fs.getFile("nonsuch.txt").getUsableSpace(); } |
CacheHealthImpl implements CacheHealth { @Override public HealthStatus getStatus() { if (!isComponentHealthy() || cache.getAdvancedCache().getAvailability() == AvailabilityMode.DEGRADED_MODE) { return HealthStatus.DEGRADED; } DistributionManager distributionManager = SecurityActions.getDistributionManager(cache); if (d... | @Test public void testHealthyStatus() { CacheImpl<Object, Object> cache = spy(new CacheImpl<>("test")); DistributionManager distributionManagerMock = mock(DistributionManager.class); doReturn(false).when(distributionManagerMock).isRehashInProgress(); doReturn(distributionManagerMock).when(cache).getDistributionManager(... |
QueueAsyncInvocationStage extends SimpleAsyncInvocationStage implements BiConsumer<Object, Throwable>,
InvocationCallback { InvocationCallback queuePoll() { InvocationCallback element; synchronized (this) { if (tail != head) { element = elements[head & mask]; head++; } else { element = null; frozen = true; } } re... | @Test(dataProvider = "offsets") public void testExpandCapacity(int splitOffset) throws Throwable { CompletableFuture<Object> future = new CompletableFuture<>(); QueueAsyncInvocationStage stage = new QueueAsyncInvocationStage(null, null, future, makeCallback(0)); assertCallback(0, stage.queuePoll()); addAndPoll(stage, s... |
UnpooledOffHeapMemoryAllocator implements OffHeapMemoryAllocator { public static long estimateSizeOverhead(long size) { return (size + 8 + 15) & ~15; } @Override long allocate(long memoryLength); @Override void deallocate(long memoryAddress, long size); @Override long getAllocatedAmount(); static long estimateSizeOver... | @Test(dataProvider = "roundings") public void testRoundings(long original, long expected) { assertEquals(expected, UnpooledOffHeapMemoryAllocator.estimateSizeOverhead(original)); } |
DataContainerFactory extends AbstractNamedCacheComponentFactory implements
AutoInstantiableFactory { @Override public Object construct(String componentName) { ClusteringConfiguration clusteringConfiguration = configuration.clustering(); boolean shouldSegment = clusteringConfiguration.cacheMode().needsStateTransfe... | @Test public void testDefaultConfigurationDataContainer() { dataContainerFactory.configuration = new ConfigurationBuilder().build(); assertEquals(DefaultDataContainer.class, dataContainerFactory.construct(COMPONENT_NAME).getClass()); }
@Test public void testOffHeap() { dataContainerFactory.configuration = new Configura... |
BaseCacheResource { private CompletionStage<RestResponse> putInCache(NettyRestResponse.Builder responseBuilder, AdvancedCache<Object, Object> cache, Object key, byte[] data, Long ttl, Long idleTime) { Configuration config = SecurityActions.getCacheConfiguration(cache); final Metadata metadata = CacheOperationsHelper.cr... | @Test public void testIntegerKeysXmlToTextValues() { Integer key = 123; String keyContentType = "application/x-java-object;type=java.lang.Integer"; String valueContentType = "application/xml; charset=UTF-8"; String value = "<root>test</root>"; putInCache("default", key, keyContentType, value, valueContentType); RestRes... |
CounterResource implements ResourceHandler { private CompletionStage<RestResponse> createCounter(RestRequest request) throws RestResponseException { NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder(); String counterName = request.variables().get("counterName"); String contents = request.content... | @Test public void testWeakCounterLifecycle() { CounterConfiguration counterConfig = CounterConfiguration.builder(CounterType.WEAK) .initialValue(5).storage(Storage.VOLATILE).concurrencyLevel(6).build(); createCounter("sample-counter", counterConfig); RestCounterClient counterClient = client.counter("sample-counter"); R... |
StringPropertyReplacer { public static String replaceProperties(final String string) { return replaceProperties(string, null); } static String replaceProperties(final String string); static String replaceProperties(final String string, final Properties props); static void replaceProperties(Map<String, String> map, Pro... | @Test public void testReplaceProperties() { Properties properties = new Properties(); properties.put("one", "1"); properties.put("two", "2"); assertEquals("V1", StringPropertyReplacer.replaceProperties("V${one}", properties)); assertEquals("VX", StringPropertyReplacer.replaceProperties("V${void:X}", properties)); asser... |
XSiteResource implements ResourceHandler { private CompletionStage<RestResponse> backupStatus(RestRequest request) { return statusOperation(request, SITES_STATUS); } XSiteResource(InvocationHelper invocationHelper); @Override Invocations getInvocations(); static final String AFTER_FAILURES_FIELD; static final String MI... | @Test public void testInvalidSite() { RestClient client = clientPerSite.get(LON); RestCacheClient cache = client.cache(CACHE_1); assertStatus(404, cache.backupStatus("invalid-site")); } |
XSiteResource implements ResourceHandler { private CompletionStage<RestResponse> pushStateStatus(RestRequest request) { return statusOperation(request, PUSH_STATE_STATUS); } XSiteResource(InvocationHelper invocationHelper); @Override Invocations getInvocations(); static final String AFTER_FAILURES_FIELD; static final S... | @Test public void testPushState() { RestCacheClient cache = getCacheClient(LON); RestCacheClient backupCache = getCacheClient(NYC); String key = "key"; String value = "value"; Function<String, Integer> keyOnBackup = k -> responseStatus(backupCache.get(key)); takeBackupOffline(LON, NYC); assertEquals(OFFLINE, getBackupS... |
XSiteResource implements ResourceHandler { private CompletionStage<RestResponse> cancelPushState(RestRequest restRequest) { return executeXSiteCacheOp(restRequest, CANCEL_PUSH_STATE); } XSiteResource(InvocationHelper invocationHelper); @Override Invocations getInvocations(); static final String AFTER_FAILURES_FIELD; st... | @Test public void testCancelPushState() throws Exception { RestCacheClient cache = getCacheClient(LON); RestCacheClient backupCache = getCacheClient(NYC); takeBackupOffline(LON, NYC); assertEquals(OFFLINE, getBackupStatus(LON, NYC)); int entries = 50; IntStream.range(0, entries).forEach(i -> assertNoContent(cache.put(S... |
PathInterpreter { static Map<String, String> resolveVariables(String expression, String str) { if (expression == null || str == null) return Collections.emptyMap(); Map<String, String> resolvedVariables = new HashMap<>(); StringBuilder variableBuilder = new StringBuilder(); State state = State.TEXT; int j = 0; int expr... | @Test public void testSingleVariable() { Map<String, String> res = resolveVariables("{id}", "5435"); assertEquals(1, res.size()); assertEquals(res.get("id"), "5435"); }
@Test public void testSingleVariable2() { Map<String, String> res = resolveVariables("{variable_name}", "a"); assertEquals(1, res.size()); assertEquals... |
RangeSet implements IntSet { @Override public int size() { return size; } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfInt iterator(); @Override int[] toIntArray(); @Override Object[] toArray... | @Test public void testSize() { RangeSet rs = new RangeSet(4); assertEquals(4, rs.size()); } |
ResourceManagerImpl implements ResourceManager { @Override public LookupResult lookupResource(Method method, String path, String action) { List<PathItem> pathItems = Arrays.stream(path.replaceAll(" .map(s -> s.isEmpty() ? "/" : s).map(QueryStringDecoder::decodeComponent).map(PathItem::fromString).collect(Collectors.toL... | @Test public void testLookupHandler() { registerHandler("root", "CompaniesHandler", "/companies", "/companies/{company}", "/companies/{company}/{id}"); registerHandler("root", "StocksHandler", "/stocks/{stock}", "/stocks/{stock}/{currency}"); registerHandler("root", "DirectorsHandler", "/directors", "/directors/directo... |
RestCacheManager { @SuppressWarnings("unchecked") public AdvancedCache<Object, V> getCache(String name, MediaType keyContentType, MediaType valueContentType, RestRequest request) { Subject subject = request.getSubject(); Flag[] flags = request.getFlags(); if (isCacheIgnored.test(name)) { throw logger.cacheUnavailable(n... | @Test public void shouldReuseEncodedCaches() { EmbeddedCacheManager embeddedCacheManager = Mockito.spy(cacheManager); RestCacheManager<Object> restCacheManager = new RestCacheManager<>(embeddedCacheManager, c -> Boolean.FALSE); Map<String, Cache<String, ?>> knownCaches = TestingUtil.extractField(restCacheManager, "know... |
RangeSet implements IntSet { @Override public boolean isEmpty() { return size <= 0; } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfInt iterator(); @Override int[] toIntArray(); @Override Obje... | @Test public void testIsEmpty() { RangeSet rs = new RangeSet(0); assertTrue(rs.isEmpty()); rs = new RangeSet(3); assertFalse(rs.isEmpty()); } |
ServiceFinder { public static <T> Collection<T> load(Class<T> contract, ClassLoader... loaders) { Map<String, T> services = new LinkedHashMap<>(); if (loaders.length == 0) { try { ServiceLoader<T> loadedServices = ServiceLoader.load(contract); addServices(loadedServices, services); } catch (Exception e) { } } else { fo... | @Test public void testDuplicateServiceFinder() { ClassLoader mainClassLoader = this.getClass().getClassLoader(); ClassLoader otherClassLoader = new ClonedClassLoader(mainClassLoader); Collection<SampleSPI> spis = ServiceFinder.load(SampleSPI.class, mainClassLoader, otherClassLoader); assertEquals(1, spis.size()); } |
RestRouteSource implements PrefixedRouteSource { @Override public void validate() { if (pathPrefix == null || !pathPrefix.matches("\\w+")) { throw new IllegalArgumentException("Path is incorrect"); } } RestRouteSource(String pathPrefix); @Override String getRoutePrefix(); @Override String toString(); @Override void val... | @Test(expected = IllegalArgumentException.class) public void shouldValidatePath() { new RestRouteSource(null).validate(); }
@Test(expected = IllegalArgumentException.class) public void shouldValidateWithWhiteCharacters() { new RestRouteSource("12312 234").validate(); }
@Test(expected = IllegalArgumentException.class) p... |
RestServerRouteDestination implements RouteDestination { @Override public void validate() { if (name == null || "".equals(name)) { throw new IllegalArgumentException("Name can not be null"); } if (restServer == null) { throw new IllegalArgumentException("REST resource can not be null"); } } RestServerRouteDestination(S... | @Test(expected = IllegalArgumentException.class) public void shouldValidateName() { new RestServerRouteDestination(null, new RestServer()).validate(); }
@Test(expected = IllegalArgumentException.class) public void shouldValidateRestResource() { new RestServerRouteDestination("test", null).validate(); } |
SniNettyRouteSource implements SniRouteSource { @Override public void validate() { if (sniHostName == null || "".equals(sniHostName)) { throw new IllegalArgumentException("SNI Host name can not be null"); } if (jdkContext == null) { throw new IllegalArgumentException("JDK SSL Context must not be null"); } } SniNettyRou... | @Test(expected = IllegalArgumentException.class) public void shouldValidateSniHostName() throws Exception { new SniNettyRouteSource(null, SSLContext.getDefault()).validate(); }
@Test(expected = IllegalArgumentException.class) public void shouldValidateSSLContext() throws Exception { new SniNettyRouteSource("test", null... |
HotRodServerRouteDestination implements RouteDestination { @Override public void validate() { if (name == null || "".equals(name)) { throw new IllegalArgumentException("Name can not be null"); } if (hotrodServer == null) { throw new IllegalArgumentException("Channels can not be null"); } } HotRodServerRouteDestination(... | @Test(expected = IllegalArgumentException.class) public void shouldValidateName() { new HotRodServerRouteDestination(null, new HotRodServer()).validate(); }
@Test(expected = IllegalArgumentException.class) public void shouldValidateChannelInitializer() { new HotRodServerRouteDestination("test", null).validate(); } |
RangeSet implements IntSet { @Override public boolean contains(Object o) { if (!(o instanceof Integer)) return false; int i = (int) o; return contains(i); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override Primitive... | @Test public void contains() throws Exception { RangeSet rs = new RangeSet(4); assertFalse(rs.contains(5)); assertTrue(rs.contains(1)); }
@Test public void contains1() throws Exception { RangeSet rs = new RangeSet(4); assertFalse(rs.contains(Integer.valueOf(5))); assertTrue(rs.contains(Integer.valueOf(1))); } |
JsonTranscoder extends OneToManyTranscoder { @Override public Object transcode(Object content, MediaType contentType, MediaType destinationType) { if (destinationType.match(APPLICATION_OCTET_STREAM) || destinationType.match(APPLICATION_UNKNOWN)) { return StandardConversions.convertTextToOctetStream(content, contentType... | @Test public void testEmptyContent() { byte[] empty = Util.EMPTY_BYTE_ARRAY; assertArrayEquals(empty, (byte[]) transcoder.transcode(empty, APPLICATION_JSON, APPLICATION_JSON.withCharset(US_ASCII))); assertArrayEquals(empty, (byte[]) transcoder.transcode(empty, APPLICATION_UNKNOWN, APPLICATION_JSON)); assertArrayEquals(... |
RestConnector implements Connector { @Override public Connection getConnection(String connectionString, SSLContextSettings sslContextSettings) { try { RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder(); if (connectionString == null || connectionString.isEmpty() || "-".equals(connectionString)... | @Test public void testUrlWithCredentials() { RestConnector connector = new RestConnector(); RestConnection connection = (RestConnection) connector.getConnection("http: RestClientConfigurationBuilder builder = connection.getBuilder(); RestClientConfiguration configuration = builder.build(); assertEquals(11222, configura... |
SpringEmbeddedCacheManager implements CacheManager { public EmbeddedCacheManager getNativeCacheManager() { return this.nativeCacheManager; } SpringEmbeddedCacheManager(final EmbeddedCacheManager nativeCacheManager); @Override SpringCache getCache(final String name); @Override Collection<String> getCacheNames(); Embedde... | @Test public final void getNativeCacheShouldReturnTheEmbeddedCacheManagerSuppliedAtConstructionTime() { withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager()) { @Override public void call() { final SpringEmbeddedCacheManager objectUnderTest = new SpringEmbeddedCacheManager(cm); final Em... |
SpringEmbeddedCacheManager implements CacheManager { @Override public SpringCache getCache(final String name) { return springCaches.computeIfAbsent(name, n -> { final Cache<Object, Object> nativeCache = this.nativeCacheManager.getCache(n); return new SpringCache(nativeCache); }); } SpringEmbeddedCacheManager(final Embe... | @Test public final void getCacheShouldReturnSameInstanceForSameName() { withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager()) { @Override public void call() { cm.defineConfiguration("same", new ConfigurationBuilder().build()); final SpringEmbeddedCacheManager objectUnderTest = new Spri... |
SpringEmbeddedCacheManagerFactoryBean extends AbstractEmbeddedCacheManagerFactory implements FactoryBean<SpringEmbeddedCacheManager>, InitializingBean, DisposableBean { @Override public SpringEmbeddedCacheManager getObject() throws Exception { return this.cacheManager; } @Override void afterPropertiesSet(); @Override ... | @Test public void testIfSpringEmbeddedCacheManagerFactoryBeanCreatesACacheManagerEvenIfNoDefaultConfigurationLocationHasBeenSet() throws Exception { objectUnderTest = SpringEmbeddedCacheManagerFactoryBeanBuilder .defaultBuilder().build(); final SpringEmbeddedCacheManager springEmbeddedCacheManager = objectUnderTest.get... |
SpringEmbeddedCacheManagerFactoryBean extends AbstractEmbeddedCacheManagerFactory implements FactoryBean<SpringEmbeddedCacheManager>, InitializingBean, DisposableBean { @Override public boolean isSingleton() { return true; } @Override void afterPropertiesSet(); @Override SpringEmbeddedCacheManager getObject(); @Overri... | @Test public void testIfSpringEmbeddedCacheManagerFactoryBeanDeclaresItselfToOnlyProduceSingletons() { objectUnderTest = new SpringEmbeddedCacheManagerFactoryBean(); assertTrue("isSingleton() should always return true. However, it returned false", objectUnderTest.isSingleton()); } |
InfinispanNamedEmbeddedCacheFactoryBean implements FactoryBean<Cache<K, V>>,
BeanNameAware, InitializingBean, DisposableBean { @Override public boolean isSingleton() { return true; } @Override void afterPropertiesSet(); @Override Cache<K, V> getObje... | @Test public final void infinispanNamedEmbeddedCacheFactoryBeanShouldDeclareItselfToBeSingleton() { final InfinispanNamedEmbeddedCacheFactoryBean<Object, Object> objectUnderTest = new InfinispanNamedEmbeddedCacheFactoryBean<Object, Object>(); assertTrue( "InfinispanNamedEmbeddedCacheFactoryBean should declare itself to... |
InfinispanEmbeddedCacheManagerFactoryBean extends AbstractEmbeddedCacheManagerFactory implements FactoryBean<EmbeddedCacheManager>, InitializingBean, DisposableBean { @Override public boolean isSingleton() { return true; } @Override void afterPropertiesSet(); @Override EmbeddedCacheManager getObject(); @Override Class... | @Test public final void infinispanEmbeddedCacheManagerFactoryBeanShouldDeclareItselfToOnlyProduceSingletons() { final InfinispanEmbeddedCacheManagerFactoryBean objectUnderTest = new InfinispanEmbeddedCacheManagerFactoryBean(); assertTrue("isSingleton() should always return true. However, it returned false", objectUnder... |
SpringRemoteCacheManagerFactoryBean extends AbstractRemoteCacheManagerFactory implements FactoryBean<SpringRemoteCacheManager>, InitializingBean, DisposableBean { @Override public void afterPropertiesSet() throws Exception { assertCorrectlyConfigured(); this.logger.info("Creating new instance of RemoteCacheManager ..."... | @Test(expectedExceptions = IllegalStateException.class) public final void shouldThrowAnIllegalStateExceptionIfBothConfigurationPropertiesAndConfifurationPropertiesFileLocationAreSet() throws Exception { objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); objectUnderTest.setConfigurationProperties(new Propertie... |
SpringRemoteCacheManagerFactoryBean extends AbstractRemoteCacheManagerFactory implements FactoryBean<SpringRemoteCacheManager>, InitializingBean, DisposableBean { @Override public boolean isSingleton() { return true; } @Override void afterPropertiesSet(); @Override SpringRemoteCacheManager getObject(); @Override Class... | @Test public final void isSingletonShouldAlwaysReturnTrue() { objectUnderTest = new SpringRemoteCacheManagerFactoryBean(); assertTrue( "isSingleton() should always return true since each SpringRemoteCacheManagerFactoryBean will always produce " + "the same SpringRemoteCacheManager instance. However,it returned false.",... |
RangeSet implements IntSet { @Override public PrimitiveIterator.OfInt iterator() { return new RangeSetIterator(size); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfInt iterator(); @Override ... | @Test public void iterator() throws Exception { RangeSet rs = new RangeSet(4); PrimitiveIterator.OfInt iterator = rs.iterator(); assertEquals(0, iterator.nextInt()); assertEquals(1, iterator.nextInt()); assertEquals(2, iterator.nextInt()); assertEquals(3, iterator.nextInt()); } |
SpringRemoteCacheManager implements org.springframework.cache.CacheManager { @Override public SpringCache getCache(final String name) { final RemoteCache<Object, Object> nativeCache = this.nativeCacheManager.getCache(name); if (nativeCache == null) { springCaches.remove(name); return null; } return springCaches.compute... | @Test public final void springRemoteCacheManagerShouldProperlyCreateCache() { final Cache defaultCache = objectUnderTest.getCache(TEST_CACHE_NAME); assertNotNull("getCache(" + TEST_CACHE_NAME + ") should have returned a default cache. However, it returned null.", defaultCache); assertEquals("getCache(" + TEST_CACHE_NAM... |
SpringRemoteCacheManager implements org.springframework.cache.CacheManager { @Override public Collection<String> getCacheNames() { return this.nativeCacheManager.getCacheNames(); } SpringRemoteCacheManager(final RemoteCacheManager nativeCacheManager, long readTimeout, long writeTimeout); SpringRemoteCacheManager(final... | @Test public final void getCacheNamesShouldReturnAllCachesDefinedInConfigurationFile() { final Collection<String> cacheNames = objectUnderTest.getCacheNames(); assertTrue("SpringRemoteCacheManager should load all named caches found in the " + "native cache manager. However, it does not know about the cache named " + TE... |
SpringRemoteCacheManager implements org.springframework.cache.CacheManager { public void start() { this.nativeCacheManager.start(); } SpringRemoteCacheManager(final RemoteCacheManager nativeCacheManager, long readTimeout, long writeTimeout); SpringRemoteCacheManager(final RemoteCacheManager nativeCacheManager); @Overr... | @Test public final void startShouldStartTheNativeRemoteCacheManager() throws IOException { objectUnderTest.start(); assertTrue("Calling start() on SpringRemoteCacheManager should start the enclosed " + "Infinispan RemoteCacheManager. However, it is still not running.", remoteCacheManager.isStarted()); } |
SpringRemoteCacheManager implements org.springframework.cache.CacheManager { public void stop() { this.nativeCacheManager.stop(); this.springCaches.clear(); } SpringRemoteCacheManager(final RemoteCacheManager nativeCacheManager, long readTimeout, long writeTimeout); SpringRemoteCacheManager(final RemoteCacheManager na... | @Test public final void stopShouldStopTheNativeRemoteCacheManager() throws IOException { objectUnderTest.stop(); assertFalse("Calling stop() on SpringRemoteCacheManager should stop the enclosed " + "Infinispan RemoteCacheManager. However, it is still running.", remoteCacheManager.isStarted()); } |
SpringRemoteCacheManager implements org.springframework.cache.CacheManager { public RemoteCacheManager getNativeCacheManager() { return this.nativeCacheManager; } SpringRemoteCacheManager(final RemoteCacheManager nativeCacheManager, long readTimeout, long writeTimeout); SpringRemoteCacheManager(final RemoteCacheManage... | @Test public final void getNativeCacheShouldReturnTheRemoteCacheManagerSuppliedAtConstructionTime() { final RemoteCacheManager nativeCacheManagerReturned = objectUnderTest.getNativeCacheManager(); assertSame( "getNativeCacheManager() should have returned the RemoteCacheManager supplied at construction time. However, it... |
ConfigurationPropertiesOverrides { public boolean isEmpty() { return this.overridingProperties.isEmpty(); } boolean isEmpty(); @Deprecated void setTransportFactory(final String TransportFactory); void setServerList(final Collection<InetSocketAddress> serverList); void setMarshaller(final String marshaller); void setCl... | @Test public final void testIfIsEmptyRecognizesThatConfigurationPropertiesOverridesAreEmpty() { final ConfigurationPropertiesOverrides objectUnderTest = new ConfigurationPropertiesOverrides(); assertTrue( "isEmpty() should have noticed that the ConfigurationPropertiesOverrides instance is indeed empty. However, it didn... |
InfinispanRemoteCacheManagerFactoryBean extends AbstractRemoteCacheManagerFactory implements FactoryBean<RemoteCacheManager>, InitializingBean, DisposableBean { @Override public void afterPropertiesSet() throws Exception { assertCorrectlyConfigured(); this.logger.info("Creating new instance of RemoteCacheManager ...");... | @Test(expectedExceptions = IllegalStateException.class) public final void shouldThrowAnIllegalStateExceptionIfBothConfigurationPropertiesAndConfigurationPropertiesFileLocationAreSet() throws Exception { final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); object... |
RangeSet implements IntSet { @Override public Object[] toArray() { Object[] array = new Object[size]; for (int i = 0; i < size; i++) { array[i] = i; } return array; } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override... | @Test public void toArray() throws Exception { RangeSet rs = new RangeSet(4); Object[] array = rs.toArray(); assertEquals(4, array.length); assertEquals(0, array[0]); assertEquals(1, array[1]); assertEquals(2, array[2]); assertEquals(3, array[3]); }
@Test public void toArray1() throws Exception { RangeSet rs = new Rang... |
InfinispanRemoteCacheManagerFactoryBean extends AbstractRemoteCacheManagerFactory implements FactoryBean<RemoteCacheManager>, InitializingBean, DisposableBean { @Override public boolean isSingleton() { return true; } @Override void afterPropertiesSet(); @Override RemoteCacheManager getObject(); @Override Class<? exten... | @Test public final void isSingletonShouldAlwaysReturnTrue() { final InfinispanRemoteCacheManagerFactoryBean objectUnderTest = new InfinispanRemoteCacheManagerFactoryBean(); assertTrue( "isSingleton() should always return true since each AbstractRemoteCacheManagerFactory will always produce " + "the same RemoteCacheMana... |
InfinispanNamedRemoteCacheFactoryBean implements FactoryBean<RemoteCache<K, V>>,
BeanNameAware, InitializingBean { @Override public boolean isSingleton() { return true; } @Override void afterPropertiesSet(); @Override void setBeanName(final String nam... | @Test public final void infinispanNamedRemoteCacheFactoryBeanShouldDeclareItselfToBeSingleton() { final InfinispanNamedRemoteCacheFactoryBean<String, Object> objectUnderTest = new InfinispanNamedRemoteCacheFactoryBean<String, Object>(); assertTrue( "InfinispanNamedRemoteCacheFactoryBean should declare itself to produce... |
RangeSet implements IntSet { @Override public int[] toIntArray() { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = i; } return array; } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override Primi... | @Test public void toIntArray() throws Exception { RangeSet rs = new RangeSet(4); int[] array = rs.toIntArray(); assertArrayEquals(new int[]{0, 1, 2, 3}, array); } |
RangeSet implements IntSet { @Override public boolean add(Integer integer) { throw new UnsupportedOperationException("RangeSet is immutable"); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfI... | @Test(expected = UnsupportedOperationException.class) public void add() throws Exception { RangeSet rs = new RangeSet(4); rs.add(1); }
@Test(expected = UnsupportedOperationException.class) public void add1() throws Exception { RangeSet rs = new RangeSet(4); rs.add(Integer.valueOf(1)); }
@Test public void equals1() thro... |
RangeSet implements IntSet { public void set(int i) { throw new UnsupportedOperationException("RangeSet is immutable"); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfInt iterator(); @Overrid... | @Test(expected = UnsupportedOperationException.class) public void set() throws Exception { RangeSet rs = new RangeSet(4); rs.set(1); } |
RangeSet implements IntSet { @Override public boolean remove(Object o) { throw new UnsupportedOperationException("RangeSet is immutable"); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfInt i... | @Test(expected = UnsupportedOperationException.class) public void remove() throws Exception { RangeSet rs = new RangeSet(4); rs.remove(1); }
@Test(expected = UnsupportedOperationException.class) public void remove1() throws Exception { RangeSet rs = new RangeSet(4); rs.remove(Integer.valueOf(1)); } |
RangeSet implements IntSet { @Override public boolean containsAll(Collection<?> c) { if (c instanceof IntSet) { return containsAll((IntSet) c); } for (Object o : c) { if (!contains(o)) return false; } return true; } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object... | @Test public void containsAll() throws Exception { RangeSet rs = new RangeSet(4); RangeSet rs2 = new RangeSet(4); assertTrue(rs.containsAll(rs2)); RangeSet rs3 = new RangeSet(3); assertTrue(rs.containsAll(rs3)); assertFalse(rs3.containsAll(rs)); } |
RangeSet implements IntSet { @Override public boolean addAll(IntSet set) { throw new UnsupportedOperationException("RangeSet is immutable"); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfInt... | @Test(expected = UnsupportedOperationException.class) public void addAll() throws Exception { RangeSet rs = new RangeSet(4); RangeSet rs2 = new RangeSet(5); rs.addAll(rs2); }
@Test(expected = UnsupportedOperationException.class) public void addAll1() throws Exception { RangeSet rs = new RangeSet(4); SmallIntSet sis = n... |
RangeSet implements IntSet { @Override public boolean removeAll(IntSet set) { throw new UnsupportedOperationException("RangeSet is immutable"); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.Of... | @Test(expected = UnsupportedOperationException.class) public void removeAll() throws Exception { RangeSet rs = new RangeSet(4); RangeSet rs2 = new RangeSet(6); rs.removeAll(rs2); }
@Test(expected = UnsupportedOperationException.class) public void removeAll1() throws Exception { RangeSet rs = new RangeSet(5); SmallIntSe... |
RangeSet implements IntSet { @Override public boolean retainAll(Collection<?> c) { throw new UnsupportedOperationException("RangeSet is immutable"); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterat... | @Test(expected = UnsupportedOperationException.class) public void retainAll() throws Exception { RangeSet rs = new RangeSet(4); RangeSet rs2 = new RangeSet(5); rs.retainAll(rs2); }
@Test(expected = UnsupportedOperationException.class) public void retainAll1() throws Exception { IntSet rs = new RangeSet(5); SmallIntSet ... |
EmptyIntSet extends AbstractImmutableIntSet { @Override public boolean isEmpty() { return true; } static IntSet getInstance(); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override PrimitiveIterat... | @Test public void testIsEmpty() { assertTrue(es.isEmpty()); } |
RangeSet implements IntSet { @Override public void clear() { throw new UnsupportedOperationException("RangeSet is immutable"); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfInt iterator(); @... | @Test(expected = UnsupportedOperationException.class) public void clear() throws Exception { RangeSet rs = new RangeSet(5); rs.clear(); } |
RangeSet implements IntSet { @Override public IntStream intStream() { return IntStream.range(0, size); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIterator.OfInt iterator(); @Override int[] toIntArra... | @Test public void intStream() throws Exception { IntSet rs = new RangeSet(5); assertEquals(10, rs.intStream().sum()); } |
RangeSet implements IntSet { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof Set)) return false; if (o instanceof RangeSet) { RangeSet integers = (RangeSet) o; return size == integers.size; } else { Set set = (Set) o; return size == set.size() && containsAll(set);... | @Test public void equals() throws Exception { RangeSet rs = new RangeSet(4); RangeSet rs2 = new RangeSet(5); assertNotEquals(rs, rs2); assertNotEquals(rs2, rs); RangeSet rs3 = new RangeSet(4); assertEquals(rs3, rs); assertEquals(rs, rs3); } |
RangeSet implements IntSet { @Override public boolean removeIf(IntPredicate filter) { throw new UnsupportedOperationException("RangeSet is immutable"); } RangeSet(int size); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean contains(int i); @Override PrimitiveIte... | @Test(expected = UnsupportedOperationException.class) public void removeIfPrimitive() { RangeSet rs = new RangeSet(4); rs.removeIf((int i) -> i == 3); }
@Test(expected = UnsupportedOperationException.class) public void removeIfObject() { RangeSet rs = new RangeSet(4); rs.removeIf((Integer i) -> i == 3); } |
SingletonIntSet extends AbstractImmutableIntSet { @Override public int size() { return 1; } SingletonIntSet(int value); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override PrimitiveIterator.OfInt... | @Test public void testSize() { IntSet rs = new SingletonIntSet(3); assertEquals(1, rs.size()); } |
SingletonIntSet extends AbstractImmutableIntSet { @Override public boolean isEmpty() { return false; } SingletonIntSet(int value); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override PrimitiveIte... | @Test public void testIsEmpty() { IntSet rs = new SingletonIntSet(3); assertFalse(rs.isEmpty()); } |
SingletonIntSet extends AbstractImmutableIntSet { @Override public boolean contains(int i) { return value == i; } SingletonIntSet(int value); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override P... | @Test public void testContains() throws Exception { IntSet sis = new SingletonIntSet(3); assertFalse(sis.contains(5)); assertTrue(sis.contains(3)); }
@Test public void testContains1() throws Exception { IntSet sis = new SingletonIntSet(3); assertFalse(sis.contains(Integer.valueOf(5))); assertTrue(sis.contains(Integer.v... |
EmptyIntSet extends AbstractImmutableIntSet { @Override public boolean contains(int i) { return false; } static IntSet getInstance(); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Primitiv... | @Test public void testContains() throws Exception { assertFalse(es.contains(5)); assertFalse(es.contains(3)); }
@Test public void testContains1() throws Exception { assertFalse(es.contains(Integer.valueOf(5))); assertFalse(es.contains(Integer.valueOf(3))); } |
SingletonIntSet extends AbstractImmutableIntSet { @Override public PrimitiveIterator.OfInt iterator() { return new SingleIntIterator(); } SingletonIntSet(int value); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contain... | @Test public void testIterator() throws Exception { IntSet sis = new SingletonIntSet(3); PrimitiveIterator.OfInt iterator = sis.iterator(); assertEquals(3, iterator.nextInt()); assertFalse(iterator.hasNext()); } |
SingletonIntSet extends AbstractImmutableIntSet { @Override public Object[] toArray() { Object[] array = new Object[1]; array[0] = value; return array; } SingletonIntSet(int value); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override... | @Test public void testToArray() throws Exception { IntSet sis = new SingletonIntSet(3); Object[] array = sis.toArray(); assertEquals(1, array.length); assertEquals(3, array[0]); }
@Test public void testToArray1() throws Exception { IntSet sis = new SingletonIntSet(3); Object[] array = sis.toArray(new Integer[1]); asser... |
SingletonIntSet extends AbstractImmutableIntSet { @Override public int[] toIntArray() { int[] array = new int[1]; array[0] = value; return array; } SingletonIntSet(int value); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boole... | @Test public void testToIntArray() throws Exception { IntSet sis = new SingletonIntSet(3); int[] array = sis.toIntArray(); assertArrayEquals(new int[]{3}, array); } |
SingletonIntSet extends AbstractImmutableIntSet { @Override public boolean containsAll(IntSet set) { int size = set.size(); return size == 0 || size == 1 && set.contains(value); } SingletonIntSet(int value); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override bo... | @Test public void testContainsAll() throws Exception { IntSet sis = new SingletonIntSet(3); IntSet sis2 = new SingletonIntSet(3); assertTrue(sis.containsAll(sis2)); assertTrue(sis2.containsAll(sis)); IntSet sis3 = new RangeSet(4); assertTrue(sis3.containsAll(sis)); assertFalse(sis.containsAll(sis3)); }
@Test public voi... |
SingletonIntSet extends AbstractImmutableIntSet { @Override public IntStream intStream() { return IntStream.of(value); } SingletonIntSet(int value); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Ove... | @Test public void testIntStream() throws Exception { IntSet sis = new SingletonIntSet(3); assertEquals(1, sis.intStream().count()); } |
SingletonIntSet extends AbstractImmutableIntSet { @Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null || !(o instanceof Set)) return false; if (o instanceof IntSet) { IntSet intSet = (IntSet) o; return intSet.size() == 1 && intSet.contains(value); } else { Set set = (Set) o; return... | @Test public void testEquals() throws Exception { IntSet sis = new SingletonIntSet(3); IntSet sis2 = new SingletonIntSet(4); assertNotEquals(sis, sis2); assertNotEquals(sis2, sis); IntSet sis3 = SmallIntSet.of(3); assertEquals(sis3, sis); assertEquals(sis, sis3); } |
ProcessorInfo { public static int availableProcessors() { if (System.getSecurityManager() != null) { return AccessController.doPrivileged((PrivilegedAction<Integer>) () -> Integer.valueOf(org.infinispan.commons.jdkspecific.ProcessorInfo.availableProcessors()).intValue()); } return org.infinispan.commons.jdkspecific.Pro... | @Test @Category(Java11.class) public void testCPUCount() { assertTrue(ProcessorInfo.availableProcessors() <= Runtime.getRuntime().availableProcessors()); } |
Features { public Features(ClassLoader classLoader) { features = new Properties(); try { Collection<URL> featureFiles = FileLookupFactory.newInstance().lookupFileLocations(FEATURES_FILE, classLoader); for (URL url : featureFiles) { try (InputStream is = url.openStream()) { features.load(is); } } if (log.isDebugEnabled(... | @Test public void testFeatures() { Features features = new Features(); assertFalse(features.isAvailable("A")); assertTrue(features.isAvailable("B")); } |
Features { public boolean isAvailable(String featureName) { String name = FEATURE_PREFIX + featureName; String sysprop = SecurityActions.getProperty(name); if (sysprop != null) { return Boolean.parseBoolean(sysprop); } else { return Boolean.parseBoolean(features.getProperty(name, "true")); } } Features(ClassLoader clas... | @Test public void featureSysOverride() { Features features = new Features(); assertFalse(features.isAvailable("A")); System.setProperty("org.infinispan.feature.A", "true"); System.setProperty("org.infinispan.feature.B", "false"); boolean a = features.isAvailable("A"); boolean b = features.isAvailable("B"); System.clear... |
JavaSerializationMarshaller extends AbstractMarshaller { @Override public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException, ClassNotFoundException { try (ObjectInputStream ois = new CheckedInputStream(new ByteArrayInputStream(buf), allowList)) { return ois.readObject(); } } JavaSeriali... | @Test public void testPrimitiveArrays() throws Exception { JavaSerializationMarshaller marshaller = new JavaSerializationMarshaller(); byte[] bytes = marshaller.objectToByteBuffer(new byte[0]); assertArrayEquals(new byte[0], (byte[]) marshaller.objectFromByteBuffer(bytes)); bytes = marshaller.objectToByteBuffer(new sho... |
JavaSerializationMarshaller extends AbstractMarshaller { @Override public boolean isMarshallable(Object o) { return o instanceof Serializable; } JavaSerializationMarshaller(); JavaSerializationMarshaller(ClassAllowList allowList); @Override void initialize(ClassAllowList classAllowList); @Override Object objectFromByt... | @Test public void testBoxedPrimitivesAndArray() throws Exception { JavaSerializationMarshaller marshaller = new JavaSerializationMarshaller(); isMarshallable(marshaller, Byte.MAX_VALUE); isMarshallable(marshaller, Short.MAX_VALUE); isMarshallable(marshaller, Integer.MAX_VALUE); isMarshallable(marshaller, Long.MAX_VALUE... |
MediaTypeResolver { public static String getMediaType(String fileName) { if (fileName == null) return null; int idx = fileName.lastIndexOf("."); if (idx == -1 || idx == fileName.length()) return null; return FILE_MAP.get(fileName.toLowerCase().substring(idx + 1)); } private MediaTypeResolver(); static String getMediaT... | @Test public void testResolver() { assertNull(MediaTypeResolver.getMediaType(null)); assertNull(MediaTypeResolver.getMediaType("noextension")); assertNull(MediaTypeResolver.getMediaType("124.")); assertEquals("application/javascript", MediaTypeResolver.getMediaType("file.js")); assertEquals("image/jpeg", MediaTypeResol... |
MediaType { @ProtoFactory public static MediaType fromString(String tree) { if (tree == null || tree.isEmpty()) throw CONTAINER.missingMediaType(); Matcher matcher = TREE_PATTERN.matcher(tree); return parseSingleMediaType(tree, matcher, false); } MediaType(String type, String subtype); MediaType(String type, String su... | @Test public void testParsingTypeSubType() { MediaType appJson = MediaType.fromString("application/json"); assertMediaTypeNoParams(appJson, "application", "json"); }
@Test(expected = EncodingException.class) public void testParsingMultipleSubType() { MediaType.fromString("application/json/on"); }
@Test(expected = Encod... |
EmptyIntSet extends AbstractImmutableIntSet { @Override public PrimitiveIterator.OfInt iterator() { return EmptyIntIterator.INSTANCE; } static IntSet getInstance(); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contain... | @Test public void testIterator() throws Exception { PrimitiveIterator.OfInt iterator = es.iterator(); assertFalse(iterator.hasNext()); } |
EmptyIntSet extends AbstractImmutableIntSet { @Override public Object[] toArray() { return new Object[0]; } static IntSet getInstance(); @Override boolean contains(int i); @Override boolean containsAll(IntSet set); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Primi... | @Test public void testToArray() throws Exception { Object[] array = es.toArray(); assertEquals(0, array.length); }
@Test public void testToArray1() throws Exception { Object[] array = es.toArray(new Integer[1]); assertEquals(1, array.length); assertEquals(null, array[0]); array = es.toArray(new Integer[0]); assertEqual... |
MediaType { @Override public String toString() { return toStringExcludingParam(WEIGHT_PARAM_NAME); } MediaType(String type, String subtype); MediaType(String type, String subtype, Map<String, String> params); MediaType(String typeSubtype); MediaType(String typeSubType, Map<String, String> params); private MediaType... | @Test public void testToString() { assertEquals("application/xml", new MediaType("application", "xml", createMap(new MapEntry("q", "0.9"))).toString()); assertEquals("text/csv", new MediaType("text", "csv").toString()); assertEquals("foo/bar; a=2", new MediaType("foo", "bar", createMap(new MapEntry("a", "2"))).toString... |
MediaType { private static double parseWeight(String weightValue) { try { return Double.parseDouble(weightValue); } catch (NumberFormatException nf) { throw CONTAINER.invalidWeight(weightValue); } } MediaType(String type, String subtype); MediaType(String type, String subtype, Map<String, String> params); MediaType(S... | @Test public void testParseWeight() { MediaType mediaType = MediaType.fromString("application/json; q=0.8"); assertEquals(0.8, mediaType.getWeight(), 0.0); } |
MediaType { public static Stream<MediaType> parseList(String mediaTypeList) { if (mediaTypeList == null || mediaTypeList.isEmpty()) throw CONTAINER.missingMediaType(); Matcher matcher = TREE_PATTERN.matcher(mediaTypeList); List<MediaType> list = new ArrayList<>(); while (true) { MediaType mediaType = parseSingleMediaTy... | @Test public void testParseList() { List<MediaType> mediaTypes = MediaType.parseList("text/html, image/png,**").collect(Collectors.toList()); assertEquals(asList(MediaType.TEXT_HTML.withParameter("a", "\"b,\""), MediaType.MATCH_ALL), mediaTypes2); }
@Test public void testParseSingleAsterix() { List<String> list = Media... |
MediaType { public boolean match(MediaType other) { if (other == this) return true; return other != null && (other.matchesAll() || this.matchesAll() || other.typeSubtype.equals(this.typeSubtype)); } MediaType(String type, String subtype); MediaType(String type, String subtype, Map<String, String> params); MediaType(S... | @Test public void testMediaTypeMatch() { MediaType one = MediaType.APPLICATION_JSON; MediaType two = MediaType.APPLICATION_JSON; assertTrue(one.match(two)); assertTrue(two.match(one)); }
@Test public void testMediaTypeUnMatch() { MediaType one = MediaType.APPLICATION_JSON; MediaType two = MediaType.APPLICATION_JAVASCRI... |
StandardConversions { public static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType) { if (source == null) return null; if (sourceType == null) throw new NullPointerException("MediaType cannot be null!"); if (!sourceType.match(MediaType.TEXT_PLAIN)) throw CONTAINER.invalidMediaTy... | @Test public void textToTextConversion() { String source = "All those moments will be lost in time, like tears in rain."; byte[] sourceAs8859 = source.getBytes(ISO_8859_1); byte[] sourceAsASCII = source.getBytes(US_ASCII); Object result = StandardConversions.convertTextToText(sourceAs8859, TEXT_PLAIN.withCharset(ISO_88... |
StandardConversions { public static byte[] convertTextToOctetStream(Object source, MediaType sourceType) { if (source == null) return null; if (sourceType == null) { throw new NullPointerException("MediaType cannot be null!"); } if (source instanceof byte[]) return (byte[]) source; return source.toString().getBytes(sou... | @Test public void testTextToOctetStreamConversion() { String source = "Like our owl?"; byte[] result = StandardConversions.convertTextToOctetStream(source, TEXT_PLAIN); assertArrayEquals(source.getBytes(UTF_8), result); } |
StandardConversions { public static String convertTextToObject(Object source, MediaType sourceType) { if (source == null) return null; if (source instanceof String) return source.toString(); if (source instanceof byte[]) { byte[] bytesSource = (byte[]) source; return new String(bytesSource, sourceType.getCharset()); } ... | @Test public void testTextToObjectConversion() { String source = "Can the maker repair what he makes?"; String source2 = "I had your job once. I was good at it."; byte[] sourceBytes = source2.getBytes(US_ASCII); Object result = StandardConversions.convertTextToObject(source, APPLICATION_OBJECT); Object result2 = Standa... |
StandardConversions { public static String convertTextToUrlEncoded(Object source, MediaType sourceType) { return urlEncode(source, sourceType); } static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType); static byte[] convertTextToOctetStream(Object source, MediaType sourceType);... | @Test public void testTextToURLEncodedConversion() throws UnsupportedEncodingException { String source = "They're either a benefit or a hazard. If they're a benefit, it's not my problem."; String result = StandardConversions.convertTextToUrlEncoded(source, TEXT_PLAIN.withCharset(UTF_16)); assertEquals(URLEncoder.encode... |
StandardConversions { public static byte[] convertOctetStreamToText(byte[] source, MediaType destination) { if (source == null) return null; return convertCharset(source, UTF_8, destination.getCharset()); } static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType); static byte[] c... | @Test public void testOctetStreamToTextConversion() { String text = "Have you ever retired a human by mistake?"; byte[] bytes1 = text.getBytes(); byte[] bytes2 = new byte[]{1, 2, 3}; byte[] result1 = StandardConversions.convertOctetStreamToText(bytes1, TEXT_PLAIN.withCharset(US_ASCII)); byte[] result2 = StandardConvers... |
StandardConversions { public static Object convertOctetStreamToJava(byte[] source, MediaType destination, Marshaller marshaller) { if (source == null) return null; if (!destination.match(MediaType.APPLICATION_OBJECT)) { throw CONTAINER.invalidMediaType(APPLICATION_OBJECT_TYPE, destination.toString()); } String classTyp... | @Test public void testOctetStreamToJavaConversion() { String value = "It's not an easy thing to meet your maker."; byte[] textStream = value.getBytes(UTF_8); byte[] randomBytes = new byte[]{23, 23, 34, 1, -1, -123}; Marshaller marshaller = new ProtoStreamMarshaller(); MediaType stringType = APPLICATION_OBJECT.withParam... |
StandardConversions { public static byte[] convertJavaToText(Object source, MediaType sourceMediaType, MediaType destinationMediaType) { if (source == null) return null; if (sourceMediaType == null || destinationMediaType == null) { throw new NullPointerException("sourceMediaType and destinationMediaType cannot be null... | @Test public void testJavaToTextConversion() { String string = "I've seen things you people wouldn't believe."; Double number = 12.1d; Calendar complex = Calendar.getInstance(); MediaType stringType = APPLICATION_OBJECT.withParameter("type", "java.lang.String"); byte[] result1 = StandardConversions.convertJavaToText(st... |
TemperatureNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { float ambientTemp = decodeTemperature(bytes[0], bytes[1]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of(TEMP_VALUE_ID, ambientTemp)); processor.onNext(sensorLog); } TemperatureNotification... | @Test public void producesValidSensorLog() { Faker faker = new Faker(); int temp = faker.number().numberBetween(-50, 50); float decimal = (float)faker.number().randomDouble(5, 0, 1); SensorConfig config = new SensorConfig("someId", "nordic", null); ReplayProcessor<SensorLog> processor = ReplayProcessor.create(10); Temp... |
ColorNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { int red = decodeColor(bytes[1], bytes[0]); int green = decodeColor(bytes[3], bytes[2]); int blue = decodeColor(bytes[5], bytes[4]); int clear = decodeColor(bytes[7], bytes[6]); SensorLog sensorLog = new SensorLog(conf... | @Test public void producesValidSensorLog() { Faker faker = new Faker(); int red = faker.number().numberBetween(0, 32768); int green = faker.number().numberBetween(0, 32768); int blue = faker.number().numberBetween(0, 32768); int clear = faker.number().numberBetween(0, 32768); SensorConfig config = new SensorConfig("som... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.