Examples of FileContentDelegate


Examples of org.rhq.core.pluginapi.content.FileContentDelegate

            }
        }

        // Store SHA256 in the agent file if deployment was exploded
        if (deploymentFile.isDirectory()) {
            FileContentDelegate fileContentDelegate = new FileContentDelegate();
            fileContentDelegate.saveDeploymentSHA(tempFile, deploymentFile, getResourceContext()
                .getResourceDataDirectory());
        }

        // Remove temporary files created by this deployment.
        deleteTemporaryFile(backupDir);
View Full Code Here

Examples of org.rhq.core.pluginapi.content.FileContentDelegate

        this.setContentContext(contentContext);
    }

    @Override
    public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
        FileContentDelegate contentDelegate = getContentDelegate(type);

        Set<ResourcePackageDetails> details = null;
        if (contentDelegate != null) {
            details = contentDelegate.discoverDeployedPackages();
        }

        return details;
    }
View Full Code Here

Examples of org.rhq.core.pluginapi.content.FileContentDelegate

        return details;
    }

    private FileContentDelegate getContentDelegate(PackageType type) {
        FileContentDelegate contentDelegate = contentDelegates.get(type);
        if (contentDelegate == null) {
            if (type.getName().equals("library")) {
                File deployLib = new File(this.getConfigurationPath(), "lib");
                contentDelegate = new JarContentDelegate(deployLib, type.getName());
            }
View Full Code Here

Examples of org.rhq.core.pluginapi.content.FileContentDelegate

     */
    private String getSHA256(File file) {
        String sha256 = null;

        try {
            FileContentDelegate fileContentDelegate = new FileContentDelegate();
            sha256 = fileContentDelegate.retrieveDeploymentSHA(file, context.getResourceDataDirectory());
        } catch (Exception iex) {
            if (getLog().isDebugEnabled()) {
                getLog().debug("Problem calculating digest of package [" + file.getPath() + "]." + iex.getMessage());
            }
        }
View Full Code Here

Examples of org.rhq.core.pluginapi.content.FileContentDelegate

        when(mockFile.exists()).thenReturn(true);
        when(mockFile.getName()).thenReturn("testFileName");

        PackageType mockPackageType = mock(PackageType.class);

        FileContentDelegate mockFileContentDelegate = mock(FileContentDelegate.class);
        PowerMockito.whenNew(FileContentDelegate.class).withArguments(any(File.class), isNull())
            .thenReturn(mockFileContentDelegate);
        when(mockFileContentDelegate.saveDeploymentSHA(any(File.class), any(File.class), any(File.class))).thenReturn(
            "abcd1234");

        //create object to test and inject required dependencies
        StandaloneManagedDeploymentComponent objectUnderTest = new StandaloneManagedDeploymentComponent();
View Full Code Here

Examples of org.rhq.core.pluginapi.content.FileContentDelegate

            if (deployExploded && this.parentResourceContext != null) {
                URI deploymentURI = URI.create(deploymentName);
                // e.g.: /C:/opt/jboss-6.0.0.Final/server/default/deploy/foo.war
                String deploymentPath = deploymentURI.getPath();
                File deploymentFile = new File(deploymentPath);
                FileContentDelegate fileContentDelegate = new FileContentDelegate();

                fileContentDelegate.saveDeploymentSHA(archiveFile, deploymentFile,
                    parentResourceContext.getFutureChildResourceDataDirectory(archiveName));
            }

            // Reload the management view to pickup the ManagedDeployment for the app we just deployed.
            ManagementView managementView = this.profileServiceConnection.getManagementView();
View Full Code Here

Examples of org.rhq.plugins.jbossas.util.FileContentDelegate

                "Path to deploy (deployDirectory) may not reference the parent directory. Path specified: "
                    + deployDirectory);
          }

          // Perform the deployment
            FileContentDelegate deployer = new FileContentDelegate(new File(getConfigurationPath(), deployDirectory),
                    "", details.getPackageTypeName());

            PropertySimple zipProperty = deployTimeConfiguration.getSimple("deployZipped");

          if (zipProperty != null && zipProperty.getBooleanValue() != null) {
            boolean zip = zipProperty.getBooleanValue();

              File tempDir = resourceContext.getTemporaryDirectory();
              File tempFile = new File(tempDir.getAbsolutePath(), "esb.bin");
              OutputStream osForTempDir = new BufferedOutputStream(new FileOutputStream(tempFile));

              contentContext = resourceContext.getContentContext();
              ContentServices contentServices = contentContext.getContentServices();
              contentServices
                      .downloadPackageBitsForChildResource(contentContext, resourceTypeName, key, osForTempDir);

              osForTempDir.close();

              InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile));
              deployer.createContent(details, isForTempDir, !zip, false);

                // Resource key should match the following:     
                // ESB: jboss.esb:deployment=jbossesb.esb

                String resourceKey;
