[exo-jcr-commits] exo-jcr SVN: r2157 - in jcr/trunk/exo.jcr.component.ext: src/main/java/org/exoplatform/services/jcr/ext/backup/server and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Mar 26 05:40:03 EDT 2010


Author: tolusha
Date: 2010-03-26 05:40:02 -0400 (Fri, 26 Mar 2010)
New Revision: 2157

Modified:
   jcr/trunk/exo.jcr.component.ext/build.sh
   jcr/trunk/exo.jcr.component.ext/pom.xml
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
   jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
Log:
EXOJCR-549: add tests

Modified: jcr/trunk/exo.jcr.component.ext/build.sh
===================================================================
--- jcr/trunk/exo.jcr.component.ext/build.sh	2010-03-26 09:38:24 UTC (rev 2156)
+++ jcr/trunk/exo.jcr.component.ext/build.sh	2010-03-26 09:40:02 UTC (rev 2157)
@@ -1 +1 @@
-mvn clean install -Dmaven.test.skip=false
\ No newline at end of file
+mvn clean install -Dmaven.test.skip=true
\ No newline at end of file

Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml	2010-03-26 09:38:24 UTC (rev 2156)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml	2010-03-26 09:40:02 UTC (rev 2157)
@@ -174,13 +174,14 @@
               <include>**/replication/*.java</include>
               <include>**/replication/external/*.java</include>
               <include>**/replication/async/**/*.java</include>
+	      <include>**/**/HTTPBackupAgentTest.java</include>
             </includes>
             <excludes>
               <exclude>**/BaseStandaloneTest.java</exclude>
               <exclude>**/replication/*.java</exclude>
               <exclude>**/replication/external/*.java</exclude>
               <exclude>**/replication/external/BaseTestCaseChecker.java</exclude>
-              <exclude>**/backup/*.java</exclude>
+              <!--exclude>**/backup/*.java</exclude-->
               <exclude>**/access/*.java</exclude>
               <exclude>**/LocalStorageMultithreadTest.java</exclude>
             </excludes>

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java	2010-03-26 09:38:24 UTC (rev 2156)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java	2010-03-26 09:40:02 UTC (rev 2157)
@@ -139,6 +139,11 @@
          public static final String CURRENT_AND_COMPLETED_BACKUPS_INFO = "/info/backup";
 
          /**
+          * The current and completed repository backups info operation.
+          */
+         public static final String CURRENT_AND_COMPLETED_BACKUPS_REPOSITORY_INFO = "/info/backup-repository";
+
+         /**
           * The current and completed backups info operation for specific workspace.
           */
          public static final String CURRENT_AND_COMPLETED_BACKUPS_INFO_ON_WS = "/info/backup";
@@ -151,7 +156,7 @@
          /**
           * The current repository backups info operations.
           */
-         public static final String CURRENT_BACKUP_REPOSITORY_INFO = "/info/backup-repository/current";
+         public static final String CURRENT_BACKUPS_REPOSITORY_INFO = "/info/backup-repository/current";
 
          /**
           * The current or completed backup info operations.
@@ -169,11 +174,21 @@
          public static final String CURRENT_RESTORE_INFO_ON_WS = "/info/restore";
 
          /**
+         * The current restore info operations for specific repository.
+         */
+         public static final String CURRENT_RESTORE_INFO_ON_REPOSITORY = "/info/restore-repository";
+
+         /**
           * The current restores info operations.
           */
          public static final String CURRENT_RESTORES = "/info/restores";
 
          /**
+          * The current repository restores info operations.
+          */
+         public static final String CURRENT_RESTORES_REPOSITORY = "/info/restores-repository";
+
+         /**
           * The completed backups info operations.
           */
          public static final String COMPLETED_BACKUPS_INFO = "/info/backup/completed";
@@ -1432,7 +1447,7 @@
             .cacheControl(noCache).build();
       }
    }
