Tabnine Logo
RandomUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
RandomUtil
in
org.apache.activemq.artemis.utils

Best Java code snippets using org.apache.activemq.artemis.utils.RandomUtil (Showing top 20 results out of 315)

origin: wildfly/wildfly

public static int randomPositiveInt() {
 return Math.abs(RandomUtil.randomInt());
}
origin: wildfly/wildfly

public static long randomPositiveLong() {
 return Math.abs(RandomUtil.randomLong());
}
origin: wildfly/wildfly

public static byte[] randomBytes() {
 return RandomUtil.randomString().getBytes();
}
origin: wildfly/wildfly

public static byte[] randomBytes(final int length) {
 byte[] bytes = new byte[length];
 for (int i = 0; i < bytes.length; i++) {
   bytes[i] = RandomUtil.randomByte();
 }
 return bytes;
}
origin: wildfly/wildfly

public byte[] getSalt() throws NoSuchAlgorithmException {
  byte[] salt = RandomUtil.randomBytes(this.saltLength);
  return salt;
}
origin: wildfly/wildfly

public static int randomMax(final int max) {
 int value = randomPositiveInt() % max;
 if (value == 0) {
   value = max;
 }
 return value;
}
origin: wildfly/wildfly

  /**
  * Returns a pseudo random number between {@code 0} (inclusive) and {@code max} exclusive.
  *
  * @param max the upper limit of the random number selection
  * @see java.util.Random#nextInt(int)
  */
  @Override
  public int select(final int max) {
   return RandomUtil.randomInterval(0, max);
  }
}
origin: apache/activemq-artemis

  @Override
  @Before
  public void setUp() throws Exception {
   super.setUp();

   TransportConfiguration connectorConfiguration = new TransportConfiguration(NETTY_CONNECTOR_FACTORY);
   List<String> connectorInfos = new ArrayList<>();
   connectorInfos.add(connectorConfiguration.getName());
   broadcastGroupConfig = new BroadcastGroupConfiguration().setName(RandomUtil.randomString()).setBroadcastPeriod(RandomUtil.randomPositiveInt()).setConnectorInfos(connectorInfos).setEndpointFactory(new UDPBroadcastEndpointFactory().setGroupAddress(getUDPDiscoveryAddress()).setGroupPort(getUDPDiscoveryPort()).setLocalBindPort(1198));

   Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true).addConnectorConfiguration(connectorConfiguration.getName(), connectorConfiguration).addBroadcastGroupConfiguration(broadcastGroupConfig);
   server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, false));
   server.start();

   broadcastGroupControl = createManagementControl(broadcastGroupConfig.getName());
  }
}
origin: apache/activemq-artemis

@Test
public void testReadData() throws Exception {
 ActiveMQBuffer dynamic = ActiveMQBuffers.dynamicBuffer(1);
 String str1 = RandomUtil.randomString();
 String str2 = RandomUtil.randomString();
 double d1 = RandomUtil.randomDouble();
 float f1 = RandomUtil.randomFloat();
 dynamic.writeUTF(str1);
 dynamic.writeString(str2);
 dynamic.writeDouble(d1);
 dynamic.writeFloat(f1);
 LargeMessageControllerImpl readBuffer = splitBuffer(3, dynamic.toByteBuffer().array());
 Assert.assertEquals(str1, readBuffer.readUTF());
 Assert.assertEquals(str2, readBuffer.readString());
 Assert.assertEquals(d1, readBuffer.readDouble(), 0.000001);
 Assert.assertEquals(f1, readBuffer.readFloat(), 0.000001);
}
origin: apache/activemq-artemis

@Test
public void testSetDeadLetterAddress() throws Exception {
 SimpleString address = RandomUtil.randomSimpleString();
 SimpleString queue = RandomUtil.randomSimpleString();
 String deadLetterAddress = RandomUtil.randomString();
 session.createQueue(address, RoutingType.MULTICAST, queue, null, durable);
 QueueControl queueControl = createManagementControl(address, queue);
 AddressSettings addressSettings = new AddressSettings().setDeadLetterAddress(new SimpleString(deadLetterAddress));
 server.getAddressSettingsRepository().addMatch(address.toString(), addressSettings);
 Assert.assertEquals(deadLetterAddress, queueControl.getDeadLetterAddress());
 session.deleteQueue(queue);
}
origin: apache/activemq-artemis

