org.apache.commons.lang.math.RandomUtils Java Examples

The following examples show how to use org.apache.commons.lang.math.RandomUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignUpControll.java    From rebuild with GNU General Public License v3.0 7 votes vote down vote up
@RequestMapping("checkout-name")
public void checkoutName(HttpServletRequest request, HttpServletResponse response) throws IOException {
	String fullName = getParameterNotNull(request, "fullName");
	
	fullName = fullName.replaceAll("[^a-zA-Z0-9\u4e00-\u9fa5]", "");
	String loginName = HanLP.convertToPinyinString(fullName, "", false);
	if (loginName.length() > 20) {
		loginName = loginName.substring(0, 20);
	}
	if (BlackList.isBlack(loginName)) {
		writeSuccess(response);
		return;
	}
	
	for (int i = 0; i < 100; i++) {
		if (Application.getUserStore().existsName(loginName)) {
			loginName += RandomUtils.nextInt(99);
		} else {
			break;
		}
	}
	
	loginName = loginName.toLowerCase();
	writeSuccess(response, loginName);
}
 
Example #2
Source File: TestZip.java    From util4j with Apache License 2.0 6 votes vote down vote up
public static void test(int x,int y,int radio,boolean print)
{
	byte[] array=new byte[x*y];
	for(int i=0;i<array.length;i++)
	{
		array[i]=(byte) RandomUtils.nextInt(radio);
	}
	byte[][] data=getData(array, x, y);
	if(print)
	{
		printArray(data);
	}
	byte[] zipData=gzipData(array);
	if(print)
	{
		printArray(getData(zipData, x, y));
	}
	int zipLen=zipData.length;
	int len=array.length-zipLen;
	int p=(int) ((len*1.0f/array.length)*100);
	System.out.println("压缩后长度:"+zipLen+",节省空间:"+p+"%");
}
 
Example #3
Source File: VCode.java    From rebuild with GNU General Public License v3.0 6 votes vote down vote up
/**
    * 生成验证码
    *
 * @param key
 * @param level complexity 1<2<3
 * @return
 */
public static String generate(String key, int level) {
	String vcode;
	if (level == 3) {
		vcode = CodecUtils.randomCode(20);
	} else if (level == 2) {
		vcode = CodecUtils.randomCode(8);
	} else {
		vcode = RandomUtils.nextInt(999999999) + "888888";
		vcode = vcode.substring(0, 6);
	}

	// 缓存 10 分钟
	Application.getCommonCache().put("VCode-" + key, vcode, CommonCache.TS_HOUR / 6);
	return vcode;
}
 
Example #4
Source File: IntentPerfInstaller.java    From onos with Apache License 2.0 6 votes vote down vote up
private Intent createIntent(Key key, long mac, NodeId node, Multimap<NodeId, Device> devices) {
    // choose a random device for which this node is master
    List<Device> deviceList = devices.get(node).stream().collect(Collectors.toList());
    Device device = deviceList.get(RandomUtils.nextInt(deviceList.size()));

    //FIXME we currently ignore the path length and always use the same device
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchEthDst(MacAddress.valueOf(mac)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    ConnectPoint ingress = new ConnectPoint(device.id(), PortNumber.portNumber(1));
    ConnectPoint egress = new ConnectPoint(device.id(), PortNumber.portNumber(2));

    return PointToPointIntent.builder()
            .appId(appId)
            .key(key)
            .selector(selector)
            .treatment(treatment)
            .filteredIngressPoint(new FilteredConnectPoint(ingress))
            .filteredEgressPoint(new FilteredConnectPoint(egress))
            .build();
}
 
Example #5
Source File: AtomReadRestraintTest.java    From tddl with Apache License 2.0 6 votes vote down vote up
@Test
public void lessThanReadRestraintByDynamicTest() throws InterruptedException {
    if (ASTATICISM_TEST) {
        return;
    }

    int executCount = 10;
    int readCount = RandomUtils.nextInt(executCount);

    MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
        " maxPoolSize=100\r\nuserName=tddl\r\nminPoolSize=1\r\nreadRestrictTimes=" + executCount + "\r\n");
    TimeUnit.SECONDS.sleep(SLEEP_TIME);

    String sql = "select * from normaltbl_0001 where pk=?";
    for (int i = 0; i < readCount; i++) {
        try {
            Map rs = tddlJT.queryForMap(sql, new Object[] { RANDOM_ID });
            Assert.assertEquals(time, String.valueOf(rs.get("gmt_create")));
            executCount--;
        } catch (DataAccessException ex) {
        }
    }

    Assert.assertTrue(executCount >= 0);
}
 
