Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToMongoFbsTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToMongoFbsTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToMongoFbsTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToMongoFbsTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli; + +import java.io.IOException; + +import static org.apache.jackrabbit.oak.upgrade.cli.container.MongoNodeStoreContainer.isMongoAvailable; +import static org.junit.Assume.assumeTrue; + +import org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileBlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.MongoNodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; + +/** + * This covers the bug GRANITE-8719. + */ +public class MongoToMongoFbsTest extends AbstractOak2OakTest { + + private final BlobStoreContainer destinationBlob; + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public MongoToMongoFbsTest() throws IOException { + assumeTrue(isMongoAvailable()); + destinationBlob = new FileBlobStoreContainer(); + source = new MongoNodeStoreContainer(); + destination = new MongoNodeStoreContainer(destinationBlob); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { "--copy-binaries", "--fileblobstore", destinationBlob.getDescription(), + source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +}
Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToMongoFdsTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToMongoFdsTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToMongoFdsTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToMongoFdsTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli; + +import static org.apache.jackrabbit.oak.upgrade.cli.container.MongoNodeStoreContainer.isMongoAvailable; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileDataStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.MongoNodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; + +public class MongoToMongoFdsTest extends AbstractOak2OakTest { + + private final BlobStoreContainer destinationBlob; + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public MongoToMongoFdsTest() throws IOException { + assumeTrue(isMongoAvailable()); + destinationBlob = new FileDataStoreContainer(); + source = new MongoNodeStoreContainer(); + destination = new MongoNodeStoreContainer(destinationBlob); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { "--copy-binaries", "--datastore", destinationBlob.getDescription(), + source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToSegmentTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToSegmentTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToSegmentTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/MongoToSegmentTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli; + +import static org.apache.jackrabbit.oak.upgrade.cli.container.MongoNodeStoreContainer.isMongoAvailable; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.upgrade.cli.container.MongoNodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; + +public class MongoToSegmentTest extends AbstractOak2OakTest { + + private final MongoNodeStoreContainer source; + + private final SegmentNodeStoreContainer destination; + + public MongoToSegmentTest() throws IOException { + assumeTrue(isMongoAvailable()); + source = new MongoNodeStoreContainer(); + destination = new SegmentNodeStoreContainer(); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToJdbcTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToJdbcTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToJdbcTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToJdbcTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.upgrade.cli.container.JdbcNodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; +import org.junit.Ignore; + +public class SegmentToJdbcTest extends AbstractOak2OakTest { + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public SegmentToJdbcTest() throws IOException { + source = new SegmentNodeStoreContainer(); + destination = new JdbcNodeStoreContainer(); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { "--disable-mmap", "--user", "sa", "--password", "sa", source.getDescription(), + destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToMongoTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToMongoTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToMongoTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToMongoTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli; + +import static org.apache.jackrabbit.oak.upgrade.cli.container.MongoNodeStoreContainer.isMongoAvailable; +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.upgrade.cli.container.MongoNodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; + +public class SegmentToMongoTest extends AbstractOak2OakTest { + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public SegmentToMongoTest() throws IOException { + assumeTrue(isMongoAvailable()); + source = new SegmentNodeStoreContainer(); + destination = new MongoNodeStoreContainer(); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToSegmentTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToSegmentTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToSegmentTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToSegmentTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli; + +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; + +import java.io.IOException; + +public class SegmentToSegmentTest extends AbstractOak2OakTest { + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public SegmentToSegmentTest() throws IOException { + source = new SegmentNodeStoreContainer(); + destination = new SegmentNodeStoreContainer(); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToSegmentWithMissingDestinationDirectoryTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToSegmentWithMissingDestinationDirectoryTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToSegmentWithMissingDestinationDirectoryTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/SegmentToSegmentWithMissingDestinationDirectoryTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli; + +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; + +import java.io.IOException; + +public class SegmentToSegmentWithMissingDestinationDirectoryTest extends AbstractOak2OakTest { + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public SegmentToSegmentWithMissingDestinationDirectoryTest() throws IOException { + source = new SegmentNodeStoreContainer(); + destination = getSegmentNodeStoreContainerWithMissingDirectory(); + } + + private SegmentNodeStoreContainer getSegmentNodeStoreContainerWithMissingDirectory() throws IOException { + SegmentNodeStoreContainer segmentNodeStoreContainer = new SegmentNodeStoreContainer(); + segmentNodeStoreContainer.getDirectory().delete(); + return segmentNodeStoreContainer; + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } + +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/Util.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/Util.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/Util.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/Util.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class Util { + + private static final Logger log = LoggerFactory.getLogger(Util.class); + + private Util() { + } + + public static void unzip(InputStream is, File targetDir) throws IOException { + long start = System.currentTimeMillis(); + log.info("Unzipping to {}", targetDir.getAbsolutePath()); + final ZipInputStream zis = new ZipInputStream(is); + try { + ZipEntry entry = null; + while((entry = zis.getNextEntry()) != null) { + if (entry.isDirectory()) { + new File(targetDir, entry.getName()).mkdirs(); + } else { + File target = new File(targetDir, entry.getName()); + target.getParentFile().mkdirs(); + OutputStream output = new FileOutputStream(target); + try { + IOUtils.copy(zis, output); + } finally { + output.close(); + } + } + } + } finally { + zis.close(); + } + final long delta = System.currentTimeMillis() - start; + if(delta > 1000L) { + log.info("Unzip took {} msec", delta); + } + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/CopyBinariesTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/CopyBinariesTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/CopyBinariesTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/CopyBinariesTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,200 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.blob; + +import static java.util.Arrays.asList; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.google.common.base.Joiner; +import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.apache.jackrabbit.oak.upgrade.cli.AbstractOak2OakTest; +import org.apache.jackrabbit.oak.upgrade.cli.OakUpgrade; +import org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileDataStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.JdbcNodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.parser.CliArgumentException; +import org.apache.jackrabbit.oak.upgrade.cli.parser.DatastoreArguments; +import org.apache.jackrabbit.oak.upgrade.cli.parser.MigrationCliArguments; +import org.apache.jackrabbit.oak.upgrade.cli.parser.MigrationOptions; +import org.apache.jackrabbit.oak.upgrade.cli.parser.OptionParserFactory; +import org.apache.jackrabbit.oak.upgrade.cli.parser.StoreArguments; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.jcr.RepositoryException; + +@RunWith(Parameterized.class) +public class CopyBinariesTest extends AbstractOak2OakTest { + + private static final Logger log = LoggerFactory.getLogger(CopyBinariesTest.class); + + @Parameterized.Parameters(name = "{0}") + public static Collection<Object[]> data() throws IOException { + List<Object[]> params = new ArrayList<Object[]>(); + + BlobStoreContainer blob = new FileDataStoreContainer(); + BlobStoreContainer blob2 = new FileDataStoreContainer(); + params.add(new Object[]{ + "Copy references, no blobstores defined, segment -> segment", + new SegmentNodeStoreContainer(blob), + new SegmentNodeStoreContainer(blob), + asList(), + DatastoreArguments.BlobMigrationCase.COPY_REFERENCES + }); + params.add(new Object[]{ + "Copy references, no blobstores defined, document -> segment", + new JdbcNodeStoreContainer(blob), + new SegmentNodeStoreContainer(blob), + asList("--src-user=sa", "--src-password=sa"), + DatastoreArguments.BlobMigrationCase.COPY_REFERENCES + }); + params.add(new Object[]{ + "Copy references, no blobstores defined, segment -> document", + new SegmentNodeStoreContainer(blob), + new JdbcNodeStoreContainer(blob), + asList("--user=sa", "--password=sa"), + DatastoreArguments.BlobMigrationCase.UNSUPPORTED + }); + params.add(new Object[]{ + "Missing source, external destination", + new SegmentNodeStoreContainer(blob), + new SegmentNodeStoreContainer(blob), + asList("--datastore=" + blob.getDescription()), + DatastoreArguments.BlobMigrationCase.UNSUPPORTED + }); + params.add(new Object[]{ + "Copy embedded to embedded, no blobstores defined", + new SegmentNodeStoreContainer(), + new SegmentNodeStoreContainer(), + asList(), + DatastoreArguments.BlobMigrationCase.EMBEDDED_TO_EMBEDDED + }); + params.add(new Object[]{ + "Copy embedded to external, no blobstores defined", + new SegmentNodeStoreContainer(), + new SegmentNodeStoreContainer(blob), + asList("--datastore=" + blob.getDescription()), + DatastoreArguments.BlobMigrationCase.EMBEDDED_TO_EXTERNAL + }); + params.add(new Object[]{ + "Copy references, src blobstore defined", + new SegmentNodeStoreContainer(blob), + new SegmentNodeStoreContainer(blob), + asList("--src-datastore=" + blob.getDescription()), + DatastoreArguments.BlobMigrationCase.COPY_REFERENCES + }); + params.add(new Object[]{ + "Copy external to embedded, src blobstore defined", + new SegmentNodeStoreContainer(blob), + new SegmentNodeStoreContainer(), + asList("--copy-binaries", "--src-datastore=" + blob.getDescription()), + DatastoreArguments.BlobMigrationCase.EXTERNAL_TO_EMBEDDED + }); + params.add(new Object[]{ + "Copy external to external, src blobstore defined", + new SegmentNodeStoreContainer(blob), + new SegmentNodeStoreContainer(blob2), + asList("--copy-binaries", "--src-datastore=" + blob.getDescription(), "--datastore=" + blob2.getDescription()), + DatastoreArguments.BlobMigrationCase.EXTERNAL_TO_EXTERNAL + }); + return params; + } + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + private final List<String> args; + + private final DatastoreArguments.BlobMigrationCase blobMigrationCase; + + public CopyBinariesTest(String name, NodeStoreContainer source, NodeStoreContainer destination, List<String> args, DatastoreArguments.BlobMigrationCase blobMigrationCase) throws IOException, CliArgumentException { + this.source = source; + this.destination = destination; + this.args = args; + this.blobMigrationCase = blobMigrationCase; + + this.source.clean(); + this.destination.clean(); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + List<String> result = new ArrayList<String>(args); + result.addAll(asList("--disable-mmap", "--skip-checkpoints", source.getDescription(), destination.getDescription())); + return result.toArray(new String[result.size()]); + } + + @Before + @Override + public void prepare() throws Exception { + NodeStore source = getSourceContainer().open(); + try { + initContent(source); + } finally { + getSourceContainer().close(); + } + + String[] args = getArgs(); + log.info("oak2oak {}", Joiner.on(' ').join(args)); + try { + MigrationCliArguments cliArgs = new MigrationCliArguments(OptionParserFactory.create().parse(args)); + MigrationOptions options = new MigrationOptions(cliArgs); + StoreArguments stores = new StoreArguments(options, cliArgs.getArguments()); + DatastoreArguments datastores = new DatastoreArguments(options, stores, stores.srcUsesEmbeddedDatastore()); + OakUpgrade.migrate(options, stores, datastores); + assertEquals(blobMigrationCase, datastores.getBlobMigrationCase()); + } catch(CliArgumentException e) { + if (blobMigrationCase == DatastoreArguments.BlobMigrationCase.UNSUPPORTED) { + return; + } else { + throw e; + } + } + createSession(); + } + + @Test + @Override + public void validateMigration() throws RepositoryException, IOException, CliArgumentException { + if (blobMigrationCase == DatastoreArguments.BlobMigrationCase.UNSUPPORTED) { + return; + } + super.validateMigration(); + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToFbsTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToFbsTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToFbsTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToFbsTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.blob; + +import org.apache.jackrabbit.oak.upgrade.cli.AbstractOak2OakTest; +import org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileBlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; + +import java.io.IOException; + +public class FbsToFbsTest extends AbstractOak2OakTest { + + private final BlobStoreContainer sourceBlob; + + private final BlobStoreContainer destinationBlob; + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public FbsToFbsTest() throws IOException { + sourceBlob = new FileBlobStoreContainer(); + destinationBlob = new FileBlobStoreContainer(); + source = new SegmentNodeStoreContainer(sourceBlob); + destination = new SegmentNodeStoreContainer(destinationBlob); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { "--copy-binaries", "--src-fileblobstore", sourceBlob.getDescription(), "--fileblobstore", + destinationBlob.getDescription(), source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToFdsTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToFdsTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToFdsTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToFdsTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.blob; + +import org.apache.jackrabbit.oak.upgrade.cli.AbstractOak2OakTest; +import org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileBlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileDataStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; + +import java.io.IOException; + +public class FbsToFdsTest extends AbstractOak2OakTest { + + private final BlobStoreContainer sourceBlob; + + private final BlobStoreContainer destinationBlob; + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public FbsToFdsTest() throws IOException { + sourceBlob = new FileBlobStoreContainer(); + destinationBlob = new FileDataStoreContainer(); + source = new SegmentNodeStoreContainer(sourceBlob); + destination = new SegmentNodeStoreContainer(destinationBlob); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { "--copy-binaries", "--src-fileblobstore", sourceBlob.getDescription(), "--datastore", + destinationBlob.getDescription(), source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToS3Test.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToS3Test.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToS3Test.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FbsToS3Test.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.blob; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.upgrade.cli.AbstractOak2OakTest; +import org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileBlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.S3DataStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; +import org.junit.Assume; + +public class FbsToS3Test extends AbstractOak2OakTest { + + private static final String S3_PROPERTIES = System.getProperty("s3.properties"); + + private final BlobStoreContainer sourceBlob; + + private final BlobStoreContainer destinationBlob; + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public FbsToS3Test() throws IOException { + Assume.assumeTrue(S3_PROPERTIES != null && !S3_PROPERTIES.isEmpty()); + sourceBlob = new FileBlobStoreContainer(); + destinationBlob = new S3DataStoreContainer(S3_PROPERTIES); + source = new SegmentNodeStoreContainer(sourceBlob); + destination = new SegmentNodeStoreContainer(destinationBlob); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { "--copy-binaries", "--src-fileblobstore", sourceBlob.getDescription(), "--s3datastore", + destinationBlob.getDescription(), "--s3config", S3_PROPERTIES, source.getDescription(), + destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FdsToFbsTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FdsToFbsTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FdsToFbsTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/FdsToFbsTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.blob; + +import org.apache.jackrabbit.oak.upgrade.cli.AbstractOak2OakTest; +import org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileBlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileDataStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; + +import java.io.IOException; + +public class FdsToFbsTest extends AbstractOak2OakTest { + + private final BlobStoreContainer sourceBlob; + + private final BlobStoreContainer destinationBlob; + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public FdsToFbsTest() throws IOException { + sourceBlob = new FileDataStoreContainer(); + destinationBlob = new FileBlobStoreContainer(); + source = new SegmentNodeStoreContainer(sourceBlob); + destination = new SegmentNodeStoreContainer(destinationBlob); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { "--copy-binaries", "--src-datastore", sourceBlob.getDescription(), "--fileblobstore", + destinationBlob.getDescription(), source.getDescription(), destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/S3ToFbsTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/S3ToFbsTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/S3ToFbsTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/S3ToFbsTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.blob; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.upgrade.cli.AbstractOak2OakTest; +import org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.FileBlobStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.NodeStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.S3DataStoreContainer; +import org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer; +import org.junit.Assume; + +public class S3ToFbsTest extends AbstractOak2OakTest { + + private static final String S3_PROPERTIES = System.getProperty("s3.properties"); + + private final BlobStoreContainer sourceBlob; + + private final BlobStoreContainer destinationBlob; + + private final NodeStoreContainer source; + + private final NodeStoreContainer destination; + + public S3ToFbsTest() throws IOException { + Assume.assumeTrue(S3_PROPERTIES != null && !S3_PROPERTIES.isEmpty()); + sourceBlob = new S3DataStoreContainer(S3_PROPERTIES); + destinationBlob = new FileBlobStoreContainer(); + source = new SegmentNodeStoreContainer(sourceBlob); + destination = new SegmentNodeStoreContainer(destinationBlob); + } + + @Override + protected NodeStoreContainer getSourceContainer() { + return source; + } + + @Override + protected NodeStoreContainer getDestinationContainer() { + return destination; + } + + @Override + protected String[] getArgs() { + return new String[] { "--copy-binaries", "--src-s3datastore", sourceBlob.getDescription(), "--src-s3config", + S3_PROPERTIES, "--fileblobstore", destinationBlob.getDescription(), source.getDescription(), + destination.getDescription() }; + } + + @Override + protected boolean supportsCheckpointMigration() { + return true; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/StripConfigValueTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/StripConfigValueTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/StripConfigValueTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/blob/StripConfigValueTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.blob; + +import static org.apache.jackrabbit.oak.upgrade.cli.blob.S3DataStoreFactory.stripValue; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class StripConfigValueTest { + + @Test + public void testStripPrefixAndQuotes() { + assertEquals("123aaa", stripValue("B\"123aaa\"")); + } + + @Test + public void testStripPrefixQuotesAndWhitespaces() { + assertEquals("123aaa", stripValue("B\"123aaa\" ")); + } + + @Test + public void testStripQuotes() { + assertEquals("123aaa", stripValue("\"123aaa\"")); + } + + @Test + public void testNoStrip() { + assertEquals("123aaa", stripValue("123aaa")); + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/BlobStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/BlobStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/BlobStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/BlobStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.Closeable; +import java.io.IOException; + +import org.apache.jackrabbit.oak.spi.blob.BlobStore; + +public interface BlobStoreContainer extends Closeable { + + BlobStore open() throws IOException; + + void clean() throws IOException; + + String getDescription(); + +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/DummyBlobStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/DummyBlobStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/DummyBlobStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/DummyBlobStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.spi.blob.BlobStore; + +public class DummyBlobStoreContainer implements BlobStoreContainer { + + @Override + public BlobStore open() throws IOException { + return null; + } + + @Override + public void close() { + } + + @Override + public void clean() throws IOException { + } + + @Override + public String getDescription() { + return ""; + } + +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.apache.commons.io.FileUtils; +import org.apache.jackrabbit.oak.spi.blob.BlobStore; +import org.apache.jackrabbit.oak.spi.blob.FileBlobStore; + +public class FileBlobStoreContainer implements BlobStoreContainer { + + private final File directory; + + public FileBlobStoreContainer() throws IOException { + this.directory = Files.createTempDirectory(Paths.get("target"), "repo-fbs").toFile(); + } + + @Override + public BlobStore open() throws IOException { + return new FileBlobStore(directory.getPath()); + } + + @Override + public void close() { + } + + @Override + public void clean() throws IOException { + FileUtils.deleteQuietly(directory); + } + + @Override + public String getDescription() { + return directory.getPath(); + } + +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.apache.commons.io.FileUtils; +import org.apache.jackrabbit.oak.spi.blob.BlobStore; +import org.apache.jackrabbit.oak.upgrade.cli.blob.FileDataStoreFactory; + +import com.google.common.io.Closer; + +public class FileDataStoreContainer implements BlobStoreContainer { + + private final File directory; + + private final Closer closer; + + public FileDataStoreContainer() throws IOException { + this.directory = Files.createTempDirectory(Paths.get("target"), "repo-fds").toFile(); + this.closer = Closer.create(); + } + + @Override + public BlobStore open() throws IOException { + return new FileDataStoreFactory(directory.getPath(), false).create(closer); + } + + @Override + public void close() throws IOException { + closer.close(); + } + + @Override + public void clean() throws IOException { + FileUtils.deleteQuietly(directory); + } + + @Override + public String getDescription() { + return directory.getPath(); + } + + public File getDirectory() { + return directory; + } + +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.apache.commons.io.FileUtils; +import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.apache.jackrabbit.oak.upgrade.cli.node.JdbcFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.Closer; + +public class JdbcNodeStoreContainer implements NodeStoreContainer { + + private static final Logger LOG = LoggerFactory.getLogger(JdbcNodeStoreContainer.class); + + private final File h2Dir; + + private final String jdbcUri; + + private final JdbcFactory jdbcFactory; + + private final BlobStoreContainer blob; + + private Closer closer; + + public JdbcNodeStoreContainer() throws IOException { + this(new DummyBlobStoreContainer()); + } + + public JdbcNodeStoreContainer(BlobStoreContainer blob) throws IOException { + this.blob = blob; + this.h2Dir = Files.createTempDirectory(Paths.get("target"), "repo-h2").toFile(); + this.jdbcUri = String.format("jdbc:h2:%s", h2Dir.getAbsolutePath() + "/JdbcNodeStoreContainer"); + this.jdbcFactory = new JdbcFactory(jdbcUri, 2, "sa", "sa", false); + } + + @Override + public NodeStore open() throws IOException { + this.closer = Closer.create(); + return jdbcFactory.create(blob.open(), closer); + } + + @Override + public void close() { + try { + if (closer != null) { + closer.close(); + closer = null; + } + } catch (IOException e) { + LOG.error("Can't close document node store", e); + } + } + + @Override + public void clean() throws IOException { + FileUtils.deleteQuietly(h2Dir); + blob.clean(); + } + + @Override + public String getDescription() { + return jdbcUri; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/MongoNodeStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/MongoNodeStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/MongoNodeStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/MongoNodeStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.IOException; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.apache.jackrabbit.oak.upgrade.cli.node.MongoFactory; +import org.junit.Assume; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.Closer; +import com.mongodb.Mongo; +import com.mongodb.MongoClient; +import com.mongodb.MongoClientURI; + +public class MongoNodeStoreContainer implements NodeStoreContainer { + + private static Boolean mongoAvailable; + + private static final Logger LOG = LoggerFactory.getLogger(MongoNodeStoreContainer.class); + + private static final String MONGO_URI = System.getProperty("oak.mongo.uri", + "mongodb://localhost:27017/oak-migration"); + + private static final AtomicInteger DATABASE_SUFFIX = new AtomicInteger(1); + + private final MongoFactory mongoFactory; + + private final BlobStoreContainer blob; + + private final String mongoUri; + + private Closer closer; + + public MongoNodeStoreContainer() throws IOException { + this(new DummyBlobStoreContainer()); + } + + public MongoNodeStoreContainer(BlobStoreContainer blob) throws IOException { + Assume.assumeTrue(isMongoAvailable()); + this.mongoUri = String.format("%s-%d", MONGO_URI, DATABASE_SUFFIX.getAndIncrement()); + this.mongoFactory = new MongoFactory(mongoUri, 2, false); + this.blob = blob; + clean(); + } + + public static boolean isMongoAvailable() { + if (mongoAvailable != null) { + return mongoAvailable; + } + + mongoAvailable = testMongoAvailability(); + return mongoAvailable; + } + + private static boolean testMongoAvailability() { + Mongo mongo = null; + try { + MongoClientURI uri = new MongoClientURI(MONGO_URI + "?connectTimeoutMS=3000"); + mongo = new MongoClient(uri); + mongo.getDatabaseNames(); + return true; + } catch (Exception e) { + return false; + } finally { + if (mongo != null) { + mongo.close(); + } + } + } + + @Override + public NodeStore open() throws IOException { + this.closer = Closer.create(); + return mongoFactory.create(blob.open(), closer); + } + + @Override + public void close() { + try { + closer.close(); + } catch (IOException e) { + LOG.error("Can't close document node store", e); + } + } + + @Override + public void clean() throws IOException { + MongoClientURI uri = new MongoClientURI(mongoUri); + MongoClient client = new MongoClient(uri); + client.dropDatabase(uri.getDatabase()); + blob.clean(); + } + + @Override + public String getDescription() { + return mongoUri; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/NodeStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/NodeStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/NodeStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/NodeStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.Closeable; +import java.io.IOException; + +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +public interface NodeStoreContainer extends Closeable { + NodeStore open() throws IOException; + + void close(); + + void clean() throws IOException; + + String getDescription(); +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.apache.commons.io.FileUtils; +import org.apache.jackrabbit.oak.spi.blob.BlobStore; +import org.apache.jackrabbit.oak.upgrade.cli.blob.S3DataStoreFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.Closer; + +public class S3DataStoreContainer implements BlobStoreContainer { + + private static final Logger log = LoggerFactory.getLogger(S3DataStoreContainer.class); + + private final File directory; + + private final S3DataStoreFactory factory; + + private final Closer closer; + + public S3DataStoreContainer(String configFile) throws IOException { + this.directory = Files.createTempDirectory(Paths.get("target"), "repo-s3").toFile(); + this.factory = new S3DataStoreFactory(configFile, directory.getPath(), false); + this.closer = Closer.create(); + } + + @Override + public BlobStore open() throws IOException { + return factory.create(closer); + } + + @Override + public void close() { + try { + closer.close(); + } catch (IOException e) { + log.error("Can't close store", e); + } + } + + @Override + public void clean() throws IOException { + FileUtils.deleteQuietly(directory); + } + + @Override + public String getDescription() { + return directory.getPath(); + } + +} \ No newline at end of file Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.container; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.io.FileUtils; +import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore; +import org.apache.jackrabbit.oak.plugins.segment.file.FileStore; +import org.apache.jackrabbit.oak.spi.state.NodeState; +import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.apache.jackrabbit.oak.upgrade.cli.node.TarNodeStore; + +public class SegmentNodeStoreContainer implements NodeStoreContainer { + + private final File directory; + + private final BlobStoreContainer blob; + + private FileStore fs; + + public SegmentNodeStoreContainer() throws IOException { + this(null, null); + } + + public SegmentNodeStoreContainer(File directory) throws IOException { + this(null, directory); + } + + public SegmentNodeStoreContainer(BlobStoreContainer blob) throws IOException { + this(blob, null); + } + + private SegmentNodeStoreContainer(BlobStoreContainer blob, File directory) throws IOException { + this.blob = blob; + this.directory = directory == null ? createTempTargetDir("repo-segment") : directory; + } + + private static File createTempTargetDir(String prefix) throws IOException { + File f = File.createTempFile(prefix, "", new File("target")); + f.delete(); + f.mkdir(); + return f; + } + + @Override + public NodeStore open() throws IOException { + directory.mkdirs(); + FileStore.Builder builder = FileStore.newFileStore(new File(directory, "segmentstore")); + if (blob != null) { + builder.withBlobStore(blob.open()); + } + fs = builder.create(); + return new TarNodeStore(new SegmentNodeStore(fs), new TarNodeStore.SuperRootProvider() { + @Override + public NodeState getSuperRoot() { + return fs.getHead(); + } + }); + } + + @Override + public void close() { + if (fs != null) { + fs.close(); + fs = null; + } + } + + @Override + public void clean() throws IOException { + FileUtils.deleteQuietly(directory); + if (blob != null) { + blob.clean(); + } + } + + @Override + public String getDescription() { + return directory.getPath(); + } + + public File getDirectory() { + return directory; + } +} Added: jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/parser/StoreArgumentsTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/parser/StoreArgumentsTest.java?rev=1792995&view=auto ============================================================================== --- jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/parser/StoreArgumentsTest.java (added) +++ jackrabbit/oak/branches/1.2/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/parser/StoreArgumentsTest.java Fri Apr 28 07:18:26 2017 @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.oak.upgrade.cli.parser; + +import org.junit.Test; + +public class StoreArgumentsTest { + + @Test(expected = CliArgumentException.class) + public void testSameRepositoryFails() throws CliArgumentException { + MigrationCliArguments parsed = new MigrationCliArguments(OptionParserFactory.create().parse("my/repo", "my/repo")); + MigrationOptions options = new MigrationOptions(parsed); + new StoreArguments(options, parsed.getArguments()); + } +}
