Package org.jboss.arquillian.graphene.spi.page

Examples of org.jboss.arquillian.graphene.spi.page.PageExtension


    }

    @Test
    public void testInstallation() {
        // page extension construction
        PageExtension pageExtensionMock = Mockito.mock(PageExtension.class);
        when(pageExtensionMock.getExtensionScript()).thenReturn(JavaScript.fromString("install"));
        when(pageExtensionMock.getInstallationDetectionScript()).thenReturn(JavaScript.fromString("check"));
        when(pageExtensionMock.getRequired()).thenReturn(Collections.EMPTY_LIST);
        when(pageExtensionMock.getName()).thenReturn("mock");
        // registry
        PageExtensionRegistry registry = new PageExtensionRegistryImpl();
        registry.register(pageExtensionMock);
        // tests
        PageExtensionInstallatorProvider provider = new RemotePageExtensionInstallatorProvider(registry, executor);
        Assert.assertFalse(provider.installator(pageExtensionMock.getName()).isInstalled());
        provider.installator(pageExtensionMock.getName()).install();
        Assert.assertTrue(provider.installator(pageExtensionMock.getName()).isInstalled());
    }
View Full Code Here


    }

    @Test
    public void testCorrectInstallation() {
        // page extension construction
        PageExtension pageExtensionMock = Mockito.mock(PageExtension.class);
        when(pageExtensionMock.getExtensionScript()).thenReturn(JavaScript.fromString("document.Graphene = {};"));
        when(pageExtensionMock.getInstallationDetectionScript()).thenReturn(JavaScript.fromString("return (typeof document.Graphene != 'undefined');"));
        when(pageExtensionMock.getRequired()).thenReturn(Collections.EMPTY_LIST);
        // registry
        PageExtensionRegistry registry = context().getPageExtensionRegistry();
        registry.register(pageExtensionMock);
        // test
        context().getPageExtensionInstallatorProvider().installator(pageExtensionMock.getName()).install();
    }
View Full Code Here

    }

    @Test(expected=IllegalStateException.class)
    public void testIncorrectInstallation() {
        // page extension construction
        PageExtension pageExtensionMock = Mockito.mock(PageExtension.class);
        when(pageExtensionMock.getExtensionScript()).thenReturn(JavaScript.fromString("var Graphene = {};"));
        when(pageExtensionMock.getInstallationDetectionScript()).thenReturn(JavaScript.fromString("return (typeof Graphene != 'undefined');"));
        when(pageExtensionMock.getRequired()).thenReturn(Collections.EMPTY_LIST);
        // registry
        PageExtensionRegistry registry = context().getPageExtensionRegistry();
        registry.register(pageExtensionMock);
        // test
        context().getPageExtensionInstallatorProvider().installator(pageExtensionMock.getName()).install();
    }
View Full Code Here

    }

    @Test
    public void testInstallationWithRequirements() {
        // page extension construction
        PageExtension pageExtensionMock = Mockito.mock(PageExtension.class);
        when(pageExtensionMock.getExtensionScript()).thenReturn(JavaScript.fromString("document.Graphene2 = document.Graphene1 + 1;"));
        when(pageExtensionMock.getInstallationDetectionScript()).thenReturn(JavaScript.fromString("return ((typeof document.Graphene2 != 'undefined') && document.Graphene2 == 2);"));
        List<String> requirements = new ArrayList<String>();
        requirements.add(SimplePageExtension.class.getName());
        when(pageExtensionMock.getRequired()).thenReturn(requirements);
        // registry
        PageExtensionRegistry registry = context().getPageExtensionRegistry();
        registry.register(new SimplePageExtension());
        registry.register(pageExtensionMock);
        // test
        context().getPageExtensionInstallatorProvider().installator(pageExtensionMock.getName()).install();
        Assert.assertTrue(context().getPageExtensionInstallatorProvider().installator(SimplePageExtension.class.getName()).isInstalled());
        Assert.assertTrue(context().getPageExtensionInstallatorProvider().installator(pageExtensionMock.getName()).isInstalled());
    }