Example #6
Source File: SampleUtils.java    From tassal with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get a uniformly random element from a Collection.
 * 
 * @param collection
 * @return
 */
public static <T> T getRandomElement(final Collection<T> collection) {
	final int randPos = RandomUtils
			.nextInt(checkNotNull(collection).size());

	T selected = null;
	int index = 0;
	for (final T element : collection) {
		if (index == randPos) {
			selected = element;
			break;
		}
		index++;
	}
	return selected;
}
 
Example #7
Source File: AtomWriteRestraintTest.java    From tddl with Apache License 2.0 6 votes vote down vote up
@Test
public void lessThanWriteRestraintTest() throws InterruptedException {
    if (ASTATICISM_TEST) {
        return;
    }

    int executCount = 10;
    int writeCount = RandomUtils.nextInt(executCount);

    MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
        " maxPoolSize=100\r\nuserName=tddl\r\nminPoolSize=1\r\nwriteRestrictTimes=" + executCount + "\r\n");
    TimeUnit.SECONDS.sleep(SLEEP_TIME);

    String sql = "update normaltbl_0001 set gmt_create=? where pk=?";
    for (int i = 0; i < writeCount; i++) {
        try {
            int rs = tddlJT.update(sql, new Object[] { nextDay, RANDOM_ID });
            Assert.assertEquals(1, rs);
            executCount--;
        } catch (DataAccessException ex) {
        }
    }
    Assert.assertTrue(executCount >= 0);
}
 
Example #8
Source File: TestSupportWithUser.java    From rebuild with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 添加一条测试记录
 *
 * @return
 */
protected ID addRecordOfTestAllFields() {
    Entity testEntity = MetadataHelper.getEntity(TEST_ENTITY);
    // 自动添加权限
    if (!Application.getSecurityManager().allowCreate(getSessionUser(), testEntity.getEntityCode())) {
        Record p = EntityHelper.forNew(EntityHelper.RolePrivileges, UserService.SYSTEM_USER);
        p.setID("roleId", SIMPLE_ROLE);
        p.setInt("entity", testEntity.getEntityCode());
        p.setString("definition", "{'A':1,'R':1,'C':4,'S':1,'D':1,'U':1}");
        Application.getCommonService().create(p, Boolean.FALSE);
        Application.getUserStore().refreshRole(SIMPLE_ROLE);
    }

    Record record = EntityHelper.forNew(testEntity.getEntityCode(), getSessionUser());
    record.setString("text", "TEXT-" + RandomUtils.nextLong());
    return Application.getGeneralEntityService().create(record).getPrimary();
}
 
Example #9
Source File: SeleniumSelect.java    From phoenix.webui.framework with Apache License 2.0 6 votes vote down vote up
@Override
public WebElement randomSelect(Element ele)
{
	Select select = createSelect(ele);
	if(select != null)
	{
		List<WebElement> options = select.getOptions();
		if(CollectionUtils.isNotEmpty(options))
		{
			int count = options.size();
			int index = RandomUtils.nextInt(count);
			index = (index == 0 ? 1 : index); //通常第一个选项都是无效的选项

			select.selectByIndex(index);
			
			return options.get(index);
		}
	}
	
	return null;
}
 
Example #10
Source File: DisposableWorkerIdAssigner.java    From uid-generator with Apache License 2.0 6 votes vote down vote up
/**
 * Build worker node entity by IP and PORT
 */