@Test
public void testWriteObjectWithDouble() throws Exception {
 doWriteObjectWithType(RandomUtil.randomDouble(), new TypeReader() {
   @Override
   public Object readType(final ActiveMQStreamMessage message) throws Exception {
    return message.readDouble();
   }
 });
}
origin: apache/activemq-artemis

@Test
public void testReadBytesFromInvalidType() throws Exception {
 doReadTypeFromInvalidType(RandomUtil.randomBoolean(), new TypeReader() {
   @Override
   public Object readType(final ActiveMQStreamMessage message) throws Exception {
    return message.readByte();
   }
 });
}
origin: apache/activemq-artemis

  @Override
  public void run() throws ActiveMQException {
   session.createTemporaryQueue(RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString());
  }
});
origin: apache/activemq-artemis

  @Override
  public void run() throws ActiveMQException {
   session.createQueue(RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString(), RandomUtil.randomBoolean());
  }
});
origin: apache/activemq-artemis

@Test
public void testValidateUTFOnDataInput() throws Exception {
 for (int i = 0; i < 100; i++) {
   // Random size between 15k and 20K
   byte[] bytes = new byte[15000 + RandomUtil.randomPositiveInt() % 5000];
   RandomUtil.getRandom().nextBytes(bytes);
   String str = new String(bytes);
   // The maximum size the encoded UTF string would reach is str.length * 3 (look at the UTF8 implementation)
   testValidateUTFOnDataInputStream(str, ActiveMQBuffers.wrappedBuffer(ByteBuffer.allocate(str.length() * 3 + DataConstants.SIZE_SHORT)));
   testValidateUTFOnDataInputStream(str, ActiveMQBuffers.dynamicBuffer(100));
   testValidateUTFOnDataInputStream(str, ActiveMQBuffers.fixedBuffer(100 * 1024));
 }
}
origin: wildfly/wildfly

public static ActiveMQBuffer randomBuffer(final int size, final long... data) {
 ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(size + 8 * data.length);
 for (long d : data) {
   buffer.writeLong(d);
 }
 for (int i = 0; i < size; i++) {
   buffer.writeByte(randomByte());
 }
 return buffer;
}
origin: apache/activemq-artemis

@Test
public void testWriteObjectWithBytes() throws Exception {
 final byte[] value = RandomUtil.randomBytes();
 doWriteObjectWithType(value, new TypeReader() {
   @Override
   public Object readType(final ActiveMQStreamMessage message) throws Exception {
    byte[] bytes = new byte[value.length];
    message.readBytes(bytes);
    return bytes;
   }
 });
}
origin: apache/activemq-artemis

public static int randomMax(final int max) {
 int value = randomPositiveInt() % max;
 if (value == 0) {
   value = max;
 }
 return value;
}
origin: wildfly/wildfly

  /**
  * @see java.util.Random#nextInt(int)
  */
  @Override
  public int select(final int max) {
   if (pos == -1) {
     pos = RandomUtil.randomInterval(0, max);
   }

   return pos;
  }
}
origin: apache/activemq-artemis

@Test
public void testSetObjectFromDouble() throws Exception {
 doTestSetObject(RandomUtil.randomDouble());
}
org.apache.activemq.artemis.utilsRandomUtil

Most used methods

  • randomInt
  • randomLong
  • randomString
  • randomByte
  • randomBytes
  • randomPositiveInt
  • randomInterval
  • randomBoolean
  • randomDouble
  • randomSimpleString
  • randomChar
  • randomPositiveLong
  • randomChar,
  • randomPositiveLong,
  • randomFloat,
  • randomShort,
  • getRandom,
  • randomBuffer

Popular in Java

  • Making http requests using okhttp
  • getApplicationContext (Context)
  • onCreateOptionsMenu (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Permission (java.security)
    Legacy security code; do not use.
  • BoxLayout (javax.swing)
  • JFrame (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now