Package org.auraframework.system

Examples of org.auraframework.system.AuraContext


public class JSTestCaseModel {
    private final String url;
    private final int count;

    public JSTestCaseModel() throws QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        BaseComponent<?, ?> component = context.getCurrentComponent();

        TestCaseDef caseDef = (TestCaseDef) component.getAttributes().getValue("case");

        String baseUrl = component.getAttributes().getValue("url").toString();
        Set<Entry<String, Object>> attributes = caseDef.getAttributeValues().entrySet();
View Full Code Here


    private final TestSuiteDef def;
    private final String url;
    private final List<TestCaseDef> tcds;

    public JSTestModel() throws QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        BaseComponent<?, ?> component = context.getCurrentComponent();
        DefinitionService defService = Aura.getDefinitionService();

        String desc = (String)component.getAttributes().getValue("descriptor");
        DefType defType = DefType.valueOf(((String)component.getAttributes().getValue("defType")).toUpperCase());

        desc = "js://" + desc.replace(':', '.');
        descriptor = defService.getDefDescriptor(desc, TestSuiteDef.class);
        def = descriptor.getDef();
        if (def == null) { throw new DefinitionNotFoundException(descriptor); }
        long nonce = System.currentTimeMillis();

        url = String.format("/%s/%s.%s?aura.nonce=%s&aura.mode=AUTO%s&aura.testReset=true", descriptor.getNamespace(),
                descriptor.getName(), defType == DefType.COMPONENT ? "cmp" : "app", nonce, context.getMode().name());

        String test = (String)component.getAttributes().getValue("test");
        tcds = filterTestCases(test);

        TestContextAdapter contextAdapter = Aura.get(TestContextAdapter.class);
View Full Code Here