private WorkerNodeEntity buildWorkerNode() {
    WorkerNodeEntity workerNodeEntity = new WorkerNodeEntity();
    if (DockerUtils.isDocker()) {
        workerNodeEntity.setType(WorkerNodeType.CONTAINER.value());
        workerNodeEntity.setHostName(DockerUtils.getDockerHost());
        workerNodeEntity.setPort(DockerUtils.getDockerPort());

    } else {
        workerNodeEntity.setType(WorkerNodeType.ACTUAL.value());
        workerNodeEntity.setHostName(NetUtils.getLocalAddress());
        workerNodeEntity.setPort(System.currentTimeMillis() + "-" + RandomUtils.nextInt(100000));
    }

    return workerNodeEntity;
}
 
Example #11
Source File: SampleUtils.java    From api-mining with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get a uniformly random element from a Collection.
 * 
 * @param collection
 * @return
 */
public static <T> T getRandomElement(final Collection<T> collection) {
	final int randPos = RandomUtils
			.nextInt(checkNotNull(collection).size());

	T selected = null;
	int index = 0;
	for (final T element : collection) {
		if (index == randPos) {
			selected = element;
			break;
		}
		index++;
	}
	return selected;
}
 
Example #12
Source File: AtomReadRestraintTest.java    From tddl5 with Apache License 2.0 6 votes vote down vote up
@Test
public void lessThanReadRestraintByDynamicTest() throws InterruptedException {
    if (ASTATICISM_TEST) {
        return;
    }

    int executCount = 10;
    int readCount = RandomUtils.nextInt(executCount);

    MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
        " maxPoolSize=100\r\nuserName=tddl\r\nminPoolSize=1\r\nreadRestrictTimes=" + executCount + "\r\n");
    TimeUnit.SECONDS.sleep(SLEEP_TIME);

    String sql = "select * from normaltbl_0001 where pk=?";
    for (int i = 0; i < readCount; i++) {
        try {
            Map rs = tddlJT.queryForMap(sql, new Object[] { RANDOM_ID });
            Assert.assertEquals(time, String.valueOf(rs.get("gmt_create")));
            executCount--;
        } catch (DataAccessException ex) {
        }
    }

    Assert.assertTrue(executCount >= 0);
}
 
Example #13
Source File: AtomWriteRestraintTest.java    From tddl5 with Apache License 2.0 6 votes vote down vote up
@Test
public void lessThanWriteRestraintTest() throws InterruptedException {
    if (ASTATICISM_TEST) {
        return;
    }

    int executCount = 10;
    int writeCount = RandomUtils.nextInt(executCount);

    MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
        " maxPoolSize=100\r\nuserName=tddl\r\nminPoolSize=1\r\nwriteRestrictTimes=" + executCount + "\r\n");
    TimeUnit.SECONDS.sleep(SLEEP_TIME);

    String sql = "update normaltbl_0001 set gmt_create=? where pk=?";
    for (int i = 0; i < writeCount; i++) {
        try {
            int rs = tddlJT.update(sql, new Object[] { nextDay, RANDOM_ID });
            Assert.assertEquals(1, rs);
            executCount--;
        } catch (DataAccessException ex) {
        }
    }
    Assert.assertTrue(executCount >= 0);
}
 
Example #14
Source File: AtlasObserverLiveTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenAtlasAndCounter_whenRegister_thenPublishedToAtlas() throws Exception {
    Counter counter = new BasicCounter(MonitorConfig
      .builder("test")
      .withTag("servo", "counter")
      .build());
    DefaultMonitorRegistry
      .getInstance()
      .register(counter);
    assertThat(atlasValuesOfTag("servo"), not(containsString("counter")));

    for (int i = 0; i < 3; i++) {
        counter.increment(RandomUtils.nextInt(10));
        SECONDS.sleep(1);
        counter.increment(-1 * RandomUtils.nextInt(10));
        SECONDS.sleep(1);
    }

    assertThat(atlasValuesOfTag("servo"), containsString("counter"));
}
 
