//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendAndReceiveString() public virtual void ShouldSendAndReceiveString() { string originalValue = RandomStringUtils.randomAlphanumeric(Size); object receivedValue = SendAndReceive(originalValue); assertEquals(originalValue, receivedValue); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void takeLabelLockForQueryWithIndexUsages() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TakeLabelLockForQueryWithIndexUsages() { string labelName = "Human"; Label human = Label.label(labelName); string propertyKey = "name"; CreateIndex(human, propertyKey); using (Transaction transaction = DatabaseRule.beginTx()) { Node node = DatabaseRule.createNode(human); node.SetProperty(propertyKey, RandomStringUtils.randomAscii(10)); transaction.Success(); } string query = "MATCH (n:" + labelName + ") where n." + propertyKey + " = \"Fry\" RETURN n "; IList <LockOperationRecord> lockOperationRecords = TraceQueryLocks(query); assertThat("Observed list of lock operations is: " + lockOperationRecords, lockOperationRecords, hasSize(1)); LockOperationRecord operationRecord = lockOperationRecords[0]; assertTrue(operationRecord.Acquisition); assertFalse(operationRecord.Exclusive); assertEquals(ResourceTypes.LABEL, operationRecord.ResourceType); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createDropNodeLongStringProperty() public virtual void CreateDropNodeLongStringProperty() { Label markerLabel = Label.label("marker"); string testPropertyKey = "testProperty"; string propertyValue = RandomStringUtils.randomAscii(255); using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(markerLabel); node.SetProperty(testPropertyKey, propertyValue); tx.Success(); } using (Transaction tx = Db.beginTx()) { Node node = Iterators.single(Db.findNodes(markerLabel)); assertEquals(propertyValue, node.GetProperty(testPropertyKey)); tx.Success(); } using (Transaction tx = Db.beginTx()) { Node node = Iterators.single(Db.findNodes(markerLabel)); node.RemoveProperty(testPropertyKey); tx.Success(); } using (Transaction tx = Db.beginTx()) { Node node = Iterators.single(Db.findNodes(markerLabel)); assertFalse(node.HasProperty(testPropertyKey)); tx.Success(); } }
public Note CreateRandomNoteForUser(User user) { var randomNote = new Note(Guid.NewGuid(), user.Id, RandomStringUtils.GenerateRandomString(8), RandomStringUtils.GenerateRandomString(16), RandomStringUtils.GenerateRandomString(48)); return(randomNote); }
public static FilePath GetTestDir(Type caller, bool create) { FilePath dir = new FilePath(Runtime.GetProperty("test.build.data", "target/test/data" ) + "/" + RandomStringUtils.RandomAlphanumeric(10), caller.Name); if (create) { dir.Mkdirs(); } return(dir); }
public EngineConfig() { Uuid = Guid.NewGuid().ToString(); HomeDirectory = "./argon"; Logger = new LoggerConfig(); UseSwagger = true; SecretKey = RandomStringUtils.RandomString(32); TimeZone = TimeZoneUtils.ToTzdb(TimeZoneInfo.Local); UnitSystem = "metric"; Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; }
public FSTestWrapper(string testRootDir) { // // Test helper methods taken from FileContextTestHelper // // Use default test dir if not provided if (testRootDir == null || testRootDir.IsEmpty()) { testRootDir = Runtime.GetProperty("test.build.data", "build/test/data"); } // salt test dir with some random digits for safe parallel runs this.testRootDir = testRootDir + "/" + RandomStringUtils.RandomAlphanumeric(10); }
public GeekUriComponents Sign(JObject data) { string nonceStr = RandomStringUtils.Random(10); string sign = geekSign.Sign(data, nonceStr, GetFullPath()); this.queryParams = new Dictionary <string, string>(); queryParams.Add("sign_type", geekSign.SignType); queryParams.Add("nonce_str", nonceStr); queryParams.Add("sign", sign); return(this); }
/// <exception cref="System.Exception"/> private void WriteTestFile(string testFileName) { Path filePath = new Path(testFileName); FSDataOutputStream stream = dfs.Create(filePath); for (int i = 0; i < 10; i++) { byte[] data = Sharpen.Runtime.GetBytesForString(RandomStringUtils.RandomAlphabetic (102400)); stream.Write(data); } stream.Hsync(); stream.Close(); }
/// <summary>Loads the memory to the target value.</summary> internal virtual void Load() { while (Runtime.GetRuntime().TotalMemory() < targetValue) { System.Console.Out.WriteLine("Loading memory with " + DefaultUnitLoadSize + " characters. Current usage : " + Runtime.GetRuntime().TotalMemory()); // load some objects in the memory loadObjects.AddItem(RandomStringUtils.Random(DefaultUnitLoadSize)); // sleep for 100ms try { Sharpen.Thread.Sleep(100); } catch (Exception) { } } }
public override void Run() { ThreadLocalRandom localRandom = ThreadLocalRandom.current(); while (!Canceled) { PageCursorCounters pageCursorCounters; using (Transaction transaction = Db.beginTx(), KernelStatement kernelStatement = GetKernelStatement((GraphDatabaseAPI)Db)) { pageCursorCounters = kernelStatement.PageCursorTracer; Node node = Db.createNode(); node.SetProperty("name", RandomStringUtils.random(localRandom.Next(100))); node.SetProperty("surname", RandomStringUtils.random(localRandom.Next(100))); node.SetProperty("age", localRandom.Next(100)); transaction.Success(); StoreCounters(pageCursorCounters); } } }
private string CreateAuthenticationDigest() { var ladanseApiSecret = _config["ladanse:api:secret"]; var currentTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); var random = RandomStringUtils.Random(16); var toHash = random + ":" + currentTimestamp + ":" + ladanseApiSecret; var bytes = Encoding.UTF8.GetBytes(toHash); var sha256Managed = new SHA256Managed(); var hash = sha256Managed.ComputeHash(bytes); var hashString = hash.Aggregate(string.Empty, (current, x) => current + string.Format("{0:x2}", x)); return(random + ":" + currentTimestamp + ":" + hashString); }
/// <summary> /// Function to test whether a dir is working correctly by actually creating a /// random directory. /// </summary> /// <param name="dir">the dir to test</param> /// <exception cref="System.IO.IOException"/> private void VerifyDirUsingMkdir(FilePath dir) { string randomDirName = RandomStringUtils.RandomAlphanumeric(5); FilePath target = new FilePath(dir, randomDirName); int i = 0; while (target.Exists()) { randomDirName = RandomStringUtils.RandomAlphanumeric(5) + i; target = new FilePath(dir, randomDirName); i++; } try { DiskChecker.CheckDir(target); } finally { FileUtils.DeleteQuietly(target); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void reTakeLabelLockForQueryWithIndexUsagesWhenSchemaStateWasUpdatedDuringLockOperations() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ReTakeLabelLockForQueryWithIndexUsagesWhenSchemaStateWasUpdatedDuringLockOperations() { string labelName = "Robot"; Label robot = Label.label(labelName); string propertyKey = "name"; CreateIndex(robot, propertyKey); using (Transaction transaction = DatabaseRule.beginTx()) { Node node = DatabaseRule.createNode(robot); node.SetProperty(propertyKey, RandomStringUtils.randomAscii(10)); transaction.Success(); } string query = "MATCH (n:" + labelName + ") where n." + propertyKey + " = \"Bender\" RETURN n "; LockOperationListener lockOperationListener = new OnceSchemaFlushListener(this); IList <LockOperationRecord> lockOperationRecords = TraceQueryLocks(query, lockOperationListener); assertThat("Observed list of lock operations is: " + lockOperationRecords, lockOperationRecords, hasSize(3)); LockOperationRecord operationRecord = lockOperationRecords[0]; assertTrue(operationRecord.Acquisition); assertFalse(operationRecord.Exclusive); assertEquals(ResourceTypes.LABEL, operationRecord.ResourceType); LockOperationRecord operationRecord1 = lockOperationRecords[1]; assertFalse(operationRecord1.Acquisition); assertFalse(operationRecord1.Exclusive); assertEquals(ResourceTypes.LABEL, operationRecord1.ResourceType); LockOperationRecord operationRecord2 = lockOperationRecords[2]; assertTrue(operationRecord2.Acquisition); assertFalse(operationRecord2.Exclusive); assertEquals(ResourceTypes.LABEL, operationRecord2.ResourceType); }
public static async Task GetToKnowUser( SocketCommandContext socketCommandContext, LaDanseUrlBuilder laDanseUrlBuilder, DiscordBotContext dbContext, DiscordUser discordUser) { #region CleanUpAuthSessions var authSessions = dbContext.AuthSessions .Where(b => b.DiscordUser == discordUser) .ToList(); foreach (var authSession in authSessions) { if (authSession.State == AuthSessionState.Pending) { authSession.State = AuthSessionState.Removed; } } #endregion #region NewAuthSession var newAuthSession = new AuthSession { Nonce = RandomStringUtils.Random(32), CreatedOn = 0, DiscordUser = discordUser, State = AuthSessionState.Pending }; dbContext.AuthSessions.Add(newAuthSession); #endregion await socketCommandContext.User.SendMessageAsync( "Click on this URL and follow the instructions if you want us to get to know each other better ...\n\n" + laDanseUrlBuilder.GetDiscordAuthInformUrl(newAuthSession.Nonce, "http://localhost:57077/connect/website")); }
private Value String(int length) { return(stringValue(RandomStringUtils.randomAlphabetic(length))); }
/// <summary> /// Creates a cluster with a random name. /// The name is used in deciding which directory the store files are placed in. /// </summary> public Cluster() : this(RandomStringUtils.randomAlphanumeric(8)) { }
private string RandomString(int size) { return(ThreadLocalRandom.current().nextBoolean() ? RandomStringUtils.random(size) : RandomStringUtils.randomAlphabetic(size)); }
/// <summary>Create helper with test root located at <wd>/build/test/data</summary> public FileSystemTestHelper() : this(Runtime.GetProperty("test.build.data", "target/test/data") + "/" + RandomStringUtils .RandomAlphanumeric(10)) { }
private string LongString(int length) { return(RandomStringUtils.random(length, true, true)); }