Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



Table of Contents

FlexDeploy provides dozens of out of the box plugins for building and deploying software using various technologies and middleware platforms. The FlexDeploy Plugin SDK allows customers or Flexagon partners to develop their own plugins. This guide provides the documentation for creating and managing these plugin implementations.

FlexDeploy plugins are implemented in Java or Docker image and are installed on the FlexDeploy server for use within workflows. These plugins are automatically distributed to the endpoints where they are defined to execute.  A A plugin consists of four components:

  • Implementation 
  • XML metadata Metadata describing its operations, properties, and other behavior
  • Setup scripts (optional) to initialize the environment prior to execution
  • Required 5.1.0 FlexDeploy libraries for Java implementation (download here)

Table of Contents

Plugin Implementation

Java Plugin

...

To fully test your plugin you will ultimately need to upload it to a FlexDeploy Server.  However, for unit testing purposes, it will be useful to test it a standalone testcase (e.g. using JUnit).  To help provide the setup which is required to test your plugin, the MockWorkflowExecutionContext class is provided.  This This class manages manages some of the conext attributes that are otherwise handled by the FlexDeploy framwork.  You will first need to satisfy the following prerequisites to test your plugin:

...

Code Block
languagejava
themeEclipse
firstline1
titleJUnit - @BeforeClass
linenumberstrue
  @BeforeClass
  public static void prepTests()
    throws IOException
  {
    WorkflowExecutionContextMockWorkflowExecutionContext context = new MockWorkflowExecutionContext();
    File file = new File(context.getTempDirectory() + File.separator + subFolder + File.separator + fileName1);
    file.getParentFile().mkdir();
    file.createNewFile();
  }

...

Code Block
languagejava
themeEclipse
firstline1
titleJUnit - @Test
linenumberstrue
  @Test
  public void test()
    throws FlexCheckedException
  {
    WorkflowExecutionContextMockWorkflowExecutionContext context = new MockWorkflowExecutionContext();
    clearFolders(context);
    AbstractPluginProvider plugin = new Build();
    plugin.setWorkflowExecutionContext(context);
    File file = new File(context.getTempDirectory() + File.separator + "TestFile1.txt");
    try
    {
      file.createNewFile();
    }
    catch (Exception e)
    {
      Assert.fail(e.getLocalizedMessage());
      e.printStackTrace();
    }
    plugin.validate();
    plugin.execute();
    Assert.assertEquals("The wrong number of files were in the zip file.", 2, plugin.getWorkflowExecutionContext().getOutputMap().get(ApacheHttpProperties.FDAH_FILE_COUNT).getValue());
    String outputPath = context.getWorkingDirectory() + File.separator + "unZipped";
    doDeploy(outputPath);
    //System.exit(6);
    File deployedFile = new File(outputPath + File.separator + fileName1);
    Assert.assertEquals("Deployed file in root folder is missing.", true, deployedFile.exists());
    deployedFile = new File(outputPath + File.separator + subFolder);
    Assert.assertEquals("subFolder is missing.", true, deployedFile.exists());
    deployedFile = new File(outputPath + File.separator + subFolder + File.separator + fileName1);
    Assert.assertEquals("File in subFolder is missing.", true, deployedFile.exists());
  }

  public void doDeploy(String outputPath)
    throws FlexCheckedException
  {
    Deploy plugin = new Deploy();
    MockWorkflowExecutionContext context = new MockWorkflowExecutionContext();

    context.addProperty(ApacheHttpProperties.FDAH_PATH_TO_DOCUMENT_ROOT, outputPath, PropertyValue.PropertyTypeEnum.String, false);
    plugin.setWorkflowExecutionContext(context);
    plugin.validate();
    plugin.execute();
  }

...