01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.plugins.repository.vfs;
19:
20: import java.io.File;
21: import java.util.ArrayList;
22: import java.util.List;
23:
24: import org.apache.commons.vfs.FileSystemException;
25: import org.apache.commons.vfs.impl.StandardFileSystemManager;
26: import org.apache.ivy.Ivy;
27: import org.apache.ivy.util.FileUtil;
28:
29: public class VfsTestHelper {
30: private Ivy ivy = null;
31:
32: public final StandardFileSystemManager fsManager;
33:
34: public static final String VFS_CONF = "ivy_vfs.xml";
35:
36: // Ivy Variables
37: public static final String PROP_VFS_HOST = "vfs.host";
38:
39: public static final String PROP_VFS_SAMBA_REPO = "vfs.samba.share";
40:
41: public static final String PROP_VFS_USER_ID = "vfs.user";
42:
43: public static final String PROP_VFS_USER_PASSWD = "vfs.passwd";
44:
45: // Resources
46: public static final String CWD = System.getProperty("user.dir");
47:
48: public static final String TEST_REPO_DIR = "test/repositories";
49:
50: public static final String IVY_CONFIG_FILE = FileUtil.concat(
51: TEST_REPO_DIR, "ivysettings.xml");
52:
53: public static final String TEST_IVY_XML = "2/mod5.1/ivy-4.2.xml";
54:
55: public static final String SCRATCH_DIR = "_vfsScratchArea";
56:
57: public VfsTestHelper() throws Exception {
58: // setup and initialize VFS
59: fsManager = new StandardFileSystemManager() {
60: protected void configurePlugins()
61: throws FileSystemException {
62: // disable automatic loading potential unsupported extensions
63: }
64: };
65: fsManager.setConfiguration(getClass().getResource(VFS_CONF)
66: .toString());
67: fsManager.init();
68:
69: // setup and initialize ivy
70: ivy = new Ivy();
71: ivy.configure(new File(IVY_CONFIG_FILE));
72: }
73:
74: /**
75: * Generate a set of well-formed VFS resource identifiers
76: *
77: * @param resource
78: * name of the resource
79: * @return <class>List</class> of well-formed VFS reosurce identifiers
80: */
81: public List createVFSUriSet(String resource) {
82: List set = new ArrayList();
83: for (int i = 0; i < VfsURI.SUPPORTED_SCHEMES.length; i++) {
84: set.add(VfsURI.vfsURIFactory(VfsURI.SUPPORTED_SCHEMES[i],
85: resource, ivy));
86: }
87: return set;
88: }
89:
90: public Ivy getIvy() {
91: return ivy;
92: }
93:
94: }
|