Example #15
Source File: AdDataGenerator.java    From examples with Apache License 2.0 6 votes vote down vote up
private byte[] getTuple()
{
  int securityCode = adId % 30;
  if (securityCode < 10) {
    securityCode += 10;
  }

  StringBuilder sb = new StringBuilder();
  sb.append(adId + ",");                                               //adId
  sb.append((adId + 10) + ",");                                        //campaignId
  sb.append("TestAdd" + ",");                                          //adName
  sb.append("2.2" + ",");                                              //bidPrice
  sb.append(startDateFormat.format(calendar.getTime()) + ",");         //startDate
  sb.append(endDateFormat.format(calendar.getTime()) + ",");           //endDate
  sb.append(adId + 10 + ",");                                          //securityCode
  sb.append(RandomUtils.nextBoolean() + ",");                          //active
  sb.append(RandomUtils.nextBoolean() ? "OPTIMIZE," : "NO_OPTIMIZE,"); //optimized
  sb.append(PARENT_CAMPAIGN);                                          //parentCampaign
  adId++;
  return String.valueOf(sb).getBytes();
}
 
Example #16
Source File: BaseDataBean.java    From qaf with MIT License 6 votes vote down vote up
/**
 * Can be used with xml configuration file or properties file
 * 
 * @param datakey
 */
public void fillFromConfig(String datakey) {
	List<Object[]> set = DataProviderUtil.getDataSetAsMap(datakey,"");
	if (set.isEmpty()) {
		return;
	}
	int index = 0;
	if (set.size() > 1) {
		if (ApplicationProperties.BEAN_POPULATE_RANDOM.getBoolenVal(false)) {
			// get random index from 0 to size-1.
			index = RandomUtils.nextInt(set.size());
		} else {
			// get next index, if index exceeds size then start with 0.
			int cindex = getBundle().getInt(RetryAnalyzer.RETRY_INVOCATION_COUNT, 0);
			index = cindex % set.size();
		}
	}
	fillData(set.get(index)[0]);

}
 
Example #17
Source File: NodeMap4.java    From util4j with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
		byte[] data=new byte[1024*1024];
		for(int i=0;i<data.length;i++)
		{
			data[i]=(byte) RandomUtils.nextInt(255);
		}
		Test t=new Test();
		Scanner sc=new Scanner(System.in);
		sc.nextLine();
//		t.testtMap(data);
//		sc.nextLine();
//		t.testMap(data);
//		sc.nextLine();
		t.testNMap(data);
		sc.nextLine();
	}
 
Example #18
Source File: NodeMap6.java    From util4j with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
		byte[] data=new byte[1024*1024];
		for(int i=0;i<data.length;i++)
		{
			data[i]=(byte) RandomUtils.nextInt(255);
		}
		Test t=new Test();
		Scanner sc=new Scanner(System.in);
		sc.nextLine();
//		t.testtMap(data);
//		sc.nextLine();
//		t.testMap(data);
//		sc.nextLine();
		t.testNMap(data);
		sc.nextLine();
	}
 
Example #19
Source File: KetamaNodeLocatorTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
    public void testNodeListAtScale() {
        final int nodeSize = 10000;
        final List<String> nodes = generateRandomStrings(nodeSize);
        final long start1 = System.currentTimeMillis();
        final KetamaNodeLocator locator = new KetamaNodeLocator(nodes);

        // Make sure the initialization doesn't take too long.
//        System.out.println("Duration: " + (System.currentTimeMillis() - start1));
        assertTrue((System.currentTimeMillis() - start1) < 5000);

        final List<String> keys = generateRandomStrings(5 + RandomUtils.nextInt(5));

        for (final String key : keys) {
            final long start2 = System.currentTimeMillis();
            final List<String> superlist = locator.getPriorityList(key, nodeSize);
//            System.out.println("Duration: " + (System.currentTimeMillis() - start2));
            assertTrue((System.currentTimeMillis() - start2) < 200);
            assertEquals(nodeSize, superlist.size());
        }
    }
 
