コード例 #1
0
ファイル: ParsysTest.java プロジェクト: wcm-io/wcm-io-wcm
  @Before
  public void setUp() {
    MockSlingExtensions.setUp(context);

    context.addModelsForPackage("io.wcm.wcm.parsys.controller");

    context.request().setAttribute(ComponentContext.CONTEXT_ATTR_NAME, componentContext);
    when(componentContext.getComponent()).thenReturn(component);
    when(component.getPath()).thenReturn(RESOURCE_TYPE_SAMPLE);
    when(component.getProperties()).thenReturn(ImmutableValueMap.of());

    page = context.create().page("/content/page1", "/apps/sample/templates/test1");
    parsysResource = context.create().resource(page.getContentResource().getPath() + "/parsys");
    par1Resource =
        context
            .create()
            .resource(
                parsysResource.getPath() + "/par1",
                ImmutableValueMap.of("sling:resourceType", COMPONENT_PATH_1));
    par2Resource =
        context
            .create()
            .resource(
                parsysResource.getPath() + "/par2",
                ImmutableValueMap.of("sling:resourceType", COMPONENT_PATH_2));

    context.currentResource(parsysResource);
  }
コード例 #2
0
    @Override
    public void execute(AemContext context) throws PersistenceException, IOException {

      // call test-specific callback first
      if (testCallback != null) {
        testCallback.execute(context);
      }

      // wcm.io Sling extensions
      MockSlingExtensions.setUp(context);

      // URL handler-specific parameter definitions
      context.registerService(ParameterProvider.class, new UrlHandlerParameterProviderImpl());

      // application provider
      context.registerService(
          ApplicationProvider.class, MockConfig.applicationProvider(APPLICATION_ID, "/content"));

      // configuration finder strategy
      context.registerService(
          ConfigurationFinderStrategy.class,
          MockConfig.configurationFinderStrategyAbsoluteParent(
              APPLICATION_ID, DummyUrlHandlerConfig.SITE_ROOT_LEVEL));

      // wcm.io configuration
      MockConfig.setUp(context);

      // media formats
      context.registerInjectActivateService(new MediaFormatProviderManagerImpl());

      // sling models registration
      context.addModelsForPackage("io.wcm.handler.url");
      context.addModelsForPackage("io.wcm.handler.media");
      context.addModelsForPackage("io.wcm.handler.link");
      context.addModelsForPackage("io.wcm.handler.richtext");

      // create current page in site context
      context.currentPage(
          context.create().page(ROOTPATH_CONTENT, DummyAppTemplate.CONTENT.getTemplatePath()));

      // default site config
      MockConfig.writeConfiguration(
          context,
          ROOTPATH_CONTENT,
          ImmutableValueMap.builder()
              .put(UrlParams.SITE_URL.getName(), "http://www.dummysite.org")
              .put(UrlParams.SITE_URL_SECURE.getName(), "https://www.dummysite.org")
              .put(UrlParams.SITE_URL_AUTHOR.getName(), "https://author.dummysite.org")
              .build());
    }