blob: 7006ae4b2e55619d778c8c52101c6b86826abae7 [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.attachments.embedded;
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>Vector_Embedded.MF4</code>.
*
* @author Christian Rechner
*/
public class Test_Vector_Embedded {
private static final String mdfFile = "org/eclipse/mdm/openatfx/mdf/mdf4/attachments/embedded/Vector_Embedded.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 props = new Properties();
props.put("$${ignore_attachments}", "true");
aoSession = reader.getAoSessionForMDF(orb, path, props);
}
@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("MCD10.00", 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_Vector_Embedded.class);
}
}