summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/runvirt-plugin-qemu/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/qemu/runvirt-plugin-qemu/src/test')
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/AppTest.java202
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/cmdln/CommandLineArgsTest.java752
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericCpuTest.java49
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskCdromDevicesTest.java65
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskFloppyDevicesTest.java66
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskStorageDevicesTest.java62
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericFileSystemDevicesTest.java66
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericInterfaceDevicesTest.java63
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericMemoryTest.java50
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericNameTest.java45
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericParallelDevicesTest.java58
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericUuidTest.java43
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuArchitectureTest.java105
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGpuPassthroughNvidiaTest.java134
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuSerialDevicesTest.java74
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationTestResources.java17
-rw-r--r--core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationTestUtils.java119
17 files changed, 1970 insertions, 0 deletions
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/AppTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/AppTest.java
new file mode 100644
index 00000000..d0eef82a
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/AppTest.java
@@ -0,0 +1,202 @@
+package org.openslx.runvirt.plugin.qemu;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs.CmdLnOption;
+
+import com.ginsberg.junit.exit.ExpectSystemExit;
+import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
+
+public class AppTest
+{
+ @BeforeAll
+ private static void setUp()
+ {
+ // disable logging with log4j
+ LogManager.getRootLogger().setLevel( Level.OFF );
+ }
+
+ @Nested
+ public class CmdLnTest
+ {
+ private final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ private final ByteArrayOutputStream err = new ByteArrayOutputStream();
+
+ private void setUp()
+ {
+ // redirect output and error stream content
+ System.setOut( new PrintStream( this.out ) );
+ System.setErr( new PrintStream( this.err ) );
+ }
+
+ @Test
+ @DisplayName( "Test ouput of correct 'help' command line option (short version)" )
+ @ExpectSystemExit
+ public void testCmdLnOptionHelpShortCorrect()
+ {
+ String[] argsShortHelpOptionCorrect = { "-" + CmdLnOption.HELP.getShortOption() };
+
+ this.setUp();
+
+ // test correct usage of the short help option
+ try {
+ App.main( argsShortHelpOptionCorrect );
+ } catch ( Exception e ) {
+ // do nothing and check output afterwards
+ }
+
+ final String shortHelpOptionCorrectOutput = new String( this.out.toString() );
+ final String shortHelpOptionCorrectErrOutput = new String( this.err.toString() );
+ assertTrue( shortHelpOptionCorrectOutput.contains( "usage" ) );
+ assertTrue( shortHelpOptionCorrectOutput.contains( App.APP_NAME ) );
+ assertTrue( shortHelpOptionCorrectOutput.contains( App.APP_INFO ) );
+ assertTrue( shortHelpOptionCorrectOutput.contains( App.APP_DESC ) );
+
+ // test that no error was logged and output is available
+ assertEquals( 2503, shortHelpOptionCorrectOutput.length() );
+ assertEquals( 0, shortHelpOptionCorrectErrOutput.length() );
+ }
+
+ @Test
+ @DisplayName( "Test ouput of correct 'help' command line option (long version)" )
+ @ExpectSystemExit
+ public void testCmdLnOptionHelpLongCorrect()
+ {
+ String[] argsLongHelpOptionCorrect = { "--" + CmdLnOption.HELP.getLongOption() };
+
+ this.setUp();
+
+ // test correct usage of the long help option
+ try {
+ App.main( argsLongHelpOptionCorrect );
+ } catch ( Exception e ) {
+ // do nothing and check output afterwards
+ }
+
+ final String longHelpOptionCorrectOutput = this.out.toString();
+ final String longHelpOptionCorrectErrOutput = this.err.toString();
+ assertTrue( longHelpOptionCorrectOutput.contains( "usage" ) );
+ assertTrue( longHelpOptionCorrectOutput.contains( App.APP_NAME ) );
+ assertTrue( longHelpOptionCorrectOutput.contains( App.APP_INFO ) );
+ assertTrue( longHelpOptionCorrectOutput.contains( App.APP_DESC ) );
+
+ // test that no error was logged and output is available
+ assertEquals( 2503, longHelpOptionCorrectOutput.length() );
+ assertEquals( 0, longHelpOptionCorrectErrOutput.length() );
+ }
+
+ @Test
+ @DisplayName( "Test ouput of incorrect 'help' command line option (short version)" )
+ @ExpectSystemExit
+ public void testCmdLnOptionHelpShortIncorrect()
+ {
+ String[] argsShortHelpOptionIncorrect = { "---" + CmdLnOption.HELP.getShortOption() };
+
+ this.setUp();
+
+ // test incorrect usage of the short help option
+ try {
+ App.main( argsShortHelpOptionIncorrect );
+ } catch ( Exception e ) {
+ // do nothing and check output afterwards
+ }
+
+ final String shortHelpOptionIncorrectOutput = this.out.toString();
+ final String shortHelpOptionIncorrectErrOutput = this.err.toString();
+ assertTrue( shortHelpOptionIncorrectOutput.contains( "usage" ) );
+ assertTrue( shortHelpOptionIncorrectOutput.contains( App.APP_NAME ) );
+ assertTrue( shortHelpOptionIncorrectOutput.contains( App.APP_INFO ) );
+ assertTrue( shortHelpOptionIncorrectOutput.contains( App.APP_DESC ) );
+
+ // test that error was logged and output is available
+ assertEquals( 2503, shortHelpOptionIncorrectOutput.length() );
+ assertEquals( 0, shortHelpOptionIncorrectErrOutput.length() );
+ }
+
+ @Test
+ @DisplayName( "Test ouput of incorrect 'help' command line option (long version)" )
+ @ExpectSystemExit
+ public void testCmdLnOptionHelpLongIncorrect()
+ {
+ String[] argsLongHelpOptionIncorrect = { "---" + CmdLnOption.HELP.getLongOption() };
+
+ this.setUp();
+
+ // test incorrect usage of the long help option
+ try {
+ App.main( argsLongHelpOptionIncorrect );
+ } catch ( Exception e ) {
+ // do nothing and check output afterwards
+ }
+
+ final String longHelpOptionIncorrectOutput = this.out.toString();
+ final String longHelpOptionIncorrectErrOutput = this.err.toString();
+ assertTrue( longHelpOptionIncorrectOutput.contains( "usage" ) );
+ assertTrue( longHelpOptionIncorrectOutput.contains( App.APP_NAME ) );
+ assertTrue( longHelpOptionIncorrectOutput.contains( App.APP_INFO ) );
+ assertTrue( longHelpOptionIncorrectOutput.contains( App.APP_DESC ) );
+
+ // test that error was logged and output is available
+ assertEquals( 2503, longHelpOptionIncorrectOutput.length() );
+ assertEquals( 0, longHelpOptionIncorrectErrOutput.length() );
+ }
+
+ @Test
+ @DisplayName( "Test exit status of application invoked with correct 'help' command line option (short version)" )
+ @ExpectSystemExitWithStatus( 0 )
+ public void testCmdLnOptionHelpShortCorrectExit()
+ {
+ String[] argsShortHelpOptionCorrect = { "-" + CmdLnOption.HELP.getShortOption() };
+
+ this.setUp();
+
+ App.main( argsShortHelpOptionCorrect );
+ }
+
+ @Test
+ @DisplayName( "Test exit status of application invoked with correct 'help' command line option (long version)" )
+ @ExpectSystemExitWithStatus( 0 )
+ public void testCmdLnOptionHelpLongCorrectExit()
+ {
+ String[] argsLongHelpOptionCorrect = { "--" + CmdLnOption.HELP.getLongOption() };
+
+ this.setUp();
+
+ App.main( argsLongHelpOptionCorrect );
+ }
+
+ @Test
+ @DisplayName( "Test exit status of application invoked with incorrect 'help' command line option (short version)" )
+ @ExpectSystemExitWithStatus( 1 )
+ public void testCmdLnOptionHelpShortIncorrectExit()
+ {
+ String[] argsShortHelpOptionCorrect = { "---" + CmdLnOption.HELP.getShortOption() };
+
+ this.setUp();
+
+ App.main( argsShortHelpOptionCorrect );
+ }
+
+ @Test
+ @DisplayName( "Test exit status of application invoked with incorrect 'help' command line option (long version)" )
+ @ExpectSystemExitWithStatus( 1 )
+ public void testCmdLnOptionHelpLongIncorrectExit()
+ {
+ String[] argsLongHelpOptionCorrect = { "---" + CmdLnOption.HELP.getLongOption() };
+
+ this.setUp();
+
+ App.main( argsLongHelpOptionCorrect );
+ }
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/cmdln/CommandLineArgsTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/cmdln/CommandLineArgsTest.java
new file mode 100644
index 00000000..77522bd6
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/cmdln/CommandLineArgsTest.java
@@ -0,0 +1,752 @@
+package org.openslx.runvirt.plugin.qemu.cmdln;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.util.List;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs.CmdLnOption;
+
+public class CommandLineArgsTest
+{
+ // @formatter:off
+ public static final String CMDLN_PREFIX_OPTION_SHORT = "-";
+ public static final String CMDLN_PREFIX_OPTION_LONG = "--";
+
+ private static final String CMDLN_TEST_DEBUG_OFF = "false";
+ private static final String CMDLN_TEST_DEBUG_ON = "true";
+ private static final String CMDLN_TEST_NAME = "test";
+ private static final String CMDLN_TEST_FILENAME = System.getProperty( "user.dir" ) + File.separator + CMDLN_TEST_NAME;
+ private static final String CMDLN_TEST_UUID = "c9570672-cbae-4cbd-801a-881b281b8d79";
+ private static final String CMDLN_TEST_OS = "Windows 10 (x64)";
+ private static final int CMDLN_TEST_NCPUS = 4;
+ private static final String CMDLN_TEST_MEM = "1024";
+ private static final String CMDLN_TEST_PARPORT = "/dev/parport0";
+ private static final String CMDLN_TEST_SERPORT = "/dev/ttyS0";
+ private static final String CMDLN_TEST_MAC = "02:42:8e:77:1b:e6";
+ private static final String CMDLN_TEST_NVGPU_DESC = "10de:0ff9";
+ private static final String CMDLN_TEST_NVGPU_ADDR = "0000:00:01.0";
+ // @formatter:on
+
+ @Test
+ @DisplayName( "Test the parsing of wrong command line options" )
+ public void testCmdlnOptionsIncorrect()
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + "hello",
+ "world argument",
+ CMDLN_PREFIX_OPTION_LONG + "info",
+ "description"
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs();
+
+ assertThrows( CommandLineArgsException.class, () -> cmdLn.parseCmdLnArgs( args ) );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the help command line option (short version)" )
+ public void testCmdlnOptionHelpShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.HELP.getShortOption()
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertTrue( cmdLn.isHelpAquired() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the help command line option (long version)" )
+ public void testCmdlnOptionHelpLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.HELP.getLongOption()
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertTrue( cmdLn.isHelpAquired() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the enabled debug command line option (short version)" )
+ public void testCmdlnOptionDebugEnabledShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.DEBUG.getShortOption(),
+ CMDLN_TEST_DEBUG_ON
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertTrue( cmdLn.isDebugEnabled() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the enabled debug command line option (long version)" )
+ public void testCmdlnOptionDebugEnabledLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.DEBUG.getLongOption(),
+ CMDLN_TEST_DEBUG_ON
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertTrue( cmdLn.isDebugEnabled() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the disabled debug command line option (short version)" )
+ public void testCmdlnOptionDebugDisabledShort() throws CommandLineArgsException
+ {
+ final String[] argsDebugOff = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.DEBUG.getShortOption(),
+ CMDLN_TEST_DEBUG_OFF
+ };
+
+ final String[] argsDebugMissing = {};
+
+ CommandLineArgs cmdLnDebugOff = new CommandLineArgs( argsDebugOff );
+ CommandLineArgs cmdLnDebugMissing = new CommandLineArgs( argsDebugMissing );
+
+ assertFalse( cmdLnDebugOff.isDebugEnabled() );
+ assertFalse( cmdLnDebugMissing.isDebugEnabled() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the disabled debug command line option (long version)" )
+ public void testCmdlnOptionDebugDisabledLong() throws CommandLineArgsException
+ {
+ final String[] argsDebugOff = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.DEBUG.getLongOption(),
+ CMDLN_TEST_DEBUG_OFF
+ };
+
+ final String[] argsDebugMissing = {};
+
+ CommandLineArgs cmdLnDebugOff = new CommandLineArgs( argsDebugOff );
+ CommandLineArgs cmdLnDebugMissing = new CommandLineArgs( argsDebugMissing );
+
+ assertFalse( cmdLnDebugOff.isDebugEnabled() );
+ assertFalse( cmdLnDebugMissing.isDebugEnabled() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM configuration input command line option (short version)" )
+ public void testCmdlnOptionVmCfgInpShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_CFGINP.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmCfgInpFileName() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM configuration input command line option (long version)" )
+ public void testCmdlnOptionVmCfgInpLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_CFGINP.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmCfgInpFileName() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM configuration output command line option (short version)" )
+ public void testCmdlnOptionVmCfgOutShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_CFGOUT.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmCfgOutFileName() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM configuration output command line option (long version)" )
+ public void testCmdlnOptionVmCfgOutLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_CFGOUT.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmCfgOutFileName() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM name command line option (short version)" )
+ public void testCmdlnOptionVmNameShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_NAME.getShortOption(),
+ CMDLN_TEST_NAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NAME, cmdLn.getVmName() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM name command line option (long version)" )
+ public void testCmdlnOptionVmNameLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_NAME.getLongOption(),
+ CMDLN_TEST_NAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NAME, cmdLn.getVmName() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM UUID command line option (short version)" )
+ public void testCmdlnOptionVmUuidShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_UUID.getShortOption(),
+ CMDLN_TEST_UUID
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_UUID, cmdLn.getVmUuid() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM UUID command line option (long version)" )
+ public void testCmdlnOptionVmUuidLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_UUID.getLongOption(),
+ CMDLN_TEST_UUID
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_UUID, cmdLn.getVmUuid() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM display name command line option (short version)" )
+ public void testCmdlnOptionVmDsplNameShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_DSPLNAME.getShortOption(),
+ CMDLN_TEST_NAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NAME, cmdLn.getVmDisplayName() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM display name command line option (long version)" )
+ public void testCmdlnOptionVmDsplNameLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_DSPLNAME.getLongOption(),
+ CMDLN_TEST_NAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NAME, cmdLn.getVmDisplayName() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM OS command line option (short version)" )
+ public void testCmdlnOptionVmOsShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_OS.getShortOption(),
+ CMDLN_TEST_OS
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_OS, cmdLn.getVmOperatingSystem() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM OS command line option (long version)" )
+ public void testCmdlnOptionVmOsLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_OS.getLongOption(),
+ CMDLN_TEST_OS
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_OS, cmdLn.getVmOperatingSystem() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM CPU number command line option (short version)" )
+ public void testCmdlnOptionVmNCpusShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_NCPUS.getShortOption(),
+ Integer.toString( CMDLN_TEST_NCPUS )
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NCPUS, cmdLn.getVmNumCpus() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM CPU number command line option (long version)" )
+ public void testCmdlnOptionVmNCpusLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_NCPUS.getLongOption(),
+ Integer.toString( CMDLN_TEST_NCPUS )
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NCPUS, cmdLn.getVmNumCpus() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM memory command line option (short version)" )
+ public void testCmdlnOptionVmMemShort() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_MEM.getShortOption(),
+ CMDLN_TEST_MEM
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_MEM, cmdLn.getVmMemory() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM memory command line option (long version)" )
+ public void testCmdlnOptionVmMemLong() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_MEM.getLongOption(),
+ CMDLN_TEST_MEM
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_MEM, cmdLn.getVmMemory() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first HDD disk image command line option (short version)" )
+ public void testCmdlnOptionVmHdd0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_HDD0.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameHDD0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first HDD disk image command line option (long version)" )
+ public void testCmdlnOptionVmHdd0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_HDD0.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameHDD0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first floppy disk image command line option (short version)" )
+ public void testCmdlnOptionVmFloppy0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_FLOPPY0.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameFloppy0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first floppy disk image command line option (long version)" )
+ public void testCmdlnOptionVmFloppy0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FLOPPY0.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameFloppy0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM second floppy disk image command line option (short version)" )
+ public void testCmdlnOptionVmFloppy1Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_FLOPPY1.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameFloppy1() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM second floppy disk image command line option (long version)" )
+ public void testCmdlnOptionVmFloppy1Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FLOPPY1.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameFloppy1() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first CDROM disk image command line option (short version)" )
+ public void testCmdlnOptionVmCdrom0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_CDROM0.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameCdrom0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first CDROM disk image command line option (long version)" )
+ public void testCmdlnOptionVmCdrom0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_CDROM0.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameCdrom0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM second CDROM disk image command line option (short version)" )
+ public void testCmdlnOptionVmCdrom1Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_CDROM1.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameCdrom1() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM second CDROM disk image command line option (long version)" )
+ public void testCmdlnOptionVmCdrom1Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_CDROM1.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmDiskFileNameCdrom1() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first parallel interface command line option (short version)" )
+ public void testCmdlnOptionVmParallel0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_PARALLEL0.getShortOption(),
+ CMDLN_TEST_PARPORT
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_PARPORT, cmdLn.getVmDeviceParallel0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first parallel interface command line option (long version)" )
+ public void testCmdlnOptionVmParallel0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_PARALLEL0.getLongOption(),
+ CMDLN_TEST_PARPORT
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_PARPORT, cmdLn.getVmDeviceParallel0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first serial interface command line option (short version)" )
+ public void testCmdlnOptionVmSerial0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_SERIAL0.getShortOption(),
+ CMDLN_TEST_SERPORT
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_SERPORT, cmdLn.getVmDeviceSerial0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first serial interface command line option (long version)" )
+ public void testCmdlnOptionVmSerial0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_SERIAL0.getLongOption(),
+ CMDLN_TEST_SERPORT
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_SERPORT, cmdLn.getVmDeviceSerial0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first network interface MAC command line option (short version)" )
+ public void testCmdlnOptionVmMac0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_MAC0.getShortOption(),
+ CMDLN_TEST_MAC
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_MAC, cmdLn.getVmMacAddress0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first network interface MAC command line option (long version)" )
+ public void testCmdlnOptionVmMac0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_MAC0.getLongOption(),
+ CMDLN_TEST_MAC
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_MAC, cmdLn.getVmMacAddress0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first file system source command line option (short version)" )
+ public void testCmdlnOptionVmFsSrc0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_FSSRC0.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmFsSrc0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first file system source command line option (long version)" )
+ public void testCmdlnOptionVmFsSrc0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FSSRC0.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmFsSrc0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first file system target command line option (short version)" )
+ public void testCmdlnOptionVmFsTgt0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_FSTGT0.getShortOption(),
+ CMDLN_TEST_NAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NAME, cmdLn.getVmFsTgt0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM first file system target command line option (long version)" )
+ public void testCmdlnOptionVmFsTgt0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FSTGT0.getLongOption(),
+ CMDLN_TEST_NAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NAME, cmdLn.getVmFsTgt0() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM second file system source command line option (short version)" )
+ public void testCmdlnOptionVmFsSrc1Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_FSSRC1.getShortOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmFsSrc1() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM second file system source command line option (long version)" )
+ public void testCmdlnOptionVmFsSrc1Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FSSRC1.getLongOption(),
+ CMDLN_TEST_FILENAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_FILENAME, cmdLn.getVmFsSrc1() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM second file system target command line option (short version)" )
+ public void testCmdlnOptionVmFsTgt1Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_FSTGT1.getShortOption(),
+ CMDLN_TEST_NAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NAME, cmdLn.getVmFsTgt1() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of the VM second file system target command line option (long version)" )
+ public void testCmdlnOptionVmFsTgt1Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FSTGT1.getLongOption(),
+ CMDLN_TEST_NAME
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ assertEquals( CMDLN_TEST_NAME, cmdLn.getVmFsTgt1() );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of NVIDIA PCI IDs command line option for the first GPU passthrough (short version)" )
+ public void testCmdlnOptionVmNvGpuIds0Short() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_SHORT + CmdLnOption.VM_NVGPUIDS0.getShortOption(),
+ CMDLN_TEST_NVGPU_DESC, CMDLN_TEST_NVGPU_ADDR
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ final List<String> nvidiaGpuIds = cmdLn.getVmNvGpuIds0();
+ assertEquals( 2, nvidiaGpuIds.size() );
+ assertEquals( CMDLN_TEST_NVGPU_DESC, nvidiaGpuIds.get( 0 ) );
+ assertEquals( CMDLN_TEST_NVGPU_ADDR, nvidiaGpuIds.get( 1 ) );
+ }
+
+ @Test
+ @DisplayName( "Test the parsing of NVIDIA PCI IDs command line option for the first GPU passthrough (long version)" )
+ public void testCmdlnOptionVmNvGpuIds0Long() throws CommandLineArgsException
+ {
+ final String[] args = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_NVGPUIDS0.getLongOption(),
+ CMDLN_TEST_NVGPU_DESC, CMDLN_TEST_NVGPU_ADDR
+ };
+
+ CommandLineArgs cmdLn = new CommandLineArgs( args );
+
+ final List<String> nvidiaGpuIds = cmdLn.getVmNvGpuIds0();
+ assertEquals( 2, nvidiaGpuIds.size() );
+ assertEquals( CMDLN_TEST_NVGPU_DESC, nvidiaGpuIds.get( 0 ) );
+ assertEquals( CMDLN_TEST_NVGPU_ADDR, nvidiaGpuIds.get( 1 ) );
+ }
+
+ @Test
+ @DisplayName( "Test whether a NVIDIA GPU passthrough is enabled" )
+ public void testIsNvidiaGpuPassthroughEnabled() throws CommandLineArgsException
+ {
+ final String[] args1 = {
+ CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_NVGPUIDS0.getLongOption(),
+ CMDLN_TEST_NVGPU_DESC, CMDLN_TEST_NVGPU_ADDR
+ };
+ final String[] args2 = {};
+
+ CommandLineArgs cmdLn1 = new CommandLineArgs( args1 );
+ CommandLineArgs cmdLn2 = new CommandLineArgs( args2 );
+
+ assertTrue( cmdLn1.isNvidiaGpuPassthroughEnabled() );
+ assertFalse( cmdLn2.isNvidiaGpuPassthroughEnabled() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericCpuTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericCpuTest.java
new file mode 100644
index 00000000..d88857a6
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericCpuTest.java
@@ -0,0 +1,49 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.Domain.CpuCheck;
+import org.openslx.libvirt.domain.Domain.CpuMode;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericCpuTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM CPU configuration" )
+ public void testTransformationGenericCpu() throws TransformationException
+ {
+ final TransformationGenericCpu transformation = new TransformationGenericCpu();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ assertNotEquals( Integer.parseInt( TransformationTestUtils.DEFAULT_VM_NCPUS ), config.getVCpu() );
+ assertNotEquals( CpuMode.HOST_PASSTHROUGH, config.getCpuMode() );
+ assertEquals( CpuCheck.PARTIAL, config.getCpuCheck() );
+
+ transformation.transform( config, args );
+
+ assertEquals( Integer.parseInt( TransformationTestUtils.DEFAULT_VM_NCPUS ), config.getVCpu() );
+ assertEquals( CpuMode.HOST_PASSTHROUGH, config.getCpuMode() );
+ assertEquals( CpuCheck.PARTIAL, config.getCpuCheck() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM CPU configuration with unspecified input data" )
+ public void testTransformationGenericCpuNoData() throws TransformationException
+ {
+ final TransformationGenericCpu transformation = new TransformationGenericCpu();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ assertThrows( TransformationException.class, () -> transformation.transform( config, args ) );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskCdromDevicesTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskCdromDevicesTest.java
new file mode 100644
index 00000000..73b37c36
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskCdromDevicesTest.java
@@ -0,0 +1,65 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.device.Disk.StorageType;
+import org.openslx.libvirt.domain.device.DiskCdrom;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericDiskCdromDevicesTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM disk CDROM devices configuration with specified input data" )
+ public void testTransformationGenericDiskCdromDevices() throws TransformationException
+ {
+ final TransformationGenericDiskCdromDevices transformation = new TransformationGenericDiskCdromDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ final ArrayList<DiskCdrom> devicesBeforeTransformation = config.getDiskCdromDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+ final DiskCdrom cdromDeviceBeforeTransformation = devicesBeforeTransformation.get( 0 );
+ assertEquals( StorageType.FILE, cdromDeviceBeforeTransformation.getStorageType() );
+ assertNotEquals( TransformationTestUtils.DEFAULT_VM_CDROM0, cdromDeviceBeforeTransformation.getStorageSource() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<DiskCdrom> devicesAfterTransformation = config.getDiskCdromDevices();
+ assertEquals( 2, devicesAfterTransformation.size() );
+ final DiskCdrom cdromDevice1AfterTransformation = devicesAfterTransformation.get( 0 );
+ final DiskCdrom cdromDevice2AfterTransformation = devicesAfterTransformation.get( 1 );
+ assertEquals( StorageType.FILE, cdromDevice1AfterTransformation.getStorageType() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_CDROM0, cdromDevice1AfterTransformation.getStorageSource() );
+ assertEquals( StorageType.FILE, cdromDevice2AfterTransformation.getStorageType() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_CDROM1, cdromDevice2AfterTransformation.getStorageSource() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM disk CDROM devices configuration with unspecified input data" )
+ public void testTransformationGenericDiskCdromDevicesNoData() throws TransformationException
+ {
+ final TransformationGenericDiskCdromDevices transformation = new TransformationGenericDiskCdromDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ final ArrayList<DiskCdrom> devicesBeforeTransformation = config.getDiskCdromDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<DiskCdrom> devicesAfterTransformation = config.getDiskCdromDevices();
+ assertEquals( 0, devicesAfterTransformation.size() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskFloppyDevicesTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskFloppyDevicesTest.java
new file mode 100644
index 00000000..3969e168
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskFloppyDevicesTest.java
@@ -0,0 +1,66 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.device.Disk.StorageType;
+import org.openslx.libvirt.domain.device.DiskFloppy;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericDiskFloppyDevicesTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM disk floppy devices configuration with specified input data" )
+ public void testTransformationGenericDiskFloppyDevices() throws TransformationException
+ {
+ final TransformationGenericDiskFloppyDevices transformation = new TransformationGenericDiskFloppyDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ final ArrayList<DiskFloppy> devicesBeforeTransformation = config.getDiskFloppyDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+ final DiskFloppy floppyDeviceBeforeTransformation = devicesBeforeTransformation.get( 0 );
+ assertEquals( StorageType.FILE, floppyDeviceBeforeTransformation.getStorageType() );
+ assertNotEquals( TransformationTestUtils.DEFAULT_VM_FLOPPY0,
+ floppyDeviceBeforeTransformation.getStorageSource() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<DiskFloppy> devicesAfterTransformation = config.getDiskFloppyDevices();
+ assertEquals( 2, devicesAfterTransformation.size() );
+ final DiskFloppy floppyDevice1AfterTransformation = devicesAfterTransformation.get( 0 );
+ final DiskFloppy floppyDevice2AfterTransformation = devicesAfterTransformation.get( 1 );
+ assertEquals( StorageType.FILE, floppyDevice1AfterTransformation.getStorageType() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_FLOPPY0, floppyDevice1AfterTransformation.getStorageSource() );
+ assertEquals( StorageType.FILE, floppyDevice2AfterTransformation.getStorageType() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_FLOPPY1, floppyDevice2AfterTransformation.getStorageSource() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM disk floppy devices configuration with unspecified input data" )
+ public void testTransformationGenericDiskFloppyDevicesNoData() throws TransformationException
+ {
+ final TransformationGenericDiskFloppyDevices transformation = new TransformationGenericDiskFloppyDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ final ArrayList<DiskFloppy> devicesBeforeTransformation = config.getDiskFloppyDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<DiskFloppy> devicesAfterTransformation = config.getDiskFloppyDevices();
+ assertEquals( 0, devicesAfterTransformation.size() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskStorageDevicesTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskStorageDevicesTest.java
new file mode 100644
index 00000000..8b52b90b
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericDiskStorageDevicesTest.java
@@ -0,0 +1,62 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.device.Disk.StorageType;
+import org.openslx.libvirt.domain.device.DiskStorage;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericDiskStorageDevicesTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM disk storage devices configuration with specified input data" )
+ public void testTransformationGenericDiskStorageDevices() throws TransformationException
+ {
+ final TransformationGenericDiskStorageDevices transformation = new TransformationGenericDiskStorageDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ final ArrayList<DiskStorage> devicesBeforeTransformation = config.getDiskStorageDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+ final DiskStorage diskDeviceBeforeTransformation = devicesBeforeTransformation.get( 0 );
+ assertNotEquals( StorageType.FILE, diskDeviceBeforeTransformation.getStorageType() );
+ assertNotEquals( TransformationTestUtils.DEFAULT_VM_HDD0, diskDeviceBeforeTransformation.getStorageSource() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<DiskStorage> devicesAfterTransformation = config.getDiskStorageDevices();
+ assertEquals( 1, devicesAfterTransformation.size() );
+ final DiskStorage diskDeviceAfterTransformation = devicesAfterTransformation.get( 0 );
+ assertEquals( StorageType.FILE, diskDeviceAfterTransformation.getStorageType() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_HDD0, diskDeviceAfterTransformation.getStorageSource() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM disk storage devices configuration with unspecified input data" )
+ public void testTransformationGenericDiskStorageDevicesNoData() throws TransformationException
+ {
+ final TransformationGenericDiskStorageDevices transformation = new TransformationGenericDiskStorageDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ final ArrayList<DiskStorage> devicesBeforeTransformation = config.getDiskStorageDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<DiskStorage> devicesAfterTransformation = config.getDiskStorageDevices();
+ assertEquals( 0, devicesAfterTransformation.size() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericFileSystemDevicesTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericFileSystemDevicesTest.java
new file mode 100644
index 00000000..7605f778
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericFileSystemDevicesTest.java
@@ -0,0 +1,66 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.device.FileSystem;
+import org.openslx.libvirt.domain.device.FileSystem.AccessMode;
+import org.openslx.libvirt.domain.device.FileSystem.Type;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericFileSystemDevicesTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM file system devices configuration with specified input data" )
+ public void testTransformationGenericFileSystemDevices() throws TransformationException
+ {
+ final TransformationGenericFileSystemDevices transformation = new TransformationGenericFileSystemDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ final ArrayList<FileSystem> devicesBeforeTransformation = config.getFileSystemDevices();
+ assertEquals( 0, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<FileSystem> devicesAfterTransformation = config.getFileSystemDevices();
+ assertEquals( 2, devicesAfterTransformation.size() );
+ final FileSystem fs1AfterTransformation = devicesAfterTransformation.get( 0 );
+ final FileSystem fs2AfterTransformation = devicesAfterTransformation.get( 1 );
+ assertEquals( Type.MOUNT, fs1AfterTransformation.getType() );
+ assertEquals( AccessMode.MAPPED, fs1AfterTransformation.getAccessMode() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_FSSRC0, fs1AfterTransformation.getSource() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_FSTGT0, fs1AfterTransformation.getTarget() );
+ assertEquals( Type.MOUNT, fs2AfterTransformation.getType() );
+ assertEquals( AccessMode.MAPPED, fs2AfterTransformation.getAccessMode() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_FSSRC1, fs2AfterTransformation.getSource() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_FSTGT1, fs2AfterTransformation.getTarget() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM file system devices configuration with unspecified input data" )
+ public void testTransformationGenericFileSystemDevicesNoData() throws TransformationException
+ {
+ final TransformationGenericFileSystemDevices transformation = new TransformationGenericFileSystemDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ final ArrayList<FileSystem> devicesBeforeTransformation = config.getFileSystemDevices();
+ assertEquals( 0, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<FileSystem> devicesAfterTransformation = config.getFileSystemDevices();
+ assertEquals( 0, devicesAfterTransformation.size() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericInterfaceDevicesTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericInterfaceDevicesTest.java
new file mode 100644
index 00000000..e4632784
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericInterfaceDevicesTest.java
@@ -0,0 +1,63 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.device.Interface;
+import org.openslx.libvirt.domain.device.Interface.Model;
+import org.openslx.libvirt.domain.device.Interface.Type;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.VirtualizationConfigurationQemu;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericInterfaceDevicesTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM network interface devices configuration with specified input data" )
+ public void testTransformationGenericInterfaceDevices() throws TransformationException
+ {
+ final TransformationGenericInterfaceDevices transformation = new TransformationGenericInterfaceDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ final ArrayList<Interface> devicesBeforeTransformation = config.getInterfaceDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<Interface> devicesAfterTransformation = config.getInterfaceDevices();
+ assertEquals( 1, devicesAfterTransformation.size() );
+ final Interface interfaceAfterTransformation = devicesAfterTransformation.get( 0 );
+ assertEquals( Type.BRIDGE, interfaceAfterTransformation.getType() );
+ assertEquals( Model.VIRTIO, interfaceAfterTransformation.getModel() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_MAC0, interfaceAfterTransformation.getMacAddress() );
+ assertEquals( VirtualizationConfigurationQemu.NETWORK_BRIDGE_NAT_DEFAULT,
+ interfaceAfterTransformation.getSource() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM network interface devices configuration with unspecified input data" )
+ public void testTransformationGenericInterfaceDevicesNoData() throws TransformationException
+ {
+ final TransformationGenericInterfaceDevices transformation = new TransformationGenericInterfaceDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ final ArrayList<Interface> devicesBeforeTransformation = config.getInterfaceDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<Interface> devicesAfterTransformation = config.getInterfaceDevices();
+ assertEquals( 0, devicesAfterTransformation.size() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericMemoryTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericMemoryTest.java
new file mode 100644
index 00000000..a93e26a5
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericMemoryTest.java
@@ -0,0 +1,50 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.math.BigInteger;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.DomainUtils;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericMemoryTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM memory configuration" )
+ public void testTransformationGenericMemory() throws TransformationException
+ {
+ final TransformationGenericMemory transformation = new TransformationGenericMemory();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ final BigInteger defaultMemory = DomainUtils.decodeMemory( TransformationTestUtils.DEFAULT_VM_MEM, "MiB" );
+
+ assertNotEquals( defaultMemory.toString(), config.getMemory().toString() );
+ assertNotEquals( defaultMemory.toString(), config.getCurrentMemory().toString() );
+
+ transformation.transform( config, args );
+
+ assertEquals( defaultMemory.toString(), config.getMemory().toString() );
+ assertEquals( defaultMemory.toString(), config.getCurrentMemory().toString() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM memory configuration with unspecified input data" )
+ public void testTransformationGenericMemoryNoData() throws TransformationException
+ {
+ final TransformationGenericMemory transformation = new TransformationGenericMemory();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ assertThrows( TransformationException.class, () -> transformation.transform( config, args ) );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericNameTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericNameTest.java
new file mode 100644
index 00000000..ca272801
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericNameTest.java
@@ -0,0 +1,45 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericNameTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM (display) name configuration" )
+ public void testTransformationGenericName() throws TransformationException
+ {
+ final TransformationGenericName transformation = new TransformationGenericName();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ assertNotEquals( TransformationTestUtils.DEFAULT_VM_NAME, config.getName() );
+ assertNotEquals( TransformationTestUtils.DEFAULT_VM_DSPLNAME, config.getTitle() );
+
+ transformation.transform( config, args );
+
+ assertEquals( TransformationTestUtils.DEFAULT_VM_NAME, config.getName() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_DSPLNAME, config.getTitle() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM (display) name configuration with unspecified input data" )
+ public void testTransformationGenericNameNoData() throws TransformationException
+ {
+ final TransformationGenericName transformation = new TransformationGenericName();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ assertThrows( TransformationException.class, () -> transformation.transform( config, args ) );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericParallelDevicesTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericParallelDevicesTest.java
new file mode 100644
index 00000000..9402b59a
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericParallelDevicesTest.java
@@ -0,0 +1,58 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.device.Parallel;
+import org.openslx.libvirt.domain.device.Parallel.Type;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericParallelDevicesTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM parallel devices configuration with specified input data" )
+ public void testTransformationGenericParallelDevices() throws TransformationException
+ {
+ final TransformationGenericParallelDevices transformation = new TransformationGenericParallelDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ final ArrayList<Parallel> devicesBeforeTransformation = config.getParallelDevices();
+ assertEquals( 0, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<Parallel> devicesAfterTransformation = config.getParallelDevices();
+ assertEquals( 1, devicesAfterTransformation.size() );
+ final Parallel parallelDeviceAfterTransformation = devicesAfterTransformation.get( 0 );
+ assertEquals( Type.DEV, parallelDeviceAfterTransformation.getType() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_PARALLEL0, parallelDeviceAfterTransformation.getSource() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM parallel devices configuration with unspecified input data" )
+ public void testTransformationGenericParallelDevicesNoData() throws TransformationException
+ {
+ final TransformationGenericParallelDevices transformation = new TransformationGenericParallelDevices();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ final ArrayList<Parallel> devicesBeforeTransformation = config.getParallelDevices();
+ assertEquals( 0, devicesBeforeTransformation.size() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<Parallel> devicesAfterTransformation = config.getParallelDevices();
+ assertEquals( 0, devicesAfterTransformation.size() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericUuidTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericUuidTest.java
new file mode 100644
index 00000000..03534d8e
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationGenericUuidTest.java
@@ -0,0 +1,43 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+public class TransformationGenericUuidTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM UUID configuration" )
+ public void testTransformationGenericUuid() throws TransformationException
+ {
+ final TransformationGenericUuid transformation = new TransformationGenericUuid();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ assertNotEquals( TransformationTestUtils.DEFAULT_VM_UUID, config.getUuid() );
+
+ transformation.transform( config, args );
+
+ assertEquals( TransformationTestUtils.DEFAULT_VM_UUID, config.getUuid() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM UUID configuration with unspecified input data" )
+ public void testTransformationGenericUuidNoData() throws TransformationException
+ {
+ final TransformationGenericUuid transformation = new TransformationGenericUuid();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ assertThrows( TransformationException.class, () -> transformation.transform( config, args ) );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuArchitectureTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuArchitectureTest.java
new file mode 100644
index 00000000..86186247
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuArchitectureTest.java
@@ -0,0 +1,105 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.InputStream;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.capabilities.Capabilities;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.Domain.OsType;
+import org.openslx.libvirt.domain.Domain.Type;
+import org.openslx.libvirt.xml.LibvirtXmlDocumentException;
+import org.openslx.libvirt.xml.LibvirtXmlSerializationException;
+import org.openslx.libvirt.xml.LibvirtXmlTestResources;
+import org.openslx.libvirt.xml.LibvirtXmlValidationException;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+class TransformationSpecificQemuArchitectureStub extends TransformationSpecificQemuArchitecture
+{
+ final String capabilityFileName;
+
+ public TransformationSpecificQemuArchitectureStub( String capabilityFileName )
+ {
+ super( null );
+
+ this.capabilityFileName = capabilityFileName;
+ }
+
+ @Override
+ protected Capabilities getCapabilities() throws TransformationException
+ {
+ final InputStream capabilityContent = LibvirtXmlTestResources.getLibvirtXmlStream( this.capabilityFileName );
+ Capabilities capabilites = null;
+
+ try {
+ capabilites = new Capabilities( capabilityContent );
+ } catch ( LibvirtXmlDocumentException | LibvirtXmlSerializationException | LibvirtXmlValidationException e ) {
+ fail( "Could not create stub for getCapabilities(): " + e.getLocalizedMessage() );
+ }
+
+ return capabilites;
+ }
+}
+
+public class TransformationSpecificQemuArchitectureTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM architecture configuration if KVM required and available" )
+ public void testTransformationSpecificQemuArchitectureKvm() throws TransformationException
+ {
+ final TransformationSpecificQemuArchitectureStub transformation;
+ transformation = new TransformationSpecificQemuArchitectureStub( "qemu-kvm_capabilities_default.xml" );
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+
+ assertEquals( Type.KVM, config.getType() );
+ assertEquals( "x86_64", config.getOsArch() );
+ assertEquals( "pc-q35-5.1", config.getOsMachine() );
+ assertEquals( OsType.HVM, config.getOsType() );
+
+ transformation.transform( config, null );
+
+ assertEquals( Type.KVM, config.getType() );
+ assertEquals( "x86_64", config.getOsArch() );
+ assertEquals( "pc-q35-5.1", config.getOsMachine() );
+ assertEquals( OsType.HVM, config.getOsType() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM architecture configuration if KVM required but not available" )
+ public void testTransformationSpecificQemuArchitectureNoKvm() throws TransformationException
+ {
+ final TransformationSpecificQemuArchitectureStub transformation;
+ transformation = new TransformationSpecificQemuArchitectureStub( "qemu-kvm_capabilities_no-kvm.xml" );
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+
+ assertEquals( Type.KVM, config.getType() );
+ assertEquals( "x86_64", config.getOsArch() );
+ assertEquals( "pc-q35-5.1", config.getOsMachine() );
+ assertEquals( OsType.HVM, config.getOsType() );
+
+ assertThrows( TransformationException.class, () -> transformation.transform( config, null ) );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM architecture configuration if version is not supported (machine version too new)" )
+ public void testTransformationSpecificQemuArchitectureMachineVersionDowngrade() throws TransformationException
+ {
+ final TransformationSpecificQemuArchitectureStub transformation;
+ transformation = new TransformationSpecificQemuArchitectureStub( "qemu-kvm_capabilities_old-version.xml" );
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+
+ assertEquals( Type.KVM, config.getType() );
+ assertEquals( "x86_64", config.getOsArch() );
+ assertEquals( "pc-q35-5.1", config.getOsMachine() );
+ assertEquals( OsType.HVM, config.getOsType() );
+
+ assertThrows( TransformationException.class, () -> transformation.transform( config, null ) );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGpuPassthroughNvidiaTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGpuPassthroughNvidiaTest.java
new file mode 100644
index 00000000..8f50b7df
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuGpuPassthroughNvidiaTest.java
@@ -0,0 +1,134 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.util.List;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.capabilities.Capabilities;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.device.HostdevPci;
+import org.openslx.libvirt.domain.device.HostdevPciDeviceAddress;
+import org.openslx.libvirt.domain.device.Shmem;
+import org.openslx.libvirt.domain.device.Video;
+import org.openslx.libvirt.xml.LibvirtXmlDocumentException;
+import org.openslx.libvirt.xml.LibvirtXmlSerializationException;
+import org.openslx.libvirt.xml.LibvirtXmlTestResources;
+import org.openslx.libvirt.xml.LibvirtXmlValidationException;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+class TransformationSpecificQemuGpuPassthroughNvidiaStub extends TransformationSpecificQemuGpuPassthroughNvidia
+{
+ final String capabilityFileName;
+
+ public TransformationSpecificQemuGpuPassthroughNvidiaStub( String capabilityFileName )
+ {
+ super( null );
+
+ this.capabilityFileName = capabilityFileName;
+ }
+
+ @Override
+ protected Capabilities getCapabilities() throws TransformationException
+ {
+ final InputStream capabilityContent = LibvirtXmlTestResources.getLibvirtXmlStream( this.capabilityFileName );
+ Capabilities capabilites = null;
+
+ try {
+ capabilites = new Capabilities( capabilityContent );
+ } catch ( LibvirtXmlDocumentException | LibvirtXmlSerializationException | LibvirtXmlValidationException e ) {
+ fail( "Could not create stub for getCapabilities(): " + e.getLocalizedMessage() );
+ }
+
+ return capabilites;
+ }
+}
+
+public class TransformationSpecificQemuGpuPassthroughNvidiaTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM GPU passthrough configuration if NVIDIA GPU passthrouh is required" )
+ public void testTransformationSpecificQemuGpuPassthroughNvidia() throws TransformationException
+ {
+ final TransformationSpecificQemuGpuPassthroughNvidiaStub transformation;
+ transformation = new TransformationSpecificQemuGpuPassthroughNvidiaStub( "qemu-kvm_capabilities_default.xml" );
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ transformation.transform( config, args );
+
+ final List<HostdevPci> pciDevices = config.getHostdevPciDevices();
+ assertNotNull( pciDevices );
+ assertEquals( 1, pciDevices.size() );
+
+ final HostdevPci pciDevice = pciDevices.get( 0 );
+ assertTrue( pciDevice.isManaged() );
+ assertEquals( HostdevPciDeviceAddress.valueOf( TransformationTestUtils.DEFAULT_VM_GPU0_ADDR ),
+ pciDevice.getSource() );
+
+ final List<Shmem> shmemDevices = config.getShmemDevices();
+ assertNotNull( shmemDevices );
+ assertEquals( 1, shmemDevices.size() );
+
+ final Shmem shmemDevice = shmemDevices.get( 0 );
+ assertEquals( "looking-glass", shmemDevice.getName() );
+ assertEquals( Shmem.Model.IVSHMEM_PLAIN, shmemDevice.getModel() );
+ assertEquals( BigInteger.valueOf( 67108864 ).toString(), shmemDevice.getSize().toString() );
+
+ assertEquals( TransformationSpecificQemuGpuPassthroughNvidia.HYPERV_VENDOR_ID,
+ config.getFeatureHypervVendorIdValue() );
+ assertTrue( config.isFeatureHypervVendorIdStateOn() );
+ assertTrue( config.isFeatureKvmHiddenStateOn() );
+
+ final List<Video> videoDevices = config.getVideoDevices();
+ assertNotNull( videoDevices );
+ for ( final Video videoDevice : videoDevices ) {
+ assertEquals( Video.Model.NONE, videoDevice.getModel() );
+ }
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM GPU passthrough configuration if NVIDIA GPU passthrouh is not specified" )
+ public void testTransformationSpecificQemuGpuPassthroughNvidiaNoGpu() throws TransformationException
+ {
+ final TransformationSpecificQemuGpuPassthroughNvidiaStub transformation;
+ transformation = new TransformationSpecificQemuGpuPassthroughNvidiaStub( "qemu-kvm_capabilities_default.xml" );
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ transformation.transform( config, args );
+
+ final List<HostdevPci> pciDevices = config.getHostdevPciDevices();
+ assertNotNull( pciDevices );
+ assertEquals( 0, pciDevices.size() );
+
+ final List<Shmem> shmemDevices = config.getShmemDevices();
+ assertNotNull( shmemDevices );
+ assertEquals( 0, shmemDevices.size() );
+
+ assertNotEquals( TransformationSpecificQemuGpuPassthroughNvidia.HYPERV_VENDOR_ID,
+ config.getFeatureHypervVendorIdValue() );
+ assertFalse( config.isFeatureHypervVendorIdStateOn() );
+ assertFalse( config.isFeatureKvmHiddenStateOn() );
+
+ final List<Video> videoDevices = config.getVideoDevices();
+ assertNotNull( videoDevices );
+ for ( final Video videoDevice : videoDevices ) {
+ assertNotEquals( Video.Model.NONE, videoDevice.getModel() );
+ }
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuSerialDevicesTest.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuSerialDevicesTest.java
new file mode 100644
index 00000000..6beada8d
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationSpecificQemuSerialDevicesTest.java
@@ -0,0 +1,74 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.ArrayList;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.domain.device.Serial;
+import org.openslx.libvirt.domain.device.Serial.Type;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.virtualization.configuration.transformation.TransformationException;
+
+class TransformationSpecificQemuSerialDevicesStub extends TransformationSpecificQemuSerialDevices
+{
+ public TransformationSpecificQemuSerialDevicesStub()
+ {
+ super( null );
+ }
+}
+
+public class TransformationSpecificQemuSerialDevicesTest
+{
+ @Test
+ @DisplayName( "Test transformation of VM serial devices configuration with specified input data" )
+ public void testTransformationGenericSerialDevices() throws TransformationException
+ {
+ final TransformationSpecificQemuSerialDevicesStub transformation = new TransformationSpecificQemuSerialDevicesStub();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
+
+ final ArrayList<Serial> devicesBeforeTransformation = config.getSerialDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+ final Serial serialDeviceBeforeTransformation = devicesBeforeTransformation.get( 0 );
+ assertEquals( Type.PTY, serialDeviceBeforeTransformation.getType() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<Serial> devicesAfterTransformation = config.getSerialDevices();
+ assertEquals( 2, devicesAfterTransformation.size() );
+ final Serial serialDevice1AfterTransformation = devicesAfterTransformation.get( 0 );
+ assertEquals( Type.PTY, serialDevice1AfterTransformation.getType() );
+ final Serial serialDevice2AfterTransformation = devicesAfterTransformation.get( 1 );
+ assertEquals( Type.DEV, serialDevice2AfterTransformation.getType() );
+ assertEquals( TransformationTestUtils.DEFAULT_VM_SERIAL0, serialDevice2AfterTransformation.getSource() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+
+ @Test
+ @DisplayName( "Test transformation of VM serial devices configuration with unspecified input data" )
+ public void testTransformationGenericSerialDevicesNoData() throws TransformationException
+ {
+ final TransformationSpecificQemuSerialDevicesStub transformation = new TransformationSpecificQemuSerialDevicesStub();
+ final Domain config = TransformationTestUtils.getDefaultDomain();
+ final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
+
+ final ArrayList<Serial> devicesBeforeTransformation = config.getSerialDevices();
+ assertEquals( 1, devicesBeforeTransformation.size() );
+ final Serial serialDeviceBeforeTransformation = devicesBeforeTransformation.get( 0 );
+ assertEquals( Type.PTY, serialDeviceBeforeTransformation.getType() );
+
+ transformation.transform( config, args );
+
+ final ArrayList<Serial> devicesAfterTransformation = config.getSerialDevices();
+ assertEquals( 1, devicesAfterTransformation.size() );
+ final Serial serialDeviceAfterTransformation = devicesBeforeTransformation.get( 0 );
+ assertEquals( Type.PTY, serialDeviceAfterTransformation.getType() );
+
+ assertDoesNotThrow( () -> config.validateXml() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationTestResources.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationTestResources.java
new file mode 100644
index 00000000..b04685f9
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationTestResources.java
@@ -0,0 +1,17 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import java.io.File;
+import java.net.URL;
+
+public class TransformationTestResources
+{
+ private static final String LIBVIRT_PREFIX_PATH = File.separator + "libvirt";
+ private static final String LIBVIRT_PREFIX_PATH_XML = LIBVIRT_PREFIX_PATH + File.separator + "xml";
+
+ public static File getLibvirtXmlFile( String libvirtXmlFileName )
+ {
+ String libvirtXmlPath = TransformationTestResources.LIBVIRT_PREFIX_PATH_XML + File.separator + libvirtXmlFileName;
+ URL libvirtXml = TransformationTestResources.class.getResource( libvirtXmlPath );
+ return new File( libvirtXml.getFile() );
+ }
+}
diff --git a/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationTestUtils.java b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationTestUtils.java
new file mode 100644
index 00000000..597fd8d6
--- /dev/null
+++ b/core/modules/qemu/runvirt-plugin-qemu/src/test/java/org/openslx/runvirt/plugin/qemu/configuration/TransformationTestUtils.java
@@ -0,0 +1,119 @@
+package org.openslx.runvirt.plugin.qemu.configuration;
+
+import static org.junit.jupiter.api.Assertions.fail;
+
+import org.openslx.libvirt.domain.Domain;
+import org.openslx.libvirt.xml.LibvirtXmlDocumentException;
+import org.openslx.libvirt.xml.LibvirtXmlSerializationException;
+import org.openslx.libvirt.xml.LibvirtXmlTestResources;
+import org.openslx.libvirt.xml.LibvirtXmlValidationException;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs.CmdLnOption;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgsException;
+import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgsTest;
+
+public class TransformationTestUtils
+{
+ // @formatter:off
+ public static final String DEFAULT_VM_NAME = "archlinux";
+ public static final String DEFAULT_VM_UUID = "4ec504d5-5eac-482f-a344-dbf1dd4956c8";
+ public static final String DEFAULT_VM_DSPLNAME = "Archlinux";
+ public static final String DEFAULT_VM_OS = "Windows 10 (x64)";
+ public static final String DEFAULT_VM_NCPUS = "16";
+ public static final String DEFAULT_VM_MEM = "1024";
+ public static final String DEFAULT_VM_HDD0 = "/mnt/vm/windows.qcow2";
+ public static final String DEFAULT_VM_FLOPPY0 = "/mnt/vm/floppy0.qcow2";
+ public static final String DEFAULT_VM_FLOPPY1 = "/mnt/vm/floppy1.qcow2";
+ public static final String DEFAULT_VM_CDROM0 = "/dev/sr0";
+ public static final String DEFAULT_VM_CDROM1 = "/mnt/vm/cdrom1.qcow2";
+ public static final String DEFAULT_VM_PARALLEL0 = "/dev/parport0";
+ public static final String DEFAULT_VM_SERIAL0 = "/dev/ttyS0";
+ public static final String DEFAULT_VM_MAC0 = "ca:06:29:84:f0:6d";
+ public static final String DEFAULT_VM_FSSRC0 = "/mnt/shared/folder0";
+ public static final String DEFAULT_VM_FSTGT0 = "folder0";
+ public static final String DEFAULT_VM_FSSRC1 = "/mnt/shared/folder1";
+ public static final String DEFAULT_VM_FSTGT1 = "folder1";
+ public static final String DEFAULT_VM_GPU0_DESC = "10de:1d01";
+ public static final String DEFAULT_VM_GPU0_ADDR = "0000:00:02.0";
+ public static final String DEFAULT_VM_NVGPUIDS0 = DEFAULT_VM_GPU0_DESC + "," + DEFAULT_VM_GPU0_ADDR;
+ // @formatter:on
+
+ private static final String[] DEFAULT_CMDLN_ARGS = {
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_NAME.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_NAME,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_UUID.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_UUID,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_DSPLNAME.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_DSPLNAME,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_OS.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_OS,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_NCPUS.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_NCPUS,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_MEM.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_MEM,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_HDD0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_HDD0,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FLOPPY0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_FLOPPY0,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FLOPPY1.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_FLOPPY1,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_CDROM0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_CDROM0,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_CDROM1.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_CDROM1,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_PARALLEL0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_PARALLEL0,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_SERIAL0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_SERIAL0,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_MAC0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_MAC0,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FSSRC0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_FSSRC0,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FSTGT0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_FSTGT0,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FSSRC1.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_FSSRC1,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_FSTGT1.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_FSTGT1,
+ CommandLineArgsTest.CMDLN_PREFIX_OPTION_LONG + CmdLnOption.VM_NVGPUIDS0.getLongOption(),
+ TransformationTestUtils.DEFAULT_VM_NVGPUIDS0
+ };
+
+ private static CommandLineArgs getCmdLnArgs( String[] args )
+ {
+ final CommandLineArgs cmdLnArgs = new CommandLineArgs();
+
+ try {
+ cmdLnArgs.parseCmdLnArgs( args );
+ } catch ( CommandLineArgsException e ) {
+ fail( e.getLocalizedMessage() );
+ }
+
+ return cmdLnArgs;
+ }
+
+ public static CommandLineArgs getDefaultCmdLnArgs()
+ {
+ return TransformationTestUtils.getCmdLnArgs( TransformationTestUtils.DEFAULT_CMDLN_ARGS );
+ }
+
+ public static CommandLineArgs getEmptyCmdLnArgs()
+ {
+ return TransformationTestUtils.getCmdLnArgs( new String[] {} );
+ }
+
+ public static Domain getDefaultDomain()
+ {
+ Domain domain = null;
+
+ try {
+ domain = new Domain( LibvirtXmlTestResources
+ .getLibvirtXmlStream( "qemu-kvm_default-ubuntu-20-04-vm_transform-non-persistent.xml" ) );
+ } catch ( LibvirtXmlDocumentException | LibvirtXmlSerializationException | LibvirtXmlValidationException e ) {
+ fail( "Cannot prepare requested Libvirt domain XML file from the resources folder: "
+ + e.getLocalizedMessage() );
+ }
+
+ return domain;
+ }
+}