Example #20
Source File: RandomFunction.java    From ureport with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(List<ExpressionData<?>> dataList, Context context,Cell currentCell) {
	int feed=0;
	if(dataList.size()>0){
		BigDecimal data=buildBigDecimal(dataList);
		feed=data.intValue();
	}
	if(feed==0){
		return Math.random();
	}
	return RandomUtils.nextInt(feed);
}
 
Example #21
Source File: WxArticleTemplateServiceImpl.java    From cms with Apache License 2.0 5 votes vote down vote up
private String getFilePath() {
    LocalDateTime localDate = LocalDateTime.now();
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");

    //4.把 2019-01-01  转成  2019/01/01
    String format = localDate.format(dtf);
    return "wechat/" + format + "/" + System.currentTimeMillis() +
            RandomUtils.nextInt(4) + ".png";
}
 
Example #22
Source File: TestDefaultQueues.java    From util4j with Apache License 2.0 5 votes vote down vote up
public void testOrder(final TaskQueueExecutor o)
    	 {
    		 final AtomicInteger atomicInteger=new AtomicInteger(0);
    		 for(int i=0;i<1000;i++)
    		 {
    			 final int x=i;
				 o.execute(new Task() {
						@Override
						public void run() {
							int sleep=RandomUtils.nextInt(100);
							if(x%2==0)
							{
								System.err.println("i="+x+",value="+atomicInteger.incrementAndGet()+",sleep="+sleep);
							}else
							{
								System.err.println("i="+x+",value="+atomicInteger.decrementAndGet()+",sleep="+sleep);
							}
//							try {
//								Thread.sleep(sleep);
//							} catch (InterruptedException e) {
//								e.printStackTrace();
//							}
						}
						@Override
						public String name() {
							return "";
						}
					});
    		 }
    	 }
 
Example #23
Source File: TestQueues.java    From util4j with Apache License 2.0 5 votes vote down vote up
public void testOrder(final TaskQueueExecutor o)
    	 {
    		 final AtomicInteger atomicInteger=new AtomicInteger(0);
    		 for(int i=0;i<1000;i++)
    		 {
    			 final int x=i;
				 o.execute(new Task() {
						@Override
						public void run() {
							int sleep=RandomUtils.nextInt(100);
							if(x%2==0)
							{
								System.err.println("i="+x+",value="+atomicInteger.incrementAndGet()+",sleep="+sleep);
							}else
							{
								System.err.println("i="+x+",value="+atomicInteger.decrementAndGet()+",sleep="+sleep);
							}
//							try {
//								Thread.sleep(sleep);
//							} catch (InterruptedException e) {
//								e.printStackTrace();
//							}
						}
						@Override
						public String name() {
							return "";
						}
					});
    		 }
    	 }
 
Example #24
Source File: NamingEvaluator.java    From naturalize with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private synchronized static void appendToStatsFile(final StringBuffer buf) {
	try {
		fileStatsOutput.write(buf.toString().getBytes());
		if (RandomUtils.nextDouble() < 0.01) {
			fileStatsOutput.flush();
		}
	} catch (final IOException e) {
		LOGGER.warning(ExceptionUtils.getFullStackTrace(e));
	}
}
 
Example #25
Source File: SampleUtilsTest.java    From tassal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * This test may be flakey, due to its probabilistic nature.
 */
