Package com.volantis.mcs.protocols

Examples of com.volantis.mcs.protocols.ScriptAttributes


                ScriptAssetReference scriptAssetReference =
                        loadAssetReference(sm.getAssetName(), pageContext);
                sm.setScriptAssetReference(scriptAssetReference);

                // collect the attributes
                final ScriptAttributes attributes =
                    assetToAttributes(sm.getScriptAssetReference());

                if (!referencableSet.contains(sm)) {
                    attributes.setEmbeddable(true);
                    attributes.setScriptFilePath(
                            new File(baseAssetsPath, attributes.getScriptReference().getURL()));
                }

                // write out the script element
                final Element scriptElement =
                    protocol.createScriptElement(attributes);
View Full Code Here


        final ScriptAsset scriptAsset = scriptReference.getScriptAsset();
        if (scriptAsset == null) {
           throw new ProtocolException(exceptionLocalizer.format(
                    "widget-missing-script-policy-variant"));
       
        final ScriptAttributes attributes = new ScriptAttributes();
        attributes.setCharSet(scriptAsset.getCharacterSet());
        attributes.setLanguage(scriptAsset.getProgrammingLanguage());
        attributes.setType(scriptAsset.getMimeType());
        attributes.setScriptReference(scriptReference);
        return attributes;
    }
