move vpnservice and cleanup poms
[netvirt.git] / ipv6service / impl / src / test / java / org / opendaylight / netvirt / ipv6service / Ipv6TestUtils.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netvirt.ipv6service;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 public class Ipv6TestUtils {
15
16     public byte[] buildPacket(String... contents) {
17         List<String[]> splitContents = new ArrayList<>();
18         int packetLength = 0;
19         for (String content : contents) {
20             String[] split = content.split(" ");
21             packetLength += split.length;
22             splitContents.add(split);
23         }
24         byte[] packet = new byte[packetLength];
25         int index = 0;
26         for (String[] split : splitContents) {
27             for (String component : split) {
28                 // We can't use Byte.parseByte() here, it refuses anything > 7F
29                 packet[index] = (byte) Integer.parseInt(component, 16);
30                 index++;
31             }
32         }
33         return packet;
34     }
35 }