public void setUp() throws RegistryException {
   super.setUp();
   /*        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain("foo.com");
   PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(1);*/
   ctx.addAspect(LIFECYCLE_NAME, new DefaultLifecycle(), MultitenantConstants.SUPER_TENANT_ID);
   EmbeddedRegistryService embeddedRegistry = ctx.getEmbeddedRegistryService();
   new RegistryCoreServiceComponent().registerBuiltInHandlers(embeddedRegistry);
   registry = embeddedRegistry.getRegistry("admin", "admin");
 }
Ejemplo n.º 2
0
  public void testBackwardCompatibility() throws RegistryException {
    Registry rootRegistry = embeddedRegistryService.getSystemRegistry();
    Resource r1 = rootRegistry.newResource();
    r1.setContent("r1 content");
    rootRegistry.put("/test/comments/r1", r1);

    rootRegistry.addComment(
        "/test/comments/r1", new Comment("backward-compatibility1 on this resource :)"));
    rootRegistry.addComment(
        "/test/comments/r1", new Comment("backward-compatibility2 on this resource :)"));

    String sql =
        "SELECT REG_COMMENT_ID FROM REG_COMMENT C, REG_RESOURCE_COMMENT RC "
            + "WHERE C.REG_COMMENT_TEXT LIKE ? AND C.REG_ID=RC.REG_COMMENT_ID";

    Resource queryR = rootRegistry.newResource();
    queryR.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
    queryR.addProperty(
        RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.COMMENTS_RESULT_TYPE);
    rootRegistry.put("/beep/x", queryR);
    Map<String, String> params = new HashMap<String, String>();
    params.put("query", sql);
    params.put(RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.COMMENTS_RESULT_TYPE);
    params.put("1", "backward-compatibility1%");
    Collection qResults = rootRegistry.executeQuery("/beep/x", params);

    String[] qPaths = (String[]) qResults.getContent();

    assertEquals("Query result count should be 1", qPaths.length, 1);
  }
Ejemplo n.º 3
0
 public void setUp() {
   super.setUp();
   if (embeddedRegistryService != null) {
     return;
   }
   try {
     embeddedRegistryService = ctx.getEmbeddedRegistryService();
     RealmUnawareRegistryCoreServiceComponent comp =
         new RealmUnawareRegistryCoreServiceComponent();
     comp.setRealmService(ctx.getRealmService());
     comp.registerBuiltInHandlers(embeddedRegistryService);
     // get the realm config to retrieve admin username, password
     RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
     registry =
         embeddedRegistryService.getConfigUserRegistry(
             realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
     systemRegistry = embeddedRegistryService.getConfigSystemRegistry();
   } catch (RegistryException e) {
     fail("Failed to initialize the registry. Caused by: " + e.getMessage());
   }
 }