Example #1
0
 /** Start a context and set up default values. */
 protected AuraContext setupContext(
     Mode mode, Format format, DefDescriptor<? extends BaseComponentDef> desc)
     throws QuickFixException {
   ContextService contextService = Aura.getContextService();
   AuraContext ctxt =
       contextService.startContext(mode, format, Authentication.AUTHENTICATED, desc);
   ctxt.setFrameworkUID(Aura.getConfigAdapter().getAuraFrameworkNonce());
   String uid = ctxt.getDefRegistry().getUid(null, desc);
   ctxt.addLoaded(desc, uid);
   return ctxt;
 }
Example #2
0
    @SuppressWarnings("unchecked")
    public NamespacePerfTestSuite(String namespace) throws Exception {
      super(namespace);
      ContextService contextService = Aura.getContextService();
      DefinitionService definitionService = Aura.getDefinitionService();

      boolean contextStarted = false;
      if (!contextService.isEstablished()) {
        contextStarted = true;
        contextService.startContext(Mode.PTEST, Format.JSON, Authentication.AUTHENTICATED);
      }

      Map<String, TestSuite> subSuites = Maps.newHashMap();

      try {
        DescriptorFilter matcher =
            new DescriptorFilter(String.format("markup://%s:*", namespace), DefType.COMPONENT);

        Set<DefDescriptor<?>> descriptors = definitionService.find(matcher);

        for (DefDescriptor<?> descriptor : descriptors) {
          if (((ComponentDef) descriptor.getDef()).isAbstract()
              || getBlacklistedComponents().contains(descriptor.getQualifiedName())) {
            continue;
          }

          Test test;
          try {
            test = new ComponentTestSuite((DefDescriptor<ComponentDef>) descriptor);
          } catch (Throwable t) {
            test = new FailTestCase(descriptor, t);
          }

          String testNamespace = descriptor.getNamespace();
          if (namespace.equals(testNamespace)) {
            addTest(test);
          } else {
            TestSuite subSuite = subSuites.get(testNamespace);
            if (subSuite == null) {
              subSuite = new TestSuite(testNamespace);
              subSuites.put(testNamespace, subSuite);
              addTest(subSuite);
            }
            subSuite.addTest(test);
          }
        }
      } catch (Throwable t) {
        LOG.log(Level.WARNING, "Failed to load component tests for namespace: " + namespace, t);
      } finally {
        if (contextStarted) {
          contextService.endContext();
        }
      }
    }
 @Override
 public void setUp() throws Exception {
   super.setUp();
   ContextService contextService = Aura.getContextService();
   AuraContext context = contextService.getCurrentContext();
   if (context == null) {
     contextService.startContext(
         AuraContext.Mode.SELENIUM,
         AuraContext.Format.HTML,
         AuraContext.Authentication.AUTHENTICATED);
   }
   clientLibraryService = Aura.getClientLibraryService();
 }
 /**
  * @return Returns the code.
  * @throws QuickFixException
  */
 public String getCode() throws QuickFixException {
   ContextService contextService = Aura.getContextService();
   boolean isEstablished = contextService.isEstablished();
   if (!isEstablished) {
     contextService.startContext(Mode.AUTOJSTEST, Format.JSON, Authentication.AUTHENTICATED);
   }
   try {
     return descriptor.getDef().getCode();
   } finally {
     if (!isEstablished) {
       contextService.endContext();
     }
   }
 }
    public NamespaceTestSuite(String namespace) throws Exception {
      super(namespace);
      ContextService contextService = Aura.getContextService();
      DefinitionService definitionService = Aura.getDefinitionService();

      boolean contextStarted = false;
      if (!contextService.isEstablished()) {
        contextStarted = true;
        contextService.startContext(Mode.JSTEST, Format.JSON, Authentication.AUTHENTICATED);
      }

      Map<String, TestSuite> subSuites = new HashMap<String, TestSuite>();
      try {
        DefDescriptor<TestSuiteDef> matcher =
            definitionService.getDefDescriptor(
                String.format("js://%s.*", namespace), TestSuiteDef.class);
        Set<DefDescriptor<TestSuiteDef>> descriptors = definitionService.find(matcher);

        for (DefDescriptor<TestSuiteDef> descriptor : descriptors) {
          Test test;
          try {
            test = new ComponentTestSuite(descriptor.getDef());
          } catch (Throwable t) {
            test = new FailTestCase(descriptor, t);
          }
          String testNamespace = descriptor.getNamespace();
          if (namespace.equals(testNamespace)) {
            addTest(test);
          } else {
            TestSuite subSuite = subSuites.get(testNamespace);
            if (subSuite == null) {
              subSuite = new TestSuite(testNamespace);
              subSuites.put(testNamespace, subSuite);
              addTest(subSuite);
            }
            subSuite.addTest(test);
          }
        }
      } catch (Throwable t) {
        System.err.println("Failed to load component tests for namespace: " + namespace);
        t.printStackTrace();
      } finally {
        if (contextStarted) {
          contextService.endContext();
        }
      }
    }