@@ -0,0 +1,3246 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.jackrabbit.core;%0A%0Aimport java.io.File;%0A%0Aimport javax.jcr.Credentials;%0Aimport javax.jcr.Node;%0Aimport javax.jcr.Property;%0Aimport javax.jcr.PropertyType;%0Aimport javax.jcr.Session;%0Aimport javax.jcr.SimpleCredentials;%0A%0Aimport junit.framework.TestCase;%0A%0Aimport org.apache.commons.io.FileUtils;%0Aimport org.apache.jackrabbit.core.RepositoryCopier;%0Aimport org.apache.jackrabbit.core.RepositoryImpl;%0Aimport org.apache.jackrabbit.core.config.RepositoryConfig;%0A%0Apublic class RepositoryCopierTest extends TestCase %7B%0A%0A    private static final Credentials CREDENTIALS =%0A        new SimpleCredentials(%22admin%22, %22admin%22.toCharArray());%0A%0A    private final File BASE = new File(%22target%22, %22RepositoryCopierTest%22);%0A%0A    private final File SOURCE = new File(BASE, %22source%22);%0A%0A    private final File TARGET = new File(BASE, %22target%22);%0A%0A    protected void setUp() %7B%0A        BASE.mkdirs();%0A    %7D%0A%0A    protected void tearDown() throws Exception %7B%0A        FileUtils.deleteDirectory(BASE);%0A    %7D%0A%0A    public void testRepositoryCopy() throws Exception %7B%0A        createSourceRepository();%0A        new RepositoryCopier(SOURCE, TARGET).copy();%0A        verifyTargetRepository();%0A    %7D%0A%0A    private void createSourceRepository() throws Exception %7B%0A        RepositoryImpl repository = RepositoryImpl.create(%0A                RepositoryConfig.install(SOURCE));%0A        try %7B%0A            Session session = repository.login(CREDENTIALS);%0A            try %7B%0A                Node test = session.getRootNode().addNode(%22test%22);%0A                test.setProperty(%22foo%22, %22bar%22);%0A                session.save();%0A            %7D finally %7B%0A                session.logout();%0A            %7D%0A        %7D finally %7B%0A            repository.shutdown();%0A        %7D%0A    %7D%0A%0A    private void verifyTargetRepository() throws Exception %7B%0A        RepositoryImpl repository = RepositoryImpl.create(%0A                RepositoryConfig.create(TARGET));%0A        try %7B%0A            Session session = repository.login(CREDENTIALS);%0A            try %7B%0A                assertTrue(session.nodeExists(%22/test%22));%0A                assertTrue(session.propertyExists(%22/test/foo%22));%0A%0A                Property foo = session.getProperty(%22/test/foo%22);%0A                assertEquals(PropertyType.STRING, foo.getType());%0A                assertEquals(%22bar%22, foo.getString());%0A            %7D finally %7B%0A                session.logout();%0A            %7D%0A        %7D finally %7B%0A            repository.shutdown();%0A        %7D%0A    %7D%0A%0A%7D%0A

Implement a backup tool