3 * * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
5 * * This program and the accompanying materials are made available under the
6 * * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * * and is available at http://www.eclipse.org/legal/epl-v10.html
12 package org.opendaylight.openflowplugin.impl.util;
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertTrue;
18 import org.junit.Test;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
21 import java.util.regex.Matcher;
22 import java.util.regex.Pattern;
24 public class FlowUtilTest {
26 private static final short DUMMY_TABLE_ID = 1;
27 public static final Pattern INDEX_PATTERN = Pattern.compile("^#UF\\$TABLE\\*1-([0-9]+)$");
30 public void createAlienFlowIdTest() {
31 final String alienFlowId1 = FlowUtil.createAlienFlowId(DUMMY_TABLE_ID).getValue();
32 final Integer index1 = parseIndex(alienFlowId1);
33 final String alienFlowId2 = FlowUtil.createAlienFlowId(DUMMY_TABLE_ID).getValue();
34 final Integer index2 = parseIndex(alienFlowId2);
36 assertNotNull("index1 parsing failed: "+alienFlowId1, index1);
37 assertNotNull("index2 parsing failed: "+alienFlowId2, index2);
38 assertTrue(index1 < index2);
41 private static Integer parseIndex(String alienFlowIdValue) {
42 final Matcher mach = INDEX_PATTERN.matcher(alienFlowIdValue);
44 return Integer.valueOf(mach.group(1));