src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
AmazonWebServiceClient { @Deprecated protected Signer getSigner() { return signerProvider.getSigner(SignerProviderContext.builder().build()); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetr...
@Test public void testOverrideSigner() { ClientConfiguration config = new ClientConfiguration(); config.setSignerOverride("QueryStringSignerType"); AmazonTestClient client = new AmazonTestClient(config); Assert.assertTrue(client.getSigner() instanceof QueryStringSigner); }
AmazonWebServiceClient { public final void setServiceNameIntern(String serviceName) { if (serviceName == null) throw new IllegalArgumentException( "The parameter serviceName must be specified!"); this.serviceName = serviceName; } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(C...
@Test public void setServiceNameIntern() { AmazonTestClient client = new AmazonTestClient(); assertEquals(client.getServiceName(), client.getServiceNameIntern()); String serviceNameOverride = "foo"; assertFalse(serviceNameOverride.equals(client.getServiceName())); client.setServiceNameIntern(serviceNameOverride); asser...
AmazonWebServiceClient { protected void setEndpointPrefix(String endpointPrefix) { if (endpointPrefix == null) { throw new IllegalArgumentException( "The parameter endpointPrefix must be specified!"); } this.endpointPrefix = endpointPrefix; } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebSe...
@Test public void setEndpointPrefix() { AmazonTestClient client = new AmazonTestClient(); Assert.assertEquals(client.getServiceName(), client.getEndpointPrefix()); String endpointPrefixOverride = "foo"; Assert.assertNotEquals(endpointPrefixOverride, client.getServiceName()); client.setEndpointPrefix(endpointPrefixOverr...
AmazonWebServiceClient { public void shutdown() { client.shutdown(); } AmazonWebServiceClient(ClientConfiguration clientConfiguration); AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector); @SdkProtectedApi protected AmazonWebServiceClient(ClientCo...
@Test public void connectionManagersAreUnregisteredFromIdleConnectionReaper() { IdleConnectionReaper.shutdown(); for (int count = 0; count < 100; count++) { new AmazonWebServiceClient(new ClientConfiguration()) { }.shutdown(); } assertEquals(0, IdleConnectionReaper.getRegisteredConnectionManagers().size()); }
DelegatingDnsResolver implements DnsResolver { @Override public InetAddress[] resolve(String host) throws UnknownHostException { return delegate.resolve(host); } DelegatingDnsResolver(com.ibm.cloud.objectstorage.DnsResolver delegate); @Override InetAddress[] resolve(String host); }
@Test public void testDelegatingDnsResolverCallsResolveOnDelegate() throws Exception { final AtomicInteger timesCalled = new AtomicInteger(); DnsResolver delegate = new DnsResolver() { @Override public InetAddress[] resolve(String host) throws UnknownHostException { timesCalled.incrementAndGet(); return new InetAddress...
CompleteMultipartUpload implements Callable<UploadResult> { @Override public UploadResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getBucketName(), origReq.getKey(), uploadId, collectPartETags()) .withRequesterPay...
@Test public void testReportFailureIsCalled() throws Exception{ UploadMonitor monitor = mock(UploadMonitor.class); CompleteMultipartUpload completeMultipartCopy = new CompleteMultipartUpload(null, null, null, null, null, null, monitor); try{ completeMultipartCopy.call(); } catch (Exception e){ } verify(monitor, times(1...
CompleteMultipartCopy implements Callable<CopyResult> { @Override public CopyResult call() throws Exception { CompleteMultipartUploadResult res; try { CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest( origReq.getDestinationBucketName(), origReq.getDestinationKey(), uploadId, collectPartETags()) ....
@Test public void testReportFailureIsCalled() throws Exception{ CopyMonitor monitor = mock(CopyMonitor.class); CompleteMultipartCopy completeMultipartCopy = new CompleteMultipartCopy(null, null, null, null, null, monitor); try{ completeMultipartCopy.call(); } catch (Exception e){ } verify(monitor, times(1)).reportFailu...
RouteSimilarity { public RouteSimilarity(RouteData routeData, String currentRoute) { this.route = routeData.getNavigationTarget(); this.routeData = routeData; int urlSimilarity = calculateSimilarity(routeData.getUrl(), currentRoute); int routeAliasSimilarity = routeData.getRouteAliases().stream().map(routeAliasData -> ...
@Test public void testRouteSimilarity() { String[] urls = new String[]{ "navigation/view1", "navigation/view2", "navigation/view3", "navigation/view4", "navigation/view5", "navigation/view6", "navigation/view7", "navigation/view8", "navigation/view9", "navigation" }; String currentRoutePart = "navigation"; RouteSimilar...
RouteSimilarity { public String getRouteString() { return routeString; } RouteSimilarity(RouteData routeData, String currentRoute); RouteSimilarity(String url, String currentRouteParts); RouteData getRouteData(); Class<? extends Component> getRoute(); String getRouteString(); int getSimilarity(); }
@Test public void testRouteSimilarity2() { String[] urls = new String[]{ "view1", "view2", "view3", "view4", "view5", "view6", "view7", "view8", "view9", "" }; String currentRoutePart = ""; RouteSimilarity r = Arrays.stream(urls) .map(s -> new RouteSimilarity(currentRoutePart, s)) .max(Comparator.comparingInt(RouteSimi...
UpNavigationHelper implements Serializable { public static Optional<RouteSimilarity> getClosestRoute(String url, String[] availableRoutes) { if (url.lastIndexOf("/") > 0) { Optional<RouteSimilarity> result = Arrays.stream(availableRoutes) .filter(routeData -> !routeData.equals(url)) .map(routeData -> new RouteSimilarit...
@Test public void getClosestRoute() { String[] urls = new String[]{ "navigation/view1", "navigation/view2", "navigation/view2/subview", "navigation/view3", "navigation/view4", "navigation/view5", "navigation/view6", "navigation/view7", "navigation/view8", "navigation/view9", "navigation" }; String currentRoutePart = "n...
EventDateComparator implements Comparator<EventAdapter.Item> { @Override public int compare(EventAdapter.Item event1, EventAdapter.Item event2) { if (event1.getEvent().getStart() == null) { if (event2.getEvent().getStart() == null) { return 0; } else { return 1; } } else if (event2.getEvent().getStart() == null) { retu...
@Test public void valueAnEventHigherThanAnEventThatStartedBefore() { assertEquals(1, comparator.compare(eventInApril, eventInMarch)); assertEquals(-1, comparator.compare(eventInMarch, eventInApril)); assertEquals(0, comparator.compare(eventInMarch, eventInMarch)); } @Test public void valueAnEventLowerThanAnEventWithout...
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException, PreventedException { try { if (this.legacyHandler.authenticate(credentialsAdapter.convert(credential))) { final CredentialMetaData md; if (crede...
@Test public void verifyAuthenticateSuccess() throws Exception { final HandlerResult result = alwaysPassHandler.authenticate(new UsernamePasswordCredential("a", "b")); assertEquals("TestAlwaysPassAuthenticationHandler", result.getHandlerName()); } @Test(expected = FailedLoginException.class) public void examineAuthenti...
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public boolean supports(final Credential credential) { return this.legacyHandler.supports(credentialsAdapter.convert(credential)); } LegacyAuthenticationHandlerAdapter(final org.jasig.cas.authentication.handler.AuthenticationHandler legacy)...
@Test public void verifySupports() throws Exception { assertTrue(alwaysPassHandler.supports(new UsernamePasswordCredential("a", "b"))); assertTrue(alwaysFailHandler.supports(new UsernamePasswordCredential("a", "b"))); } @Test public void testSupports() throws Exception { assertTrue(alwaysPassHandler.supports(new Userna...
LegacyAuthenticationHandlerAdapter implements AuthenticationHandler { @Override public String getName() { if (this.legacyHandler instanceof NamedAuthenticationHandler) { return ((NamedAuthenticationHandler) this.legacyHandler).getName(); } else { return this.legacyHandler.getClass().getSimpleName(); } } LegacyAuthentic...
@Test public void verifyGetName() throws Exception { assertEquals("TestAlwaysPassAuthenticationHandler", alwaysPassHandler.getName()); assertEquals("TestAlwaysFailAuthenticationHandler", alwaysFailHandler.getName()); } @Test public void testGetName() throws Exception { assertEquals("TestAlwaysPassAuthenticationHandler"...
SmartOpenIdController extends DelegateController implements Serializable { @Override public boolean canHandle(final HttpServletRequest request, final HttpServletResponse response) { final String openIdMode = request.getParameter(OpenIdConstants.OPENID_MODE); if (StringUtils.equals(openIdMode, OpenIdConstants.ASSOCIATE)...
@Test public void verifyCanHandle() { request.addParameter("openid.mode", "associate"); final boolean canHandle = smartOpenIdController.canHandle(request, response); request.removeParameter("openid.mode"); assertEquals(true, canHandle); } @Test public void verifyCannotHandle() { request.addParameter("openid.mode", "any...
SmartOpenIdController extends DelegateController implements Serializable { public Map<String, String> getAssociationResponse(final HttpServletRequest request) { final ParameterList parameters = new ParameterList(request.getParameterMap()); final String mode = parameters.hasParameter(OpenIdConstants.OPENID_MODE) ? param...
@Test public void verifyGetAssociationResponse() { request.addParameter("openid.mode", "associate"); request.addParameter("openid.session_type", "DH-SHA1"); request.addParameter("openid.assoc_type", "HMAC-SHA1"); request.addParameter("openid.dh_consumer_public", "NzKoFMyrzFn/5iJFPdX6MVvNA/BChV1/sJdnYbupDn7ptn+cerwEzyFf...
CompositionBundle implements Bundle { private static Function composition(Context context) { return args -> { final Composition composition; switch (args.length) { case 0: composition = new Composition(); break; case 1: double frameRate = args[0].asDouble(); composition = new Composition(frameRate); break; case 2: int ...
@Test void testBundle() { final var context = new Context(); BundleLoader.loadSingle(context, CompositionBundle.class); assertThat(context.functions(), hasKey("composition")); assertThat(context.composition(), nullValue()); assertThat(context.variables(), allOf( not(hasKey("Width")), not(hasKey("Height")), not(hasKey("...
HotaruLexer extends Lexer { private Token tokenizeText(char openChar) { next(); clearBuffer(); int startPos = getPos() - 1; char current = peek(0); while (true) { if (current == '\\') { final var buffer = getBuffer(); current = next(); if (current == openChar) { current = next(); buffer.append(openChar); continue; } sw...
@Test void testTokenizeText() { assertThat(t("1 \" 1\n2 3 '\""), contains( tokenId(HotaruTokenId.NUMBER), tokenId(HotaruTokenId.TEXT) )); assertThat(t("1 ' 1\n2 3 ' 2"), contains( tokenId(HotaruTokenId.NUMBER), tokenId(HotaruTokenId.TEXT), tokenId(HotaruTokenId.NUMBER) )); assertThrows(LexerException.class, () -> { all...
InterpreterVisitor implements ResultVisitor<Value, Context> { @Override public Value get(AccessNode node, Context context) { Value container = node.root.accept(this, context); return getContainer(node.indices, context, container) .orElseThrow(() -> new TypeException("Unable to get property from non-accessible type", no...
@Test void testMapAccess() { Context context = new Context(); eval("A = {x: 0, y: 22, z: 0, text: 'hello'}\n" + "A.x = 20\n" + "A.z = A.y\n" + "A.newKey = 'newValue'", context); Value value = context.variables().get("A"); assertThat(value, instanceOf(MapValue.class)); Map<String, Value> map = ((MapValue) value).getMap(...
Composition { public int getVirtualWidth() { return virtualWidth; } Composition(); Composition(double frameRate); Composition(int sceneWidth, int sceneHeight); Composition(int sceneWidth, int sceneHeight, double frameRate); Composition(int sceneWidth, int sceneHeight, double frameRate, Paint background); int getVir...
@Test void testVirtualSize() { Composition composition; composition = new Composition(1280, 720, 30); assertThat(composition.getVirtualWidth(), is(1920)); composition = new Composition(1280, 1280, 30); assertThat(composition.getVirtualWidth(), is(1080)); }
CGLibProxy implements MethodInterceptor { public <T> T proxy(Class<T> clazz, Object shadowObject) { if (!ArgumentsUtils.hasNoArgumentsConstructor(clazz)) { Class[] argTypes = ArgumentsUtils.getConstructorsArgumensTypes(clazz); Object[] args = ArgumentsUtils.getArgumens(argTypes); return proxy(clazz, shadowObject, argTy...
@Test public void getInstance() throws Exception { A proxyA = new CGLibProxy().proxy(A.class, new B()); Assert.assertTrue(proxyA instanceof A); }
KbSqlParser { public static String bindArgs(String sql, @Nullable Object[] bindArgs) { if (bindArgs == null || bindArgs.length == 0 || sql.startsWith("PRAGMA")) { return sql; } try { KbSqlParserManager pm = new KbSqlParserManager(); Statement statement = pm.parse(sql); Set<Expression> expressionSet = findBindArgsExpres...
@Test public void bindDeleteArgs() { Object[] args = new Object[]{1}; String sql = "DELETE FROM person WHERE id = ?"; String boundSql = KbSqlParser.bindArgs(sql, args); Assert.assertEquals("DELETE FROM person WHERE id = 1", boundSql); } @Test public void bindUpdateArgs() { Object[] args = new Object[]{"kk", 1}; String ...
KbSqlParser { protected static int getBindArgsCount(String sql) { Set<Expression> expressionSet = findBindArgsExpressions(sql); int count = 0; for (Expression expression : expressionSet) { count += getBindArgsCount(expression); } return count; } static String bindArgs(String sql, @Nullable Object[] bindArgs); }
@Test public void getBindArgsCount() throws Exception { String sql0 = "select * from person where id=? and (uid BETWEEN ? and ?) and test LIKE ? order by id"; String sql1 = "INSERT INTO person (id, name) VALUES (?, ?)"; String sql2 = "DELETE FROM person WHERE id in (?,?)"; String sql3 = "UPDATE person SET name = ? WHER...
KbSqlParser { protected static Set<Expression> findBindArgsExpressions(String sql) { if (sql == null || sql.startsWith("PRAGMA") || !sql.contains("?")) { return new LinkedHashSet<>(); } KbSqlParserManager pm = new KbSqlParserManager(); try { Statement statement = pm.parse(sql); Set<Expression> expressionSet = findBindA...
@Test public void findJdbcParamExpressions() throws Exception { String sql = "DELETE FROM person WHERE id = ?"; Set<Expression> expressionSet = KbSqlParser.findBindArgsExpressions(sql); System.out.println(); }
ShadowContext implements Shadow { public File getFilesDir() { return getAndCreateDir("build/files/"); } ShadowContext(Resources resources); ShadowContext(Resources resources, ShadowResources shadowResources); @NonNull final String getString(@StringRes int resId); Resources getResources(); SharedPreferences getSharedPr...
@Test public void getFilesDir() throws Exception { List<File> dirs = Arrays.asList(mShadowContext.getFilesDir(), mShadowContext.getCacheDir(), mShadowContext.getDataDir()); for (File dir : dirs) { Assert.assertTrue(dir.isDirectory()); Assert.assertTrue(dir.exists()); } }
ShadowResources { public String getString(@StringRes int id) throws NotFoundException { return getText(id).toString(); } ShadowResources(); int getColor(@ColorRes int id); int getColor(@ColorRes int id, @Nullable Resources.Theme theme); String getString(@StringRes int id); @NonNull String[] getStringArray(@ArrayRes int...
@Test public void getString() throws Exception { Assert.assertEquals("Yui Hatano", resources.getString(R.string.test_string)); }
ShadowResources { @NonNull public String[] getStringArray(@ArrayRes int id) throws NotFoundException { Map<Integer, String> idNameMap = getIdTable(R_ARRAY); Map<String, List<String>> stringArrayMap = getResourceStringArrayMap(); if (idNameMap.containsKey(id)) { String name = idNameMap.get(id); if (stringArrayMap.contai...
@Test public void getStringArray() throws Exception { String[] array = resources.getStringArray(R.array.arrayName); Assert.assertEquals("item0", array[0]); Assert.assertEquals("item1", array[1]); }
ShadowResources { public int getColor(@ColorRes int id) throws NotFoundException { return getColor(id, null); } ShadowResources(); int getColor(@ColorRes int id); int getColor(@ColorRes int id, @Nullable Resources.Theme theme); String getString(@StringRes int id); @NonNull String[] getStringArray(@ArrayRes int id); @No...
@Test public void getColor() throws Exception { int color = resources.getColor(R.color.my_color); int realColor = Color.parseColor("#47474d"); Assert.assertEquals(realColor, color); }
ShadowResources { @NonNull public int[] getIntArray(@ArrayRes int id) throws NotFoundException { Map<Integer, String> idNameMap = getIdTable(R_ARRAY); Map<String, List<Integer>> intArrayMap = getResourceIntArrayMap(); if (idNameMap.containsKey(id)) { String name = idNameMap.get(id); if (intArrayMap.containsKey(name)) {...
@Test public void getIntArray() { int[] intArray = resources.getIntArray(R.array.intArray); Assert.assertEquals(0, intArray[0]); Assert.assertEquals(1, intArray[1]); int[] intArrayNoItem = resources.getIntArray(R.array.intArrayNoItem); Assert.assertEquals(0, intArrayNoItem.length); }
ShadowResources { public String getPackageName() { if (!TextUtils.isEmpty(mPackageName)) { return mPackageName; } String manifestPath = null; List<String> manifestPaths = Arrays.asList( "build/intermediates/manifests/aapt/debug/AndroidManifest.xml", "build/intermediates/manifests/aapt/release/AndroidManifest.xml", "bui...
@Test public void getPackageName() throws Exception { Assert.assertEquals("net.yui", resources.getPackageName()); }
ReflectUtils { public static Object invokeStatic(String className, String methodName, Object... arguments) { try { Class clazz = Class.forName(className); return invokeStatic(clazz, methodName, arguments); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; } static boolean hasClass(String classNa...
@Test public void invokeStatic() { Assert.assertEquals("value", ReflectUtils.invokeStatic("net.yui.utils.MockHelper", "testStatic")); Assert.assertEquals("arg0", ReflectUtils.invokeStatic("net.yui.utils.MockHelper", "testStatic", "arg0")); MockHelper mockHelper = new MockHelper(); Assert.assertEquals("value", ReflectUt...
FileUtils { public static boolean deleteDir(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; } } } return dir.delete(); } static boolean deleteDir(File dir); }
@Test public void deleteDir() throws Exception { File dir = new File("build/files"); dir.mkdirs(); File file = new File(dir, "myfile"); file.createNewFile(); Assert.assertTrue(file.exists()); Assert.assertFalse(dir.delete()); Assert.assertTrue(dir.exists()); FileUtils.deleteDir(dir); Assert.assertFalse(dir.exists()); }
ArgumentsUtils { public static Class[] getConstructorsArgumensTypes(Class clazz) { Constructor[] constructors = getNotPrivateConstructors(clazz); if (constructors == null || constructors.length == 0) { return new Class[0]; } return constructors[0].getParameterTypes(); } static Class[] getConstructorsArgumensTypes(Clas...
@Test public void getConstructorsArgumensTypes() { ArgumentsUtils.getConstructorsArgumensTypes(Object.class); }
ShadowCursor implements Cursor { protected Object getObject(int columnIndex, Object defaultValue) { Object value = getObject(columnIndex); if (value == null) { return defaultValue; } return value; } ShadowCursor(List<String> colums, List<List<Object>> datas); @Override int getCount(); @Override int getPosition(); @Over...
@Test public void getObject() { List<Object> data0 = Arrays.asList((Object) 1, "kk"); cursor = new ShadowCursor(Arrays.asList("id", "name"), Arrays.asList(data0)); cursor.moveToFirst(); Assert.assertEquals(1, cursor.getObject(0)); Assert.assertEquals("kk", cursor.getObject(1)); }
ShadowCursor implements Cursor { @Override public String getString(int columnIndex) { Object value = getObject(columnIndex); return value == null ? null : value.toString(); } ShadowCursor(List<String> colums, List<List<Object>> datas); @Override int getCount(); @Override int getPosition(); @Override boolean move(int of...
@Test public void getString() { List<Object> data0 = Arrays.asList((Object) 1, "kk"); List<Object> data1 = Arrays.asList((Object) 2, null); cursor = new ShadowCursor(Arrays.asList("id", "name"), Arrays.asList(data0, data1)); cursor.moveToFirst(); Assert.assertEquals("1", cursor.getString(0)); Assert.assertEquals("kk", ...
XMLUtils { public static Document stringToDoc(String str) throws IOException { if (StringUtils.isNotEmpty(str)) { try { Reader reader = new StringReader(str); DocumentBuilder db = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); Document doc = db.parse(new InputSource(reader)); reader.close(); return doc; } ...
@Test public void testStringToDoc() throws IOException { XMLUtils.stringToDoc(XML_STRING); XMLUtils.stringToDoc(XML_STRING_HUGE); }
JMXFactory { public String getDomain() { return domain; } static ObjectName createMBean(String className, String attributes); static ObjectName createObjectName(String... strings); static ObjectName createSimpleMBean(String className, String objectNameStr); static String getDefaultDomain(); static MBeanServer getMB...
@Test public void testGetDomain() { System.out.println("Not yet implemented"); }
JMXFactory { public static MBeanServer getMBeanServer() { return mbs; } static ObjectName createMBean(String className, String attributes); static ObjectName createObjectName(String... strings); static ObjectName createSimpleMBean(String className, String objectNameStr); static String getDefaultDomain(); static MBe...
@Test public void testGetMBeanServer() { System.out.println("Not yet implemented"); }
JMXFactory { public void setDomain(String domain) { JMXFactory.domain = domain; } static ObjectName createMBean(String className, String attributes); static ObjectName createObjectName(String... strings); static ObjectName createSimpleMBean(String className, String objectNameStr); static String getDefaultDomain(); ...
@Test public void testSetDomain() { System.out.println("Not yet implemented"); }
ClientRegistry implements IClientRegistry, ClientRegistryMBean { public IClient newClient(Object[] params) throws ClientNotFoundException, ClientRejectedException { String id = nextId(); IClient client = new Client(id, this); addClient(id, client); return client; } ClientRegistry(); ClientRegistry(String name); Client...
@Test public void testNewClient() { IClient client = reg.newClient(null); Assert.assertNotNull(client); Assert.assertTrue(client.getId() != null); Assert.assertTrue(Integer.valueOf(client.getId()) >= 0); }
ClientRegistry implements IClientRegistry, ClientRegistryMBean { protected void addClient(IClient client) { addClient(client.getId(), client); } ClientRegistry(); ClientRegistry(String name); Client getClient(String id); ClientList<Client> getClientList(); boolean hasClient(String id); IClient lookupClient(String id);...
@Test public void testAddClient() { reg.addClient(new Client(reg.nextId(), reg)); Assert.assertNotNull(reg.getClient("1")); Assert.assertTrue(reg.getClients().size() >= 1); }
ClientRegistry implements IClientRegistry, ClientRegistryMBean { public IClient lookupClient(String id) throws ClientNotFoundException { return getClient(id); } ClientRegistry(); ClientRegistry(String name); Client getClient(String id); ClientList<Client> getClientList(); boolean hasClient(String id); IClient lookupCl...
@Test public void testLookupClient() { IClient client = reg.lookupClient("0"); Assert.assertNotNull(client); }
ClientRegistry implements IClientRegistry, ClientRegistryMBean { public Client getClient(String id) throws ClientNotFoundException { final Client result = (Client) clients.get(id); if (result == null) { throw new ClientNotFoundException(id); } return result; } ClientRegistry(); ClientRegistry(String name); Client getC...
@Test public void testGetClient() { IClient client = reg.getClient("0"); Assert.assertNotNull(client); IClient client2 = null; try { client2 = reg.getClient("999999"); fail("An exception should occur here"); } catch (ClientNotFoundException e) { Assert.assertTrue(true); } Assert.assertNull(client2); }
ClientRegistry implements IClientRegistry, ClientRegistryMBean { public ClientList<Client> getClientList() { ClientList<Client> list = new ClientList<Client>(); for (IClient c : clients.values()) { list.add((Client) c); } return list; } ClientRegistry(); ClientRegistry(String name); Client getClient(String id); Client...
@Test public void testGetClientList() { ClientList<Client> clients = reg.getClientList(); int listSize = clients.size(); Assert.assertTrue(listSize > 0); System.out.println("List size: " + listSize); for (int c = 0; c < listSize; c++) { Client client = clients.get(c); System.out.println(client); Assert.assertTrue(clien...
ClientRegistry implements IClientRegistry, ClientRegistryMBean { @SuppressWarnings("unchecked") protected Collection<IClient> getClients() { if (!hasClients()) { return Collections.EMPTY_SET; } return Collections.unmodifiableCollection(clients.values()); } ClientRegistry(); ClientRegistry(String name); Client getClien...
@Test public void testGetClients() { for (int c = 0; c < 10; c++) { reg.addClient(new Client(reg.nextId(), reg)); } Assert.assertNotNull(reg.getClient("2")); System.gc(); try { Thread.sleep(2000); System.gc(); } catch (InterruptedException e) { } Assert.assertTrue(reg.getClients().size() >= 10); }
ClientRegistry implements IClientRegistry, ClientRegistryMBean { protected void removeClient(IClient client) { clients.remove(client.getId()); } ClientRegistry(); ClientRegistry(String name); Client getClient(String id); ClientList<Client> getClientList(); boolean hasClient(String id); IClient lookupClient(String id);...
@Test public void testRemoveClient() { IClient client = reg.lookupClient("1"); Assert.assertNotNull(client); reg.removeClient(client); IClient client2 = null; try { client2 = reg.getClient("1"); fail("An exception should occur here"); } catch (ClientNotFoundException e) { Assert.assertTrue(true); } Assert.assertNull(cl...
XMLUtils { public static String docToString(Document dom) { return XMLUtils.docToString1(dom); } static Document stringToDoc(String str); static String docToString(Document dom); static String docToString1(Document dom); static String docToString2(Document domDoc); }
@Test @Ignore public void testDocToString() { fail("Not yet implemented"); }
ConversionUtils { public static Object convert(Object source, Class<?> target) throws ConversionException { if (target == null) { throw new ConversionException("Unable to perform conversion, target was null"); } if (source == null) { if (target.isPrimitive()) { throw new ConversionException(String.format("Unable to con...
@Test public void testBasic() { Object result = ConversionUtils.convert(new Integer(42), String.class); if (!(result instanceof String)) { fail("Should be a string"); } String str = (String) result; assertEquals("42", str); } @Test public void testConvertListToStringArray() { ArrayList<String> source = new ArrayList<St...
StreamUtils { public static IServerStream createServerStream(IScope scope, String name) { logger.debug("Creating server stream: {} scope: {}", name, scope); ServerStream stream = new ServerStream(); stream.setScope(scope); stream.setName(name); stream.setPublishedName(name); String key = scope.getName() + '/' + name; s...
@Test public void testCreateServerStream() { System.out.println("Not yet implemented"); }
StreamUtils { public static IServerStream getServerStream(IScope scope, String name) { logger.debug("Looking up server stream: {} scope: {}", name, scope); String key = scope.getName() + '/' + name; if (serverStreamMap.containsKey(key)) { return serverStreamMap.get(key); } else { logger.warn("Server stream not found wi...
@Test public void testGetServerStream() { System.out.println("Not yet implemented"); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public ScheduledThreadPoolExecutor getExecutor() { if (executor == null) { log.warn("ScheduledThreadPoolExecutor was null on request"); } return executor; } PlaylistSubscriberStream(); voi...
@Test public void testGetExecutor() { System.out.println("testGetExecutor"); assertTrue(pss.getExecutor() != null); }
XMLUtils { public static String docToString1(Document dom) { StringWriter sw = new StringWriter(); DOM2Writer.serializeAsXML(dom, sw); return sw.toString(); } static Document stringToDoc(String str); static String docToString(Document dom); static String docToString1(Document dom); static String docToString2(Document ...
@Test @Ignore public void testDocToString1() { fail("Not yet implemented"); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void start() { if (engine == null) { IScope scope = getScope(); if (scope != null) { IContext ctx = scope.getContext(); ISchedulingService schedulingService = (ISchedulingService) c...
@Test public void testStart() { System.out.println("testStart"); SimplePlayItem item = new SimplePlayItem(); item.setName("DarkKnight.flv"); pss.addItem(item); pss.start(); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void play() throws IOException { int count = items.size(); if (count == 0) { return; } if (currentItemIndex == -1) { moveToNext(); } while (count-- > 0) { IPlayItem item = null; rea...
@Test public void testPlay() throws Exception { System.out.println("testPlay"); pss.play(); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void pause(int position) { try { engine.pause(position); } catch (IllegalStateException e) { log.debug("pause caught an IllegalStateException"); } } PlaylistSubscriberStream(); void...
@Test public void testPause() { System.out.println("testPause"); long sent = pss.getBytesSent(); pss.pause((int) sent); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void resume(int position) { try { engine.resume(position); } catch (IllegalStateException e) { log.debug("resume caught an IllegalStateException"); } } PlaylistSubscriberStream(); v...
@Test public void testResume() { System.out.println("testResume"); long sent = pss.getBytesSent(); pss.resume((int) sent); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void seek(int position) throws OperationNotSupportedException { try { engine.seek(position); } catch (IllegalStateException e) { log.debug("seek caught an IllegalStateException"); }...
@Test public void testSeek() { System.out.println("testSeek"); long sent = pss.getBytesSent(); try { pss.seek((int) (sent * 2)); } catch (OperationNotSupportedException e) { e.printStackTrace(); } }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void addItem(IPlayItem item) { write.lock(); try { items.add(item); } finally { write.unlock(); } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor...
@Test public void testAddItemIPlayItem() { System.out.println("testAddItemIPlayItem"); SimplePlayItem item = new SimplePlayItem(); item.setName("IronMan.flv"); pss.addItem(item); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void previousItem() { stop(); moveToPrevious(); if (currentItemIndex == -1) { return; } IPlayItem item = null; int count = items.size(); while (count-- > 0) { read.lock(); try { ite...
@Test public void testPreviousItem() { log.error("Not yet implemented -- get on that"); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void nextItem() { moveToNext(); if (currentItemIndex == -1) { return; } IPlayItem item = null; int count = items.size(); while (count-- > 0) { read.lock(); try { item = items.get(cu...
@Test public void testNextItem() { log.error("Not yet implemented -- get on that"); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void setItem(int index) { if (index < 0 || index >= items.size()) { return; } stop(); currentItemIndex = index; read.lock(); try { IPlayItem item = items.get(currentItemIndex); engi...
@Test public void testSetItem() { log.error("Not yet implemented -- get on that"); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void stop() { try { engine.stop(); } catch (IllegalStateException e) { log.debug("stop caught an IllegalStateException"); } } PlaylistSubscriberStream(); void setExecutor(ScheduledT...
@Test public void testStop() { System.out.println("testStop"); pss.stop(); }
XMLUtils { public static String docToString2(Document domDoc) throws IOException { try { TransformerFactory transFact = TransformerFactory.newInstance(); Transformer trans = transFact.newTransformer(); trans.setOutputProperty(OutputKeys.INDENT, "no"); StringWriter sw = new StringWriter(); Result result = new StreamResu...
@Test @Ignore public void testDocToString2() { fail("Not yet implemented"); }
PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void close() { engine.close(); bwController.unregisterBWControllable(bwContext); notifySubscriberClose(); } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor ...
@Test public void testClose() { System.out.println("testClose"); pss.close(); }
Scope extends BasicScope implements IScope, IScopeStatistics, ScopeMBean { public Scope() { this(null); } Scope(); Scope(String name); boolean addChildScope(IBasicScope scope); boolean connect(IConnection conn); boolean connect(IConnection conn, Object[] params); boolean createChildScope(String name); void destroy()...
@Test public void testScope() { if (appScope == null) { appScope = (WebScope) applicationContext.getBean("web.scope"); log.debug("Application / web scope: {}", appScope); } TestCase.assertTrue(appScope.createChildScope("room1")); IScope room1 = appScope.getScope("room1"); log.debug("Room 1: {}", room1); IContext rmCtx1...
ExtendedPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer { public Properties getMergedProperties() { return mergedProperties; } Properties getMergedProperties(); void setWildcardLocations( String[] locations ); static synchronized void addGlobalProperty( String key, String val ); }
@Test public void testLocationsProperty() { ExtendedPropertyPlaceholderConfigurer configurer = (ExtendedPropertyPlaceholderConfigurer)context.getBean( "boringPlaceholderConfig" ); assertEquals( testProperties, configurer.getMergedProperties() ); } @Test public void testWildcardLocationsProperty() { ExtendedPropertyPlac...
HMAC { public byte[] computeMac() { Mac hm = null; byte[] result = null; if (log.isDebugEnabled()) { log.debug("Key data: {}", byteArrayToHex(keyBytes)); log.debug("Hash data: {}", byteArrayToHex(dataBytes)); log.debug("Algorithm: {}", ALGORITHM_ID); } try { hm = Mac.getInstance(ALGORITHM_ID); Key k1 = new SecretKeySpe...
@Test public void testHMAC() { HMAC h1 = new HMAC(); assertNotNull(h1); try { Provider sp = new com.sun.crypto.provider.SunJCE(); Security.addProvider(sp); } catch (Exception e) { fail("Problem loading crypto provider" + e); } byte[] hmac = h1.computeMac(); assertNull("Currently HMAC is broken since you can't actually ...
JMXAgent implements NotificationListener { public void init() { HashMap<String, Object> env = null; if (enableRmiAdapter) { log.debug("Create an RMI connector server"); System.setProperty("java.rmi.server.hostname", rmiAdapterHost); try { Registry r = null; try { r = LocateRegistry.getRegistry(Integer .valueOf(rmiAdapt...
@Test public void testInit() { System.out.println("Not yet implemented"); }
JMXAgent implements NotificationListener { public static boolean unregisterMBean(ObjectName oName) { boolean unregistered = false; if (null != oName) { try { if (mbs.isRegistered(oName)) { log.debug("Mbean is registered"); mbs.unregisterMBean(oName); unregistered = !mbs.isRegistered(oName); } else { log.debug("Mbean is...
@Test public void testUnregisterMBean() throws Exception { logger.info("Default jmx domain: {}", JMXFactory.getDefaultDomain()); JMXAgent agent = new JMXAgent(); agent.init(); MBeanServer mbs = JMXFactory.getMBeanServer(); ObjectName oName = JMXFactory.createMBean( "org.red5.server.net.rtmp.RTMPMinaConnection", "connec...
JMXFactory { public static ObjectName createMBean(String className, String attributes) { log.info("Create the {} MBean within the MBeanServer", className); ObjectName objectName = null; try { StringBuilder objectNameStr = new StringBuilder(domain); objectNameStr.append(":type="); objectNameStr.append(className .substri...
@Test public void testCreateMBean() { ObjectName objectName = null; try { objectName = JMXFactory.createMBean( "org.red5.server.jmx.JMXFactoryTest", "test=1"); assertNotNull(objectName); objectName = JMXFactory.createMBean( "org.red5.server.jmx.JMXFactoryTest", "test=2"); assertNotNull(objectName); objectName = JMXFact...
JMXFactory { public static ObjectName createSimpleMBean(String className, String objectNameStr) { log.info("Create the {} MBean within the MBeanServer", className); log.info("ObjectName = {}", objectNameStr); try { ObjectName objectName = ObjectName.getInstance(objectNameStr); if (!mbs.isRegistered(objectName)) { mbs.c...
@Test public void testCreateSimpleMBean() { System.out.println("Not yet implemented"); }
JMXFactory { public static String getDefaultDomain() { return domain; } static ObjectName createMBean(String className, String attributes); static ObjectName createObjectName(String... strings); static ObjectName createSimpleMBean(String className, String objectNameStr); static String getDefaultDomain(); static MBe...
@Test public void testGetDefaultDomain() { System.out.println("Not yet implemented"); }
PhysicsUnit implements Unit<Q>, XMLSerializable { public static PhysicsUnit<?> valueOf(CharSequence charSequence) { return UCUMFormat.getCaseSensitiveInstance().parse(charSequence, new ParsePosition(0)); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(...
@Test public void testValueOf() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final UnitConverter getConverterToAny(Unit<?> that) throws IncommensurableException, UnconvertibleException { if (!isCompatible(that)) throw new IncommensurableException(this + " is not compatible with " + that); PhysicsUnit thatPhysics = (PhysicsUnit)t...
@Test public void testGetConverterToAny() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<?> alternate(String symbol) { return new AlternateUnit(this, symbol); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); ...
@Test public void testAlternate() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<Q> transform(UnitConverter operation) { PhysicsUnit<Q> systemUnit = this.getSystemUnit(); UnitConverter cvtr = this.getConverterToSI().concatenate(operation); if (cvtr.equals(PhysicsConverter.IDENTITY)) return systemUnit; return new Tr...
@Test public void testTransform() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<Q> add(double offset) { if (offset == 0) return this; return transform(new AddConverter(offset)); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> a...
@Test public void testAdd() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<?> inverse() { if (this.equals(SI.ONE)) return this; return ProductUnit.getQuotientInstance(SI.ONE, this); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); Annotated...
@Test public void testInverse() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<?> root(int n) { if (n > 0) return ProductUnit.getRootInstance(this, n); else if (n == 0) throw new ArithmeticException("Root's order of zero"); else return SI.ONE.divide(this.root(-n)); } protected PhysicsUnit(); boolean isSI(); abst...
@Test public void testRoot() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<?> pow(int n) { if (n > 0) return this.multiply(this.pow(n - 1)); else if (n == 0) return SI.ONE; else return SI.ONE.divide(this.pow(-n)); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConvert...
@Test public void testPow() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public abstract int hashCode(); protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Overri...
@Test public void testHashCode() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public abstract boolean equals(Object that); protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSeque...
@Test public void testEquals() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { public AnnotatedUnit<Q> annotate(String annotation) { return new AnnotatedUnit<Q>(this, annotation); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); stat...
@Test public void testAnnotate() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public String toString() { TextBuilder tmp = TextBuilder.newInstance(); try { return UCUMFormat.getCaseSensitiveInstance().format(this, tmp).toString(); } catch (IOException ioException) { throw new Error(ioException); } finally { TextBuilder.recycle(tmp); } }...
@Test public void testToString() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public String getSymbol() { return null; } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequenc...
@Test public void testGetSymbol() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<Q> getSystemUnit() { return toSI(); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(Char...
@Test public void testGetSystemUnit() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valu...
@Test public void testGetProductUnits() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public abstract PhysicsDimension getDimension(); protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charS...
@Test public void testGetDimension() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final boolean isCompatible(Unit<?> that) { if ((this == that) || this.equals(that)) return true; if (!(that instanceof PhysicsUnit)) return false; PhysicsDimension thisDimension = this.getDimension(); PhysicsDimension thatDimension = ((PhysicsUnit)that)...
@Test public void testIsCompatible() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final <T extends Quantity<T>> PhysicsUnit<T> asType(Class<T> type) { PhysicsDimension typeDimension = PhysicsDimension.getDimension(type); if ((typeDimension != null) && (!this.getDimension().equals(typeDimension))) throw new ClassCastException("The uni...
@Test public void testAsType() { }
PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final UnitConverter getConverterTo(Unit<Q> that) throws UnconvertibleException { if ((this == that) || this.equals(that)) return PhysicsConverter.IDENTITY; Unit<Q> thisSystemUnit = this.getSystemUnit(); Unit<Q> thatSystemUnit = that.getSystemUnit(); if ...
@Test public void testGetConverterTo() { }
SpansToDependencyLinks implements Function<Iterable<Span>, Iterable<Dependency>> { protected Optional<Dependency> sharedSpanDependency(Set<Span> sharedSpans) { String clientService = null; String serverService = null; for (Span span: sharedSpans) { for (KeyValue tag: span.getTags()) { if (Tags.SPAN_KIND_CLIENT.equals(t...
@Test public void shouldReturnDependencyWithClientAndServerSpans() { SpansToDependencyLinks spansToDependencyLinks = new SpansToDependencyLinks(""); Set<Span> sharedSpans = new HashSet<>(); sharedSpans.add(createSpan("clientName", Tags.SPAN_KIND_CLIENT)); sharedSpans.add(createSpan("serverName", Tags.SPAN_KIND_SERVER))...
DirectSerializationMetadata { public static SerializationMetadata extractMetadata(List<Field> fields) { if (fields.isEmpty()) return EmptyObjectMetadata; Offsets offsets = minMaxOffsets(fields); long totalSize = OBJECT_HEADER_SIZE + offsets.max - offsets.min + 1; return new SerializationMetadata(offsets.min, padToObjec...
@Test public void primitives1Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives1()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives1.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(4, serializationMetadata.length); } @Tes...
DirectSerializationFilter { public static List<Field> stopAtFirstIneligibleField(List<Field> fields) { ArrayList<Field> eligibleFields = new ArrayList<Field>(); for (Field f : fields) { if (checkEligible(f)) { eligibleFields.add(f); } else { break; } } return eligibleFields.isEmpty() ? Collections.<Field>emptyList() : ...
@Test public void staticPrimitivesAreNotEligible() { List<Field> field = fieldsNamed("staticIntField"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void staticPrimitiveArraysAreNotEligible() { List<Field> field = fieldsNamed("staticDoubleArray"); assertTrue(stopAtFirstIneligibleField(field)....
RawCopier { public static <T> RawCopier<T> copies(Class<T> tClass) { return new RawCopier<T>(tClass); } private RawCopier(Class<T> tClass); static RawCopier<T> copies(Class<T> tClass); int start(); int end(); void toBytes(Object obj, Bytes bytes); void fromBytes(Bytes bytes, Object obj); void copy(T from, T to); }
@Test public void testStartEnd() { RawCopier<A> aRawCopier = RawCopier.copies(A.class); if (aRawCopier.start != 8) assertEquals(12, aRawCopier.start); assertEquals(aRawCopier.start + 3 * 4, aRawCopier.end); RawCopier<B> bRawCopier = RawCopier.copies(B.class); if (aRawCopier.start != 8) assertEquals(16, bRawCopier.start...
ResizeableMappedStore extends AbstractMappedStore { public void resize(long newSize) throws IOException { validateSize(newSize); unmapAndSyncToDisk(); resizeIfNeeded(0L, newSize); this.mmapInfoHolder.setSize(newSize); map(0L); } ResizeableMappedStore(File file, FileChannel.MapMode mode, long size); ResizeableMappedSto...
@Test public void testResizableMappedStore() throws IOException { File file = MappedStoreTest.getStoreFile("resizable-mapped-store.tmp"); final int smallSize = 1024, largeSize = 10 * smallSize; { ResizeableMappedStore ms = new ResizeableMappedStore(file, FileChannel.MapMode.READ_WRITE, smallSize); DirectBytes slice1 = ...
VanillaMappedFile implements VanillaMappedResource { @Override public synchronized void close() throws IOException { if (this.fileChannel.isOpen()) { long start = System.nanoTime(); this.fileChannel.close(); this.fileLifecycleListener.onEvent(EventType.CLOSE, this.path, System.nanoTime() - start); } } VanillaMappedFile...
@Test public void testMappedCache3() throws IOException { VanillaMappedCache<Integer> cache = new VanillaMappedCache(32, false); VanillaMappedBytes buffer = null; File file = null; for (int j = 0; j < 5; j++) { long start = System.nanoTime(); int maxRuns = 10000, runs; for (runs = 0; runs < maxRuns; runs++) { file = ne...
DataValueGenerator { public <T> T heapInstance(Class<T> tClass) { try { return (T) acquireHeapClass(tClass).newInstance(); } catch (Exception e) { throw new AssertionError(e); } } static Class firstPrimitiveFieldType(Class valueClass); static String bytesType(Class type); static String simpleName(Class<?> type); stati...
@Test public void testGenerateJavaCode() { DataValueGenerator dvg = new DataValueGenerator(); JavaBeanInterface jbi = dvg.heapInstance(JavaBeanInterface.class); jbi.setByte((byte) 1); jbi.setChar('2'); jbi.setShort((short) 3); jbi.setInt(4); jbi.setFloat(5); jbi.setLong(6); jbi.setDouble(7); jbi.setFlag(true); assertEq...
DataValueGenerator { public String generateNativeObject(Class<?> tClass) { return generateNativeObject(DataValueModels.acquireModel(tClass)); } static Class firstPrimitiveFieldType(Class valueClass); static String bytesType(Class type); static String simpleName(Class<?> type); static CharSequence normalize(Class aClas...
@Test public void testGenerateNativeWithGetUsing() throws ClassNotFoundException, IllegalAccessException, InstantiationException { String actual = new DataValueGenerator().generateNativeObject(JavaBeanInterfaceGetUsing.class); System.out.println(actual); CachedCompiler cc = new CachedCompiler(null, null); Class aClass ...
DataValueGenerator { public <T> T nativeInstance(Class<T> tClass) { try { return (T) acquireNativeClass(tClass).newInstance(); } catch (Exception e) { throw new AssertionError(e); } } static Class firstPrimitiveFieldType(Class valueClass); static String bytesType(Class type); static String simpleName(Class<?> type); s...
@Test public void testGenerateInterfaceWithEnumNativeInstance() { DataValueGenerator dvg = new DataValueGenerator(); JavaBeanInterfaceGetMyEnum jbie = dvg.nativeInstance(JavaBeanInterfaceGetMyEnum.class); Bytes bytes = ByteBufferBytes.wrap(ByteBuffer.allocate(64)); ((Byteable) jbie).bytes(bytes, 0L); jbie.setMyEnum(MyE...