blob: dbe73efbafd16f8770fef9238ec53ed996691b7d [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
package org.eclipse.mdm.openatfx.mdf.mdf4.datatypes.integer_types;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import org.asam.ods.AoException;
import org.asam.ods.AoSession;
import org.asam.ods.ApplicationStructure;
import org.asam.ods.InstanceElement;
import org.eclipse.mdm.openatfx.mdf.MDFConverter;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.omg.CORBA.ORB;
import de.rechner.openatfx.util.ODSHelper;
import junit.framework.JUnit4TestAdapter;
/**
* Test case for reading the example MDF4-file
* <code>dSPACE_IntegerTypes.mf4</code>.
*
* @author Christian Rechner
*/
public class Test_dSPACE_IntegerTypes {
private static final String mdfFile = "org/eclipse/mdm/openatfx/mdf/mdf4/datatypes/integer_types/dSPACE_IntegerTypes.mf4";
private static ORB orb;
private static AoSession aoSession;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
orb = ORB.init(new String[0], System.getProperties());
Path path = Paths.get(ClassLoader.getSystemResource(mdfFile).toURI());
MDFConverter reader = new MDFConverter();
Properties properties = new Properties();
properties.put("skip_uint64_data_channels", "true");
aoSession = reader.getAoSessionForMDF(orb, path, properties);
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
if (aoSession != null) {
aoSession.close();
}
}
@Test
public void testReadIDBlock() {
try {
ApplicationStructure as = aoSession.getApplicationStructure();
InstanceElement ieTst = as.getElementByName("tst").getInstances("*").nextOne();
assertEquals("MDF ", ODSHelper.getStringVal(ieTst.getValue("mdf_file_id")));
assertEquals("4.10 ", ODSHelper.getStringVal(ieTst.getValue("mdf_version_str")));
assertEquals(410, ODSHelper.getLongVal(ieTst.getValue("mdf_version")));
assertEquals("CtrlDesk", ODSHelper.getStringVal(ieTst.getValue("mdf_program")));
assertEquals(0, ODSHelper.getLongVal(ieTst.getValue("mdf_unfin_flags")));
assertEquals(0, ODSHelper.getLongVal(ieTst.getValue("mdf_custom_unfin_flags")));
} catch (AoException e) {
fail(e.reason);
}
}
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(Test_dSPACE_IntegerTypes.class);
}
}