View Full Code Here

Examples of org.rhq.plugins.jbossas.util.FileContentDelegate

        File sampleWithManifestWar = new File(this.getClass().getResource("/sampleWithManifest.war").getFile());
        Assert.assertTrue(sampleWithManifestWar.exists());

        //create object to test and inject required dependencies
        FileContentDelegate objectUnderTest = new FileContentDelegate(deploymentDirectory, "", null);

        PackageDetails mockPackageDetails = mock(PackageDetails.class);
        PackageDetailsKey mockPackageDetailsKey = mock(PackageDetailsKey.class);
        when(mockPackageDetails.getKey()).thenReturn(mockPackageDetailsKey);
        when(mockPackageDetailsKey.getName()).thenReturn("deploymentFile");

        //run code under test
        objectUnderTest.createContent(mockPackageDetails, sampleWithManifestWar, true, false);
        String actualShaReturned = objectUnderTest.getSHA(new File(deploymentDirectory, "/deploymentFile"));

        //verify the results (Assert and mock verification)
        File manifestFile = new File(deploymentDirectory.getAbsolutePath() + "/deploymentFile/META-INF/MANIFEST.MF");
        Assert.assertTrue(manifestFile.exists(), "Manifest file not created properly!");
        Assert.assertNotEquals(manifestFile.length(), 0, "Empty manifest!!");
View Full Code Here

Examples of org.rhq.plugins.jbossas.util.FileContentDelegate

        Assert.assertTrue(sampleWithManifestWar.exists());

        ZipUtil.unzipFile(sampleWithManifestWar, deploymentDirectory);

        //create object to test and inject required dependencies
        FileContentDelegate objectUnderTest = new FileContentDelegate(deploymentDirectory, null, null);

        //run code under test
        String actualShaReturned = objectUnderTest.getSHA(deploymentDirectory);

        //verify the results (Assert and mock verification)
        File manifestFile = new File(deploymentDirectory.getAbsolutePath() + "/META-INF/MANIFEST.MF");
        Assert.assertTrue(manifestFile.exists(), "Manifest file not created properly!");
        Assert.assertNotEquals(manifestFile.length(), 0, "Empty manifest!!");
View Full Code Here

Examples of org.rhq.plugins.jbossas.util.FileContentDelegate

        File sampleWithoutManifestWar = new File(this.getClass().getResource("/sampleWithoutManifest.war").getFile());
        Assert.assertTrue(sampleWithoutManifestWar.exists());

        //create object to test and inject required dependencies
        FileContentDelegate objectUnderTest = new FileContentDelegate(deploymentDirectory, "", null);

        PackageDetails mockPackageDetails = mock(PackageDetails.class);
        PackageDetailsKey mockPackageDetailsKey = mock(PackageDetailsKey.class);
        when(mockPackageDetails.getKey()).thenReturn(mockPackageDetailsKey);
        when(mockPackageDetailsKey.getName()).thenReturn("deploymentFile");

        //run code under test
        objectUnderTest.createContent(mockPackageDetails, sampleWithoutManifestWar, true, false);
        String actualShaReturned = objectUnderTest.getSHA(new File(deploymentDirectory, "/deploymentFile"));

        //verify the results (Assert and mock verification)
        File manifestFile = new File(deploymentDirectory.getAbsolutePath() + "/deploymentFile/META-INF/MANIFEST.MF");
        Assert.assertTrue(manifestFile.exists(), "Manifest file not created properly!");
        Assert.assertNotEquals(manifestFile.length(), 0, "Empty manifest!!");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.