Examples of TomcatWarComponent


Examples of org.jboss.on.plugins.tomcat.TomcatWarComponent

    @Test
    public void testDiscoverZippedDeployment() throws Exception {
        //create the object under test as a partial mock because only one
        //public method will be tested, while the rest will be mocked.
        TomcatWarComponent objectUnderTest = mock(TomcatWarComponent.class);

        //tell the method story as it happens: mock dependencies and configure
        //those dependencies to get the method under test to completion.
        File fileUsedInTest = new File(this.getClass().getResource("/sampleWithManifest.war").getFile());

        @SuppressWarnings("unchecked")
        ResourceContext<TomcatVHostComponent> mockResourceContext = mock(ResourceContext.class);
        when(objectUnderTest.getResourceContext()).thenReturn(mockResourceContext);
        Configuration mockConfiguration = mock(Configuration.class);
        when(mockResourceContext.getPluginConfiguration()).thenReturn(mockConfiguration);
        when(mockConfiguration.getSimpleValue(eq("filename"), isNull(String.class))).thenReturn(
            fileUsedInTest.getAbsolutePath());

        PackageType mockPackageType = mock(PackageType.class);

        when(objectUnderTest.discoverDeployedPackages(any(PackageType.class))).thenCallRealMethod();

        //run code under test
        Set<ResourcePackageDetails> actualResult = objectUnderTest.discoverDeployedPackages(mockPackageType);

        //verify the results (Assert and mock verification)
        Assert.assertEquals(actualResult.size(), 1);

        ResourcePackageDetails actualResourcePackageDetails = (ResourcePackageDetails) actualResult.toArray()[0];
View Full Code Here

Examples of org.jboss.on.plugins.tomcat.TomcatWarComponent

        expectedDisplayVersion.put(testArchiveFiles[4], "1.234 (9.990)");

        for (String availableArchiveFile : testArchiveFiles) {
            //create the object under test as a partial mock because only one
            //public method will be tested, while the rest will be mocked.
            TomcatWarComponent objectUnderTest = mock(TomcatWarComponent.class);

            //tell the method story as it happens: mock dependencies and configure
            //those dependencies to get the method under test to completion.
            File archiveUsedInTest = new File(this.getClass().getResource(availableArchiveFile).getFile());
            File deploymentFolderUsedInTest = new File(this.getClass().getResource("/").getFile() + "deploymentFolder");
            ZipUtil.unzipFile(archiveUsedInTest, deploymentFolderUsedInTest);

            @SuppressWarnings("unchecked")
            ResourceContext<TomcatVHostComponent> mockResourceContext = mock(ResourceContext.class);
            when(objectUnderTest.getResourceContext()).thenReturn(mockResourceContext);
            Configuration mockConfiguration = mock(Configuration.class);
            when(mockResourceContext.getPluginConfiguration()).thenReturn(mockConfiguration);
            when(mockConfiguration.getSimpleValue(eq("filename"), isNull(String.class))).thenReturn(
                deploymentFolderUsedInTest.getAbsolutePath());

            PackageType mockPackageType = mock(PackageType.class);

            when(objectUnderTest.discoverDeployedPackages(any(PackageType.class))).thenCallRealMethod();

            //run code under test
            Set<ResourcePackageDetails> actualResult = objectUnderTest.discoverDeployedPackages(mockPackageType);

            //verify the results (Assert and mock verification)
            Assert.assertEquals(actualResult.size(), 1);

            ResourcePackageDetails actualResourcePackageDetails = (ResourcePackageDetails) actualResult.toArray()[0];
View Full Code Here

Examples of org.jboss.on.plugins.tomcat.TomcatWarComponent

    @Test
    public void testDiscoverNoFileOnDisk() throws Exception {
        //create the object under test as a partial mock because only one
        //public method will be tested, while the rest will be mocked.
        TomcatWarComponent objectUnderTest = mock(TomcatWarComponent.class);

        //tell the method story as it happens: mock dependencies and configure
        //those dependencies to get the method under test to completion.
        File fileUsedInTest = new File(this.getClass().getResource("/").getFile() + "randomNonExistingFile");

        @SuppressWarnings("unchecked")
        ResourceContext<TomcatVHostComponent> mockResourceContext = mock(ResourceContext.class);
        when(objectUnderTest.getResourceContext()).thenReturn(mockResourceContext);
        Configuration mockConfiguration = mock(Configuration.class);
        when(mockResourceContext.getPluginConfiguration()).thenReturn(mockConfiguration);
        when(mockConfiguration.getSimpleValue(eq("filename"), isNull(String.class))).thenReturn(
            fileUsedInTest.getAbsolutePath());

        PackageType mockPackageType = mock(PackageType.class);

        when(objectUnderTest.discoverDeployedPackages(any(PackageType.class))).thenCallRealMethod();

        //run code under test
        Set<ResourcePackageDetails> actualResult = objectUnderTest.discoverDeployedPackages(mockPackageType);

        //verify the results (Assert and mock verification)
        Assert.assertEquals(actualResult.size(), 0);

        verify(mockResourceContext, times(1)).getPluginConfiguration();
View Full Code Here

Examples of org.jboss.on.plugins.tomcat.TomcatWarComponent

    @Test(expectedExceptions = IllegalStateException.class)
    public void testDiscoverIncorrectConfiguration() throws Exception {
        //create the object under test as a partial mock because only one
        //public method will be tested, while the rest will be mocked.
        TomcatWarComponent objectUnderTest = mock(TomcatWarComponent.class);

        //tell the method story as it happens: mock dependencies and configure
        //those dependencies to get the method under test to completion.
        @SuppressWarnings("unchecked")
        ResourceContext<TomcatVHostComponent> mockResourceContext = mock(ResourceContext.class);
        when(objectUnderTest.getResourceContext()).thenReturn(mockResourceContext);
        Configuration mockConfiguration = mock(Configuration.class);
        when(mockResourceContext.getPluginConfiguration()).thenReturn(mockConfiguration);
        when(mockConfiguration.getSimpleValue(eq("filename"), isNull(String.class))).thenReturn(null);

        PackageType mockPackageType = mock(PackageType.class);

        when(objectUnderTest.discoverDeployedPackages(any(PackageType.class))).thenCallRealMethod();

        //run code under test
        Set<ResourcePackageDetails> actualResult = objectUnderTest.discoverDeployedPackages(mockPackageType);

        //verify the results (Assert and mock verification)
        Assert.assertEquals(actualResult.size(), 0);

        verify(mockResourceContext, times(1)).getPluginConfiguration();
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.