1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.pcap
.core
.tests
.protocol
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.fail
;
18 import java
.util
.ArrayList
;
19 import java
.util
.List
;
21 import org
.eclipse
.linuxtools
.pcap
.core
.protocol
.Protocol
;
22 import org
.eclipse
.linuxtools
.pcap
.core
.protocol
.ProtocolValues
;
23 import org
.junit
.Test
;
26 * JUnit Class that tests whether protocol operation are happening without
29 * @author Vincent Perot
31 public class ProtocolTest
{
34 * Test that verify if the protocol attributes are as expected.
37 public void TestProtocolAttributes() {
38 assertEquals(Protocol
.PCAP
.getName(), "Packet Capture");
39 assertEquals(Protocol
.PCAP
.getShortName(), "pcap");
40 assertEquals(Protocol
.PCAP
.getLayer(), ProtocolValues
.LAYER_0
);
44 * Test that verify if the protocol getter methods are working properly.
47 public void TestgetProtocols() {
48 List
<Protocol
> list
= new ArrayList
<>();
49 List
<Protocol
> manualListLayer
= new ArrayList
<>();
50 for (int i
= ProtocolValues
.LAYER_0
; i
<= ProtocolValues
.LAYER_7
; i
++) {
51 List
<Protocol
> listLayer
= Protocol
.getProtocolsOnLayer(i
);
52 list
.addAll(listLayer
);
54 manualListLayer
.clear();
56 case ProtocolValues
.LAYER_0
:
57 manualListLayer
.add(Protocol
.PCAP
);
59 case ProtocolValues
.LAYER_1
:
61 case ProtocolValues
.LAYER_2
:
62 manualListLayer
.add(Protocol
.ETHERNET_II
);
64 case ProtocolValues
.LAYER_3
:
65 manualListLayer
.add(Protocol
.IPV4
);
67 case ProtocolValues
.LAYER_4
:
68 manualListLayer
.add(Protocol
.TCP
);
69 manualListLayer
.add(Protocol
.UDP
);
71 case ProtocolValues
.LAYER_5
:
73 case ProtocolValues
.LAYER_6
:
75 case ProtocolValues
.LAYER_7
:
76 manualListLayer
.add(Protocol
.UNKNOWN
);
79 fail("Illegal layer value!");
81 assertEquals(manualListLayer
, listLayer
);
83 assertEquals(Protocol
.getAllProtocols(), list
);
This page took 0.031758 seconds and 5 git commands to generate.