| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2013 Ericsson |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * Matthew Khouzam - Initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | |
| 12 | package org.eclipse.linuxtools.ctf.core.tests.trace; |
| 13 | |
| 14 | import static org.junit.Assert.assertNotNull; |
| 15 | import static org.junit.Assert.assertNull; |
| 16 | import static org.junit.Assume.assumeTrue; |
| 17 | |
| 18 | import java.nio.ByteOrder; |
| 19 | |
| 20 | import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; |
| 21 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
| 22 | import org.eclipse.linuxtools.ctf.core.trace.Metadata; |
| 23 | import org.junit.Before; |
| 24 | import org.junit.Test; |
| 25 | |
| 26 | /** |
| 27 | * The class <code>MetadataTest</code> contains tests for the class |
| 28 | * <code>{@link Metadata}</code>. |
| 29 | * |
| 30 | * @author ematkho |
| 31 | * @version $Revision: 1.0 $ |
| 32 | */ |
| 33 | @SuppressWarnings("javadoc") |
| 34 | public class MetadataTest { |
| 35 | |
| 36 | private static final int TRACE_INDEX = 0; |
| 37 | |
| 38 | private Metadata fixture; |
| 39 | |
| 40 | /** |
| 41 | * Perform pre-test initialization. |
| 42 | * |
| 43 | * @throws CTFReaderException |
| 44 | */ |
| 45 | @Before |
| 46 | public void setUp() throws CTFReaderException { |
| 47 | assumeTrue(CtfTestTraces.tracesExist()); |
| 48 | fixture = new Metadata(CtfTestTraces.getTestTrace(TRACE_INDEX)); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Run the Metadata(CTFTrace) constructor test. |
| 53 | */ |
| 54 | @Test |
| 55 | public void testMetadata() { |
| 56 | assertNotNull(fixture); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Run the ByteOrder getDetectedByteOrder() method test. |
| 61 | */ |
| 62 | @Test |
| 63 | public void testGetDetectedByteOrder() { |
| 64 | ByteOrder result = fixture.getDetectedByteOrder(); |
| 65 | assertNull(result); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Test toString |
| 70 | */ |
| 71 | @Test |
| 72 | public void testToSting() { |
| 73 | String result = fixture.toString(); |
| 74 | assertNotNull(result); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Run the void parse() method test. |
| 79 | * |
| 80 | * @throws CTFReaderException |
| 81 | */ |
| 82 | @Test(expected = org.eclipse.linuxtools.ctf.core.trace.CTFReaderException.class) |
| 83 | public void testParse() throws CTFReaderException { |
| 84 | fixture.parse(); |
| 85 | } |
| 86 | } |