Skip to content

Commit

Permalink
Add an AnIML HPLC-DAD export/import test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Feb 22, 2024
1 parent 2c82ed0 commit d767e35
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2013, 2024 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
*******************************************************************************/
package net.openchrom.wsd.converter.supplier.animl;

import java.io.IOException;
import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.osgi.framework.Bundle;

public class PathResolver {

/**
* Returns a absolute path of the specified Folder. For example
* TESTDATA_IMPORT_EMPTY as an absolute Path:
* $PluginPath$/testData/files/file.animl
*
* @param string
* @return String absolutePath
*/
public static String getAbsolutePath(String string) {

Bundle bundle = Platform.getBundle(Activator.getContext().getBundle().getSymbolicName());
IPath path = new Path(string);
URL url = FileLocator.find(bundle, path, null);
try {
return FileLocator.resolve(url).getPath().toString();
} catch(IOException e) {
e.printStackTrace();
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>net.openchrom.wsd.converter.supplier.animl.fragment.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=utf8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=17
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Manifest-Version: 1.0
Automatic-Module-Name: net.openchrom.wsd.converter.supplier.animl.fragment.test
Bundle-ManifestVersion: 2
Bundle-Name: AnIML WSD Test
Bundle-SymbolicName: net.openchrom.wsd.converter.supplier.animl.fragment.test
Bundle-Version: 1.5.0.qualifier
Bundle-Vendor: OpenChrom
Fragment-Host: net.openchrom.wsd.converter.supplier.animl;bundle-version="1.5.0"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.junit;bundle-version="4.11.0",
org.eclipse.chemclipse.rcp.app.test;bundle-version="0.9.0",
com.sun.xml.bind.jaxb-core;bundle-version="4.0.1",
com.sun.xml.bind.jaxb-impl;bundle-version="4.0.1",
org.glassfish.hk2.osgi-resource-locator;bundle-version="1.0.3"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2015, 2024 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Dr. Alexander Kerner - initial API and implementation
* Matthias Mailänder - initial API and implementation
*******************************************************************************/
package net.openchrom.wsd.converter.supplier.animl;

import org.eclipse.chemclipse.rcp.app.test.TestAssembler;

import junit.framework.Test;
import junit.framework.TestSuite;

public class AllTests {

public static Test suite() {

TestAssembler testAssembler = new TestAssembler(Activator.getContext().getBundle().getBundleContext().getBundles());
TestSuite suite = new TestSuite("Run all tests.");
String bundleAndPackageName = "net.openchrom.wsd.converter.supplier.animl";
testAssembler.assembleTests(suite, bundleAndPackageName, bundleAndPackageName, "*_Test"); // Unit
testAssembler.assembleTests(suite, bundleAndPackageName, bundleAndPackageName, "*_ITest"); // Integration
return suite;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2020, 2024 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Matthias Mailänder - initial API and implementation
*******************************************************************************/
package net.openchrom.wsd.converter.supplier.animl;

public class TestPathHelper extends PathResolver {

/*
* IMPORT
*/
public static final String TESTFILE_IMPORT_DEMO = "testData/files/import/Demo.ocb";
/*
* EXPORT
*/
public static final String DIRECTORY_EXPORT_TEST = "testData/files/export";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Matthias Mailänder - initial API and implementation
*******************************************************************************/
package net.openchrom.wsd.converter.supplier.animl.converter;

import java.io.File;
import java.util.ArrayList;

import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.IProcessingMessage;
import org.eclipse.chemclipse.wsd.converter.chromatogram.ChromatogramConverterWSD;
import org.eclipse.chemclipse.wsd.model.core.IChromatogramWSD;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;

import net.openchrom.wsd.converter.supplier.animl.TestPathHelper;

import junit.framework.TestCase;

public class ChromatogramImportExport_ITest extends TestCase {

protected IChromatogramWSD chromatogramImport;
protected IChromatogramWSD chromatogram;
protected String pathImport;
protected String pathExport;
protected File fileImport;
protected File fileExport;
protected String extensionPointImport;
protected String extensionPointExportReimport;

@Override
protected void setUp() {

/*
* Import
*/
pathImport = TestPathHelper.getAbsolutePath(TestPathHelper.TESTFILE_IMPORT_DEMO);
extensionPointImport = "org.eclipse.chemclipse.xxd.converter.supplier.chemclipse";
/*
* Export/Reimport
*/
File directory = new File(TestPathHelper.DIRECTORY_EXPORT_TEST);
directory.mkdir();
pathExport = TestPathHelper.getAbsolutePath(TestPathHelper.DIRECTORY_EXPORT_TEST) + File.separator + "Test.animl";
extensionPointExportReimport = "net.openchrom.wsd.converter.supplier.animl.chromatogram";
/*
* Import the chromatogram.
*/
fileImport = new File(this.pathImport);
IProcessingInfo<IChromatogramWSD> processingInfoImport = ChromatogramConverterWSD.getInstance().convert(fileImport, this.extensionPointImport, new NullProgressMonitor());
chromatogramImport = processingInfoImport.getProcessingResult();
for(IProcessingMessage message : processingInfoImport.getMessages()) {
System.out.println(message.getMessage());
}
/*
* Export the chromatogram.
*/
fileExport = new File(this.pathExport);
IProcessingInfo<File> processingInfoExport = ChromatogramConverterWSD.getInstance().convert(fileExport, chromatogramImport, this.extensionPointExportReimport, new NullProgressMonitor());
fileExport = processingInfoExport.getProcessingResult();
for(IProcessingMessage message : processingInfoExport.getMessages()) {
System.out.println(message.getMessage());
}
/*
* Reimport the exported chromatogram.
*/
chromatogramImport = null;
IProcessingInfo<IChromatogramWSD> processingInfo = ChromatogramConverterWSD.getInstance().convert(fileExport, this.extensionPointExportReimport, new NullProgressMonitor());
chromatogram = processingInfo.getProcessingResult();
for(IProcessingMessage message : processingInfo.getMessages()) {
System.out.println(message.getMessage());
}
}

@Override
protected void tearDown() throws Exception {

pathImport = null;
pathExport = null;
fileImport = null;
fileExport.delete();
fileExport = null;
chromatogramImport = null;
chromatogram = null;
super.tearDown();
}

@Test
public void testReimport() {

assertNotNull(chromatogram);
assertEquals(4950, chromatogram.getNumberOfScans());
assertEquals(280f, new ArrayList<>(chromatogram.getWavelengths()).get(0));
}
}
Binary file not shown.

0 comments on commit d767e35

Please sign in to comment.