@Test
public void testRandomPartitionAvgBehavior() {
	// Check a random sample of 100 randomly created partitions and elements
	// that are statistically "ok".
	for (int i = 0; i < 100; i++) {
		final Map<Integer, Double> partitionWeights = Maps.newHashMap();
		final Map<Integer, Double> elementWeights = Maps.newHashMap();

		final int nPartitions = RandomUtils.nextInt(99) + 1;
		final int nElements = RandomUtils.nextInt(1000) + 5000;

		for (int partition = 0; partition < nPartitions; partition++) {
			partitionWeights.put(partition, RandomUtils.nextDouble());
		}
		for (int element = 0; element < nElements; element++) {
			elementWeights.put(element, RandomUtils.nextDouble());
		}

		final Multimap<Integer, Integer> partitions = SampleUtils
				.randomPartition(elementWeights, partitionWeights);
		final double partitionsTotalSum = StatsUtil.sum(partitionWeights
				.values());

		double sumDifference = 0;
		for (final int partitionId : partitions.keySet()) {
			final int partitionSize = partitions.get(partitionId).size();
			final double expectedPartitionPct = partitionWeights
					.get(partitionId) / partitionsTotalSum;
			final double actualPartitionPct = ((double) partitionSize)
					/ nElements;
			sumDifference += Math.abs(expectedPartitionPct
					- actualPartitionPct);
		}

		// On average we are not off by 1%
		assertEquals(sumDifference / partitions.keySet().size(), 0, 1E-2);

	}
}
 
Example #26
Source File: UploadServiceImpl.java    From cms with Apache License 2.0 5 votes vote down vote up
private String getFilePath(String sourceFileName) {
    LocalDateTime localDate = LocalDateTime.now();
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");

    //4.把 2019-01-01  转成  2019/01/01
    String format = localDate.format(dtf);
    return "images/" + format + "/" + System.currentTimeMillis() +
            RandomUtils.nextInt(4) + "." +
            StringUtils.substringAfterLast(sourceFileName, ".");
}
 
Example #27
Source File: WechatServiceImpl.java    From cms with Apache License 2.0 5 votes vote down vote up
private String getFilePath() {
//        LocalDateTime localDate = LocalDateTime.now();
//        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");

        //4.把 2019-01-01  转成  2019/01/01
//        String format = localDate.format(dtf);
        String location = properties.getLocationDirectory();
        String fileName = System.currentTimeMillis() + RandomUtils.nextInt(4) + ".png";
        String path = "/wechat/" + fileName;
        return location + path;
    }
 
Example #28
Source File: SampleUtils.java    From tassal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get a uniformly random element from a Multiset.
 * 
 * @param set
 * @return
 */
public static <T> T getRandomElement(final Multiset<T> set) {
	final int randPos = RandomUtils.nextInt(checkNotNull(set).size());

	T selected = null;
	int i = 0;
	for (final Multiset.Entry<T> entry : set.entrySet()) {
		i += entry.getCount();
		if (i > randPos) {
			selected = entry.getElement();
			break;
		}
	}
	return selected;
}
 
Example #29
Source File: ZookeeperConfigurationWriterTest.java    From chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void basePathExists_overwrite() throws Exception {
    Assert.assertNull(curatorFramework.checkExists().forPath(base));

    try (CuratorFramework zkCurator = createCuratorFramework()) {
     ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, true);
	
     writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
	
     Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
     Assert.assertEquals(val2, new String(curatorFramework.getData().forPath(base + "/" + key2)));
	
     String key3 = RandomUtils.nextInt() + "";
     String val3 = RandomUtils.nextInt() + "";
     String newVal1 = RandomUtils.nextInt() + "";
	
     props.clear();
	
     //updates key1
     props.put(key1, newVal1);
     //adds key3
     props.put(key3, val3);
	
     //key2 should be deleted
	
     writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
	
     Assert.assertEquals(newVal1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
     Assert.assertEquals(val3, new String(curatorFramework.getData().forPath(base + "/" + key3)));
     Assert.assertNull(curatorFramework.checkExists().forPath(base + "/" + key2));
    }
}
 
Example #30
Source File: TagImageCmdIT.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Test
public void tagImage() throws Exception {
    String tag = "" + RandomUtils.nextInt(Integer.MAX_VALUE);

    dockerRule.getClient().tagImageCmd("busybox:latest", "docker-java/busybox", tag).exec();

    dockerRule.getClient().removeImageCmd("docker-java/busybox:" + tag).exec();
}