-   
+
    /**
     * Will be returned the detailed information about last restores.
     * 
@@ -1469,8 +1484,8 @@
          for (JobRepositoryRestore job : jobs)
          {
             ShortInfo info =
-               new ShortInfo(ShortInfo.RESTORE, job.getRepositoryBackupChainLog(), job.getStartTime(), job.getEndTime(), job
-                  .getStateRestore(), job.getRepositoryName());
+               new ShortInfo(ShortInfo.RESTORE, job.getRepositoryBackupChainLog(), job.getStartTime(),
+                  job.getEndTime(), job.getStateRestore(), job.getRepositoryName());
             list.add(info);
          }
 

Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java	2010-03-26 09:38:24 UTC (rev 2156)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java	2010-03-26 09:40:02 UTC (rev 2157)
@@ -189,7 +189,7 @@
       Thread.sleep(5000);
    }
 
-   public void testRepositoryStartBackup() throws Exception
+   public void testStartBackupRepository() throws Exception
    {
       // login to workspace '/db6/ws2'
       // Start repository backup
@@ -222,55 +222,76 @@
       assertEquals(200, cres.getStatus());
 
       Thread.sleep(10000);
+   }
 
-      // Get repository backup id for backup on workspace /db6/ws2
-      String id = null;
+   public void testInfoBackup() throws Exception
+   {
+      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+      ContainerRequestUserRole creq =
+         new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+            + HTTPBackupAgent.Constants.OperationType.CURRENT_AND_COMPLETED_BACKUPS_INFO), new URI(""), null,
+            new InputHeadersMap(headers));
 
-      {
-         headers = new MultivaluedMapImpl();
-         creq =
-            new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
-               + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUP_REPOSITORY_INFO), new URI(""), null,
-               new InputHeadersMap(headers));
+      ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+      ContainerResponse cres = new ContainerResponse(responseWriter);
+      handler.handleRequest(creq, cres);
 
-         responseWriter = new ByteArrayContainerResponseWriter();
-         cres = new ContainerResponse(responseWriter);
-         handler.handleRequest(creq, cres);
+      assertEquals(200, cres.getStatus());
 
-         assertEquals(200, cres.getStatus());
+      ShortInfoList infoList = (ShortInfoList)getObject(ShortInfoList.class, responseWriter.getBody());
+      List<ShortInfo> list = new ArrayList<ShortInfo>(infoList.getBackups());
 
-         ShortInfoList infoList = (ShortInfoList)getObject(ShortInfoList.class, responseWriter.getBody());
-         List<ShortInfo> list = new ArrayList<ShortInfo>(infoList.getBackups());
+      assertEquals(1, list.size());
 
-         assertEquals(1, list.size());
+      ShortInfo info = list.get(0);
 
-         ShortInfo info = list.get(0);
+      assertNotNull(info);
+      assertEquals(BackupManager.FULL_AND_INCREMENTAL, info.getBackupType().intValue());
+      assertNotNull(info.getStartedTime());
+      assertNotNull(info.getFinishedTime());
+      assertEquals(ShortInfo.CURRENT, info.getType().intValue());
+      assertEquals(BackupJob.FINISHED, info.getState().intValue());
+      assertEquals("db6", info.getRepositoryName());
+      assertEquals("ws2", info.getWorkspaceName());
+   }
 
-         assertEquals(info.getRepositoryName(), "db6");
-
-         id = info.getBackupId();
-      }
-
-      headers = new MultivaluedMapImpl();
-      creq =
+   public void testInfoBackupRepository() throws Exception
+   {
+      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+      ContainerRequestUserRole creq =
          new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
-            + HTTPBackupAgent.Constants.OperationType.STOP_BACKUP_REPOSITORY + "/" + id), new URI(""), null,
-            new InputHeadersMap(headers));
+            + HTTPBackupAgent.Constants.OperationType.CURRENT_AND_COMPLETED_BACKUPS_REPOSITORY_INFO), new URI(""),
+            null, new InputHeadersMap(headers));
 
-      responseWriter = new ByteArrayContainerResponseWriter();
-      cres = new ContainerResponse(responseWriter);
+      ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+      ContainerResponse cres = new ContainerResponse(responseWriter);
       handler.handleRequest(creq, cres);
 
       assertEquals(200, cres.getStatus());
+
+      ShortInfoList infoList = (ShortInfoList)getObject(ShortInfoList.class, responseWriter.getBody());
+      List<ShortInfo> list = new ArrayList<ShortInfo>(infoList.getBackups());
+
+      assertEquals(1, list.size());
+
+      ShortInfo info = list.get(0);
+
+      assertNotNull(info);
+      assertEquals(BackupManager.FULL_AND_INCREMENTAL, info.getBackupType().intValue());
+      assertNotNull(info.getStartedTime());
+      assertNotNull(info.getFinishedTime());
+      assertEquals(ShortInfo.CURRENT, info.getType().intValue());
+      assertEquals(BackupJob.FINISHED, info.getState().intValue());
+      assertEquals("db6", info.getRepositoryName());
    }
 
-   public void testInfoBackup() throws Exception
+   public void testInfoBackupOnWorkspace() throws Exception
    {
       MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
       ContainerRequestUserRole creq =
          new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
-            + HTTPBackupAgent.Constants.OperationType.CURRENT_AND_COMPLETED_BACKUPS_INFO), new URI(""), null,
-            new InputHeadersMap(headers));
+            + HTTPBackupAgent.Constants.OperationType.CURRENT_AND_COMPLETED_BACKUPS_INFO_ON_WS + "/db6/ws2"), new URI(
+            ""), null, new InputHeadersMap(headers));
 
       ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
       ContainerResponse cres = new ContainerResponse(responseWriter);
@@ -295,12 +316,12 @@
       assertEquals("ws2", info.getWorkspaceName());
    }
 
-   public void testInfoBackupOnWorkspace() throws Exception
+   public void testInfoBackupOnRepository() throws Exception
    {
       MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
       ContainerRequestUserRole creq =
          new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
-            + HTTPBackupAgent.Constants.OperationType.CURRENT_AND_COMPLETED_BACKUPS_INFO_ON_WS + "/db6/ws2"), new URI(
+            + HTTPBackupAgent.Constants.OperationType.CURRENT_AND_COMPLETED_BACKUPS_REPOSITORY_INFO + "/db6"), new URI(
             ""), null, new InputHeadersMap(headers));
 
       ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
@@ -323,7 +344,6 @@
       assertEquals(ShortInfo.CURRENT, info.getType().intValue());
       assertEquals(BackupJob.FINISHED, info.getState().intValue());
       assertEquals("db6", info.getRepositoryName());
-      assertEquals("ws2", info.getWorkspaceName());
    }
 
    public void testInfoBackupCurrent() throws Exception
@@ -362,7 +382,7 @@
       MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
       ContainerRequestUserRole creq =
          new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
-            + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUP_REPOSITORY_INFO), new URI(""), null,
+            + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_REPOSITORY_INFO), new URI(""), null,
             new InputHeadersMap(headers));
 
       ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
@@ -444,6 +464,61 @@
       assertNotNull(info.getBackupConfig());
    }
 
+   public void testInfoBackupRepositoryId() throws Exception
+   {
+      // Get backup id for backup on workspace /db6/ws2
+      String id = null;
+
+      {
+         MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+         ContainerRequestUserRole creq =
+            new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+               + HTTPBackupAgent.Constants.OperationType.CURRENT_AND_COMPLETED_BACKUPS_REPOSITORY_INFO), new URI(""),
+               null, new InputHeadersMap(headers));
+
+         ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+         ContainerResponse cres = new ContainerResponse(responseWriter);
+         handler.handleRequest(creq, cres);
+
+         assertEquals(200, cres.getStatus());
+
+         ShortInfoList infoList = (ShortInfoList)getObject(ShortInfoList.class, responseWriter.getBody());
+         List<ShortInfo> list = new ArrayList<ShortInfo>(infoList.getBackups());
+
+         assertEquals(1, list.size());
+
+         ShortInfo info = list.get(0);
+
+         assertEquals(info.getRepositoryName(), "db6");
+         assertEquals(info.getWorkspaceName(), "ws2");
+
+         id = info.getBackupId();
+      }
+
+      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+      ContainerRequestUserRole creq =
+         new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+            + HTTPBackupAgent.Constants.OperationType.CURRENT_OR_COMPLETED_BACKUP_REPOSITORY_INFO + "/" + id), new URI(
+            ""), null, new InputHeadersMap(headers));
+
+      ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+      ContainerResponse cres = new ContainerResponse(responseWriter);
+      handler.handleRequest(creq, cres);
+
+      assertEquals(200, cres.getStatus());
+
+      DetailedInfo info = (DetailedInfo)getObject(DetailedInfo.class, responseWriter.getBody());
+
+      assertNotNull(info);
+      assertEquals(BackupManager.FULL_AND_INCREMENTAL, info.getBackupType().intValue());
+      assertNotNull(info.getStartedTime());
+      assertNotNull(info.getFinishedTime());
+      assertEquals(ShortInfo.CURRENT, info.getType().intValue());
+      assertEquals(BackupJob.FINISHED, info.getState().intValue());
+      assertEquals("db6", info.getRepositoryName());
+      assertNotNull(info.getBackupConfig());
+   }
+
    public void testStop() throws Exception
    {
       // Get backup id for backup on workspace /db6/ws2
@@ -488,6 +563,48 @@
       assertEquals(200, cres.getStatus());
    }
 
+   public void testStopBackupRepository() throws Exception
+   {
+      String id = null;
+
+      {
+         MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+         ContainerRequestUserRole creq =
+            new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+               + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_REPOSITORY_INFO), new URI(""), null,
+               new InputHeadersMap(headers));
+
+         ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+         ContainerResponse cres = new ContainerResponse(responseWriter);
+         handler.handleRequest(creq, cres);
+
+         assertEquals(200, cres.getStatus());
+
+         ShortInfoList infoList = (ShortInfoList)getObject(ShortInfoList.class, responseWriter.getBody());
+         List<ShortInfo> list = new ArrayList<ShortInfo>(infoList.getBackups());
+
+         assertEquals(1, list.size());
+
+         ShortInfo info = list.get(0);
+
+         assertEquals(info.getRepositoryName(), "db6");
+
+         id = info.getBackupId();
+      }
+
+      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+      ContainerRequestUserRole creq =
+         new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+            + HTTPBackupAgent.Constants.OperationType.START_BACKUP_REPOSITORY + "/" + id), new URI(""), null,
+            new InputHeadersMap(headers));
+
+      ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+      ContainerResponse cres = new ContainerResponse(responseWriter);
+      handler.handleRequest(creq, cres);
+
+      assertEquals(200, cres.getStatus());
+   }
+
    public void testInfoBackupCompleted() throws Exception
    {
       MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
@@ -626,6 +743,25 @@
       assertEquals(repository.getConfiguration().getDefaultWorkspaceName(), defEntry.getName());
    }
 
+   public void testGetDefaultRepositoryConfig() throws Exception
+   {
+      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+      ContainerRequestUserRole creq =
+         new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+            + HTTPBackupAgent.Constants.OperationType.GET_DEFAULT_REPOSITORY_CONFIG), new URI(""), null,
+            new InputHeadersMap(headers));
+
+      ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+      ContainerResponse cres = new ContainerResponse(responseWriter);
+      handler.handleRequest(creq, cres);
+
+      assertEquals(200, cres.getStatus());
+
+      WorkspaceEntry defEntry = (WorkspaceEntry)getObject(WorkspaceEntry.class, responseWriter.getBody());
+
+      assertEquals(repository.getConfiguration().getDefaultWorkspaceName(), defEntry.getName());
+   }
+
    public void testWorkspaceEntryRestore() throws Exception
    {
       // Getting default WorkspaceEntry
@@ -831,7 +967,7 @@
          MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
          ContainerRequestUserRole creq =
             new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
-               + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUP_REPOSITORY_INFO), new URI(""), null,
+               + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_REPOSITORY_INFO), new URI(""), null,
                new InputHeadersMap(headers));
 
          ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
@@ -929,7 +1065,7 @@
          MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
          ContainerRequestUserRole creq =
             new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
-               + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_WS + "/" + "db6" + "/" + "ws3"),
+               + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_REPOSITORY + "/" + "db6"),
                new URI(""), null, new InputHeadersMap(headers));
 
          ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
@@ -960,8 +1096,8 @@
          MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
          ContainerRequestUserRole creq =
             new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
-               + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORES), new URI(""), null, new InputHeadersMap(
-               headers));
+               + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORES_REPOSITORY), new URI(""), null,
+               new InputHeadersMap(headers));
 
          ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
          ContainerResponse cres = new ContainerResponse(responseWriter);



More information about the exo-jcr-commits mailing list