1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.core.testUtil;
11  
12  import java.util.Random;
13  
14  public class RandomUtil {
15  
16    private static Random random = new Random();
17  
18    public static int getRandomServerPort() {
19      int r = random.nextInt(20000);
20      // the first 1024 ports are usually reserved for the OS
21      return r + 1024;
22    }
23  
24    public static int getPositiveInt() {
25      int r = random.nextInt();
26      if (r < 0) {
27        r = -r;
28      }
29      return r;
30    }
31  }