View Full Code Here

    /**
     * This method tests the method public void writeOpenScript ( ScriptAttributes )
     * for the com.volantis.mcs.protocols.VolantisProtocol class.
     */
    public void testWriteOpenScript() throws Exception {
        final ScriptAttributes attributes =
                (ScriptAttributes) ProtocolIntegrationTestHelper.
                provideAttributes(ScriptAttributes.class);

        final VolantisProtocol protocol = getProtocol();

View Full Code Here

    /**
     * Opens script element with standard JavaScript attributes
     */
    protected Element openScriptElement(DOMOutputBuffer dom) {
        ScriptAttributes sa = new ScriptAttributes();
        sa.setType("text/javascript");
        return openScriptElement(sa, dom);
    }
View Full Code Here

        protocolMock.fuzzy.createScriptElement(
            mockFactory.expectsInstanceOf(ScriptAttributes.class)).does(
                new MethodAction(){
                    public Object perform(final MethodActionEvent event)
                            throws Throwable {
                        final ScriptAttributes attributes =
                            (ScriptAttributes) event.getArguments()[0];
                        final Element scriptElement =
                            protocolMock.getDOMFactory().createElement("script");
                        scriptElement.setAttribute("charset",
                            attributes.getCharSet());
                        scriptElement.setAttribute("language",
                            attributes.getLanguage());
                        scriptElement.setAttribute("src",
                            attributes.getScriptReference().getURL());
                        return scriptElement;
                    }
                }).any();

        final MarinerPageContextMock marinerPageContextMock =
            new MarinerPageContextMock("MarinerPageContextMock", expectations);
        marinerPageContextMock.expects.getAssetResolver().returns(
            assetResolverMock).any();
        marinerPageContextMock.expects.getProtocol().returns(protocolMock).any();

        final RuntimePolicyReferenceMock runtimePolicyReferenceMock1 =
            new RuntimePolicyReferenceMock("RuntimePolicyReferenceMock1",
                expectations);
        runtimePolicyReferenceMock1.expects.getName().returns("name1").any();
        final RuntimePolicyReferenceMock runtimePolicyReferenceMock2 =
            new RuntimePolicyReferenceMock("RuntimePolicyReferenceMock2",
                expectations);
        runtimePolicyReferenceMock2.expects.getName().returns("name2").any();
        final RuntimePolicyReferenceMock runtimePolicyReferenceMock3 =
            new RuntimePolicyReferenceMock("RuntimePolicyReferenceMock3",
                expectations);
        runtimePolicyReferenceMock3.expects.getName().returns("name3").any();
        final RuntimePolicyReferenceMock runtimePolicyReferenceMock4 =
            new RuntimePolicyReferenceMock("RuntimePolicyReferenceMock4",
                expectations);
        runtimePolicyReferenceMock4.expects.getName().returns("name4").any();

        final ScriptLibraryManager slm = new ScriptLibraryManager(protocolMock);
        final VariantMock variantMock =
            new VariantMock("VariantMock", expectations);
        variantMock.expects.getVariantType().returns(VariantType.SCRIPT).any();

        final ActivatedVariablePolicyMock policyMock1 =
            new ActivatedVariablePolicyMock("ActivatedVariablePolicyMock1",
                expectations);
        policyMock1.expects.getName().returns("name1").any();
        final SelectedVariantMock selectedVariantMock1 =
            new SelectedVariantMock("SelectedVariantMock1", expectations);
        assetResolverMock.expects.selectBestVariant(
            runtimePolicyReferenceMock1, null).returns(selectedVariantMock1).any();
        selectedVariantMock1.expects.getVariant().returns(variantMock).any();
        selectedVariantMock1.expects.getPolicy().returns(policyMock1).any();
        selectedVariantMock1.expects.getOldObject().returns(
            new ScriptAsset("name1", "deviceName1", "javascript1", "mimeType1",
                "charSet1", ScriptAsset.URL, "assetGroupName1", "value1")).any();
        final DefaultComponentScriptAssetReference scriptAssetReference1 =
            new DefaultComponentScriptAssetReference(
                runtimePolicyReferenceMock1, assetResolverMock);
        assertTrue(slm.addScript(scriptAssetReference1));

        final ActivatedVariablePolicyMock policyMock2 =
            new ActivatedVariablePolicyMock("ActivatedVariablePolicyMock2",
                expectations);
        policyMock2.expects.getName().returns("name2").any();
        final SelectedVariantMock selectedVariantMock2 =
            new SelectedVariantMock("SelectedVariantMock2", expectations);
        selectedVariantMock2.expects.getVariant().returns(variantMock).any();
        selectedVariantMock2.expects.getPolicy().returns(policyMock2).any();
        selectedVariantMock2.expects.getOldObject().returns(
            new ScriptAsset("name2", "deviceName2", "javascript2", "mimeType2",
                "charSet2", ScriptAsset.URL, "assetGroupName2", "value2")).any();
        assetResolverMock.expects.selectBestVariant(
            runtimePolicyReferenceMock2, null).returns(selectedVariantMock2).any();
        final DefaultComponentScriptAssetReference scriptAssetReference2 =
            new DefaultComponentScriptAssetReference(
                runtimePolicyReferenceMock2, assetResolverMock);
        assertTrue(slm.addScript(scriptAssetReference2));

        final SelectedVariantMock selectedVariantMock1b =
            new SelectedVariantMock("SelectedVariantMock1b", expectations);
        selectedVariantMock1b.expects.getVariant().returns(variantMock).any();
        selectedVariantMock1b.expects.getPolicy().returns(policyMock1).any();
        selectedVariantMock1b.expects.getOldObject().returns(new ScriptAsset(
            "name1b", "deviceName1b", "javascript1b", "mimeType1b", "charSet1b",
            ScriptAsset.URL, "assetGroupName1b", "value1b")).any();
        final DefaultComponentScriptAssetReference scriptAssetReference1b =
            new DefaultComponentScriptAssetReference(
                runtimePolicyReferenceMock1, assetResolverMock);
        assertFalse(slm.addScript(scriptAssetReference1b));

        final ActivatedVariablePolicyMock policyMock3 =
            new ActivatedVariablePolicyMock("ActivatedVariablePolicyMock3",
                expectations);
        policyMock3.expects.getName().returns("name3").any();
        final SelectedVariantMock selectedVariantMock3 =
            new SelectedVariantMock("SelectedVariantMock3", expectations);
        selectedVariantMock3.expects.getVariant().returns(variantMock).any();
        selectedVariantMock3.expects.getPolicy().returns(policyMock3).any();
        selectedVariantMock3.expects.getOldObject().returns(
            new ScriptAsset("name3", "deviceName3", "javascript3", "mimeType3",
                "charSet3", ScriptAsset.URL, "assetGroupName3", "value3")).any();
        assetResolverMock.expects.selectBestVariant(
            runtimePolicyReferenceMock3, null).returns(selectedVariantMock3).any();
        final DefaultComponentScriptAssetReference scriptAssetReference3 =
            new DefaultComponentScriptAssetReference(
                runtimePolicyReferenceMock3, assetResolverMock);
        assertTrue(slm.addScript(scriptAssetReference3));

        assetResolverMock.expects.computeURLAsString(selectedVariantMock1).
            returns("source1").any();
        assetResolverMock.expects.computeURLAsString(selectedVariantMock2).
            returns("source2").any();
        assetResolverMock.expects.computeURLAsString(selectedVariantMock3).
            returns("source3").any();

        assetResolverMock.expects.rewriteURLWithPageURLRewriter("source1", PageURLType.SCRIPT)
            .returns("source1").any();
        assetResolverMock.expects.rewriteURLWithPageURLRewriter("source2", PageURLType.SCRIPT)
            .returns("source2").any();
        assetResolverMock.expects.rewriteURLWithPageURLRewriter("source3", PageURLType.SCRIPT)
            .returns("source3").any();
       
        slm.writeScriptElements();

        assertEquals(3, scriptAttributesList.size());
        final ScriptAttributes scriptAttributes1 =
            (ScriptAttributes) scriptAttributesList.get(0);
        assertEquals("charSet1", scriptAttributes1.getCharSet());
        assertEquals("javascript1", scriptAttributes1.getLanguage());
        assertEquals("source1", scriptAttributes1.getScriptReference().getURL());
        final ScriptAttributes scriptAttributes2 =
            (ScriptAttributes) scriptAttributesList.get(1);
        assertEquals("charSet2", scriptAttributes2.getCharSet());
        assertEquals("javascript2", scriptAttributes2.getLanguage());
        assertEquals("source2", scriptAttributes2.getScriptReference().getURL());
        final ScriptAttributes scriptAttributes3 =
            (ScriptAttributes) scriptAttributesList.get(2);
        assertEquals("charSet3", scriptAttributes3.getCharSet());
        assertEquals("javascript3", scriptAttributes3.getLanguage());
        assertEquals("source3", scriptAttributes3.getScriptReference().getURL());

        final Element headRoot =
            ((DOMOutputBuffer) pageHead.getHead()).getRoot();
        assertEquals("DELETE_ME", ((Element) headRoot.getHead()).getName());
View Full Code Here

   
    // Javadoc inherited
    public void closeFeedPoller(FeedPollerAttributes attributes) throws ProtocolException {
        // Create script element with the content written
        // using scriptContentWriter
        ScriptAttributes scriptAttributes = new ScriptAttributes();

        protocol.writeOpenScript(scriptAttributes);

        try {
            // Write content of all scripts, excepts for item addition
View Full Code Here

        // It is doing in such way because it is not possible pasing pseudo
        // elements or class in response:response body

        if (activeStyles != null) {
            DOMOutputBuffer currentBuffer = getCurrentBuffer(protocol);
            ScriptAttributes sa = new ScriptAttributes();

            sa.setLanguage("JavaScript");
            sa.setType("text/javascript");
            openScriptElement(sa, currentBuffer);

            StylesExtractor extractor = createStylesExtractor(protocol,
                    activeStyles);
           
View Full Code Here

        if (isNew) {
            if (markerElement == null) {
                scriptReferences.add(scriptReference);
            } else {
                // collect the attributes
                final ScriptAttributes attributes =
                    assetToAttributes(scriptReference);
                final Element scriptElement =
                    protocol.createScriptElement(attributes);
                scriptElement.insertBefore(markerElement);
            }
View Full Code Here

     * @return the created ScriptAttributes object
     */
    private ScriptAttributes assetToAttributes(
            final ScriptAssetReference scriptReference) {
        final ScriptAsset scriptAsset = scriptReference.getScriptAsset();
        final ScriptAttributes attributes = new ScriptAttributes();
        attributes.setCharSet(scriptAsset.getCharacterSet());
        attributes.setLanguage(scriptAsset.getProgrammingLanguage());
        attributes.setType(scriptAsset.getMimeType());
        attributes.setScriptReference(scriptReference);
        return attributes;
    }
View Full Code Here

        for (Iterator iter = scriptReferences.iterator(); iter.hasNext(); ) {
            final ScriptAssetReference scriptVariant =
                (ScriptAssetReference) iter.next();

            // collect the attributes
            final ScriptAttributes attributes =
                assetToAttributes(scriptVariant);

            // write out the script element
            protocol.pushHeadBuffer();
            protocol.writeOpenScript(attributes);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.ScriptAttributes

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.