     * an expired lastmod timestamp is used in a POST request.
     *
     * @throws Exception
     */
    public void testPostRequestWithDifferentUID() throws Exception {
        AuraContext ctx = startContext("auratest:test_TokenValidation", ComponentDef.class);

        HttpPost post = getPostMethod(ctx, true);
        HttpResponse httpResponse = perform(post);                                                        // days
        int statusCode = getStatusCode(httpResponse);
        String response = getResponseBody(httpResponse);
View Full Code Here

     *
     * @throws Exception
     */
    @AuraTestLabels("auraSanity")
    public void testPostRequestWithValidUID() throws Exception {
        AuraContext ctx = startContext("auratest:test_TokenValidation", ComponentDef.class);
        HttpPost post = getPostMethod(ctx, false);
        HttpResponse httpResponse = perform(post);
        int statusCode = getStatusCode(httpResponse);
        String response = getResponseBody(httpResponse);
        post.releaseConnection();
View Full Code Here

    private final boolean isAbstract;
    private final List<String> interfaces = Lists.newArrayList();

    public DefOverviewModel() throws QuickFixException {

        AuraContext context = Aura.getContextService().getCurrentContext();
        BaseComponent<?, ?> component = context.getCurrentComponent();

        String desc = (String) component.getAttributes().getValue("descriptor");

        DefType defType = DefType.valueOf(((String) component.getAttributes().getValue("defType")).toUpperCase());
        descriptor = Aura.getDefinitionService().getDefDescriptor(desc, defType.getPrimaryInterface());
View Full Code Here

    @Override
    public <T extends Definition> T getDefinition(DefDescriptor<T> descriptor) throws QuickFixException {
        ContextService contextService = Aura.getContextService();
        contextService.assertEstablished();

        AuraContext context = Aura.getContextService().getCurrentContext();
        T def = context.getDefRegistry().getDef(descriptor);

        if (def != null && descriptor.getDefType() == DefType.APPLICATION && def.getAccess().requiresAuthentication() &&
            context.getAccess() != Authentication.AUTHENTICATED) {
            def = null;
        }
       
        if (def == null) {
            throw new DefinitionNotFoundException(descriptor);
View Full Code Here

    @Override
    public <D extends Definition> Set<DefDescriptor<D>> find(DefDescriptor<D> matcher) {
        Aura.getContextService().assertEstablished();

        AuraContext context = Aura.getContextService().getCurrentContext();
        return context.getDefRegistry().find(matcher);
    }
View Full Code Here

    @Override
    public Set<DefDescriptor<?>> find(DescriptorFilter matcher) {
        Aura.getContextService().assertEstablished();

        AuraContext context = Aura.getContextService().getCurrentContext();
        return context.getDefRegistry().find(matcher);
    }
View Full Code Here

     * @throws QuickFixException if a definition can't be compiled.
     */
    @Override
    public void updateLoaded(DefDescriptor<?> loading) throws QuickFixException, ClientOutOfSyncException {
        ContextService contextService = Aura.getContextService();
        AuraContext context;
        MasterDefRegistry mdr;
        Set<DefDescriptor<?>> loaded = Sets.newHashSet();
        Set<DefDescriptor<?>> prev = Sets.newHashSet();
        Set<DefDescriptor<?>> remove = null;

        contextService.assertEstablished();
        context = contextService.getCurrentContext();
        mdr = context.getDefRegistry();
        if (context.getPreloadedDefinitions() == null) {
            //
            // TODO (optimize): we could reverse this set randomly to try
            // to sanitize the list in opposite directions. No need to be
            // exact (hard to test though).
            //
            for (Map.Entry<DefDescriptor<?>, String> entry : context.getClientLoaded().entrySet()) {
                DefDescriptor<?> descriptor = entry.getKey();
                if (loaded.contains(descriptor)) {
                    context.dropLoaded(descriptor);
                } else {
                    // validate the uid.
                    String uid = entry.getValue();
                    String tuid = null;
                    QuickFixException qfe = null;

                    if (uid == null) {
                        // If we are given a null, bounce out.
                        throw new ClientOutOfSyncException(descriptor + ": missing UID ");
                    }
                    try {
                        tuid = mdr.getUid(uid, descriptor);
                    } catch (QuickFixException broke) {
                        //
                        // See note above. This is how we enforce precedence of ClientOutOfSyncException
                        //
                        qfe = broke;
                    }
                    if (!uid.equals(tuid)) {
                        throw new ClientOutOfSyncException(descriptor + ": mismatched UIDs " + uid + " != " + tuid);
                    }
                    if (qfe != null) {
                        throw qfe;
                    }
                    Set<DefDescriptor<?>> deps = mdr.getDependencies(uid);
                    loaded.addAll(deps);
                    for (DefDescriptor<?> x : prev) {
                        if (deps.contains(x)) {
                            if (remove == null) {
                                remove = Sets.newHashSet();
                            }
                            remove.add(x);
                        }
                    }
                    prev.add(descriptor);
                }
            }
            context.setPreloadedDefinitions(loaded);
        } else {
            loaded = context.getPreloadedDefinitions();
        }
        if (remove != null) {
            for (DefDescriptor<?> x : remove) {
                context.dropLoaded(x);
            }
        }
        //
        // Now make sure that our current definition is somewhere there
        // If this fails, we will throw an exception, and all will be
        // well.
        //
        if (loading != null && !loaded.contains(loading) && !context.getLoaded().containsKey(loading)) {
            String uid = mdr.getUid(null, loading);

            if (uid == null) {
                throw new DefinitionNotFoundException(loading, null);
            } else {
                context.addLoaded(loading, uid);
            }
        }
    }
View Full Code Here

        return getFormatAdapter(null, type);
    }

    private <T> FormatAdapter<T> getFormatAdapter(String format, Class<T> type) throws QuickFixException {
        if (format == null) {
            AuraContext context = Aura.getContextService().getCurrentContext();
            format = context.getFormat().name();   
        }
        FormatAdapter<T> ret = AuraImpl.getFormatAdapter(format, type);
        if (ret == null) {
            throw new AuraRuntimeException(String.format("No FormatAdapter found for '%s' in '%s' Format",
                    type.getName(), format));
View Full Code Here

TOP

Related Classes of org.auraframework.system.AuraContext

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.