View Full Code Here

    }

    @Test(expected=IllegalStateException.class)
    public void testInstallationWithCyclicRequirements() {
        // page extension construction
        PageExtension pageExtensionMock = Mockito.mock(PageExtension.class);
        when(pageExtensionMock.getExtensionScript()).thenReturn(JavaScript.fromString("document.Graphene2 = document.Graphene1 + 1;"));
        when(pageExtensionMock.getInstallationDetectionScript()).thenReturn(JavaScript.fromString("return ((typeof document.Graphene2 != 'undefined') && document.Graphene2 == 2);"));
        List<String> requirements = new ArrayList<String>();
        requirements.add(SimplePageExtension.class.getName());
        requirements.add(CyclicPageExtension1.class.getName());
        requirements.add(CyclicPageExtension2.class.getName());
        when(pageExtensionMock.getRequired()).thenReturn(requirements);
        // registry
        PageExtensionRegistry registry = context().getPageExtensionRegistry();
        registry.register(new SimplePageExtension());
        registry.register(pageExtensionMock);
        registry.register(new CyclicPageExtension1());
        registry.register(new CyclicPageExtension2());
        // test
        context().getPageExtensionInstallatorProvider().installator(pageExtensionMock.getName()).install();
    }
View Full Code Here

        return installator(name, true);
    }

    @Override
    public final PageExtensionInstallator installator(String name, boolean checkRequirements) {
        PageExtension extension = getRegistry().getExtension(name);
        if (extension == null) {
            return null;
        }
        if (checkRequirements) {
            checkRequirements(name);
View Full Code Here

        stack.add(extensionName);
        checkRequirements(stack);
    }

    private void checkRequirements(List<String> stack) {
        PageExtension top = getRegistry().getExtension(stack.get(stack.size()-1));
        if (top == null) {
            throw new IllegalArgumentException("There is no registered extension '"+stack.get(stack.size()-1)+"'.");
        }
        for (String requiredName: top.getRequired()) {
            PageExtension required = getRegistry().getExtension(requiredName);
            for (String onStack: stack) {
                if (required.getName().equals(onStack)) {
                    throw new IllegalStateException("There is a cycle in page extension requirements, DFS stack: " + stack);
                }
            }
            stack.add(required.getName());
            checkRequirements(stack);
        }
        stack.remove(stack.size()-1);
    }
View Full Code Here

        return installator(name, true);
    }

    @Override
    public final PageExtensionInstallator installator(String name, boolean checkRequirements) {
        PageExtension extension = getRegistry().getExtension(name);
        if (extension == null) {
            return null;
        }
        if (checkRequirements) {
            checkRequirements(name);
View Full Code Here

        stack.add(extensionName);
        checkRequirements(stack);
    }

    private void checkRequirements(List<String> stack) {
        PageExtension top = getRegistry().getExtension(stack.get(stack.size()-1));
        if (top == null) {
            throw new IllegalArgumentException("There is no registered extension '"+stack.get(stack.size()-1)+"'.");
        }
        for (String requiredName: top.getRequired()) {
            PageExtension required = getRegistry().getExtension(requiredName);
            for (String onStack: stack) {
                if (required.getName().equals(onStack)) {
                    throw new IllegalStateException("There is a cycle in page extension requirements, DFS stack: " + stack);
                }
            }
            stack.add(required.getName());
            checkRequirements(stack);
        }
        stack.remove(stack.size()-1);
    }
View Full Code Here

        return installator(name, true);
    }

    @Override
    public final PageExtensionInstallator installator(String name, boolean checkRequirements) {
        PageExtension extension = getRegistry().getExtension(name);
        if (extension == null) {
            return null;
        }
        if (checkRequirements) {
            checkRequirements(name);
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.graphene.spi.page.PageExtension

Copyright © 2018 www.massapicom. 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.